1 | <?php |
---|
2 | |
---|
3 | /* ----------------------------------------------------------------------------- |
---|
4 | class name : GPCCore |
---|
5 | class version : 1.4.3 |
---|
6 | plugin version : 3.5.4 |
---|
7 | date : 2012-07-27 |
---|
8 | ------------------------------------------------------------------------------ |
---|
9 | author: grum at piwigo.org |
---|
10 | << May the Little SpaceFrog be with you >> |
---|
11 | ------------------------------------------------------------------------------ |
---|
12 | |
---|
13 | :: HISTORY |
---|
14 | |
---|
15 | | release | date | |
---|
16 | | 1.0.0 | 2010/03/30 | * Update class & function names |
---|
17 | | | | |
---|
18 | | 1.1.0 | 2010/03/30 | * add the BBtoHTML function |
---|
19 | | | | |
---|
20 | | 1.2.0 | 2010/07/28 | * add the loadConfigFromFile function |
---|
21 | | | | |
---|
22 | | 1.3.0 | 2010/10/13 | * add the addHeaderCSS, addHeaderJS functions |
---|
23 | | | | |
---|
24 | | 1.3.1 | 2010/10/20 | * applyHeaderItems functions implemented with an |
---|
25 | | | | higher priority on the 'loc_begin_page_header' event |
---|
26 | | | | |
---|
27 | | | | * implement the getUserLanguageDesc() function, using |
---|
28 | | | | extended description function if present |
---|
29 | | | | |
---|
30 | | | | * implement the getPiwigoSystemPath() function |
---|
31 | | | | |
---|
32 | | | | * implement the rmDir() function |
---|
33 | | | | |
---|
34 | | 1.3.2 | 2011/01/28 | * implement the addUI() function |
---|
35 | | | | |
---|
36 | | | | * implement getMinified() & setMinifiedState() functions |
---|
37 | | | | |
---|
38 | | 1.3.3 | 2011/02/01 | * fix bug on loadConfig() function |
---|
39 | | | | |
---|
40 | | | | * update deleteConfig() function (allow to be used to |
---|
41 | | | | delete the GPCCore config) |
---|
42 | | | | |
---|
43 | | | | * mantis bug:2167 |
---|
44 | | | | |
---|
45 | | 1.3.4 | 2011/02/02 | * mantis bug:2170 |
---|
46 | | | | . File path for RBuilder registered plugins is corrupted |
---|
47 | | | | |
---|
48 | | | | * mantis bug:2178 |
---|
49 | | | | . RBuilder register function don't work |
---|
50 | | | | |
---|
51 | | | | * mantis bug:2179 |
---|
52 | | | | . JS file loaded in wrong order made incompatibility |
---|
53 | | | | with Lightbox, GMaps & ASE plugins (and probably other) |
---|
54 | | | | |
---|
55 | | 1.4.0 | 2011/04/10 | * Updated for piwigo 2.2 |
---|
56 | | | | |
---|
57 | | 1.4.1 | 2011/09/19 | * Add [var] and [form_mail] markup interpreter |
---|
58 | | | | |
---|
59 | | | 2012/05/25 | * Add GPCUserAgent class |
---|
60 | | | | |
---|
61 | | | | * Compatibility with jquery 1.7.2 & jquery-ui 1.8.16 |
---|
62 | | | | . remove getMinified() & setMinifiedState() functions |
---|
63 | | | | (let piwigo combined function manage the minified |
---|
64 | | | | state) |
---|
65 | | | | . add manually each component for ui functionnalities |
---|
66 | | | | |
---|
67 | | | | * Remove google translate connector (google has changed the useage |
---|
68 | | | | and now an API key is needed) |
---|
69 | | | | |
---|
70 | | | | * Add js objects: inputDate, inputFilterBox, inputPages, inputSortBox, inputTag |
---|
71 | | | | dynamicTable |
---|
72 | | | | |
---|
73 | | | | * AddHeaderCSS and AddJS are ignored if called in an ajax session (AJAX_CALL defined) |
---|
74 | | | | |
---|
75 | | 1.4.2 | 2012/07/27 | * AddHeaderContent can manage 'raw' content |
---|
76 | | | | |
---|
77 | | 1.4.3 | 2012/08/29 | * Add js objects: inputTreeList + inputExportBox + download |
---|
78 | | | | |
---|
79 | | | | * Update js objects: inputText (bug fix) |
---|
80 | | | | |
---|
81 | | | | * Add urlBuild function |
---|
82 | | | | |
---|
83 | | | | |
---|
84 | | | | |
---|
85 | |
---|
86 | ------------------------------------------------------------------------------ |
---|
87 | no constructor, only static function are provided |
---|
88 | - static function loadConfig |
---|
89 | - static function loadConfigFromFile |
---|
90 | - static function saveConfig |
---|
91 | - static function deleteConfig |
---|
92 | - static function getRegistered |
---|
93 | - static function getModulesInfos |
---|
94 | - static function register |
---|
95 | - static function unregister |
---|
96 | - static function BBtoHTML |
---|
97 | - static function VarToHTML |
---|
98 | - static function TabsToHTML |
---|
99 | - static function FormMailToHTML |
---|
100 | - static function addHeaderCSS |
---|
101 | - static function addHeaderJS |
---|
102 | - static function addUI |
---|
103 | - static function getUserLanguageDesc |
---|
104 | - static function getPiwigoSystemPath |
---|
105 | - static function formatOctet |
---|
106 | - static function rmDir |
---|
107 | - static function applyMarkups |
---|
108 | - static function setTemplateToken |
---|
109 | - static function addHeaderContent |
---|
110 | - static function urlBuild |
---|
111 | ---------------------------------------------------------------------- */ |
---|
112 | |
---|
113 | |
---|
114 | |
---|
115 | class GPCCore |
---|
116 | { |
---|
117 | static private $piwigoSystemPath; |
---|
118 | |
---|
119 | static public $pluginName = "GPCCore"; |
---|
120 | static protected $headerItems = array( |
---|
121 | 'css' => array(), |
---|
122 | 'js' => array() |
---|
123 | ); |
---|
124 | |
---|
125 | static public function init() |
---|
126 | { |
---|
127 | global $conf; |
---|
128 | |
---|
129 | self::$piwigoSystemPath=dirname(dirname(dirname(dirname(__FILE__)))); |
---|
130 | |
---|
131 | if((isset($conf['gpc.markup.bb']) && $conf['gpc.markup.bb']) || |
---|
132 | (isset($conf['gpc.markup.var']) && $conf['gpc.markup.var']) || |
---|
133 | (isset($conf['gpc.markup.form']) && $conf['gpc.markup.form']) |
---|
134 | ) |
---|
135 | { |
---|
136 | add_event_handler('render_category_name', array('GPCCore', 'applyMarkups'), EVENT_HANDLER_PRIORITY_NEUTRAL+5); |
---|
137 | add_event_handler('render_category_description', array('GPCCore', 'applyMarkups'), EVENT_HANDLER_PRIORITY_NEUTRAL+5, 2); |
---|
138 | add_event_handler('render_element_description', array('GPCCore', 'applyMarkups'), EVENT_HANDLER_PRIORITY_NEUTRAL+5); |
---|
139 | add_event_handler('AP_render_content', array('GPCCore', 'applyMarkups'), EVENT_HANDLER_PRIORITY_NEUTRAL+5); |
---|
140 | } |
---|
141 | } |
---|
142 | |
---|
143 | /* --------------------------------------------------------------------------- |
---|
144 | * grum plugin classes informations functions |
---|
145 | * -------------------------------------------------------------------------*/ |
---|
146 | static public function getModulesInfos() |
---|
147 | { |
---|
148 | return( |
---|
149 | Array( |
---|
150 | Array('name' => "CommonPlugin", 'version' => "2.3.0"), |
---|
151 | Array('name' => "GPCAjax", 'version' => "3.1.0"), |
---|
152 | Array('name' => "GPCCategorySelector", 'version' => "1.0.1"), |
---|
153 | Array('name' => "GPCCompress", 'version' => "1.4.0"), |
---|
154 | Array('name' => "GPCCore", 'version' => "1.4.3"), |
---|
155 | //Array('name' => "GPCCss", 'version' => "3.1.0"), removed with v1.4.1 |
---|
156 | Array('name' => "GPCExport", 'version' => "1.0.0"), |
---|
157 | Array('name' => "GPCPagesNavigation", 'version' => "2.0.0"), |
---|
158 | Array('name' => "GPCPublicIntegration", 'version' => "2.0.0"), |
---|
159 | Array('name' => "GPCRequestBuilder", 'version' => "1.1.7"), |
---|
160 | Array('name' => "GPCTables", 'version' => "1.5.0"), |
---|
161 | Array('name' => "GPCTabSheet", 'version' => "1.1.2"), |
---|
162 | //Array('name' => "GPCTranslate", 'version' => "2.1.1"), doesn't exist anymore |
---|
163 | Array('name' => "GPCUserAgent", 'version' => "1.0.1"), |
---|
164 | Array('name' => "GPCUsersGroups", 'version' => "2.1.0") |
---|
165 | ) |
---|
166 | ); |
---|
167 | } |
---|
168 | |
---|
169 | |
---|
170 | /* --------------------------------------------------------------------------- |
---|
171 | * register oriented functions |
---|
172 | * -------------------------------------------------------------------------*/ |
---|
173 | |
---|
174 | /** |
---|
175 | * register a plugin using GPC |
---|
176 | * |
---|
177 | * @param String $pluginName : the plugin name |
---|
178 | * @param String $release : the plugin version like "2.0.0" |
---|
179 | * @param String $GPCNeed : the minimal version of GPC needed by the plugin to |
---|
180 | * work |
---|
181 | * @return Boolean : true if registering is Ok, otherwise false |
---|
182 | */ |
---|
183 | static public function register($plugin, $release, $GPCneeded) |
---|
184 | { |
---|
185 | $config=Array(); |
---|
186 | if(!self::loadConfig(self::$pluginName, $config)) |
---|
187 | { |
---|
188 | $config['registered']=array(); |
---|
189 | } |
---|
190 | |
---|
191 | $config['registered'][$plugin]=Array( |
---|
192 | 'name' => $plugin, |
---|
193 | 'release' => $release, |
---|
194 | 'needed' => $GPCneeded, |
---|
195 | 'date' => date("Y-m-d"), |
---|
196 | ); |
---|
197 | return(self::saveConfig(self::$pluginName, $config)); |
---|
198 | } |
---|
199 | |
---|
200 | /** |
---|
201 | * unregister a plugin using GPC |
---|
202 | * |
---|
203 | * assume that if the plugin was not registerd before, unregistering returns |
---|
204 | * a true value |
---|
205 | * |
---|
206 | * @param String $pluginName : the plugin name |
---|
207 | * @return Boolean : true if registering is Ok, otherwise false |
---|
208 | */ |
---|
209 | static public function unregister($plugin) |
---|
210 | { |
---|
211 | $config=Array(); |
---|
212 | if(self::loadConfig(self::$pluginName, $config)) |
---|
213 | { |
---|
214 | if(array_key_exists('registered', $config)) |
---|
215 | { |
---|
216 | if(array_key_exists($plugin, $config['registered'])) |
---|
217 | { |
---|
218 | unset($config['registered'][$plugin]); |
---|
219 | return(self::saveConfig(self::$pluginName, $config)); |
---|
220 | } |
---|
221 | } |
---|
222 | } |
---|
223 | // assume if the plugin was not registered before, unregistering it is OK |
---|
224 | return(true); |
---|
225 | } |
---|
226 | |
---|
227 | /** |
---|
228 | * return the list of registered plugins |
---|
229 | * @return Array : list of registered plugins |
---|
230 | */ |
---|
231 | static public function getRegistered() |
---|
232 | { |
---|
233 | $config=Array(); |
---|
234 | if(self::loadConfig(self::$pluginName, $config)) |
---|
235 | { |
---|
236 | if(array_key_exists('registered', $config)) |
---|
237 | { |
---|
238 | return($config['registered']); |
---|
239 | } |
---|
240 | } |
---|
241 | return(Array()); |
---|
242 | } |
---|
243 | |
---|
244 | |
---|
245 | |
---|
246 | /* --------------------------------------------------------------------------- |
---|
247 | * config oriented functions |
---|
248 | * -------------------------------------------------------------------------*/ |
---|
249 | |
---|
250 | /** |
---|
251 | * load config from CONFIG_TABLE into an array |
---|
252 | * |
---|
253 | * @param String $pluginName : the plugin name, must contain only alphanumerical |
---|
254 | * character |
---|
255 | * @param Array $config : array, initialized or not with default values ; the |
---|
256 | * config values are loaded in this value |
---|
257 | * @return Boolean : true if config is loaded, otherwise false |
---|
258 | */ |
---|
259 | static public function loadConfig($pluginName, &$config=Array()) |
---|
260 | { |
---|
261 | global $conf; |
---|
262 | |
---|
263 | if(!isset($conf[$pluginName.'_config'])) |
---|
264 | { |
---|
265 | return(false); |
---|
266 | } |
---|
267 | |
---|
268 | $configValues = unserialize($conf[$pluginName.'_config']); |
---|
269 | reset($configValues); |
---|
270 | while (list($key, $val) = each($configValues)) |
---|
271 | { |
---|
272 | if(is_array($val)) |
---|
273 | { |
---|
274 | foreach($val as $key2 => $val2) |
---|
275 | { |
---|
276 | $config[$key][$key2]=$val2; |
---|
277 | |
---|
278 | if(isset($conf['plugin.'.$pluginName]) and isset($conf['plugin.'.$pluginName][$key]) and isset($conf['plugin.'.$pluginName][$key][$key2])) |
---|
279 | $config[$key][$key2]=$conf['plugin.'.$pluginName][$key][$key2]; |
---|
280 | } |
---|
281 | } |
---|
282 | else |
---|
283 | { |
---|
284 | $config[$key]=$val; |
---|
285 | if(isset($conf['plugin.'.$pluginName]) and isset($conf['plugin.'.$pluginName][$key])) |
---|
286 | $config[$key]=$conf['plugin.'.$pluginName][$key]; |
---|
287 | } |
---|
288 | } |
---|
289 | |
---|
290 | $conf[$pluginName.'_config']=serialize($config); |
---|
291 | |
---|
292 | return(true); |
---|
293 | } |
---|
294 | |
---|
295 | /** |
---|
296 | * load config from a file into an array |
---|
297 | * |
---|
298 | * note : the config file is a PHP file one var $conf used as an array, |
---|
299 | * like the piwigo $conf var |
---|
300 | * |
---|
301 | * @param String $fileName : the file name |
---|
302 | * @param Array $config : array, initialized or not with default values ; the |
---|
303 | * config values are loaded in this value |
---|
304 | * @return Boolean : true if config is loaded, otherwise false |
---|
305 | */ |
---|
306 | static public function loadConfigFromFile($fileName, &$config=Array()) |
---|
307 | { |
---|
308 | $conf=array(); |
---|
309 | |
---|
310 | if(!is_array($config) or !file_exists($fileName)) |
---|
311 | { |
---|
312 | return(false); |
---|
313 | } |
---|
314 | |
---|
315 | include_once($fileName); |
---|
316 | |
---|
317 | foreach($conf as $key=>$val) |
---|
318 | { |
---|
319 | $config[$key]=$val; |
---|
320 | } |
---|
321 | return(true); |
---|
322 | } |
---|
323 | |
---|
324 | |
---|
325 | /** |
---|
326 | * save var $my_config into CONFIG_TABLE |
---|
327 | * |
---|
328 | * @param String $pluginName : the plugin name, must contain only alphanumerical |
---|
329 | * character |
---|
330 | * @param Array $config : array of configuration values |
---|
331 | * @return Boolean : true if config is saved, otherwise false |
---|
332 | */ |
---|
333 | static public function saveConfig($pluginName, $config) |
---|
334 | { |
---|
335 | global $conf; |
---|
336 | |
---|
337 | $sql="REPLACE INTO ".CONFIG_TABLE." |
---|
338 | VALUES('".$pluginName."_config', '" |
---|
339 | .pwg_db_real_escape_string(serialize($config))."', '')"; |
---|
340 | $result=pwg_query($sql); |
---|
341 | if($result) |
---|
342 | { |
---|
343 | $conf[$pluginName.'_config']=serialize($config); |
---|
344 | return true; |
---|
345 | } |
---|
346 | else |
---|
347 | { |
---|
348 | return false; |
---|
349 | } |
---|
350 | } |
---|
351 | |
---|
352 | /** |
---|
353 | * delete config from CONFIG_TABLE |
---|
354 | * |
---|
355 | * @param String $pluginName : the plugin name, must contain only alphanumerical |
---|
356 | * character ; if empty, assume GPCCore config |
---|
357 | * @return Boolean : true if config is deleted, otherwise false |
---|
358 | */ |
---|
359 | static public function deleteConfig($pluginName='') |
---|
360 | { |
---|
361 | if($pluginName=='') $pluginName=self::$pluginName; |
---|
362 | $sql="DELETE FROM ".CONFIG_TABLE." |
---|
363 | WHERE param='".$pluginName."_config'"; |
---|
364 | $result=pwg_query($sql); |
---|
365 | if($result) |
---|
366 | { return true; } |
---|
367 | else |
---|
368 | { return false; } |
---|
369 | } |
---|
370 | |
---|
371 | |
---|
372 | /** |
---|
373 | * convert (light) BB tag to HTML tag |
---|
374 | * |
---|
375 | * all BB codes are not recognized, only : |
---|
376 | * - [ul] [/ul] |
---|
377 | * - [li] [/li] |
---|
378 | * - [b] [/b] |
---|
379 | * - [i] [/i] |
---|
380 | * - [url] [/url] |
---|
381 | * - carriage return is replaced by a <br> |
---|
382 | * |
---|
383 | * @param String $text : text to convert |
---|
384 | * @return String : BB to HTML text |
---|
385 | */ |
---|
386 | static public function BBtoHTML($text) |
---|
387 | { |
---|
388 | $patterns = Array( |
---|
389 | '/\[li\](.*?)\[\/li\]\n*/im', |
---|
390 | '/\[b\](.*?)\[\/b\]/ism', |
---|
391 | '/\[i\](.*?)\[\/i\]/ism', |
---|
392 | '/\[p\](.*?)\[\/p\]/ism', |
---|
393 | '/\[url\]([\w]+?:\/\/[^ \"\n\r\t<]*?)\[\/url\]/ism', |
---|
394 | '/\[url=([\w]+?:\/\/[^ \"\n\r\t<]*?)\](.*?)\[\/url\]/ism', |
---|
395 | '/\n{0,1}\[ul\]\n{0,1}/im', |
---|
396 | '/\n{0,1}\[\/ul\]\n{0,1}/im', |
---|
397 | '/\n{0,1}\[ol\]\n{0,1}/im', |
---|
398 | '/\n{0,1}\[\/ol\]\n{0,1}/im', |
---|
399 | '/\n/im', |
---|
400 | ); |
---|
401 | $replacements = Array( |
---|
402 | '<li>\1</li>', |
---|
403 | '<b>\1</b>', |
---|
404 | '<i>\1</i>', |
---|
405 | '<p>\1</p>', |
---|
406 | '<a href="\1">\1</a>', |
---|
407 | '<a href="\1">\2</a>', |
---|
408 | '<ul>', |
---|
409 | '</ul>', |
---|
410 | '<ol>', |
---|
411 | '</ol>', |
---|
412 | '<br>', |
---|
413 | ); |
---|
414 | |
---|
415 | return(preg_replace($patterns, $replacements, $text)); |
---|
416 | } |
---|
417 | |
---|
418 | /** |
---|
419 | * apply [var] tag |
---|
420 | * |
---|
421 | * [var=<name>] |
---|
422 | * with <name> : |
---|
423 | * - USER |
---|
424 | * - GALLERY_TITLE |
---|
425 | * - NB_PHOTOS |
---|
426 | * - CATEGORY |
---|
427 | * - TOKEN |
---|
428 | * - IP |
---|
429 | * |
---|
430 | * @param String $text : text to convert |
---|
431 | * @return String : processed text |
---|
432 | */ |
---|
433 | static public function VarToHTML($text) |
---|
434 | { |
---|
435 | global $user, $page, $conf; |
---|
436 | |
---|
437 | $patterns = Array( |
---|
438 | '/\[var=user\]/im', |
---|
439 | '/\[var=gallery_title\]/im', |
---|
440 | '/\[var=nb_photos\]/im', |
---|
441 | '/\[var=category\]/im', |
---|
442 | '/\[var=token\]/im', |
---|
443 | '/\[var=ip\]/im' |
---|
444 | ); |
---|
445 | $replacements = Array( |
---|
446 | isset($user['username'])?$user['username']:'', |
---|
447 | isset($conf['gallery_title'])?$conf['gallery_title']:'', |
---|
448 | isset($user['nb_total_images'])?$user['nb_total_images']:'', |
---|
449 | isset($page['category']['name'])?$page['category']['name']:'', |
---|
450 | get_pwg_token(), |
---|
451 | $_SERVER['REMOTE_ADDR'] |
---|
452 | ); |
---|
453 | |
---|
454 | return(preg_replace($patterns, $replacements, $text)); |
---|
455 | } |
---|
456 | |
---|
457 | /** |
---|
458 | * apply [form_mail] tag |
---|
459 | * |
---|
460 | * @param String $text : text to convert |
---|
461 | * @return String : processed text |
---|
462 | */ |
---|
463 | static public function FormMailToHTML($text) |
---|
464 | { |
---|
465 | global $template; |
---|
466 | |
---|
467 | $file=GPCCore::getPiwigoSystemPath().'/'.PWG_LOCAL_DIR.'templates/GPCFormMsg.tpl'; |
---|
468 | if(!file_exists($file)) $file=dirname(dirname(__FILE__))."/templates/GPCFormMsg.tpl"; |
---|
469 | |
---|
470 | $template->set_filename('gpc_form', $file); |
---|
471 | |
---|
472 | $template->assign('token', get_pwg_token() ); |
---|
473 | |
---|
474 | $patterns = Array( |
---|
475 | '/\[form_mail\]/im' |
---|
476 | ); |
---|
477 | $replacements = Array( |
---|
478 | $template->parse('gpc_form', true) |
---|
479 | ); |
---|
480 | |
---|
481 | if(preg_match($patterns[0], $text)>0) |
---|
482 | { |
---|
483 | GPCCore::addHeaderJS('gpc.markup.formMail', GPC_PATH.'js/markup.formMail.js', array('jquery')); |
---|
484 | return(preg_replace($patterns, $replacements, $text)); |
---|
485 | } |
---|
486 | return($text); |
---|
487 | } |
---|
488 | |
---|
489 | /** |
---|
490 | * apply [tab], [/tab] and [tabs] tags |
---|
491 | * |
---|
492 | * @param String $text : text to convert |
---|
493 | * @return String : processed text |
---|
494 | */ |
---|
495 | static public function TabsToHTML($text) |
---|
496 | { |
---|
497 | $result=array(); |
---|
498 | |
---|
499 | $tabs=''; |
---|
500 | if(preg_match_all('/\[tab=([^(;\]).]*)(?:;(default))?;([^\].]*)\]/im', $text, $result, PREG_SET_ORDER)>0) |
---|
501 | { |
---|
502 | foreach($result as $val) |
---|
503 | { |
---|
504 | $tabs.="<li class='gpcTabSeparator'><a id='iGpcTab".$val[1]."' class='".($val[2]=='default'?'gpcTabSelected':'gpcTabNotSelected')."' tabId='#iGpcTabContent".$val[1]."'>".$val[3]."</a></li>"; |
---|
505 | } |
---|
506 | $tabs="<div id='iGpcTabs'><ul>".$tabs."</ul></div>"; |
---|
507 | } |
---|
508 | else return($text); |
---|
509 | |
---|
510 | $patterns = Array( |
---|
511 | '/\[tabs\]/im', |
---|
512 | '/\[tab=([^(;\]).]*)(?!;default);.*\]/im', |
---|
513 | '/\[tab=([^(;\]).]*);default;(.*)\]/im', |
---|
514 | '/\[\/tab\]/im' |
---|
515 | ); |
---|
516 | $replacements = Array( |
---|
517 | $tabs, |
---|
518 | '<div id="iGpcTabContent\1" class="gpcTabContent" style="display:none;">', |
---|
519 | '<div id="iGpcTabContent\1" class="gpcTabContent">', |
---|
520 | '</div>' |
---|
521 | ); |
---|
522 | |
---|
523 | if(preg_match($patterns[0], $text)>0) |
---|
524 | { |
---|
525 | GPCCore::addHeaderJS('gpc.markup.tabs', GPC_PATH.'js/markup.tabs.js', array('jquery')); |
---|
526 | GPCCore::addHeaderCSS('gpc.markup.tabs', GPC_PATH.'css/gpcTabs.css'); |
---|
527 | return(preg_replace($patterns, $replacements, $text)); |
---|
528 | } |
---|
529 | return($text); |
---|
530 | } |
---|
531 | |
---|
532 | /** |
---|
533 | * analyze and replace markups by their value, according to $conf parameted |
---|
534 | * @param String $text: text to analyze |
---|
535 | * @return String: analyzed text |
---|
536 | */ |
---|
537 | static public function applyMarkups($text) |
---|
538 | { |
---|
539 | global $conf; |
---|
540 | |
---|
541 | if(isset($conf['gpc.markup.form']) && $conf['gpc.markup.form']) |
---|
542 | { |
---|
543 | $text=GPCCore::FormMailToHTML($text); |
---|
544 | } |
---|
545 | |
---|
546 | if(isset($conf['gpc.markup.tabs']) && $conf['gpc.markup.tabs']) |
---|
547 | { |
---|
548 | $text=GPCCore::TabsToHTML($text); |
---|
549 | } |
---|
550 | |
---|
551 | if(isset($conf['gpc.markup.var']) && $conf['gpc.markup.var']) |
---|
552 | { |
---|
553 | $text=GPCCore::VarToHTML($text); |
---|
554 | } |
---|
555 | |
---|
556 | if(isset($conf['gpc.markup.bb']) && $conf['gpc.markup.bb']) |
---|
557 | { |
---|
558 | $text=GPCCore::BBtoHTML($text); |
---|
559 | } |
---|
560 | |
---|
561 | |
---|
562 | return($text); |
---|
563 | } |
---|
564 | |
---|
565 | /** |
---|
566 | * used to add a js or css directly in the header |
---|
567 | * use 'raw' type to add any raw data in the header |
---|
568 | * |
---|
569 | * @param String $id : a unique id for the file |
---|
570 | * @param String $file : the css file |
---|
571 | * @param String $order: priority |
---|
572 | */ |
---|
573 | static public function addHeaderContent($type, $content) |
---|
574 | { |
---|
575 | global $template; |
---|
576 | $null=null; |
---|
577 | |
---|
578 | if(defined('AJAX_CALL')) return(false); // not needed for an ajax call |
---|
579 | |
---|
580 | switch($type) |
---|
581 | { |
---|
582 | case 'css': |
---|
583 | $template->block_html_style(null, $content, $null, $null); |
---|
584 | break; |
---|
585 | case 'js': |
---|
586 | $template->block_html_head(null, '<script type="text/javascript">'.$content.'</script>', $null, $null); |
---|
587 | break; |
---|
588 | case 'raw': |
---|
589 | $template->block_html_head(null, $content); |
---|
590 | break; |
---|
591 | } |
---|
592 | } |
---|
593 | |
---|
594 | /** |
---|
595 | * used to add a css file in the header |
---|
596 | * |
---|
597 | * @param String $id : a unique id for the file |
---|
598 | * @param String $file : the css file |
---|
599 | * @param String $order: priority |
---|
600 | */ |
---|
601 | static public function addHeaderCSS($id, $file, $order=0) |
---|
602 | { |
---|
603 | global $template; |
---|
604 | |
---|
605 | if(defined('AJAX_CALL')) return(false); // no CSS needed for an ajax call |
---|
606 | if(!array_key_exists($id, self::$headerItems['css']) and file_exists($file)) |
---|
607 | { |
---|
608 | self::$headerItems['css'][$id]=$file; |
---|
609 | $template->func_combine_css(array('path'=>$file, 'order'=>$order), $template->smarty); |
---|
610 | } |
---|
611 | } |
---|
612 | |
---|
613 | /** |
---|
614 | * used to add a js file in the header |
---|
615 | * |
---|
616 | * @param String $id : a unique id for the file |
---|
617 | * @param String $file : the js file |
---|
618 | * @param Array $require : list of required files |
---|
619 | */ |
---|
620 | static public function addHeaderJS($id, $file, $require=array()) |
---|
621 | { |
---|
622 | global $template; |
---|
623 | |
---|
624 | if(defined('AJAX_CALL')) return(false); // no JS needed for an ajax call |
---|
625 | if(!array_key_exists($id, self::$headerItems['js']) and file_exists($file)) |
---|
626 | { |
---|
627 | self::$headerItems['js'][$id]=$file; |
---|
628 | $template->scriptLoader->add($id, 'header', $require, $file, 0); |
---|
629 | } |
---|
630 | } |
---|
631 | |
---|
632 | /** |
---|
633 | * add a ui component ; css & js dependencies are managed |
---|
634 | * |
---|
635 | * @param Array $list : possibles values are |
---|
636 | * - categorySelector |
---|
637 | * - dynamicTable |
---|
638 | * - inputCheckbox |
---|
639 | * - inputColorPicker |
---|
640 | * - inputColorsFB |
---|
641 | * - inputConsole |
---|
642 | * - inputDate |
---|
643 | * - inputDotArea |
---|
644 | * - inputFilterBox |
---|
645 | * - inputList |
---|
646 | * - inputNum |
---|
647 | * - inputPosition |
---|
648 | * - inputRadio |
---|
649 | * - inputSortBox |
---|
650 | * - inputStatusBar |
---|
651 | * - inputTag |
---|
652 | * - inputText |
---|
653 | */ |
---|
654 | static public function addUI($list) |
---|
655 | { |
---|
656 | global $template, $lang_info; |
---|
657 | |
---|
658 | if(is_string($list)) $list=explode(',', $list); |
---|
659 | if(!is_array($list)) return(false); |
---|
660 | |
---|
661 | if(defined('IN_ADMIN')) |
---|
662 | { |
---|
663 | $themeFile=GPC_PATH.'css/%s_'.$template->get_themeconf('name').'.css'; |
---|
664 | } |
---|
665 | else |
---|
666 | { |
---|
667 | $themeFile='themes/'.$template->get_themeconf('name').'/css/GPC%s.css'; |
---|
668 | } |
---|
669 | |
---|
670 | foreach($list as $ui) |
---|
671 | { |
---|
672 | switch($ui) |
---|
673 | { |
---|
674 | case 'gpcCSS': |
---|
675 | $fileName='./plugins/'.basename(dirname(dirname(__FILE__))).'/css/gpc'; |
---|
676 | self::addHeaderCSS('gpc.css', $fileName.'.css', 10); |
---|
677 | self::addHeaderCSS('gpc.cssT', $fileName.'_'.$template->get_themeconf('name').'.css', 15); |
---|
678 | break; |
---|
679 | case 'canvasDraw.graph': |
---|
680 | self::addHeaderCSS('gpc.canvasDraw', GPC_PATH.'css/canvasDraw.css'); |
---|
681 | self::addHeaderCSS('gpc.canvasDrawT', sprintf($themeFile, 'canvasDraw')); |
---|
682 | self::addHeaderJS('jquery.ui', 'themes/default/js/ui/jquery.ui.core.js', array('jquery')); |
---|
683 | self::addHeaderJS('jquery.ui.widget', 'themes/default/js/ui/jquery.ui.widget.js', array('jquery.ui')); |
---|
684 | self::addHeaderJS('jquery.ui.mouse', 'themes/default/js/ui/jquery.ui.mouse.js', array('jquery.ui.widget')); |
---|
685 | self::addHeaderJS('gpc.canvasDraw.commonClasses', GPC_PATH.'js/CanvasDraw.CommonClasses.js', array('jquery.ui.widget')); |
---|
686 | self::addHeaderJS('gpc.canvasDraw.graphClasses', GPC_PATH.'js/CanvasDraw.GraphClasses.js', array('gpc.canvasDraw.commonClasses')); |
---|
687 | self::addHeaderJS('gpc.canvasDraw.drawing', GPC_PATH.'js/CanvasDraw.Drawing.js', array('gpc.canvasDraw.graphClasses')); |
---|
688 | self::addHeaderJS('gpc.canvasDraw', GPC_PATH.'js/canvasDraw.js', array('gpc.canvasDraw.drawing')); |
---|
689 | self::addHeaderJS('gpc.canvasDraw.drawingGraph', GPC_PATH.'js/canvasDraw.ui.drawingGraph.js', array('gpc.canvasDraw')); |
---|
690 | break; |
---|
691 | case 'categorySelector': |
---|
692 | self::addHeaderCSS('gpc.categorySelector', GPC_PATH.'css/categorySelector.css'); |
---|
693 | self::addHeaderCSS('gpc.categorySelectorT', sprintf($themeFile, 'categorySelector')); |
---|
694 | self::addHeaderJS('jquery.ui', 'themes/default/js/ui/jquery.ui.core.js', array('jquery')); |
---|
695 | self::addHeaderJS('jquery.ui.widget', 'themes/default/js/ui/jquery.ui.widget.js', array('jquery.ui')); |
---|
696 | self::addHeaderJS('jquery.ui.mouse', 'themes/default/js/ui/jquery.ui.mouse.js', array('jquery.ui.widget')); |
---|
697 | self::addHeaderJS('gpc.categorySelector', GPC_PATH.'js/ui.categorySelector.js', array('jquery.ui.widget')); |
---|
698 | break; |
---|
699 | case 'inputCheckbox': |
---|
700 | self::addHeaderCSS('gpc.inputCheckbox', GPC_PATH.'css/inputCheckbox.css'); |
---|
701 | self::addHeaderJS('jquery.ui', 'themes/default/js/ui/jquery.ui.core.js', array('jquery')); |
---|
702 | self::addHeaderJS('gpc.inputCheckbox', GPC_PATH.'js/ui.inputCheckbox.js', array('jquery.ui')); |
---|
703 | break; |
---|
704 | case 'inputColorPicker': |
---|
705 | self::addHeaderCSS('gpc.inputText', GPC_PATH.'css/inputText.css'); |
---|
706 | self::addHeaderCSS('gpc.inputNum', GPC_PATH.'css/inputNum.css'); |
---|
707 | self::addHeaderCSS('gpc.inputColorsFB', GPC_PATH.'css/inputColorsFB.css'); |
---|
708 | self::addHeaderCSS('gpc.inputDotArea', GPC_PATH.'css/inputDotArea.css'); |
---|
709 | self::addHeaderCSS('gpc.inputColorPicker', GPC_PATH.'css/inputColorPicker.css'); |
---|
710 | self::addHeaderCSS('gpc.inputTextT', sprintf($themeFile, 'inputText')); |
---|
711 | self::addHeaderCSS('gpc.inputNumT', sprintf($themeFile, 'inputNum')); |
---|
712 | self::addHeaderCSS('gpc.inputColorsFBT', sprintf($themeFile, 'inputColorsFB')); |
---|
713 | self::addHeaderCSS('gpc.inputDotAreaT', sprintf($themeFile, 'inputDotArea')); |
---|
714 | self::addHeaderCSS('gpc.inputColorPickerT', sprintf($themeFile, 'inputColorPicker')); |
---|
715 | self::addHeaderJS('jquery.ui', 'themes/default/js/ui/jquery.ui.core.js', array('jquery')); |
---|
716 | self::addHeaderJS('jquery.ui.widget', 'themes/default/js/ui/jquery.ui.widget.js', array('jquery.ui')); |
---|
717 | self::addHeaderJS('jquery.ui.mouse', 'themes/default/js/ui/jquery.ui.mouse.js', array('jquery.ui.widget')); |
---|
718 | self::addHeaderJS('jquery.ui.position', 'themes/default/js/ui/jquery.ui.position.js', array('jquery.ui.widget')); |
---|
719 | self::addHeaderJS('jquery.ui.draggable', 'themes/default/js/ui/jquery.ui.draggable.js', array('jquery.ui.widget')); |
---|
720 | self::addHeaderJS('jquery.ui.dialog', 'themes/default/js/ui/jquery.ui.dialog.js', array('jquery.ui.widget')); |
---|
721 | self::addHeaderJS('jquery.ui.slider', 'themes/default/js/ui/jquery.ui.slider.js', array('jquery.ui.widget')); |
---|
722 | self::addHeaderJS('gpc.inputText', GPC_PATH.'js/ui.inputText.js', array('jquery.ui.widget')); |
---|
723 | self::addHeaderJS('gpc.inputNum', GPC_PATH.'js/ui.inputNum.js', array('jquery.ui.widget')); |
---|
724 | self::addHeaderJS('gpc.inputColorsFB', GPC_PATH.'js/ui.inputColorsFB.js', array('jquery.ui.widget')); |
---|
725 | self::addHeaderJS('gpc.inputDotArea', GPC_PATH.'js/ui.inputDotArea.js', array('jquery.ui.widget')); |
---|
726 | self::addHeaderJS('gpc.inputColorPicker', GPC_PATH.'js/ui.inputColorPicker.js', array('jquery.ui.slider','gpc.inputText','gpc.inputNum','gpc.inputColorsFB','gpc.inputDotArea')); |
---|
727 | break; |
---|
728 | case 'inputColorsFB': |
---|
729 | self::addHeaderCSS('gpc.inputColorsFB', GPC_PATH.'css/inputColorsFB.css'); |
---|
730 | self::addHeaderCSS('gpc.inputColorsFBT', sprintf($themeFile, 'inputColorsFB')); |
---|
731 | self::addHeaderJS('jquery.ui', 'themes/default/js/ui/jquery.ui.core.js', array('jquery')); |
---|
732 | self::addHeaderJS('jquery.ui.widget', 'themes/default/js/ui/jquery.ui.widget.js', array('jquery.ui')); |
---|
733 | self::addHeaderJS('gpc.inputColorsFB', GPC_PATH.'js/ui.inputColorsFB.js', array('jquery.ui.widget')); |
---|
734 | break; |
---|
735 | case 'inputConsole': |
---|
736 | self::addHeaderCSS('gpc.inputConsole', GPC_PATH.'css/inputConsole.css'); |
---|
737 | self::addHeaderCSS('gpc.inputConsoleT', sprintf($themeFile, 'inputConsole')); |
---|
738 | self::addHeaderJS('jquery.ui', 'themes/default/js/ui/jquery.ui.core.js', array('jquery')); |
---|
739 | self::addHeaderJS('jquery.ui.widget', 'themes/default/js/ui/jquery.ui.widget.js', array('jquery.ui')); |
---|
740 | self::addHeaderJS('gpc.inputConsole', GPC_PATH.'js/ui.inputConsole.js', array('jquery.ui.widget')); |
---|
741 | break; |
---|
742 | case 'inputDate': |
---|
743 | self::addHeaderCSS('jquery.ui.datepicker', 'themes/default/js/ui/theme/jquery.ui.datepicker.css'); |
---|
744 | self::addHeaderCSS('gpc.inputDate', GPC_PATH.'css/inputDate.css'); |
---|
745 | self::addHeaderCSS('gpc.inputDateT', sprintf($themeFile, 'inputDate')); |
---|
746 | self::addHeaderJS('jquery.ui', 'themes/default/js/ui/jquery.ui.core.js', array('jquery')); |
---|
747 | self::addHeaderJS('jquery.ui.widget', 'themes/default/js/ui/jquery.ui.widget.js', array('jquery.ui')); |
---|
748 | self::addHeaderJS('jquery.ui.datepicker', 'themes/default/js/ui/jquery.ui.datepicker.js', array('jquery.ui.widget')); |
---|
749 | self::addHeaderJS('jquery.ui.datepicker-'.$lang_info['code'], self::getPiwigoSystemPath().'themes/default/js/ui/i18n/jquery.ui.datepicker-'.$lang_info['code'].'.js'); |
---|
750 | self::addHeaderJS('gpc.inputDate', GPC_PATH.'js/ui.inputDate.js', array('jquery.ui.widget')); |
---|
751 | break; |
---|
752 | case 'inputDotArea': |
---|
753 | self::addHeaderCSS('gpc.inputDotArea', GPC_PATH.'css/inputDotArea.css'); |
---|
754 | self::addHeaderCSS('gpc.inputDotAreaT', sprintf($themeFile, 'inputDotArea')); |
---|
755 | self::addHeaderJS('jquery.ui', 'themes/default/js/ui/jquery.ui.core.js', array('jquery')); |
---|
756 | self::addHeaderJS('jquery.ui.widget', 'themes/default/js/ui/jquery.ui.widget.js', array('jquery.ui')); |
---|
757 | self::addHeaderJS('gpc.inputDotArea', GPC_PATH.'js/ui.inputDotArea.js', array('jquery.ui.widget')); |
---|
758 | break; |
---|
759 | case 'inputExportBox': |
---|
760 | self::addHeaderCSS('gpc.inputText', GPC_PATH.'css/inputText.css'); |
---|
761 | self::addHeaderCSS('gpc.inputTextT', sprintf($themeFile, 'inputText')); |
---|
762 | self::addHeaderCSS('gpc.inputList', GPC_PATH.'css/inputList.css'); |
---|
763 | self::addHeaderCSS('gpc.inputListT', sprintf($themeFile, 'inputList')); |
---|
764 | self::addHeaderCSS('gpc.inputExportBox', GPC_PATH.'css/inputExportBox.css'); |
---|
765 | self::addHeaderCSS('gpc.inputExportBoxT', sprintf($themeFile, 'inputExportBox')); |
---|
766 | |
---|
767 | self::addHeaderJS('jquery.ui', 'themes/default/js/ui/jquery.ui.core.js', array('jquery')); |
---|
768 | self::addHeaderJS('jquery.ui.widget', 'themes/default/js/ui/jquery.ui.widget.js', array('jquery.ui')); |
---|
769 | |
---|
770 | self::addHeaderJS('jquery.ui.widget', 'themes/default/js/ui/jquery.ui.widget.js', array('jquery.ui')); |
---|
771 | self::addHeaderJS('jquery.ui.mouse', 'themes/default/js/ui/jquery.ui.mouse.js', array('jquery.ui.widget')); |
---|
772 | self::addHeaderJS('jquery.ui.position', 'themes/default/js/ui/jquery.ui.position.js', array('jquery.ui.mouse')); |
---|
773 | self::addHeaderJS('jquery.ui.resizable', 'themes/default/js/ui/jquery.ui.resizable.js', array('jquery.ui.position')); |
---|
774 | self::addHeaderJS('jquery.ui.draggable', 'themes/default/js/ui/jquery.ui.draggable.js', array('jquery.ui.resizable')); |
---|
775 | self::addHeaderJS('jquery.ui.sortable', 'themes/default/js/ui/jquery.ui.sortable.js', array('jquery.ui.draggable')); |
---|
776 | self::addHeaderJS('jquery.ui.dialog', 'themes/default/js/ui/jquery.ui.dialog.js', array('jquery.ui.sortable')); |
---|
777 | |
---|
778 | self::addHeaderJS('gpc.inputText', GPC_PATH.'js/ui.inputText.js', array('jquery.ui.dialog')); |
---|
779 | self::addHeaderJS('gpc.inputList', GPC_PATH.'js/ui.inputList.js', array('jquery.ui.dialog')); |
---|
780 | self::addHeaderJS('gpc.inputExportBox', GPC_PATH.'js/ui.inputExportBox.js', array('jquery.ui.dialog')); |
---|
781 | break; |
---|
782 | case 'inputFilterBox': |
---|
783 | self::addHeaderCSS('jquery.ui.datepicker', 'themes/default/js/ui/theme/jquery.ui.datepicker.css'); |
---|
784 | self::addHeaderCSS('gpc.inputNum', GPC_PATH.'css/inputNum.css'); |
---|
785 | self::addHeaderCSS('gpc.inputNumT', sprintf($themeFile, 'inputNum')); |
---|
786 | self::addHeaderCSS('gpc.inputDate', GPC_PATH.'css/inputDate.css'); |
---|
787 | self::addHeaderCSS('gpc.inputDateT', sprintf($themeFile, 'inputDate')); |
---|
788 | self::addHeaderCSS('gpc.inputText', GPC_PATH.'css/inputText.css'); |
---|
789 | self::addHeaderCSS('gpc.inputTextT', sprintf($themeFile, 'inputText')); |
---|
790 | self::addHeaderCSS('gpc.inputList', GPC_PATH.'css/inputList.css'); |
---|
791 | self::addHeaderCSS('gpc.inputListT', sprintf($themeFile, 'inputList')); |
---|
792 | self::addHeaderCSS('gpc.inputFilterBox', GPC_PATH.'css/inputFilterBox.css'); |
---|
793 | self::addHeaderCSS('gpc.inputFilterBoxT', sprintf($themeFile, 'inputFilterBox')); |
---|
794 | |
---|
795 | self::addHeaderJS('jquery.ui', 'themes/default/js/ui/jquery.ui.core.js', array('jquery')); |
---|
796 | self::addHeaderJS('jquery.ui.widget', 'themes/default/js/ui/jquery.ui.widget.js', array('jquery.ui')); |
---|
797 | |
---|
798 | self::addHeaderJS('jquery.ui.widget', 'themes/default/js/ui/jquery.ui.widget.js', array('jquery.ui')); |
---|
799 | self::addHeaderJS('jquery.ui.mouse', 'themes/default/js/ui/jquery.ui.mouse.js', array('jquery.ui.widget')); |
---|
800 | self::addHeaderJS('jquery.ui.position', 'themes/default/js/ui/jquery.ui.position.js', array('jquery.ui.mouse')); |
---|
801 | self::addHeaderJS('jquery.ui.resizable', 'themes/default/js/ui/jquery.ui.resizable.js', array('jquery.ui.position')); |
---|
802 | self::addHeaderJS('jquery.ui.draggable', 'themes/default/js/ui/jquery.ui.draggable.js', array('jquery.ui.resizable')); |
---|
803 | self::addHeaderJS('jquery.ui.sortable', 'themes/default/js/ui/jquery.ui.sortable.js', array('jquery.ui.draggable')); |
---|
804 | self::addHeaderJS('jquery.ui.dialog', 'themes/default/js/ui/jquery.ui.dialog.js', array('jquery.ui.sortable')); |
---|
805 | self::addHeaderJS('jquery.ui.datepicker', 'themes/default/js/ui/jquery.ui.datepicker.js', array('jquery.ui.widget')); |
---|
806 | self::addHeaderJS('jquery.ui.datepicker-'.$lang_info['code'], self::getPiwigoSystemPath().'themes/default/js/ui/i18n/jquery.ui.datepicker-'.$lang_info['code'].'.js'); |
---|
807 | |
---|
808 | self::addHeaderJS('gpc.inputNum', GPC_PATH.'js/ui.inputNum.js', array('jquery.ui.dialog')); |
---|
809 | self::addHeaderJS('gpc.inputList', GPC_PATH.'js/ui.inputList.js', array('jquery.ui.dialog')); |
---|
810 | self::addHeaderJS('gpc.inputText', GPC_PATH.'js/ui.inputText.js', array('jquery.ui.dialog')); |
---|
811 | self::addHeaderJS('gpc.inputDate', GPC_PATH.'js/ui.inputDate.js', array('jquery.ui.dialog')); |
---|
812 | self::addHeaderJS('gpc.inputFilterBox', GPC_PATH.'js/ui.inputFilterBox.js', array('jquery.ui.dialog')); |
---|
813 | break; |
---|
814 | case 'inputList': |
---|
815 | self::addHeaderCSS('gpc.inputList', GPC_PATH.'css/inputList.css'); |
---|
816 | self::addHeaderCSS('gpc.inputListT', sprintf($themeFile, 'inputList')); |
---|
817 | self::addHeaderJS('jquery.ui', 'themes/default/js/ui/jquery.ui.core.js', array('jquery')); |
---|
818 | self::addHeaderJS('jquery.ui.widget', 'themes/default/js/ui/jquery.ui.widget.js', array('jquery.ui')); |
---|
819 | self::addHeaderJS('gpc.inputList', GPC_PATH.'js/ui.inputList.js', array('jquery.ui.widget')); |
---|
820 | break; |
---|
821 | case 'inputNum': |
---|
822 | self::addHeaderCSS('gpc.inputNum', GPC_PATH.'css/inputNum.css'); |
---|
823 | self::addHeaderCSS('gpc.inputNumT', sprintf($themeFile, 'inputNum')); |
---|
824 | self::addHeaderJS('jquery.ui', 'themes/default/js/ui/jquery.ui.core.js', array('jquery')); |
---|
825 | self::addHeaderJS('jquery.ui.widget', 'themes/default/js/ui/jquery.ui.widget.js', array('jquery.ui')); |
---|
826 | self::addHeaderJS('jquery.ui.mouse', 'themes/default/js/ui/jquery.ui.mouse.js', array('jquery.ui.widget')); |
---|
827 | self::addHeaderJS('jquery.ui.slider', 'themes/default/js/ui/jquery.ui.slider.js', array('jquery.ui.widget')); |
---|
828 | self::addHeaderJS('gpc.inputNum', GPC_PATH.'js/ui.inputNum.js', array('jquery','jquery.ui.slider')); |
---|
829 | break; |
---|
830 | case 'inputPages': |
---|
831 | self::addHeaderCSS('gpc.inputPages', GPC_PATH.'css/inputPages.css'); |
---|
832 | self::addHeaderCSS('gpc.inputPagesT', sprintf($themeFile, 'inputPages')); |
---|
833 | self::addHeaderJS('jquery.ui', 'themes/default/js/ui/jquery.ui.core.js', array('jquery')); |
---|
834 | self::addHeaderJS('jquery.ui.widget', 'themes/default/js/ui/jquery.ui.widget.js', array('jquery.ui')); |
---|
835 | self::addHeaderJS('gpc.inputPages', GPC_PATH.'js/ui.inputPages.js', array('jquery','jquery.ui.widget')); |
---|
836 | break; |
---|
837 | case 'inputPath': |
---|
838 | self::addHeaderCSS('gpc.inputPath', GPC_PATH.'css/inputPath.css'); |
---|
839 | self::addHeaderCSS('gpc.inputPathT', sprintf($themeFile, 'inputPath')); |
---|
840 | self::addHeaderJS('jquery.ui', 'themes/default/js/ui/jquery.ui.core.js', array('jquery')); |
---|
841 | self::addHeaderJS('jquery.ui.widget', 'themes/default/js/ui/jquery.ui.widget.js', array('jquery.ui')); |
---|
842 | self::addHeaderJS('gpc.inputPath', GPC_PATH.'js/ui.inputPath.js', array('jquery','jquery.ui.widget')); |
---|
843 | break; |
---|
844 | case 'inputPosition': |
---|
845 | self::addHeaderCSS('gpc.inputPosition', GPC_PATH.'css/inputPosition.css'); |
---|
846 | self::addHeaderCSS('gpc.inputPositionT', sprintf($themeFile, 'inputPosition')); |
---|
847 | self::addHeaderJS('jquery.ui', 'themes/default/js/ui/jquery.ui.core.js', array('jquery')); |
---|
848 | self::addHeaderJS('jquery.ui.widget', 'themes/default/js/ui/jquery.ui.widget.js', array('jquery.ui')); |
---|
849 | self::addHeaderJS('gpc.inputPosition', GPC_PATH.'js/ui.inputPosition.js', array('jquery.ui.widget')); |
---|
850 | break; |
---|
851 | case 'inputRadio': |
---|
852 | self::addHeaderJS('jquery.ui', 'themes/default/js/ui/jquery.ui.core.js', array('jquery')); |
---|
853 | self::addHeaderJS('jquery.ui.widget', 'themes/default/js/ui/jquery.ui.widget.js', array('jquery.ui')); |
---|
854 | self::addHeaderJS('gpc.inputRadio', GPC_PATH.'js/ui.inputRadio.js', array('jquery.ui.widget')); |
---|
855 | break; |
---|
856 | case 'inputSortBox': |
---|
857 | self::addHeaderCSS('gpc.inputSortBox', GPC_PATH.'css/inputSortBox.css'); |
---|
858 | self::addHeaderCSS('gpc.inputSortBoxT', sprintf($themeFile, 'inputSortBox')); |
---|
859 | self::addHeaderJS('jquery.ui', 'themes/default/js/ui/jquery.ui.core.js', array('jquery')); |
---|
860 | self::addHeaderJS('jquery.ui.widget', 'themes/default/js/ui/jquery.ui.widget.js', array('jquery.ui')); |
---|
861 | self::addHeaderJS('jquery.ui.mouse', 'themes/default/js/ui/jquery.ui.mouse.js', array('jquery.ui.widget')); |
---|
862 | self::addHeaderJS('jquery.ui.position', 'themes/default/js/ui/jquery.ui.position.js', array('jquery.ui.mouse')); |
---|
863 | self::addHeaderJS('jquery.ui.draggable', 'themes/default/js/ui/jquery.ui.draggable.js', array('jquery.ui.position')); |
---|
864 | self::addHeaderJS('jquery.ui.sortable', 'themes/default/js/ui/jquery.ui.sortable.js', array('jquery.ui.draggable')); |
---|
865 | self::addHeaderJS('jquery.ui.dialog', 'themes/default/js/ui/jquery.ui.dialog.js', array('jquery.ui.sortable')); |
---|
866 | self::addHeaderJS('gpc.inputSortBox', GPC_PATH.'js/ui.inputSortBox.js', array('jquery.ui.dialog')); |
---|
867 | break; |
---|
868 | case 'inputStatusBar': |
---|
869 | self::addHeaderCSS('gpc.inputStatusBar', GPC_PATH.'css/inputStatusBar.css'); |
---|
870 | self::addHeaderCSS('gpc.inputStatusBarT', sprintf($themeFile, 'inputStatusBar')); |
---|
871 | self::addHeaderJS('jquery.ui', 'themes/default/js/ui/jquery.ui.core.js', array('jquery')); |
---|
872 | self::addHeaderJS('jquery.ui.widget', 'themes/default/js/ui/jquery.ui.widget.js', array('jquery.ui')); |
---|
873 | self::addHeaderJS('gpc.inputStatusBar', GPC_PATH.'js/ui.inputStatusBar.js', array('jquery.ui.widget')); |
---|
874 | break; |
---|
875 | case 'inputSwitchButton': |
---|
876 | self::addHeaderCSS('gpc.inputSwitchButton', GPC_PATH.'css/inputSwitchButton.css'); |
---|
877 | self::addHeaderCSS('gpc.inputSwitchButtonT', sprintf($themeFile, 'inputSwitchButton')); |
---|
878 | self::addHeaderJS('jquery.ui', 'themes/default/js/ui/jquery.ui.core.js', array('jquery')); |
---|
879 | self::addHeaderJS('jquery.ui.widget', 'themes/default/js/ui/jquery.ui.widget.js', array('jquery.ui')); |
---|
880 | self::addHeaderJS('gpc.inputSwitchButton', GPC_PATH.'js/ui.inputSwitchButton.js', array('jquery.ui.widget')); |
---|
881 | break; |
---|
882 | case 'inputTag': |
---|
883 | self::addHeaderCSS('gpc.inputTag', GPC_PATH.'css/inputTag.css'); |
---|
884 | self::addHeaderCSS('gpc.inputTagT', sprintf($themeFile, 'inputTag')); |
---|
885 | self::addHeaderJS('jquery.ui', 'themes/default/js/ui/jquery.ui.core.js', array('jquery')); |
---|
886 | self::addHeaderJS('jquery.ui.widget', 'themes/default/js/ui/jquery.ui.widget.js', array('jquery.ui')); |
---|
887 | self::addHeaderJS('gpc.inputTag', GPC_PATH.'js/ui.inputTag.js', array('jquery.ui.widget')); |
---|
888 | break; |
---|
889 | case 'inputText': |
---|
890 | self::addHeaderCSS('gpc.inputText', GPC_PATH.'css/inputText.css'); |
---|
891 | self::addHeaderCSS('gpc.inputTextT', sprintf($themeFile, 'inputText')); |
---|
892 | self::addHeaderJS('jquery.ui', 'themes/default/js/ui/jquery.ui.core.js', array('jquery')); |
---|
893 | self::addHeaderJS('jquery.ui.widget', 'themes/default/js/ui/jquery.ui.widget.js', array('jquery.ui')); |
---|
894 | self::addHeaderJS('gpc.inputText', GPC_PATH.'js/ui.inputText.js', array('jquery.ui.widget')); |
---|
895 | break; |
---|
896 | case 'inputTreeList': |
---|
897 | self::addHeaderCSS('gpc.inputTreeList', GPC_PATH.'css/inputTreeList.css'); |
---|
898 | self::addHeaderCSS('gpc.inputTreeListT', sprintf($themeFile, 'inputTreeList')); |
---|
899 | self::addHeaderJS('jquery.ui', 'themes/default/js/ui/jquery.ui.core.js', array('jquery')); |
---|
900 | self::addHeaderJS('jquery.ui.widget', 'themes/default/js/ui/jquery.ui.widget.js', array('jquery.ui')); |
---|
901 | self::addHeaderJS('gpc.inputTreeList', GPC_PATH.'js/ui.inputTreeList.js', array('jquery.ui.widget')); |
---|
902 | break; |
---|
903 | case 'simpleTip': |
---|
904 | self::addHeaderCSS('gpc.simpleTip', GPC_PATH.'css/simpleTip.css'); |
---|
905 | self::addHeaderCSS('gpc.simpleTipT', sprintf($themeFile, 'simpleTip')); |
---|
906 | self::addHeaderJS('jquery.ui', 'themes/default/js/ui/jquery.ui.core.js', array('jquery')); |
---|
907 | self::addHeaderJS('jquery.ui.widget', 'themes/default/js/ui/jquery.ui.widget.js', array('jquery.ui')); |
---|
908 | self::addHeaderJS('gpc.simpleTip', GPC_PATH.'js/simpleTip.js', array('jquery.ui.widget')); |
---|
909 | break; |
---|
910 | case 'download': |
---|
911 | self::addHeaderJS('jquery.ui', 'themes/default/js/ui/jquery.ui.core.js', array('jquery')); |
---|
912 | self::addHeaderJS('gpc.download', GPC_PATH.'js/ui.download.js', array('jquery')); |
---|
913 | break; |
---|
914 | case 'dynamicTable': |
---|
915 | self::addHeaderCSS('jquery.ui.datepicker', 'themes/default/js/ui/theme/jquery.ui.datepicker.css'); |
---|
916 | self::addHeaderCSS('gpc.inputNum', GPC_PATH.'css/inputNum.css'); |
---|
917 | self::addHeaderCSS('gpc.inputNumT', sprintf($themeFile, 'inputNum')); |
---|
918 | self::addHeaderCSS('gpc.inputDate', GPC_PATH.'css/inputDate.css'); |
---|
919 | self::addHeaderCSS('gpc.inputDateT', sprintf($themeFile, 'inputDate')); |
---|
920 | self::addHeaderCSS('gpc.inputText', GPC_PATH.'css/inputText.css'); |
---|
921 | self::addHeaderCSS('gpc.inputTextT', sprintf($themeFile, 'inputText')); |
---|
922 | self::addHeaderCSS('gpc.inputList', GPC_PATH.'css/inputList.css'); |
---|
923 | self::addHeaderCSS('gpc.inputListT', sprintf($themeFile, 'inputList')); |
---|
924 | self::addHeaderCSS('gpc.inputSortBox', GPC_PATH.'css/inputSortBox.css'); |
---|
925 | self::addHeaderCSS('gpc.inputSortBoxT', sprintf($themeFile, 'inputSortBox')); |
---|
926 | self::addHeaderCSS('gpc.inputFilterBox', GPC_PATH.'css/inputFilterBox.css'); |
---|
927 | self::addHeaderCSS('gpc.inputFilterBoxT', sprintf($themeFile, 'inputFilterBox')); |
---|
928 | self::addHeaderCSS('gpc.inputPages', GPC_PATH.'css/inputPages.css'); |
---|
929 | self::addHeaderCSS('gpc.inputPagesT', sprintf($themeFile, 'inputPages')); |
---|
930 | self::addHeaderCSS('gpc.dynamicTable', GPC_PATH.'css/dynamicTable.css'); |
---|
931 | self::addHeaderCSS('gpc.dynamicTableT', sprintf($themeFile, 'dynamicTable')); |
---|
932 | |
---|
933 | self::addHeaderJS('jquery.ui', 'themes/default/js/ui/jquery.ui.core.js', array('jquery')); |
---|
934 | self::addHeaderJS('jquery.ui.widget', 'themes/default/js/ui/jquery.ui.widget.js', array('jquery.ui')); |
---|
935 | |
---|
936 | self::addHeaderJS('jquery.ui.mouse', 'themes/default/js/ui/jquery.ui.mouse.js', array('jquery.ui.widget')); |
---|
937 | self::addHeaderJS('jquery.ui.position', 'themes/default/js/ui/jquery.ui.position.js', array('jquery.ui.mouse')); |
---|
938 | self::addHeaderJS('jquery.ui.resizable', 'themes/default/js/ui/jquery.ui.resizable.js', array('jquery.ui.position')); |
---|
939 | self::addHeaderJS('jquery.ui.draggable', 'themes/default/js/ui/jquery.ui.draggable.js', array('jquery.ui.resizable')); |
---|
940 | self::addHeaderJS('jquery.ui.sortable', 'themes/default/js/ui/jquery.ui.sortable.js', array('jquery.ui.draggable')); |
---|
941 | self::addHeaderJS('jquery.ui.dialog', 'themes/default/js/ui/jquery.ui.dialog.js', array('jquery.ui.sortable')); |
---|
942 | self::addHeaderJS('jquery.ui.datepicker', 'themes/default/js/ui/jquery.ui.datepicker.js', array('jquery.ui.widget')); |
---|
943 | self::addHeaderJS('jquery.ui.datepicker-'.$lang_info['code'], self::getPiwigoSystemPath().'themes/default/js/ui/i18n/jquery.ui.datepicker-'.$lang_info['code'].'.js'); |
---|
944 | |
---|
945 | self::addHeaderJS('gpc.inputNum', GPC_PATH.'js/ui.inputNum.js', array('jquery.ui.dialog')); |
---|
946 | self::addHeaderJS('gpc.inputList', GPC_PATH.'js/ui.inputList.js', array('jquery.ui.dialog')); |
---|
947 | self::addHeaderJS('gpc.inputText', GPC_PATH.'js/ui.inputText.js', array('jquery.ui.dialog')); |
---|
948 | self::addHeaderJS('gpc.inputDate', GPC_PATH.'js/ui.inputDate.js', array('jquery.ui.dialog')); |
---|
949 | self::addHeaderJS('gpc.inputFilterBox', GPC_PATH.'js/ui.inputFilterBox.js', array('jquery.ui.dialog')); |
---|
950 | self::addHeaderJS('gpc.inputSortBox', GPC_PATH.'js/ui.inputSortBox.js', array('jquery.ui.dialog')); |
---|
951 | self::addHeaderJS('gpc.inputPages', GPC_PATH.'js/ui.inputPages.js', array('jquery.ui.dialog')); |
---|
952 | self::addHeaderJS('gpc.dynamicTable', GPC_PATH.'js/ui.dynamicTable.js', array('jquery.ui.dialog')); |
---|
953 | break; |
---|
954 | case 'progressArea': |
---|
955 | self::addHeaderCSS('gpc.progressArea', GPC_PATH.'css/progressArea.css'); |
---|
956 | self::addHeaderCSS('gpc.progressAreaT', sprintf($themeFile, 'progressArea')); |
---|
957 | self::addHeaderJS('jquery.ui', 'themes/default/js/ui/jquery.ui.core.js', array('jquery')); |
---|
958 | self::addHeaderJS('jquery.ui.widget', 'themes/default/js/ui/jquery.ui.widget.js', array('jquery.ui')); |
---|
959 | self::addHeaderJS('jquery.ui.mouse', 'themes/default/js/ui/jquery.ui.mouse.js', array('jquery.ui.widget')); |
---|
960 | self::addHeaderJS('jquery.ui.position', 'themes/default/js/ui/jquery.ui.position.js', array('jquery.ui.mouse')); |
---|
961 | self::addHeaderJS('jquery.ui.draggable', 'themes/default/js/ui/jquery.ui.draggable.js', array('jquery.ui.position')); |
---|
962 | self::addHeaderJS('jquery.ui.sortable', 'themes/default/js/ui/jquery.ui.sortable.js', array('jquery.ui.draggable')); |
---|
963 | self::addHeaderJS('jquery.ui.dialog', 'themes/default/js/ui/jquery.ui.dialog.js', array('jquery.ui.sortable')); |
---|
964 | self::addHeaderJS('gpc.progressArea', GPC_PATH.'js/ui.progressArea.js', array('jquery.ui.dialog')); |
---|
965 | break; |
---|
966 | case 'timer': |
---|
967 | self::addHeaderJS('gpc.timer', GPC_PATH.'js/ui.timer.js', array('jquery')); |
---|
968 | break; |
---|
969 | } |
---|
970 | } |
---|
971 | } |
---|
972 | |
---|
973 | |
---|
974 | /** |
---|
975 | * build an url from given properties |
---|
976 | * |
---|
977 | * @param String $urlType: type of url to build |
---|
978 | * @param Array $properties: properties used to build url |
---|
979 | * @return String: url, or empty string if not possible to build it |
---|
980 | */ |
---|
981 | static public function urlBuild($type, $properties=array()) |
---|
982 | { |
---|
983 | $returned=''; |
---|
984 | switch($type) |
---|
985 | { |
---|
986 | case 'admin.picture': |
---|
987 | if(isset($properties['pictureId'])) |
---|
988 | { |
---|
989 | $returned='./admin.php?page=photo-'.$properties['pictureId']; |
---|
990 | } |
---|
991 | break; |
---|
992 | case 'admin.category': |
---|
993 | case 'admin.album': |
---|
994 | if(isset($properties['categoryId'])) |
---|
995 | { |
---|
996 | $returned='./admin.php?page=album-'.$properties['categoryId']; |
---|
997 | } |
---|
998 | break; |
---|
999 | } |
---|
1000 | return($returned); |
---|
1001 | } |
---|
1002 | |
---|
1003 | |
---|
1004 | /** |
---|
1005 | * use the extended description get_user_language_desc() function if exist |
---|
1006 | * otherwise returns the value |
---|
1007 | * |
---|
1008 | * @param String $value : value to translate |
---|
1009 | * @return String : translated value |
---|
1010 | */ |
---|
1011 | static public function getUserLanguageDesc($value) |
---|
1012 | { |
---|
1013 | if(function_exists('get_user_language_desc')) |
---|
1014 | { |
---|
1015 | return(get_user_language_desc($value)); |
---|
1016 | } |
---|
1017 | else |
---|
1018 | { |
---|
1019 | return($value); |
---|
1020 | } |
---|
1021 | } |
---|
1022 | |
---|
1023 | |
---|
1024 | /** |
---|
1025 | * remove a path recursively |
---|
1026 | * |
---|
1027 | * @param String $directory : directory to remove |
---|
1028 | * @param Bool $removePath : if set to true, remove the path himself, if set |
---|
1029 | * to false, remove only file & sub-directories |
---|
1030 | * @return Bool : true if directory was succesfully removed, otherwise false |
---|
1031 | */ |
---|
1032 | static public function rmDir($directory, $removePath=true) |
---|
1033 | { |
---|
1034 | $directory=rtrim($directory, '\/').'/'; |
---|
1035 | $returned=true; |
---|
1036 | if(file_exists($directory) and is_dir($directory) and $directory!='./' and $directory!='../') |
---|
1037 | { |
---|
1038 | $dhandle=scandir($directory); |
---|
1039 | foreach($dhandle as $file) |
---|
1040 | { |
---|
1041 | if($file!='.' and $file!='..' ) |
---|
1042 | { |
---|
1043 | if(is_dir($directory.$file)) |
---|
1044 | { |
---|
1045 | $returned=self::rmDir($directory.$file, true) & $returned; |
---|
1046 | } |
---|
1047 | else |
---|
1048 | { |
---|
1049 | $returned=unlink($directory.$file) & $returned; |
---|
1050 | } |
---|
1051 | } |
---|
1052 | } |
---|
1053 | if($returned and $removePath) $returned=rmdir($directory); |
---|
1054 | } |
---|
1055 | return($returned); |
---|
1056 | } |
---|
1057 | |
---|
1058 | |
---|
1059 | /** |
---|
1060 | * returns the piwigo system path |
---|
1061 | * @return String |
---|
1062 | */ |
---|
1063 | static public function getPiwigoSystemPath() |
---|
1064 | { |
---|
1065 | return(self::$piwigoSystemPath); |
---|
1066 | } |
---|
1067 | |
---|
1068 | |
---|
1069 | /** |
---|
1070 | * formats a file size into a human readable size |
---|
1071 | * |
---|
1072 | * @param String $format : "A" : auto |
---|
1073 | * "Ai" : auto (io) |
---|
1074 | * "O" : o |
---|
1075 | * "K" : Ko |
---|
1076 | * "M" : Mo |
---|
1077 | * "G" : Go |
---|
1078 | * "Ki" : Kio |
---|
1079 | * "Mi" : Mio |
---|
1080 | * "Gi" : Gio |
---|
1081 | * @param String $thsep : thousand separator |
---|
1082 | * @param Integer $prec : number of decimals |
---|
1083 | * @param Bool $visible : display or not the unit |
---|
1084 | * @return String : a formatted file size |
---|
1085 | */ |
---|
1086 | static public function formatOctet($octets, $format="Ai", $thsep="", $prec=2, $visible=true) |
---|
1087 | { |
---|
1088 | if($format=="Ai") |
---|
1089 | { |
---|
1090 | if($octets<1024) |
---|
1091 | { $format="O"; } |
---|
1092 | elseif($octets<1024000) |
---|
1093 | { $format="Ki"; } |
---|
1094 | elseif($octets<1024000000) |
---|
1095 | { $format="Mi"; } |
---|
1096 | else |
---|
1097 | { $format="Gi"; } |
---|
1098 | } |
---|
1099 | elseif($format=="A") |
---|
1100 | { |
---|
1101 | if($octets<1000) |
---|
1102 | { $format="O"; } |
---|
1103 | elseif($octets<1000000) |
---|
1104 | { $format="Ki"; } |
---|
1105 | elseif($octets<1000000000) |
---|
1106 | { $format="Mi"; } |
---|
1107 | else |
---|
1108 | { $format="Gi"; } |
---|
1109 | } |
---|
1110 | |
---|
1111 | switch($format) |
---|
1112 | { |
---|
1113 | case "O": |
---|
1114 | $unit="o"; $div=1; |
---|
1115 | break; |
---|
1116 | case "K": |
---|
1117 | $unit="Ko"; $div=1000; |
---|
1118 | break; |
---|
1119 | case "M": |
---|
1120 | $unit="Mo"; $div=1000000; |
---|
1121 | break; |
---|
1122 | case "G": |
---|
1123 | $unit="Go"; $div=1000000000; |
---|
1124 | break; |
---|
1125 | case "Ki": |
---|
1126 | $unit="Kio"; $div=1024; |
---|
1127 | break; |
---|
1128 | case "Mi": |
---|
1129 | $unit="Mio"; $div=1024000; |
---|
1130 | break; |
---|
1131 | case "Gi": |
---|
1132 | $unit="Gio"; $div=1024000000; |
---|
1133 | break; |
---|
1134 | } |
---|
1135 | |
---|
1136 | $returned=number_format($octets/$div, $prec, '.', $thsep); |
---|
1137 | if($visible) $returned.=' '.$unit; |
---|
1138 | return($returned); |
---|
1139 | } //function formatOctet |
---|
1140 | |
---|
1141 | |
---|
1142 | /** |
---|
1143 | * affect a valid token in a template var {$token} |
---|
1144 | */ |
---|
1145 | static public function setTemplateToken() |
---|
1146 | { |
---|
1147 | global $template; |
---|
1148 | |
---|
1149 | $template->assign('token', get_pwg_token()); |
---|
1150 | } |
---|
1151 | |
---|
1152 | |
---|
1153 | } //class |
---|
1154 | |
---|
1155 | GPCCore::init(); |
---|
1156 | |
---|
1157 | ?> |
---|