noalyss Version-9
mobile.class.php
Go to the documentation of this file.
1<?php
2
3/*
4 * This file is part of NOALYSS.
5 *
6 * PhpCompta is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * PhpCompta is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with PhpCompta; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20// Copyright (2002-2021) Author Dany De Bontridder <danydb@noalyss.eu>
21
22namespace Noalyss;
23
24use \HtmlInput;
25use \Dossier;
26use \User;
27
28/**
29 * @file
30 * @brief Main class for Mobile device
31 */
32
33/**
34 * @class Mobile
35 * @brief Main class for Mobile device
36 */
37class Mobile
38{
39 /**
40 * @brief Load a module with all its data from database thanks the access_code
41 * @global \Noalyss\type $g_user
42 * @param type $p_access_code
43 * @return type
44 */
45
46 function load_module($p_access_code)
47 {
48 global $g_user;
50 $aModule=$cn->get_row("
51 select
52 me_file,me_parameter,me_javascript,me_type,menu_ref.me_code,
53 pmo_id,pmo_order,pmo_default
54 from menu_ref
55 join profile_mobile using (me_code)
56 where
57 me_code=$1 and
58 (me_file is not null or trim(me_file) <>'' or
59 me_javascript is not null or trim (me_javascript) <> '')
60 and profile_mobile.p_id=$2",
61 array($p_access_code,$g_user->get_profile()));
62
63 if (count($aModule)==0)
64 {
65 return [];
66 }
67 return $aModule;
68 }
69 /**
70 * @brief HTML Page
71 * @staticvar int $already_call
72 * @return type
73 */
74 function page_start()
75 {
76 global $version_noalyss;
77 // check not called twiced
78 static $already_call=0;
79 if ($already_call==1)
80 return;
81 $already_call=1;
82
83 $style="style-classic7.css";
84
85 $title="NOALYSS";
86 echo '<!doctype html>';
87 printf("\n");
88
89 echo "<HTML>";
90
91 echo "<HEAD>";
92 echo '<meta charset="utf-8">';
93 echo "<META http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">";
94 echo "
95 <TITLE>$title</TITLE>
96 <link rel=\"icon\" type=\"image/ico\" href=\"favicon.ico\" />
97 <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">
98 <LINK id=\"bootstrap\" REL=\"stylesheet\" type=\"text/css\" href=\"css/bootstrap.min.css\" media=\"screen\"/>
99 <LINK id=\"fontello\" REL=\"stylesheet\" type=\"text/css\" href=\"css/font/fontello/css/fontello.css\" media=\"screen\"/>
100 <LINK id=\"pagestyle\" REL=\"stylesheet\" type=\"text/css\" href=\"css/".$style."?version=".$version_noalyss."\" media=\"screen\"/>
101 <link rel=\"stylesheet\" type=\"text/css\" href=\"css/style-print.css?version=".$version_noalyss."\" media=\"print\"/>";
102
103 // preload font
104 echo '<link rel="preload" href="./css/font/OpenSansRegular.woff" as="font" crossorigin="anonymous" />';
105 echo '<link rel="preload" href="./css/font/SansationLight/SansationLight.woff" as="font" crossorigin="anonymous" />';
106 echo '<link rel="preload" href="./css/font/fontello/fontello.woff" as="font" crossorigin="anonymous" />';
107
108 echo '<script language="javascript" src="js/calendar.js"></script>
109 <script type="text/javascript" src="js/lang/calendar-en.js"></script>';
110
111 if (isset($_SESSION[SESSION_KEY.'g_lang'])&&$_SESSION[SESSION_KEY.'g_lang']=='fr_FR.utf8')
112 {
113 echo '<script type="text/javascript" src="js/lang/calendar-fr.js"></script>';
114 }
115 elseif (isset($_SESSION[SESSION_KEY.'g_lang'])&&$_SESSION[SESSION_KEY.'g_lang']=='nl_NL.utf8')
116 {
117 echo '<script type="text/javascript" src="js/lang/calendar-nl.js"></script>';
118 }
119
120 echo '
121 <script language="javascript" src="js/calendar-setup.js"></script>
122 <LINK REL="stylesheet" type="text/css" href="css/calendar-blue.css" media="screen">
123 ';
124 // language
125 if (isset($_SESSION[SESSION_KEY.'g_lang']))
126 {
127 set_language();
128 }
129
130 echo load_all_script();
131 echo ' </HEAD> ';
132
133 echo "<BODY>";
134 echo '<div id="info_div"></div>';
135 echo '<div id="error_div">'.
136 HtmlInput::title_box(_("Erreur"), 'error_div', 'hide').
137 '<div id="error_content_div">'.
138 '</div>'.
139 '<p style="text-align:center">'.
140 HtmlInput::button_action('Valider',
141 '$(\'error_div\').style.visibility=\'hidden\';$(\'error_content_div\').innerHTML=\'\';').
142 '</p>'.
143 '</div>';
144 }
145
146 /**
147 * @brief Display the menu available for this folder
148 *
149 */
150 public function display_menu()
151 {
152 if (DEBUGNOALYSS>1)
153 {
154 echo __CLASS__."&rarr;".__FUNCTION__;
155 }
157 $user=new \Noalyss_user($cn);
158
159 $aModule=$cn->get_array("select *
160 from profile_mobile pm
161 join menu_ref mr on (pm.me_code=mr.me_code)
162 where p_id=$1 order by pmo_order", [$user->get_profile()]);
163 require_once NOALYSS_TEMPLATE."/mobile-display_menu.php";
164 }
165
166 /**
167 * @brief execute the menu
168 * @global type $g_user
169 * @staticvar int $level
170 * @param type $p_access_code
171 * @return type
172 */
173 public function execute_menu($p_access_code)
174 {
175 global $g_user,$g_parameter,$cn;
176 $aModule=$this->load_module($p_access_code);
177 if ( empty($aModule)) {
178 return;
179 }
180 /*-- Load the standard headers if needed -- */
181 if ( $aModule['pmo_default'] == 1) {
182 $this->page_start();
183 }
184
185 echo HtmlInput::anchor("&#10094;"._("Retour"), "mobile.php?".http_build_query(["gDossier"=>Dossier::id()]));
186
187 if ($aModule['me_file']!="")
188 {
189 if ($aModule['me_parameter']!=="")
190 {
191 // if there are paramter put them in superglobal
192 $array=compute_variable($aModule['me_parameter']);
194 }
195 if (DEBUGNOALYSS==2)
196 {
197 echo $aModule['me_file'], " param : ", $aModule['me_parameter'];
198 }
199 /*
200 * Log the file we input to put in the folder test-noalyss for replaying it
201 */
202 if (LOGINPUT)
203 {
204 $file_loginput=fopen($_ENV['TMP'].'/scenario-'.$_SERVER['REQUEST_TIME'].'.php', 'a+');
205 fwrite($file_loginput, "include '".$aModule['me_file']."';");
206 fwrite($file_loginput, "\n");
207 fclose($file_loginput);
208 }
209 // if file is not a plugin, include the file, otherwise
210 // include the plugin launcher
211 if ($aModule['me_type']!='PL')
212 {
213 if (file_exists($aModule['me_file']))
214 {
215 require_once $aModule['me_file'];
216 }
217 elseif (file_exists(NOALYSS_INCLUDE.'/'.$aModule['me_file']))
218 {
219 require_once NOALYSS_INCLUDE.'/'.$aModule['me_file'];
220 }
221 else
222 {
223 echo echo_warning(_("Fichier non trouvé"));
224 }
225 }
226 else
227 {
228 require 'extension_get.inc.php';
229 }
230
231 exit();
232 }
233 elseif ($aModule['me_javascript']!='')
234 {
235 $js=noalyss_str_replace('<DOSSIER>', dossier::id(), $aModule['me_javascript']);
236 echo create_script($js);
237 }
238 }
239
240}
compute_variable($p_string)
the string has the format a=b&c=d, it is parsed and an array[][key,value] is returned
Definition: ac_common.php:1250
put_global($array)
Put in superglobal (get,post,request) the value contained in the parameter field (me_parameter)
Definition: ac_common.php:1233
echo_warning($p_string)
warns
Definition: ac_common.php:589
noalyss_str_replace($search, $replace, $string)
Definition: ac_common.php:1553
set_language()
set the lang thanks the _SESSION['g_lang'] var.
Definition: ac_common.php:754
global $g_parameter
global $g_user
if no group available , then stop
$input_from id
Definition: balance.inc.php:63
static id()
return the 'gDossier' value after a check
static connect()
static anchor($p_text, $p_url="", $p_js="", $p_style=' class="line" ', $p_title="click", array $p_attribute=[])
Return a simple anchor with a url or a javascript if $p_js is not null then p_url will be javascript:...
static button_action($action, $javascript, $id=NULL, $p_class="button", $p_symbole="")
button Html with javascript
static title_box($p_name, $p_div, $p_mod="close", $p_js="", $p_draggable="n", $p_enlarge='n')
Title for boxes, you can customize the symbol thanks symbol with the mode "custom".
Main class for Mobile device.
load_module($p_access_code)
Load a module with all its data from database thanks the access_code @global \Noalyss\type $g_user.
display_menu()
Display the menu available for this folder.
execute_menu($p_access_code)
execute the menu @global type $g_user @staticvar int $level
page_start()
HTML Page @staticvar int $already_call.
global $version_noalyss
Definition: constant.php:26
for($e=0; $e< count($afiche); $e++) exit
load_all_script()
load all the javascript only one time
create_script($p_string)
create the HTML for adding the script tags around of the script
if( $delta< 0) elseif( $delta==0)