From 7ebed797262c7f3371ae1b16ed455f7e9879caf0 Mon Sep 17 00:00:00 2001 From: grum Date: Sun, 3 Aug 2008 07:48:39 +0000 Subject: Asked by rvelices on this topic http://forum.phpwebgallery.net/viewtopic.php?pid=92097#p92097 A plugin to integrate the menu class see test_menu directory A plugin to show how to use the menu class see AMenuManager directory And common classes needed for the AMenuManager plugin see grum_plugins_classes-2 directory See topic http://forum.phpwebgallery.net/viewtopic.php?pid=92637#p92637 for more informations git-svn-id: http://piwigo.org/svn/trunk@2466 68402e56-0260-453c-a942-63ccdbb3a9ee --- .../public_integration.class.inc.php | 202 +++++++++++++++++++++ 1 file changed, 202 insertions(+) create mode 100755 plugins/grum_plugins_classes-2/public_integration.class.inc.php (limited to 'plugins/grum_plugins_classes-2/public_integration.class.inc.php') diff --git a/plugins/grum_plugins_classes-2/public_integration.class.inc.php b/plugins/grum_plugins_classes-2/public_integration.class.inc.php new file mode 100755 index 000000000..db61e51b3 --- /dev/null +++ b/plugins/grum_plugins_classes-2/public_integration.class.inc.php @@ -0,0 +1,202 @@ +> + ------------------------------------------------------------------------------ + + this class provides base functions to manage an integration into main index + page + the class use plugin MenuBarManager function if installed + + - constructor public_integration($section) + - (public) function init_events() + - (public) function set_callback_page_function($value) + - (public) function set_callback_init_menu_function($value) + - (public) function set_menu_tpl($tpl_code) + - (public) function set_menu_list($list) + - (public) function set_menu_title($title) + - (public) function set_lnk_admin_add($text, $link) + - (public) function set_lnk_admin_edit($text, $link) + - (private) function update_menubar() + - (private) function init_section() + - (private) function call_page() + + use init_events() function to initialize needed triggers for updating menubar + use set_menu_tpl() function to initialize the template of menu + use set_menu_title() function to initialize the title of menu + use set_menu_list() function to initialize the elements of menu (see function for use) + use set_lnk_admin_add() and set_lnk_admin_edit() functions for displaying specific admin links + + the "callback_page_function" is called everytime a specific page is displayed + the "callback_init_menu_function" is called everytime the menu is made (allows + for example to prepare menu's title and list using user's language) + +----------------------------------------------------------------------------- */ + +class public_integration +{ + var $menu_tpl; //template definition for the menu + var $menu_list; //an array of arrays array(array('text' => '', 'id' => '', 'link' => ''), array... ) + var $menu_title; //menu's title + var $lnk_admin_add; //if set array('text'=>'', 'link'=>''), add a link "add" to the menu + var $lnk_admin_edit; //if set array('text'=>'', 'link'=>''), add a link "edit" to the menu's elements + var $section; //section applied to the page viewed + var $callback_page_function; //called function to display page + var $callback_init_menu_function; //called function to initialize menu + + function public_integration($section) + { + $this->menu_tpl=""; + $this->menu_list=array(); + $this->menu_title=""; + $this->lnk_admin_add=array(); + $this->lnk_admin_edit=array(); + $this->section=$section; + $this->callback_page_function=''; + $this->callback_init_menu_function=''; + } + + //initialize events to manage menu & page integration + function init_events() + { + add_event_handler('loc_begin_menubar', array(&$this, 'init_smarty')); + add_event_handler('loc_end_menubar', array(&$this, 'update_menubar')); + add_event_handler('loc_end_section_init', array(&$this, 'init_section')); + add_event_handler('loc_end_index', array(&$this, 'call_page')); + } + + function set_callback_page_function($value) + { + $this->callback_page_function=$value; + } + + function set_callback_init_menu_function($value) + { + $this->callback_init_menu_function=$value; + } + + // set template definition for menu + function set_menu_tpl($tpl_code) + { + $this->menu_tpl = $tpl_code; + } + + //set menu list + function set_menu_list($list) + { + $this->menu_list = $list; + } + + //set menu title + function set_menu_title($title) + { + $this->menu_title = $title; + } + + //set 'add' link to menu + function set_lnk_admin_add($text, $link) + { + $this->lnk_admin_add = array('text' => $text, 'link' => $link); + } + + //set 'edit' link to menu + function set_lnk_admin_edit($text, $link) + { + $this->lnk_admin_edit = array('text' => $text, 'link' => $link); + } + + function init_smarty() + { + global $template; + + $template->smarty->register_prefilter(array(&$this, 'modify_tpl')); + } + + function modify_tpl($tpl_source, &$smarty) + { + return(str_replace('