From abb2f22b2e96a89a44ad9d36db3bf612c6f88b9f Mon Sep 17 00:00:00 2001 From: rvelices Date: Thu, 28 Aug 2008 00:32:39 +0000 Subject: - based on test_menu by grum (thanks to you) - integration of dynamic menu bar to pwg - the menubar is composed now of dynamic blocks that can be ordered/hidden - plugins can add their own blocks git-svn-id: http://piwigo.org/svn/trunk@2488 68402e56-0260-453c-a942-63ccdbb3a9ee --- plugins/AMenuManager/amm_root.class.inc.php | 62 ++++++++++++++++------------- 1 file changed, 34 insertions(+), 28 deletions(-) (limited to 'plugins/AMenuManager/amm_root.class.inc.php') diff --git a/plugins/AMenuManager/amm_root.class.inc.php b/plugins/AMenuManager/amm_root.class.inc.php index 2dfa604e0..38440a2d0 100644 --- a/plugins/AMenuManager/amm_root.class.inc.php +++ b/plugins/AMenuManager/amm_root.class.inc.php @@ -37,33 +37,28 @@ class AMM_root extends common_plugin /* this function initialize var $my_config with default values */ public function init_config() { - global $menu; - $this->my_config=array( 'amm_links_show_icons' => 'y', - 'amm_links_active' => 'y', 'amm_links_title' => array(), - 'amm_sections_visible' => array(), - 'amm_randompicture_active' => 'n', 'amm_randompicture_showname' => 'n', //n:no, o:over, u:under 'amm_randompicture_showcomment' => 'n', //n:no, o:over, u:under 'amm_randompicture_title' => array(), - 'amm_sections_modspecial' => array( - 'favorite_cat' => 'y', - 'most_visited_cat' => 'y', - 'best_rated_cat' => 'y', - 'random_cat' => 'y', - 'recent_pics_cat' => 'y', - 'recent_cats_cat' => 'y', + 'amm_sections_modspecials' => array( + 'favorites' => 'y', + 'most_visited' => 'y', + 'best_rated' => 'y', + 'random' => 'y', + 'recent_pics' => 'y', + 'recent_cats' => 'y', 'calendar' => 'y' ), 'amm_sections_modmenu' => array( 'qsearch' => 'y', - 'Tags' => 'y', - 'Search' => 'y', + 'tags' => 'y', + 'search' => 'y', 'comments' => 'y', - 'About' => 'y', - 'Notification' => 'y' + 'about' => 'y', + 'notification' => 'y' ) ); @@ -82,28 +77,39 @@ class AMM_root extends common_plugin } } - $sections=$menu->registered(); - foreach($sections as $key => $val) - { - $this->my_config['amm_sections_visible'][$key]='y'; - } } public function load_config() { - global $menu; - parent::load_config(); + } - $sections=$menu->registered(); - foreach($sections as $key => $val) + public function init_events() + { + add_event_handler('blockmanager_register_blocks', array(&$this, 'register_blocks') ); + } + + public function register_blocks( $menu_ref_arr ) + { + $menu = & $menu_ref_arr[0]; + if ($menu->get_id() != 'menubar') + return; + $menu->register_block( new RegisteredBlock( 'mbAMM_randompict', 'Random pictures', 'AMM')); + $menu->register_block( new RegisteredBlock( 'mbAMM_links', 'Links', 'AMM')); + + $sections=$this->get_sections(true); + if(count($sections)) { - if(!isset($this->my_config['amm_sections_visible'][$key])) + $id_done=array(); + foreach($sections as $key => $val) { - $this->my_config['amm_sections_visible'][$key]='y'; + if(!isset($id_done[$val['id']])) + { + $menu->register_block( new RegisteredBlock( 'mbAMM_personalised'.$val['id'], $val['title'], 'AMM')); + $id_done[$val['id']]=""; + } } } - } // return an array of urls (each url is an array) -- cgit v1.2.3