1 | <?php |
---|
2 | /* ----------------------------------------------------------------------------- |
---|
3 | Plugin : Advanced Menu Manager |
---|
4 | Author : Grum |
---|
5 | email : grum@grum.dnsalias.com |
---|
6 | website : http://photos.grum.dnsalias.com |
---|
7 | PWG user : http://forum.phpwebgallery.net/profile.php?id=3706 |
---|
8 | |
---|
9 | << May the Little SpaceFrog be with you ! >> |
---|
10 | ------------------------------------------------------------------------------ |
---|
11 | See main.inc.php for release information |
---|
12 | |
---|
13 | AIP classe => manage integration in administration interface |
---|
14 | |
---|
15 | --------------------------------------------------------------------------- */ |
---|
16 | if (!defined('PHPWG_ROOT_PATH')) { die('Hacking attempt!'); } |
---|
17 | |
---|
18 | include_once(PHPWG_PLUGINS_PATH.'AMenuManager/amm_root.class.inc.php'); |
---|
19 | include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php'); |
---|
20 | include_once(PHPWG_PLUGINS_PATH.'grum_plugins_classes-2/css.class.inc.php'); |
---|
21 | include_once(PHPWG_PLUGINS_PATH.'grum_plugins_classes-2/ajax.class.inc.php'); |
---|
22 | include_once(PHPWG_PLUGINS_PATH.'grum_plugins_classes-2/genericjs.class.inc.php'); |
---|
23 | include_once(PHPWG_PLUGINS_PATH.'grum_plugins_classes-2/translate.class.inc.php'); |
---|
24 | |
---|
25 | class AMM_AIP extends AMM_root |
---|
26 | { |
---|
27 | protected $google_translate; |
---|
28 | protected $tabsheet; |
---|
29 | protected $css; //the css object |
---|
30 | protected $ajax; |
---|
31 | |
---|
32 | protected $urls_modes=array(0 => 'new_window', 1 => 'current_window'); |
---|
33 | |
---|
34 | function AMM_AIP($prefixeTable, $filelocation) |
---|
35 | { |
---|
36 | parent::__construct($prefixeTable, $filelocation); |
---|
37 | |
---|
38 | $this->load_config(); |
---|
39 | $this->init_events(); |
---|
40 | |
---|
41 | $this->tabsheet = new tabsheet(); |
---|
42 | $this->tabsheet->add('setmenu', |
---|
43 | l10n('g002_setmenu'), |
---|
44 | $this->page_link.'&fAMM_tabsheet=setmenu'); |
---|
45 | $this->tabsheet->add('links', |
---|
46 | l10n('g002_addlinks'), |
---|
47 | $this->page_link.'&fAMM_tabsheet=links'); |
---|
48 | $this->tabsheet->add('randompict', |
---|
49 | l10n('g002_randompict'), |
---|
50 | $this->page_link.'&fAMM_tabsheet=randompict'); |
---|
51 | $this->tabsheet->add('personnalblock', |
---|
52 | l10n('g002_personnalblock'), |
---|
53 | $this->page_link.'&fAMM_tabsheet=personnalblock'); |
---|
54 | $this->css = new css(dirname($this->filelocation).'/'.$this->plugin_name_files.".css"); |
---|
55 | $this->ajax = new Ajax(); |
---|
56 | $this->google_translate = new translate(); |
---|
57 | } |
---|
58 | |
---|
59 | |
---|
60 | /* --------------------------------------------------------------------------- |
---|
61 | Public classe functions |
---|
62 | --------------------------------------------------------------------------- */ |
---|
63 | |
---|
64 | /* |
---|
65 | manage plugin integration into piwigo's admin interface |
---|
66 | */ |
---|
67 | public function manage() |
---|
68 | { |
---|
69 | global $template; |
---|
70 | |
---|
71 | |
---|
72 | $template->set_filename('plugin_admin_content', dirname(__FILE__)."/admin/amm_admin.tpl"); |
---|
73 | |
---|
74 | $this->return_ajax_content(); |
---|
75 | |
---|
76 | $this->init_request(); |
---|
77 | |
---|
78 | $this->tabsheet->select($_REQUEST['fAMM_tabsheet']); |
---|
79 | $this->tabsheet->assign(); |
---|
80 | $selected_tab=$this->tabsheet->get_selected(); |
---|
81 | $template->assign($this->tabsheet->get_titlename(), "[".$selected_tab['caption']."]"); |
---|
82 | |
---|
83 | $template_plugin["AMM_VERSION"] = "<i>".$this->plugin_name."</i> ".l10n('g002_version').AMM_VERSION; |
---|
84 | $template_plugin["AMM_PAGE"] = $_REQUEST['fAMM_tabsheet']; |
---|
85 | $template_plugin["PATH"] = AMM_PATH; |
---|
86 | |
---|
87 | $template->assign('plugin', $template_plugin); |
---|
88 | |
---|
89 | |
---|
90 | if(isset($_POST['famm_modeedit'])) |
---|
91 | { |
---|
92 | $post_action=$_POST['famm_modeedit']; |
---|
93 | } |
---|
94 | else |
---|
95 | { |
---|
96 | $post_action=""; |
---|
97 | } |
---|
98 | |
---|
99 | $page_nfo=""; |
---|
100 | if($_REQUEST['fAMM_tabsheet']=='links') |
---|
101 | { |
---|
102 | $page_nfo=l10n('g002_addlinks_nfo'); |
---|
103 | |
---|
104 | switch($_REQUEST['action']) |
---|
105 | { |
---|
106 | case 'list': |
---|
107 | $this->display_links_list_page(); |
---|
108 | break; |
---|
109 | case 'create': |
---|
110 | case 'modify': |
---|
111 | if($post_action==$_REQUEST['action']) |
---|
112 | { |
---|
113 | if(!$this->adviser_abort()) |
---|
114 | { |
---|
115 | $this->action_create_modify_url(); |
---|
116 | } |
---|
117 | $this->display_links_list_page(); |
---|
118 | } |
---|
119 | else |
---|
120 | { |
---|
121 | ($_REQUEST['action']=='modify')?$urlid=$_REQUEST['fItem']:$urlid=0; |
---|
122 | $this->display_links_manage_page($_REQUEST['action'], $urlid); |
---|
123 | } |
---|
124 | break; |
---|
125 | case 'config': |
---|
126 | if($post_action==$_REQUEST['action']) |
---|
127 | { |
---|
128 | if(!$this->adviser_abort()) |
---|
129 | { |
---|
130 | $this->action_links_modify_config(); |
---|
131 | } |
---|
132 | } |
---|
133 | $this->display_links_config_page(); |
---|
134 | break; |
---|
135 | } |
---|
136 | } |
---|
137 | elseif($_REQUEST['fAMM_tabsheet']=='randompict') |
---|
138 | { |
---|
139 | $page_nfo=l10n('g002_randompict_nfo'); |
---|
140 | if($post_action=='config') |
---|
141 | { |
---|
142 | if(!$this->adviser_abort()) |
---|
143 | { |
---|
144 | $this->action_randompic_modify_config(); |
---|
145 | } |
---|
146 | } |
---|
147 | $this->display_randompic_config_page(); |
---|
148 | } |
---|
149 | elseif($_REQUEST['fAMM_tabsheet']=='personnalblock') |
---|
150 | { |
---|
151 | $page_nfo=l10n('g002_personnalblock_nfo'); |
---|
152 | |
---|
153 | switch($_REQUEST['action']) |
---|
154 | { |
---|
155 | case 'list': |
---|
156 | $this->display_personalised_list_page(); |
---|
157 | break; |
---|
158 | case 'create': |
---|
159 | case 'modify': |
---|
160 | if($post_action==$_REQUEST['action']) |
---|
161 | { |
---|
162 | if(!$this->adviser_abort()) |
---|
163 | { |
---|
164 | $this->action_create_modify_personalised(); |
---|
165 | } |
---|
166 | $this->display_personalised_list_page(); |
---|
167 | } |
---|
168 | else |
---|
169 | { |
---|
170 | ($_REQUEST['action']=='modify')?$sectionid=$_REQUEST['fItem']:$sectionid=0; |
---|
171 | $this->display_personalised_manage_page($_REQUEST['action'], $sectionid); |
---|
172 | } |
---|
173 | break; |
---|
174 | } |
---|
175 | } |
---|
176 | elseif($_REQUEST['fAMM_tabsheet']=='setmenu') |
---|
177 | { |
---|
178 | $page_nfo=l10n('g002_setmenu_nfo'); |
---|
179 | $this->display_sections_list_page($_REQUEST['action']); |
---|
180 | } |
---|
181 | |
---|
182 | $template->assign('page_nfo', $page_nfo); |
---|
183 | |
---|
184 | $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content'); |
---|
185 | } |
---|
186 | |
---|
187 | /* |
---|
188 | initialize events call for the plugin |
---|
189 | */ |
---|
190 | public function init_events() |
---|
191 | { |
---|
192 | add_event_handler('loc_end_page_header', array(&$this->css, 'apply_CSS')); |
---|
193 | } |
---|
194 | |
---|
195 | /* --------------------------------------------------------------------------- |
---|
196 | Private classe functions |
---|
197 | --------------------------------------------------------------------------- */ |
---|
198 | |
---|
199 | /* |
---|
200 | return ajax content |
---|
201 | */ |
---|
202 | protected function return_ajax_content() |
---|
203 | { |
---|
204 | global $ajax, $template; |
---|
205 | |
---|
206 | if(isset($_REQUEST['ajaxfct'])) |
---|
207 | { |
---|
208 | //$this->debug("AJAXFCT:".$_REQUEST['ajaxfct']); |
---|
209 | $result="<p class='errors'>".l10n('g002_error_invalid_ajax_call')."</p>"; |
---|
210 | switch($_REQUEST['ajaxfct']) |
---|
211 | { |
---|
212 | case 'links_list': |
---|
213 | $result=$this->ajax_amm_links_list(); |
---|
214 | break; |
---|
215 | case 'links_permut': |
---|
216 | $result=$this->ajax_amm_links_permut($_REQUEST['fItem'], $_REQUEST['fPermut']); |
---|
217 | break; |
---|
218 | case 'links_delete': |
---|
219 | $result=$this->ajax_amm_links_delete($_REQUEST['fItem']); |
---|
220 | break; |
---|
221 | case 'setmenu_list_sections_list': |
---|
222 | $result=$this->ajax_amm_setmenu_list_section_list(); |
---|
223 | break; |
---|
224 | case 'setmenu_list_sections_position': |
---|
225 | $result=$this->ajax_amm_setmenu_list_section_position($_REQUEST['fItem'], $_REQUEST['fPosition']); |
---|
226 | break; |
---|
227 | case 'setmenu_list_sections_showhide': |
---|
228 | $result=$this->ajax_amm_setmenu_list_section_showhide($_REQUEST['fItem']); |
---|
229 | break; |
---|
230 | |
---|
231 | case 'setmenu_modmenu_sections_list': |
---|
232 | $result=$this->ajax_amm_setmenu_mod_section_list('amm_sections_modmenu'); |
---|
233 | break; |
---|
234 | case 'setmenu_modmenu_sections_showhide': |
---|
235 | $result=$this->ajax_amm_setmenu_mod_section_showhide('amm_sections_modmenu', $_REQUEST['fItem']); |
---|
236 | break; |
---|
237 | |
---|
238 | case 'setmenu_modspecial_sections_list': |
---|
239 | $result=$this->ajax_amm_setmenu_mod_section_list('amm_sections_modspecials'); |
---|
240 | break; |
---|
241 | case 'setmenu_modspecial_sections_showhide': |
---|
242 | $result=$this->ajax_amm_setmenu_mod_section_showhide('amm_sections_modspecials', $_REQUEST['fItem']); |
---|
243 | break; |
---|
244 | |
---|
245 | case 'personalised_list': |
---|
246 | $result=$this->ajax_amm_personalised_list(); |
---|
247 | break; |
---|
248 | case 'personalised_delete': |
---|
249 | $result=$this->ajax_amm_personalised_delete($_REQUEST['fItem']); |
---|
250 | break; |
---|
251 | } |
---|
252 | //$template-> |
---|
253 | $this->ajax->return_result($result); |
---|
254 | } |
---|
255 | } |
---|
256 | |
---|
257 | /* |
---|
258 | if empty, initialize $_request |
---|
259 | */ |
---|
260 | private function init_request() |
---|
261 | { |
---|
262 | //initialise $REQUEST values if not defined |
---|
263 | if(!array_key_exists('fAMM_tabsheet', $_REQUEST)) |
---|
264 | { |
---|
265 | $_REQUEST['fAMM_tabsheet']='setmenu'; |
---|
266 | } |
---|
267 | |
---|
268 | if((($_REQUEST['fAMM_tabsheet']=='links') or |
---|
269 | ($_REQUEST['fAMM_tabsheet']=='personnalblock') or |
---|
270 | ($_REQUEST['fAMM_tabsheet']=='setmenu')) and !isset($_REQUEST['action'])) |
---|
271 | { |
---|
272 | $_REQUEST['action']='list'; |
---|
273 | } |
---|
274 | |
---|
275 | |
---|
276 | } //init_request |
---|
277 | |
---|
278 | |
---|
279 | /* |
---|
280 | manage display for urls table page |
---|
281 | */ |
---|
282 | private function display_links_list_page() |
---|
283 | { |
---|
284 | global $template, $user; |
---|
285 | $template->set_filename('body_page', |
---|
286 | dirname($this->filelocation).'/admin/amm_linkslist.tpl'); |
---|
287 | |
---|
288 | $tmp=$this->get_count_url(); |
---|
289 | if($tmp==0) |
---|
290 | { |
---|
291 | $tmp=l10n("g002_nolinks"); |
---|
292 | } |
---|
293 | elseif($tmp==1) |
---|
294 | { |
---|
295 | $tmp="1 ".l10n("g002_link"); |
---|
296 | } |
---|
297 | else |
---|
298 | { |
---|
299 | $tmp=$tmp." ".l10n("g002_links"); |
---|
300 | } |
---|
301 | |
---|
302 | |
---|
303 | $template_datas=array( |
---|
304 | 'lnk_create' => $this->page_link.'&fAMM_tabsheet=links&action=create', |
---|
305 | 'lnk_config' => $this->page_link.'&fAMM_tabsheet=links&action=config', |
---|
306 | 'AMM_AJAX_URL_LIST' => $this->page_link."&ajaxfct=", |
---|
307 | 'nburl' => $tmp |
---|
308 | ); |
---|
309 | |
---|
310 | $template->assign("datas", $template_datas); |
---|
311 | $template->assign_var_from_handle('AMM_BODY_PAGE', 'body_page'); |
---|
312 | } |
---|
313 | |
---|
314 | /* |
---|
315 | manage display for urls config page |
---|
316 | */ |
---|
317 | private function display_links_config_page() |
---|
318 | { |
---|
319 | global $template, $user; |
---|
320 | $template->set_filename('body_page', |
---|
321 | dirname($this->filelocation).'/admin/amm_linksconfig.tpl'); |
---|
322 | |
---|
323 | $template_datas=array( |
---|
324 | 'lnk_list' => $this->page_link.'&fAMM_tabsheet=links', |
---|
325 | 'AMM_AJAX_URL_LIST' => $this->page_link."&ajaxfct=", |
---|
326 | 'show_icons_selected' => $this->my_config['amm_links_show_icons'], |
---|
327 | 'lang_selected' => $user['language'], |
---|
328 | 'fromlang' => substr($user['language'],0,2) |
---|
329 | ); |
---|
330 | |
---|
331 | $template_datas['language_list'] = array(); |
---|
332 | foreach($this->my_config['amm_links_title'] as $key => $val) |
---|
333 | { |
---|
334 | $template_datas['language_list'][] = array( |
---|
335 | 'LANG' => $key, |
---|
336 | 'MENUBARTIT' => base64_decode($val) |
---|
337 | ); |
---|
338 | } |
---|
339 | |
---|
340 | |
---|
341 | |
---|
342 | $lang=get_languages(); |
---|
343 | foreach($lang as $key => $val) |
---|
344 | { |
---|
345 | $template_datas['language_list_values'][] = $key; |
---|
346 | $template_datas['language_list_labels'][] = $val; |
---|
347 | } |
---|
348 | |
---|
349 | |
---|
350 | $template_datas['yesno_values'] = array('y','n'); |
---|
351 | $template_datas['yesno_labels'][] = l10n('g002_yesno_y'); |
---|
352 | $template_datas['yesno_labels'][] = l10n('g002_yesno_n'); |
---|
353 | |
---|
354 | |
---|
355 | $template->assign("datas", $template_datas); |
---|
356 | $template->assign_var_from_handle('AMM_BODY_PAGE', 'body_page'); |
---|
357 | } |
---|
358 | |
---|
359 | /* |
---|
360 | manage display for urls create/modify page |
---|
361 | */ |
---|
362 | private function display_links_manage_page($modeedit = 'create', $urlid=0) |
---|
363 | { |
---|
364 | global $template, $user; |
---|
365 | $template->set_filename('body_page', |
---|
366 | dirname($this->filelocation).'/admin/amm_linkslist_edit.tpl'); |
---|
367 | |
---|
368 | $extensions_list=array('jpg'=>0,'jpeg'=>0,'gif'=>0,'png'=>0); |
---|
369 | $template_icons_list=array(); |
---|
370 | $directory=dir(dirname($this->filelocation).'/links_pictures/'); |
---|
371 | while($file=$directory->read()) |
---|
372 | { |
---|
373 | if(isset($extensions_list[get_extension(strtolower($file))])) |
---|
374 | { |
---|
375 | $template_icons_list[]=$file; |
---|
376 | } |
---|
377 | } |
---|
378 | |
---|
379 | |
---|
380 | if($modeedit=='modify') |
---|
381 | { |
---|
382 | $url=$this->get_url($urlid); |
---|
383 | |
---|
384 | $template_datas=array( |
---|
385 | 'id' => $urlid, |
---|
386 | 'modeedit' => 'modify', |
---|
387 | 'label' => htmlentities($url['label'], ENT_QUOTES, 'UTF-8'), |
---|
388 | 'url' => $url['url'], |
---|
389 | 'icons_selected' => $url['icon'], |
---|
390 | 'mode_selected' => $url['mode'], |
---|
391 | 'visible_selected' => $url['visible'] |
---|
392 | ); |
---|
393 | } |
---|
394 | else |
---|
395 | { |
---|
396 | $template_datas=array( |
---|
397 | 'id' => '', |
---|
398 | 'modeedit' => 'create', |
---|
399 | 'label' => '', |
---|
400 | 'url' => '', |
---|
401 | 'icons_selected' => $template_icons_list[0], |
---|
402 | 'mode_selected' => 0, |
---|
403 | 'visible_selected' => 'y' |
---|
404 | ); |
---|
405 | } |
---|
406 | |
---|
407 | $template_datas['lnk_list'] = $this->page_link.'&fAMM_tabsheet=links'; |
---|
408 | $template_datas['icons_img'] = AMM_PATH."links_pictures/".$template_datas['icons_selected']; |
---|
409 | $template_datas['icons_values'] = array(); |
---|
410 | foreach($template_icons_list as $key => $val) |
---|
411 | { |
---|
412 | $template_datas['icons_values'][] = array( |
---|
413 | 'img' => AMM_PATH."links_pictures/".$val, |
---|
414 | 'value' => $val, |
---|
415 | 'label' => $val |
---|
416 | ); |
---|
417 | } |
---|
418 | $template_datas['mode_values'] = array(0,1); |
---|
419 | $template_datas['mode_labels'][] = l10n("g002_mode_".$this->urls_modes[0]); |
---|
420 | $template_datas['mode_labels'][] = l10n("g002_mode_".$this->urls_modes[1]); |
---|
421 | $template_datas['visible_values'] = array('y','n'); |
---|
422 | $template_datas['visible_labels'][] = l10n('g002_yesno_y'); |
---|
423 | $template_datas['visible_labels'][] = l10n('g002_yesno_n'); |
---|
424 | |
---|
425 | $template->assign("datas", $template_datas); |
---|
426 | $template->assign_var_from_handle('AMM_BODY_PAGE', 'body_page'); |
---|
427 | } |
---|
428 | |
---|
429 | /* |
---|
430 | manage create/modify url into database and display result |
---|
431 | */ |
---|
432 | protected function action_create_modify_url() |
---|
433 | { |
---|
434 | $datas=array( |
---|
435 | 'id' => $_POST['famm_id'], |
---|
436 | 'label' => $_POST['famm_label'], |
---|
437 | 'url' => $_POST['famm_url'], |
---|
438 | 'mode' => $_POST['famm_mode'], |
---|
439 | 'icon' => $_POST['famm_icon'], |
---|
440 | 'position' => 0, |
---|
441 | 'visible' => $_POST['famm_visible'] |
---|
442 | ); |
---|
443 | |
---|
444 | switch($_POST['famm_modeedit']) |
---|
445 | { |
---|
446 | case 'create': |
---|
447 | $this->add_url($datas); |
---|
448 | break; |
---|
449 | case 'modify': |
---|
450 | $this->modify_url($datas); |
---|
451 | } |
---|
452 | } |
---|
453 | |
---|
454 | /* |
---|
455 | manage urls config save into database |
---|
456 | */ |
---|
457 | protected function action_links_modify_config() |
---|
458 | { |
---|
459 | $this->my_config['amm_links_show_icons']=$_POST['famm_links_show_icons']; |
---|
460 | $languages=get_languages(); |
---|
461 | foreach($languages as $key => $val) |
---|
462 | { |
---|
463 | $this->my_config['amm_links_title'][$key]=base64_encode($_POST['famm_links_title_'.$key]); |
---|
464 | } |
---|
465 | $this->save_config(); |
---|
466 | } |
---|
467 | |
---|
468 | /* |
---|
469 | manage randompic config save into database |
---|
470 | */ |
---|
471 | protected function action_randompic_modify_config() |
---|
472 | { |
---|
473 | $this->my_config['amm_randompicture_showname']=$_POST['famm_randompicture_showname']; |
---|
474 | $this->my_config['amm_randompicture_showcomment']=$_POST['famm_randompicture_showcomment']; |
---|
475 | $languages=get_languages(); |
---|
476 | foreach($languages as $key => $val) |
---|
477 | { |
---|
478 | $this->my_config['amm_randompicture_title'][$key]=base64_encode(stripslashes($_POST['famm_randompicture_title_'.$key])); |
---|
479 | } |
---|
480 | $this->save_config(); |
---|
481 | } |
---|
482 | |
---|
483 | |
---|
484 | |
---|
485 | /* |
---|
486 | manage display for sections table page |
---|
487 | */ |
---|
488 | private function display_sections_list_page($action) |
---|
489 | { |
---|
490 | global $template, $user; |
---|
491 | $template->set_filename('body_page', |
---|
492 | dirname($this->filelocation).'/admin/amm_sections.tpl'); |
---|
493 | |
---|
494 | switch($action) |
---|
495 | { |
---|
496 | case 'list': |
---|
497 | $tmp_list=array( |
---|
498 | array('separator' => '', 'link' => '', 'label' => 'g002_sectionslist'), |
---|
499 | array('separator' => ' / ', 'link' => $this->page_link.'&fAMM_tabsheet=setmenu&action=modmenu', 'label' => 'g002_modmenu'), |
---|
500 | array('separator' => ' / ', 'link' => $this->page_link.'&fAMM_tabsheet=setmenu&action=modspecial', 'label' => 'g002_modspecial') |
---|
501 | ); |
---|
502 | break; |
---|
503 | case 'modmenu': |
---|
504 | $tmp_list=array( |
---|
505 | array('separator' => '', 'link' => $this->page_link.'&fAMM_tabsheet=setmenu&action=list', 'label' => 'g002_sectionslist'), |
---|
506 | array('separator' => ' / ', 'link' => '', 'label' => 'g002_modmenu'), |
---|
507 | array('separator' => ' / ', 'link' => $this->page_link.'&fAMM_tabsheet=setmenu&action=modspecial', 'label' => 'g002_modspecial') |
---|
508 | ); |
---|
509 | break; |
---|
510 | case 'modspecial': |
---|
511 | $tmp_list=array( |
---|
512 | array('separator' => '', 'link' => $this->page_link.'&fAMM_tabsheet=setmenu&action=list', 'label' => 'g002_sectionslist'), |
---|
513 | array('separator' => ' / ', 'link' => $this->page_link.'&fAMM_tabsheet=setmenu&action=modmenu', 'label' => 'g002_modmenu'), |
---|
514 | array('separator' => ' / ', 'link' => '', 'label' => 'g002_modspecial') |
---|
515 | ); |
---|
516 | break; |
---|
517 | } |
---|
518 | |
---|
519 | $template_datas=array( |
---|
520 | 'AMM_AJAX_URL_LIST' => $this->page_link."&ajaxfct=setmenu_".$action."_", |
---|
521 | 'LIST' => $tmp_list |
---|
522 | ); |
---|
523 | |
---|
524 | $template->assign("datas", $template_datas); |
---|
525 | $template->assign_var_from_handle('AMM_BODY_PAGE', 'body_page'); |
---|
526 | } |
---|
527 | |
---|
528 | |
---|
529 | /* |
---|
530 | manage display for randompic config page |
---|
531 | */ |
---|
532 | private function display_randompic_config_page() |
---|
533 | { |
---|
534 | global $template, $user; |
---|
535 | $template->set_filename('body_page', |
---|
536 | dirname($this->filelocation).'/admin/amm_randompicconfig.tpl'); |
---|
537 | |
---|
538 | $template_datas=array( |
---|
539 | 'lnk_list' => $this->page_link.'&fAMM_tabsheet=links', |
---|
540 | 'showname_selected' => $this->my_config['amm_randompicture_showname'], |
---|
541 | 'showcomment_selected' => $this->my_config['amm_randompicture_showcomment'], |
---|
542 | 'lang_selected' => $user['language'], |
---|
543 | 'fromlang' => substr($user['language'],0,2) |
---|
544 | ); |
---|
545 | |
---|
546 | $template_datas['language_list'] = array(); |
---|
547 | foreach($this->my_config['amm_randompicture_title'] as $key => $val) |
---|
548 | { |
---|
549 | $template_datas['language_list'][] = array( |
---|
550 | 'LANG' => $key, |
---|
551 | 'MENUBARTIT' => htmlentities(base64_decode($val), ENT_QUOTES, 'UTF-8') |
---|
552 | ); |
---|
553 | } |
---|
554 | |
---|
555 | |
---|
556 | |
---|
557 | $lang=get_languages(); |
---|
558 | foreach($lang as $key => $val) |
---|
559 | { |
---|
560 | $template_datas['language_list_values'][] = $key; |
---|
561 | $template_datas['language_list_labels'][] = $val; |
---|
562 | } |
---|
563 | |
---|
564 | |
---|
565 | $template_datas['yesno_values'] = array('y','n'); |
---|
566 | $template_datas['yesno_labels'][] = l10n('g002_yesno_y'); |
---|
567 | $template_datas['yesno_labels'][] = l10n('g002_yesno_n'); |
---|
568 | |
---|
569 | $template_datas['show_values'] = array('n', 'o', 'u'); |
---|
570 | $template_datas['show_labels'][] = l10n('g002_show_n'); |
---|
571 | $template_datas['show_labels'][] = l10n('g002_show_o'); |
---|
572 | $template_datas['show_labels'][] = l10n('g002_show_u'); |
---|
573 | |
---|
574 | |
---|
575 | $template->assign("datas", $template_datas); |
---|
576 | $template->assign_var_from_handle('AMM_BODY_PAGE', 'body_page'); |
---|
577 | } |
---|
578 | |
---|
579 | |
---|
580 | |
---|
581 | |
---|
582 | |
---|
583 | |
---|
584 | |
---|
585 | /* |
---|
586 | manage display for personalised sections list page |
---|
587 | */ |
---|
588 | private function display_personalised_list_page() |
---|
589 | { |
---|
590 | global $template, $user; |
---|
591 | $template->set_filename('body_page', |
---|
592 | dirname($this->filelocation).'/admin/amm_personalisedlist.tpl'); |
---|
593 | |
---|
594 | $sql="SELECT COUNT(DISTINCT ID) as countid FROM ".$this->tables['personalised']; |
---|
595 | $result=pwg_query($sql); |
---|
596 | if($result) |
---|
597 | { |
---|
598 | $tmp=mysql_fetch_row($result); |
---|
599 | $tmp=$tmp[0]; |
---|
600 | } |
---|
601 | else |
---|
602 | { |
---|
603 | $tmp=0; |
---|
604 | } |
---|
605 | |
---|
606 | if($tmp==0) |
---|
607 | { |
---|
608 | $tmp=l10n("g002_nosections"); |
---|
609 | } |
---|
610 | elseif($tmp==1) |
---|
611 | { |
---|
612 | $tmp="1 ".l10n("g002_section"); |
---|
613 | } |
---|
614 | else |
---|
615 | { |
---|
616 | $tmp=$tmp." ".l10n("g002_sections"); |
---|
617 | } |
---|
618 | |
---|
619 | |
---|
620 | $template_datas=array( |
---|
621 | 'lnk_create' => $this->page_link.'&fAMM_tabsheet=personnalblock&action=create', |
---|
622 | 'AMM_AJAX_URL_LIST' => $this->page_link."&ajaxfct=", |
---|
623 | 'nbsections' => $tmp |
---|
624 | ); |
---|
625 | |
---|
626 | $template->assign("datas", $template_datas); |
---|
627 | $template->assign_var_from_handle('AMM_BODY_PAGE', 'body_page'); |
---|
628 | } |
---|
629 | |
---|
630 | |
---|
631 | |
---|
632 | /* |
---|
633 | manage display for personalised sections create/modify page |
---|
634 | */ |
---|
635 | private function display_personalised_manage_page($modeedit = 'create', $sectionid=0) |
---|
636 | { |
---|
637 | global $template, $user; |
---|
638 | $template->set_filename('body_page', |
---|
639 | dirname($this->filelocation).'/admin/amm_personalisedlist_edit.tpl'); |
---|
640 | |
---|
641 | $template_datas=array(); |
---|
642 | |
---|
643 | $lang=get_languages(); |
---|
644 | $lang['all']=l10n('g002_all_languages'); |
---|
645 | foreach($lang as $key => $val) |
---|
646 | { |
---|
647 | $template_datas['language_list_values'][] = $key; |
---|
648 | $template_datas['language_list_labels'][] = $val; |
---|
649 | $template_datas['language_list'][$key]=array( |
---|
650 | 'LANG' => $key, |
---|
651 | 'MENUBARTIT' => '', |
---|
652 | 'MENUBARCONTENT' => '' |
---|
653 | ); |
---|
654 | } |
---|
655 | |
---|
656 | |
---|
657 | if($modeedit=='modify') |
---|
658 | { |
---|
659 | $sections=$this->get_personalised($sectionid); |
---|
660 | |
---|
661 | $template_datas['id'] = $sectionid; |
---|
662 | $template_datas['modeedit'] = 'modify'; |
---|
663 | $template_datas['visible_selected'] = $sections[0]['visible']; |
---|
664 | $template_datas['nfo'] = htmlentities($sections[0]['nfo'], ENT_QUOTES, 'UTF-8'); |
---|
665 | |
---|
666 | foreach($sections as $key => $val) |
---|
667 | { |
---|
668 | $lang=($val['lang']=='*')?'all':$val['lang']; |
---|
669 | $template_datas['language_list'][$lang] = array( |
---|
670 | 'LANG' => $lang, |
---|
671 | 'MENUBARTIT' => htmlentities($val['title'], ENT_QUOTES, 'UTF-8'), |
---|
672 | 'MENUBARCONTENT' => htmlentities($val['content'], ENT_QUOTES, 'UTF-8'), |
---|
673 | ); |
---|
674 | } |
---|
675 | } |
---|
676 | else |
---|
677 | { |
---|
678 | $template_datas['nfo'] = ''; |
---|
679 | $template_datas['id'] = ''; |
---|
680 | $template_datas['modeedit'] = 'create'; |
---|
681 | $template_datas['visible_selected'] = 'y'; |
---|
682 | } |
---|
683 | |
---|
684 | $template_datas['lang_selected'] = $user['language']; |
---|
685 | |
---|
686 | $template_datas['personalised_list'] = $this->page_link.'&fAMM_tabsheet=personnalblock'; |
---|
687 | $template_datas['yesno_values'] = array('y','n'); |
---|
688 | $template_datas['yesno_labels'][] = l10n('g002_yesno_y'); |
---|
689 | $template_datas['yesno_labels'][] = l10n('g002_yesno_n'); |
---|
690 | |
---|
691 | $template->assign("datas", $template_datas); |
---|
692 | $template->assign_var_from_handle('AMM_BODY_PAGE', 'body_page'); |
---|
693 | } |
---|
694 | |
---|
695 | /* |
---|
696 | manage create/modify pesonalised sections into database and display result |
---|
697 | */ |
---|
698 | protected function action_create_modify_personalised() |
---|
699 | { |
---|
700 | global $user; |
---|
701 | |
---|
702 | if($_POST['famm_modeedit']=='create') |
---|
703 | { |
---|
704 | $id=$this->get_personalised_id(); |
---|
705 | } |
---|
706 | else |
---|
707 | { |
---|
708 | $id=$_POST['famm_id']; |
---|
709 | } |
---|
710 | $languages=get_languages(); |
---|
711 | $languages['all']='*'; |
---|
712 | foreach($languages as $key => $val) |
---|
713 | { |
---|
714 | $datas=array( |
---|
715 | 'id' => $id, |
---|
716 | 'lang' => ($key=='all')?'*':$key, |
---|
717 | 'visible' => $_POST['famm_personalised_visible'], |
---|
718 | 'nfo' => ($_POST['famm_personalised_nfo']=='')?$_POST['famm_personalised_title_'.$user['language']]:$_POST['famm_personalised_nfo'], |
---|
719 | 'title' => $_POST['famm_personalised_title_'.$key], |
---|
720 | 'content' => $_POST['famm_personalised_content_'.$key] |
---|
721 | ); |
---|
722 | switch($_POST['famm_modeedit']) |
---|
723 | { |
---|
724 | case 'create': |
---|
725 | $this->add_personalised($datas); |
---|
726 | break; |
---|
727 | case 'modify': |
---|
728 | $this->modify_personalised($datas); |
---|
729 | } |
---|
730 | } |
---|
731 | } |
---|
732 | |
---|
733 | |
---|
734 | |
---|
735 | |
---|
736 | |
---|
737 | /* |
---|
738 | manage adviser profile |
---|
739 | return true if user is adviser |
---|
740 | */ |
---|
741 | protected function adviser_abort() |
---|
742 | { |
---|
743 | if(is_adviser()) |
---|
744 | { |
---|
745 | $this->display_result(l10n("g002_adviser_not_allowed"), false); |
---|
746 | return(true); |
---|
747 | } |
---|
748 | return(false); |
---|
749 | } |
---|
750 | |
---|
751 | /* --------------------------------------------------------------------------- |
---|
752 | functions to manage urls tables |
---|
753 | --------------------------------------------------------------------------- */ |
---|
754 | // protected function get_urls() |
---|
755 | // protected function get_count_url() |
---|
756 | // => defined in root class |
---|
757 | |
---|
758 | // return properties of an given url |
---|
759 | private function get_url($url_id) |
---|
760 | { |
---|
761 | $returned=array(); |
---|
762 | $sql="SELECT * FROM ".$this->tables['urls']." WHERE id = '".$url_id."'"; |
---|
763 | $result=pwg_query($sql); |
---|
764 | if($result) |
---|
765 | { |
---|
766 | $returned=mysql_fetch_array($result); |
---|
767 | //$returned['label']=stripslashes($returned['label']); |
---|
768 | } |
---|
769 | return($returned); |
---|
770 | } |
---|
771 | |
---|
772 | // permut position of two 2 urls |
---|
773 | private function permut_url($url_id, $url_permut) |
---|
774 | { |
---|
775 | $sql="SELECT id, position FROM ".$this->tables['urls']." WHERE id IN ('".$url_id."','".$url_permut."')"; |
---|
776 | $result=pwg_query($sql); |
---|
777 | if($result) |
---|
778 | { |
---|
779 | $tmp=array(); |
---|
780 | while($row=mysql_fetch_array($result)) |
---|
781 | { |
---|
782 | $tmp[$row['id']]=$row['position']; |
---|
783 | } |
---|
784 | $sql="UPDATE ".$this->tables['urls']." SET position = ".$tmp[$url_id]." WHERE id = '".$url_permut."'"; |
---|
785 | pwg_query($sql); |
---|
786 | $sql="UPDATE ".$this->tables['urls']." SET position = ".$tmp[$url_permut]." WHERE id = '".$url_id."'"; |
---|
787 | pwg_query($sql); |
---|
788 | } |
---|
789 | } |
---|
790 | |
---|
791 | // delete an url |
---|
792 | private function delete_url($url_id) |
---|
793 | { |
---|
794 | $sql="DELETE FROM ".$this->tables['urls']." WHERE id = '".$url_id."' "; |
---|
795 | return(pwg_query($sql)); |
---|
796 | } |
---|
797 | |
---|
798 | // add an url |
---|
799 | private function add_url($datas) |
---|
800 | { |
---|
801 | $numurl=$this->get_count_url(); |
---|
802 | $sql="INSERT INTO ".$this->tables['urls']." (label, url, mode, icon, position, visible) |
---|
803 | VALUES ('".$datas['label']."', '".$datas['url']."', '".$datas['mode']."', |
---|
804 | '".$datas['icon']."', '".$numurl."', '".$datas['visible']."')"; |
---|
805 | return(pwg_query($sql)); |
---|
806 | } |
---|
807 | |
---|
808 | // modify an url |
---|
809 | private function modify_url($datas) |
---|
810 | { |
---|
811 | $sql="UPDATE ".$this->tables['urls']." SET label = '".$datas['label']."', |
---|
812 | url = '".$datas['url']."', mode = '".$datas['mode']."', icon = '".$datas['icon']."', |
---|
813 | visible = '".$datas['visible']."' |
---|
814 | WHERE id = '".$datas['id']."'"; |
---|
815 | return(pwg_query($sql)); |
---|
816 | } |
---|
817 | |
---|
818 | // just modify url visibility |
---|
819 | private function set_url_visibility($urlid, $visible) |
---|
820 | { |
---|
821 | $sql="UPDATE ".$this->tables['urls']." SET visible = '".$visible."' |
---|
822 | WHERE id = '".$urlid."'"; |
---|
823 | return(pwg_query($sql)); |
---|
824 | } |
---|
825 | |
---|
826 | /* --------------------------------------------------------------------------- |
---|
827 | functions to manage sections tables |
---|
828 | --------------------------------------------------------------------------- */ |
---|
829 | // protected function get_sections($only_visible=false, $lang="") |
---|
830 | // => defined in root class |
---|
831 | |
---|
832 | // return properties of a given section (return each languages) |
---|
833 | private function get_personalised($section_id) |
---|
834 | { |
---|
835 | $returned=array(); |
---|
836 | $sql="SELECT * FROM ".$this->tables['personalised']." WHERE id = '".$section_id."'"; |
---|
837 | $result=pwg_query($sql); |
---|
838 | if($result) |
---|
839 | { |
---|
840 | while($returned[]=mysql_fetch_array($result)); |
---|
841 | } |
---|
842 | return($returned); |
---|
843 | } |
---|
844 | |
---|
845 | // delete a section |
---|
846 | private function delete_personalised($section_id) |
---|
847 | { |
---|
848 | $sql="DELETE FROM ".$this->tables['personalised']." WHERE id = '".$section_id."' "; |
---|
849 | return(pwg_query($sql)); |
---|
850 | } |
---|
851 | |
---|
852 | // add a section |
---|
853 | private function add_personalised($datas) |
---|
854 | { |
---|
855 | $sql="INSERT INTO ".$this->tables['personalised']." (id, lang, title, content, visible, nfo) |
---|
856 | VALUES ('".$datas['id']."', '".$datas['lang']."', '".$datas['title']."', '".$datas['content']."', '".$datas['visible']."', '".$datas['nfo']."')"; |
---|
857 | return(pwg_query($sql)); |
---|
858 | } |
---|
859 | |
---|
860 | // modify a section |
---|
861 | private function modify_personalised($datas) |
---|
862 | { |
---|
863 | $sql="UPDATE ".$this->tables['personalised']." SET title = '".$datas['title']."', |
---|
864 | content = '".$datas['content']."', visible = '".$datas['visible']."', |
---|
865 | nfo = '".$datas['nfo']."' |
---|
866 | WHERE id = '".$datas['id']."' |
---|
867 | AND lang = '".$datas['lang']."'"; |
---|
868 | return(pwg_query($sql)); |
---|
869 | } |
---|
870 | |
---|
871 | // return the next personalised id |
---|
872 | private function get_personalised_id() |
---|
873 | { |
---|
874 | $sql='SELECT MAX(ID) FROM '.$this->tables['personalised']; |
---|
875 | $result=pwg_query($sql); |
---|
876 | if($result) |
---|
877 | { |
---|
878 | $row=mysql_fetch_row($result); |
---|
879 | if(is_array($row)) |
---|
880 | { |
---|
881 | return($row[0]+1); |
---|
882 | } |
---|
883 | } |
---|
884 | return(0); |
---|
885 | } |
---|
886 | |
---|
887 | |
---|
888 | /* --------------------------------------------------------------------------- |
---|
889 | ajax functions |
---|
890 | --------------------------------------------------------------------------- */ |
---|
891 | |
---|
892 | // return a html formatted list of urls |
---|
893 | private function ajax_amm_links_list() |
---|
894 | { |
---|
895 | global $template, $user; |
---|
896 | $local_tpl = new Template(AMM_PATH."admin/", ""); |
---|
897 | $local_tpl->set_filename('body_page', |
---|
898 | dirname($this->filelocation).'/admin/amm_linkslist_detail.tpl'); |
---|
899 | |
---|
900 | $template_datas['urls']=array(); |
---|
901 | $urls=$this->get_urls(); |
---|
902 | for($i=0;$i<count($urls);$i++) |
---|
903 | { |
---|
904 | $template_datas['urls'][]=array( |
---|
905 | 'img' => AMM_PATH."links_pictures/".$urls[$i]['icon'], |
---|
906 | 'label' => $urls[$i]['label'], |
---|
907 | 'url' => $urls[$i]['url'], |
---|
908 | 'mode' => l10n("g002_mode_".$this->urls_modes[$urls[$i]['mode']]), |
---|
909 | 'up' => ($i==0)?false:true, |
---|
910 | 'down' => ($i<(count($urls)-1))?true:false, |
---|
911 | 'edit' => $this->page_link.'&fAMM_tabsheet=links&action=modify&fItem='.$urls[$i]['id'], |
---|
912 | 'ID' => $urls[$i]['id'], |
---|
913 | 'IDPREV' => ($i==0)?0:$urls[$i-1]['id'], |
---|
914 | 'IDNEXT' => ($i<(count($urls)-1))?$urls[$i+1]['id']:0, |
---|
915 | 'visible' => l10n('g002_yesno_'.$urls[$i]['visible']) |
---|
916 | ); |
---|
917 | } |
---|
918 | |
---|
919 | $themeconf=array( |
---|
920 | 'icon_dir' => $template->get_themeconf('icon_dir') |
---|
921 | ); |
---|
922 | |
---|
923 | $local_tpl->assign('themeconf', $themeconf); |
---|
924 | $local_tpl->assign('datas', $template_datas); |
---|
925 | $local_tpl->assign('plugin', array('PATH' => AMM_PATH)); |
---|
926 | |
---|
927 | return($local_tpl->parse('body_page', true)); |
---|
928 | } |
---|
929 | |
---|
930 | // permut position of 2 urls and returns a html formatted list of urls |
---|
931 | private function ajax_amm_links_permut($urlid, $urlpermut) |
---|
932 | { |
---|
933 | $this->permut_url($urlid, $urlpermut); |
---|
934 | return($this->ajax_amm_links_list()); |
---|
935 | } |
---|
936 | |
---|
937 | // delete an url and returns a html formatted list of urls |
---|
938 | private function ajax_amm_links_delete($urlid) |
---|
939 | { |
---|
940 | if(!$this->adviser_abort()) |
---|
941 | { |
---|
942 | $this->delete_url($urlid); |
---|
943 | } |
---|
944 | return($this->ajax_amm_links_list()); |
---|
945 | } |
---|
946 | |
---|
947 | |
---|
948 | |
---|
949 | |
---|
950 | // return a html formatted list of menu's sections |
---|
951 | private function ajax_amm_setmenu_list_section_list() |
---|
952 | { |
---|
953 | global $menu; |
---|
954 | $local_tpl = new Template(AMM_PATH."admin/", ""); |
---|
955 | $local_tpl->set_filename('body_page', |
---|
956 | dirname($this->filelocation).'/admin/amm_sectionslist_detail.tpl'); |
---|
957 | |
---|
958 | $sections=$menu->registered(); |
---|
959 | $i=0; |
---|
960 | foreach($sections as $key => $val) |
---|
961 | { |
---|
962 | $template_datas['sections'][]=array( |
---|
963 | 'OWNER' => $val['OWNER'], |
---|
964 | 'NAME' => l10n($val['NAME']), |
---|
965 | 'ID' => $key, |
---|
966 | 'VISIBLE' => l10n('g002_yesno_'.$this->my_config['amm_sections_visible'][$key]), |
---|
967 | 'POSITION' => $val['POSITION'], |
---|
968 | 'NEXTPOS' => $val['POSITION']+2, |
---|
969 | 'PREVPOS' => $val['POSITION']-1, |
---|
970 | 'up' => ($i==0)?false:true, |
---|
971 | 'down' => ($i<(count($sections)-1))?true:false |
---|
972 | ); |
---|
973 | $i++; |
---|
974 | } |
---|
975 | |
---|
976 | $local_tpl->assign('datas', $template_datas); |
---|
977 | $local_tpl->assign('plugin', array('PATH' => AMM_PATH)); |
---|
978 | |
---|
979 | return($local_tpl->parse('body_page', true)); |
---|
980 | } |
---|
981 | |
---|
982 | // move item to the specified position |
---|
983 | private function ajax_amm_setmenu_list_section_position($urlid, $position) |
---|
984 | { |
---|
985 | global $menu; |
---|
986 | |
---|
987 | $menu->register_position($urlid, $position); |
---|
988 | return($this->ajax_amm_setmenu_list_section_list()); |
---|
989 | } |
---|
990 | |
---|
991 | // show/hide item to the specified position |
---|
992 | private function ajax_amm_setmenu_list_section_showhide($urlid) |
---|
993 | { |
---|
994 | $switchvisible=array('y'=>'n', 'n'=>'y'); |
---|
995 | |
---|
996 | $this->my_config['amm_sections_visible'][$urlid]=$switchvisible[$this->my_config['amm_sections_visible'][$urlid]]; |
---|
997 | $this->save_config(); |
---|
998 | |
---|
999 | return($this->ajax_amm_setmenu_list_section_list()); |
---|
1000 | } |
---|
1001 | |
---|
1002 | // return a html formatted list of personalised sections |
---|
1003 | private function ajax_amm_personalised_list() |
---|
1004 | { |
---|
1005 | global $template, $user; |
---|
1006 | $local_tpl = new Template(AMM_PATH."admin/", ""); |
---|
1007 | $local_tpl->set_filename('body_page', |
---|
1008 | dirname($this->filelocation).'/admin/amm_personalisedlist_detail.tpl'); |
---|
1009 | |
---|
1010 | $template_datas['sections']=array(); |
---|
1011 | |
---|
1012 | $sections=$this->get_sections(false, '', false); |
---|
1013 | $is_done=array(); |
---|
1014 | foreach($sections as $key => $val) |
---|
1015 | { |
---|
1016 | if(!isset($is_done[$val['id']])) |
---|
1017 | { |
---|
1018 | $template_datas['sections'][]=array( |
---|
1019 | 'title' => ($val['title']!='')?$val['title']:l10n('g002_notitle'), |
---|
1020 | 'edit' => $this->page_link.'&fAMM_tabsheet=personnalblock&action=modify&fItem='.$val['id'], |
---|
1021 | 'ID' => $val['id'], |
---|
1022 | 'visible' => l10n('g002_yesno_'.$val['visible']), |
---|
1023 | 'nfo' => $val['nfo'] |
---|
1024 | ); |
---|
1025 | $is_done[$val['id']]=''; |
---|
1026 | } |
---|
1027 | } |
---|
1028 | |
---|
1029 | $themeconf=array( |
---|
1030 | 'icon_dir' => $template->get_themeconf('icon_dir') |
---|
1031 | ); |
---|
1032 | |
---|
1033 | $local_tpl->assign('themeconf', $themeconf); |
---|
1034 | $local_tpl->assign('datas', $template_datas); |
---|
1035 | $local_tpl->assign('plugin', array('PATH' => AMM_PATH)); |
---|
1036 | |
---|
1037 | return($local_tpl->parse('body_page', true)); |
---|
1038 | } |
---|
1039 | |
---|
1040 | // delete a section and returns a html formatted list |
---|
1041 | private function ajax_amm_personalised_delete($sectionid) |
---|
1042 | { |
---|
1043 | if(!$this->adviser_abort()) |
---|
1044 | { |
---|
1045 | $this->delete_personalised($sectionid); |
---|
1046 | } |
---|
1047 | return($this->ajax_amm_personalised_list()); |
---|
1048 | } |
---|
1049 | |
---|
1050 | |
---|
1051 | |
---|
1052 | |
---|
1053 | // return a html formatted list of special menu sections items |
---|
1054 | private function ajax_amm_setmenu_mod_section_list($menuname) |
---|
1055 | { |
---|
1056 | $local_tpl = new Template(AMM_PATH."admin/", ""); |
---|
1057 | $local_tpl->set_filename('body_page', |
---|
1058 | dirname($this->filelocation).'/admin/amm_sectionsmod_detail.tpl'); |
---|
1059 | |
---|
1060 | $template_datas = array('LIST' => array()); |
---|
1061 | foreach($this->my_config[$menuname] as $key => $val) |
---|
1062 | { |
---|
1063 | $template_datas['LIST'][] = array( |
---|
1064 | 'ID' => base64_encode($key), |
---|
1065 | 'LABEL' => $key, |
---|
1066 | 'VISIBLE' => 'g002_yesno_'.$val |
---|
1067 | ); |
---|
1068 | } |
---|
1069 | |
---|
1070 | $local_tpl->assign('datas', $template_datas); |
---|
1071 | $local_tpl->assign('plugin', array('PATH' => AMM_PATH)); |
---|
1072 | |
---|
1073 | return($local_tpl->parse('body_page', true)); |
---|
1074 | } |
---|
1075 | |
---|
1076 | |
---|
1077 | // move item to the specified position |
---|
1078 | private function ajax_amm_setmenu_mod_section_showhide($menuname, $urlid) |
---|
1079 | { |
---|
1080 | $switchvisible=array('y'=>'n', 'n'=>'y'); |
---|
1081 | |
---|
1082 | $this->my_config[$menuname][base64_decode($urlid)]=$switchvisible[$this->my_config[$menuname][base64_decode($urlid)]]; |
---|
1083 | $this->save_config(); |
---|
1084 | |
---|
1085 | return($this->ajax_amm_setmenu_mod_section_list($menuname)); |
---|
1086 | } |
---|
1087 | |
---|
1088 | |
---|
1089 | |
---|
1090 | |
---|
1091 | } // AMM_AIP class |
---|
1092 | |
---|
1093 | |
---|
1094 | ?> |
---|