aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--admin.php3
-rw-r--r--admin/include/functions.php31
-rw-r--r--admin/menubar.php162
-rw-r--r--admin/template/yoga/admin.tpl1
-rw-r--r--admin/template/yoga/admin/menubar.tpl30
-rw-r--r--admin/template/yoga/theme/admin/themeconf.inc.php3
-rw-r--r--include/block.class.php214
-rw-r--r--include/common.inc.php1
-rw-r--r--include/functions_html.inc.php14
-rw-r--r--include/menubar.inc.php467
-rw-r--r--index.php3
-rw-r--r--install/config.sql1
-rw-r--r--[-rwxr-xr-x]install/db/74-database.php (renamed from plugins/test_menu/index.php)41
-rw-r--r--plugins/AMenuManager/admin/amm_linksconfig.tpl9
-rw-r--r--plugins/AMenuManager/admin/amm_randompicconfig.tpl9
-rwxr-xr-xplugins/AMenuManager/amm_aim.class.inc.php1
-rwxr-xr-xplugins/AMenuManager/amm_aip.class.inc.php26
-rw-r--r--plugins/AMenuManager/amm_install.class.inc.php6
-rw-r--r--plugins/AMenuManager/amm_pip.class.inc.php113
-rw-r--r--plugins/AMenuManager/amm_root.class.inc.php62
-rwxr-xr-xplugins/AMenuManager/main.inc.php4
-rwxr-xr-xplugins/AMenuManager/maintain.inc.php25
-rw-r--r--plugins/AMenuManager/menu_templates/menubar_links.tpl10
-rw-r--r--plugins/AMenuManager/menu_templates/menubar_personalised.tpl6
-rw-r--r--plugins/AMenuManager/menu_templates/menubar_randompic.tpl14
-rwxr-xr-xplugins/test_menu/main.inc.php53
-rw-r--r--plugins/test_menu/maintain.inc.php44
-rw-r--r--plugins/test_menu/menu.class.inc.php511
-rw-r--r--plugins/test_menu/menu_templates/menubar_categories.tpl24
-rw-r--r--plugins/test_menu/menu_templates/menubar_generic.tpl10
-rw-r--r--plugins/test_menu/menu_templates/menubar_identification.tpl67
-rw-r--r--plugins/test_menu/menu_templates/menubar_links.tpl17
-rw-r--r--plugins/test_menu/menu_templates/menubar_main.tpl15
-rw-r--r--plugins/test_menu/menu_templates/menubar_menu.tpl21
-rw-r--r--plugins/test_menu/menu_templates/menubar_special.tpl10
-rw-r--r--plugins/test_menu/menu_templates/menubar_tags.tpl19
-rw-r--r--plugins/test_menu/menubar.inc.php320
-rw-r--r--template/yoga/menubar.tpl175
-rw-r--r--template/yoga/menubar_categories.tpl22
-rw-r--r--template/yoga/menubar_identification.tpl64
-rw-r--r--template/yoga/menubar_links.tpl15
-rw-r--r--template/yoga/menubar_menu.tpl18
-rw-r--r--template/yoga/menubar_specials.tpl9
-rw-r--r--template/yoga/menubar_tags.tpl18
44 files changed, 989 insertions, 1699 deletions
diff --git a/admin.php b/admin.php
index adc654879..eb6d07931 100644
--- a/admin.php
+++ b/admin.php
@@ -79,6 +79,7 @@ $template->assign(
'U_CONFIG_GENERAL'=> $link_start.'configuration',
'U_CONFIG_DISPLAY'=> $conf_link.'default',
'U_CONFIG_EXTENTS'=> $link_start.'extend_for_templates',
+ 'U_CONFIG_MENUBAR'=> $link_start.'menubar',
'U_CATEGORIES'=> $link_start.'cat_list',
'U_MOVE'=> $link_start.'cat_move',
'U_CAT_OPTIONS'=> $link_start.'cat_options',
@@ -138,7 +139,7 @@ if (count($page['infos']) != 0)
// Add the Piwigo Official menu
$template->assign( 'pwgmenu', pwg_URL() );
-
+
include(PHPWG_ROOT_PATH.'include/page_header.php');
$template->pparse('admin');
diff --git a/admin/include/functions.php b/admin/include/functions.php
index 59c63ff0c..db95ab383 100644
--- a/admin/include/functions.php
+++ b/admin/include/functions.php
@@ -1845,7 +1845,7 @@ UPDATE '.USER_CACHE_TABLE.'
*/
function create_table_add_character_set($query)
{
- defined('DB_CHARSET') or die('create_table_add_character_set DB_CHARSET undefined');
+ defined('DB_CHARSET') or trigger_error('create_table_add_character_set DB_CHARSET undefined', E_USER_ERROR);
if ('DB_CHARSET'!='')
{
if ( version_compare(mysql_get_server_info(), '4.1.0', '<') )
@@ -1853,17 +1853,34 @@ function create_table_add_character_set($query)
return $query;
}
$charset_collate = " DEFAULT CHARACTER SET ".DB_CHARSET;
- if ('DB_COLLATE'!='')
+ if (DB_COLLATE!='')
{
$charset_collate .= " COLLATE ".DB_COLLATE;
}
- $query=trim($query);
- $query=trim($query, ';');
- if (preg_match('/^CREATE\s+TABLE/i',$query))
+ if ( is_array($query) )
{
- $query.=$charset_collate;
+ foreach( $query as $id=>$q)
+ {
+ $q=trim($q);
+ $q=trim($q, ';');
+ if (preg_match('/^CREATE\s+TABLE/i',$q))
+ {
+ $q.=$charset_collate;
+ }
+ $q .= ';';
+ $query[$id] = $q;
+ }
+ }
+ else
+ {
+ $query=trim($query);
+ $query=trim($query, ';');
+ if (preg_match('/^CREATE\s+TABLE/i',$query))
+ {
+ $query.=$charset_collate;
+ }
+ $query .= ';';
}
- $query .= ';';
}
return $query;
}
diff --git a/admin/menubar.php b/admin/menubar.php
new file mode 100644
index 000000000..bdd761762
--- /dev/null
+++ b/admin/menubar.php
@@ -0,0 +1,162 @@
+<?php
+// +-----------------------------------------------------------------------+
+// | Piwigo - a PHP based picture gallery |
+// +-----------------------------------------------------------------------+
+// | Copyright(C) 2008 Piwigo Team http://piwigo.org |
+// | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |
+// | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |
+// +-----------------------------------------------------------------------+
+// | This program is free software; you can redistribute it and/or modify |
+// | it under the terms of the GNU General Public License as published by |
+// | the Free Software Foundation |
+// | |
+// | This program is distributed in the hope that it will be useful, but |
+// | WITHOUT ANY WARRANTY; without even the implied warranty of |
+// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
+// | General Public License for more details. |
+// | |
+// | You should have received a copy of the GNU General Public License |
+// | along with this program; if not, write to the Free Software |
+// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
+// | USA. |
+// +-----------------------------------------------------------------------+
+
+if (!defined('PHPWG_ROOT_PATH'))
+{
+ die ("Hacking attempt!");
+}
+
+
+function abs_fn_cmp($a, $b)
+{
+ return abs($a)-abs($b);
+}
+
+function make_consecutive( &$orders, $step=50 )
+{
+ uasort( $orders, 'abs_fn_cmp' );
+ $crt = 1;
+ foreach( $orders as $id=>$pos)
+ {
+ $orders[$id] = $step * ($pos<0 ? -$crt : $crt);
+ $crt++;
+ }
+}
+
+
+global $template;
+
+include_once(PHPWG_ROOT_PATH.'include/block.class.php');
+
+$menu = new BlockManager('menubar');
+$menu->load_registered_blocks();
+$reg_blocks = $menu->get_registered_blocks();
+
+$mb_conf = @$conf[ 'blk_'.$menu->get_id() ];
+if ( is_string($mb_conf) )
+ $mb_conf = unserialize( $mb_conf );
+if ( !is_array($mb_conf) )
+ $mb_conf=array();
+
+foreach ($mb_conf as $id => $pos)
+{
+ if (!isset($reg_blocks[$id]))
+ unset($mb_conf[$id]);
+}
+
+if ( isset($_POST['reset']) )
+{
+ $mb_conf = array();
+ $query = '
+UPDATE '.CONFIG_TABLE.'
+ SET value=""
+ WHERE param="blk_'.addslashes($menu->get_id()).'"
+ LIMIT 1';
+ pwg_query($query);
+}
+
+
+$idx=1;
+foreach ($reg_blocks as $id => $block)
+{
+ if ( !isset($mb_conf[$id]) )
+ $mb_conf[$id] = $idx*50;
+ $idx++;
+}
+
+
+if ( isset($_POST['submit']) )
+{
+ foreach ( $mb_conf as $id => $pos )
+ {
+ $hide = isset($_POST['hide_'.$id]);
+ $mb_conf[$id] = ($hide ? -1 : +1)*abs($pos);
+
+ $pos = (int)@$_POST['pos_'.$id];
+ if ($pos>0)
+ $mb_conf[$id] = $mb_conf[$id] > 0 ? $pos : -$pos;
+ }
+ make_consecutive( $mb_conf );
+
+ // BEGIN OPTIM - DONT ASK ABOUT THIS ALGO - but optimizes the size of the array we save in DB
+ $reg_keys = array_keys($reg_blocks);
+ $cnf_keys = array_keys($mb_conf);
+ $best_slice = array( 'len'=>0 );
+ for ($i=0; $i<count($reg_keys); $i++)
+ {
+ for ($j=0; $j<count($cnf_keys); $j++)
+ {
+ for ($k=0; max($i,$j)+$k<count($cnf_keys); $k++)
+ {
+ if ($cnf_keys[$j+$k] == $reg_keys[$i+$k] )
+ {
+ if ( 1+$k>$best_slice['len'])
+ {
+ $best_slice['len'] = 1+$k;
+ $best_slice['start_cnf'] = $j;
+ }
+ }
+ else
+ break;
+ }
+ }
+ }
+ $mb_conf_db = $mb_conf;
+ if ($best_slice['len'])
+ {
+ for ($j=0; $j<$best_slice['start_cnf']; $j++ )
+ {
+ $sign = $mb_conf_db[ $cnf_keys[$j] ] > 0 ? 1 : -1;
+ $mb_conf_db[ $cnf_keys[$j] ] = $sign * ( ($best_slice['start_cnf'])*50 - ($best_slice['start_cnf']-$j) );
+ }
+ for ($j=$best_slice['start_cnf']; $j<$best_slice['start_cnf']+$best_slice['len']; $j++ )
+ {
+ if ($mb_conf_db[ $cnf_keys[$j] ] > 0)
+ unset( $mb_conf_db[ $cnf_keys[$j] ] );
+ }
+ }
+ //var_export( $best_slice ); var_export($mb_conf); var_export($mb_conf_db);
+ // END OPTIM
+
+ $query = '
+UPDATE '.CONFIG_TABLE.'
+ SET value="'.addslashes(serialize($mb_conf_db)).'"
+ WHERE param="blk_'.addslashes($menu->get_id()).'"
+ LIMIT 1';
+ pwg_query($query);
+}
+
+make_consecutive( $mb_conf );
+
+foreach ($mb_conf as $id => $pos )
+{
+ $template->append( 'blocks',
+ array(
+ 'pos' => $pos/5,
+ 'reg' => $reg_blocks[$id]
+ )
+ );
+}
+$template->set_filename( 'menubar_admin_content', 'admin/menubar.tpl' );
+$template->assign_var_from_handle( 'ADMIN_CONTENT', 'menubar_admin_content');
+?>
diff --git a/admin/template/yoga/admin.tpl b/admin/template/yoga/admin.tpl
index 49441f8e5..4914477d0 100644
--- a/admin/template/yoga/admin.tpl
+++ b/admin/template/yoga/admin.tpl
@@ -23,6 +23,7 @@
<ul>
<li><a href="{$U_CONFIG_GENERAL}">{'conf_general'|@translate}</a></li>
<li><a href="{$U_CONFIG_DISPLAY}">{'conf_display'|@translate}</a></li>
+ <li><a href="{$U_CONFIG_MENUBAR}">{'title_menu'|@translate}</a></li>
<li><a href="{$U_CONFIG_EXTENTS}">{'conf_extents'|@translate}</a></li>
</ul>
</dd>
diff --git a/admin/template/yoga/admin/menubar.tpl b/admin/template/yoga/admin/menubar.tpl
new file mode 100644
index 000000000..06ff9ee9a
--- /dev/null
+++ b/admin/template/yoga/admin/menubar.tpl
@@ -0,0 +1,30 @@
+{* $Id: tracer_admin.tpl 2342 2008-05-15 18:43:33Z rub $ *}
+
+<div class="titrePage">
+ <h2>Menubar</h2>
+</div>
+
+<form method="post" class="properties">
+<table class="table2">
+ <tr class="throw">
+ <td>Id</td>
+ <td>{'Author'|@translate}</td>
+ <td>{'Name'|@translate}</td>
+ <td>{'Position'|@translate}</td>
+ <td>Hide</td>
+ </tr>
+ {foreach from=$blocks item=block name="block_loop"}
+ <tr class="{if $smarty.foreach.block_loop.index is odd}row1{else}row2{/if}">
+ <td>{$block.reg->get_id()}</td>
+ <td>{$block.reg->get_owner()}</td>
+ <td>{$block.reg->get_name()|@translate}</td>
+ <td><input type="input" name="pos_{$block.reg->get_id()}" value={math equation="abs(pos)" pos=$block.pos} size="2"></td>
+ <td><input type="checkbox" name="hide_{$block.reg->get_id()}" {if $block.pos<0}checked="checked"{/if} ></td>
+ </tr>
+ {/foreach}
+</table>
+<p>
+ <input type="submit" name="submit" value="{'Submit'|@translate}" >
+ <input type="submit" name="reset" value="{'Reset'|@translate}" >
+</p>
+</form> \ No newline at end of file
diff --git a/admin/template/yoga/theme/admin/themeconf.inc.php b/admin/template/yoga/theme/admin/themeconf.inc.php
index e3b6fc63e..6a87b0f4e 100644
--- a/admin/template/yoga/theme/admin/themeconf.inc.php
+++ b/admin/template/yoga/theme/admin/themeconf.inc.php
@@ -9,6 +9,7 @@ function selected_admin_menu()
switch ($_GET['page']) {
case 'configuration':
case 'extend_for_templates':
+ case 'menubar':
return 1;
case 'site_manager':
case 'site_update':
@@ -55,7 +56,7 @@ $themeconf = array(
'admin_icon_dir' => 'template/yoga/icon/admin',
'mime_icon_dir' => 'template/yoga/icon/mimetypes/',
'local_head' => '
-<!-- New template location for admin -->
+<!-- New template location for admin -->
<!-- Admin Accordion Menus -->
<script type="text/javascript" src="template-common/lib/jquery.js"></script>
<script type="text/javascript" src="template-common/lib/chili-1.7.pack.js"></script>
diff --git a/include/block.class.php b/include/block.class.php
new file mode 100644
index 000000000..c40a695aa
--- /dev/null
+++ b/include/block.class.php
@@ -0,0 +1,214 @@
+<?php
+// +-----------------------------------------------------------------------+
+// | Piwigo - a PHP based picture gallery |
+// +-----------------------------------------------------------------------+
+// | Copyright(C) 2008 Piwigo Team http://piwigo.org |
+// +-----------------------------------------------------------------------+
+// | This program is free software; you can redistribute it and/or modify |
+// | it under the terms of the GNU General Public License as published by |
+// | the Free Software Foundation |
+// | |
+// | This program is distributed in the hope that it will be useful, but |
+// | WITHOUT ANY WARRANTY; without even the implied warranty of |
+// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
+// | General Public License for more details. |
+// | |
+// | You should have received a copy of the GNU General Public License |
+// | along with this program; if not, write to the Free Software |
+// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
+// | USA. |
+// +-----------------------------------------------------------------------+
+
+class BlockManager
+{
+ protected $id;
+ protected $registered_blocks=array();
+ protected $display_blocks = array();
+
+ public function BlockManager($id)
+ {
+ $this->id = $id;
+ }
+
+ /** triggers an action that allows implementors of menu blocks to register the blocks*/
+ public function load_registered_blocks()
+ {
+ trigger_action('blockmanager_register_blocks', array(&$this) );
+ }
+
+ public function get_id()
+ {
+ return $this->id;
+ }
+
+ public function get_registered_blocks()
+ {
+ return $this->registered_blocks;
+ }
+
+ /** registers a block with this menu. usually called as a result of menubar_register_blocks action
+ * @param MenuBlock block
+ */
+ public function register_block(&$block)
+ {
+ if ( isset($this->registered_blocks[$block->get_id()] ) )
+ {
+ trigger_error("Block '".$block->get_id()."' is already registered", E_USER_WARNING);
+ return false;
+ }
+ $this->registered_blocks[$block->get_id()] = &$block;
+ return true;
+ }
+
+ /** performs one time preparation of registered blocks for display;
+ * triggers the action menubar_prepare_display where implementors can
+ * reposition or hide blocks
+ */
+ public function prepare_display()
+ {
+ global $conf;
+ $conf_id = 'blk_'.$this->id;
+ $mb_conf = isset($conf[$conf_id]) ? $conf[$conf_id] : array();
+ if ( !is_array($mb_conf) )
+ $mb_conf = @unserialize($mb_conf);
+
+ $idx = 1;
+ foreach( $this->registered_blocks as $id => $block )
+ {
+ $pos = isset( $mb_conf[$id] ) ? $mb_conf[$id] : $idx*50;
+ if ( $pos>0 )
+ {
+ $this->display_blocks[$id] = new DisplayBlock($block);
+ $this->display_blocks[$id]->set_position($pos);
+ }
+ $idx++;
+ }
+ $this->sort_blocks();
+ trigger_action( 'blockmanager_prepare_display', array(&$this) );
+ $this->sort_blocks();
+ }
+
+ /** returns true if the block whose id is hidden
+ * @param string block_id
+ */
+ public function is_hidden($block_id)
+ {
+ return isset($this->display_blocks[$block_id]) ? false : true;
+ }
+
+ public function hide_block($block_id)
+ {
+ unset( $this->display_blocks[$block_id] );
+ }
+
+ public function &get_block($block_id)
+ {
+ $tmp = null;
+ if ( isset($this->display_blocks[$block_id]) )
+ {
+ return $this->display_blocks[$block_id];
+ }
+ return $tmp;
+ }
+
+ public function set_block_position($block_id, $position)
+ {
+ if ( isset($this->display_blocks[$block_id]) )
+ {
+ $this->display_blocks[$block_id]->set_position($position);
+ }
+ }
+
+ protected function sort_blocks()
+ {
+ uasort( $this->display_blocks, array('BlockManager', 'cmp_by_position') );
+ }
+
+ static protected function cmp_by_position($a, $b)
+ {
+ return $a->get_position() - $b->get_position();
+ }
+
+ public function apply($var, $file)
+ {
+ global $template;
+
+ $template->set_filename('menubar', $file);
+ trigger_action('blockmanager_apply', array(&$this) );
+
+ foreach( $this->display_blocks as $id=>$block)
+ {
+ if (empty($block->raw_content) and empty($block->template) )
+ {
+ $this->hide_block($id);
+ }
+ }
+ $this->sort_blocks();
+ $template->assign('blocks', $this->display_blocks);
+ $template->assign_var_from_handle($var, 'menubar');
+ }
+}
+
+/**
+ * Represents a menu block registered in a Menu object.
+ */
+class RegisteredBlock
+{
+ protected $id;
+ protected $name;
+ protected $owner;
+
+ public function RegisteredBlock($id, $name, $owner)
+ {
+ $this->id = $id;
+ $this->name = $name;
+ $this->owner = $owner;
+ }
+
+ public function get_id() { return $this->id; }
+ public function get_name() { return $this->name; }
+ public function get_owner() { return $this->owner; }
+}
+
+/**
+ * Represents a menu block ready for display in the Menu object.
+ */
+class DisplayBlock
+{
+ protected $_registeredBlock;
+ protected $_position;
+
+ protected $_title;
+
+ public $data;
+ public $template;
+ public $raw_content;
+
+ public function DisplayBlock($registeredBlock)
+ {
+ $this->_registeredBlock = &$registeredBlock;
+ }
+
+ public function &get_block() { return $this->_registeredBlock; }
+
+ public function get_position() { return $this->_position; }
+ public function set_position($position)
+ {
+ $this->_position = $position;
+ }
+
+ public function get_title()
+ {
+ if (isset($this->_title))
+ return $this->_title;
+ else
+ return $this->_registeredBlock->get_name();
+ }
+
+ public function set_title($title)
+ {
+ $this->_title = $title;
+ }
+}
+
+?> \ No newline at end of file
diff --git a/include/common.inc.php b/include/common.inc.php
index d12b8bb70..a762eeade 100644
--- a/include/common.inc.php
+++ b/include/common.inc.php
@@ -283,5 +283,6 @@ add_event_handler('render_category_description', 'render_category_description');
add_event_handler('render_comment_content', 'htmlspecialchars');
add_event_handler('render_comment_content', 'parse_comment_content');
add_event_handler('render_comment_author', 'strip_tags');
+add_event_handler('blockmanager_register_blocks', 'register_default_menubar_blocks', EVENT_HANDLER_PRIORITY_NEUTRAL-1);
trigger_action('init');
?>
diff --git a/include/functions_html.inc.php b/include/functions_html.inc.php
index 2578fc8c3..ff03675b1 100644
--- a/include/functions_html.inc.php
+++ b/include/functions_html.inc.php
@@ -772,4 +772,18 @@ function order_by_name($element_ids,$name)
return $ordered_element_ids;
}
+/*event handler for menu*/
+function register_default_menubar_blocks( $menu_ref_arr )
+{
+ $menu = & $menu_ref_arr[0];
+ if ($menu->get_id() != 'menubar')
+ return;
+ $menu->register_block( new RegisteredBlock( 'mbLinks', 'Links', 'piwigo'));
+ $menu->register_block( new RegisteredBlock( 'mbCategories', 'Categories', 'piwigo'));
+ $menu->register_block( new RegisteredBlock( 'mbTags', 'Related tags', 'piwigo'));
+ $menu->register_block( new RegisteredBlock( 'mbSpecials', 'special_categories', 'piwigo'));
+ $menu->register_block( new RegisteredBlock( 'mbMenu', 'title_menu', 'piwigo'));
+ $menu->register_block( new RegisteredBlock( 'mbIdentification', 'identification', 'piwigo') );
+}
+
?>
diff --git a/include/menubar.inc.php b/include/menubar.inc.php
index 0ff64827e..b04a960a8 100644
--- a/include/menubar.inc.php
+++ b/include/menubar.inc.php
@@ -25,281 +25,278 @@
* This file is included by the main page to show the menu bar
*
*/
-$template->set_filenames(
- array(
- 'menubar' => 'menubar.tpl',
- )
- );
-trigger_action('loc_begin_menubar');
+include_once(PHPWG_ROOT_PATH.'include/block.class.php');
-$template->assign(
- array(
- 'NB_PICTURE' => $user['nb_total_images'],
- 'MENU_CATEGORIES_CONTENT' => get_categories_menu(),
- 'U_CATEGORIES' => make_index_url(array('section' => 'categories')),
- 'U_LOST_PASSWORD' => get_root_url().'password.php',
- 'U_UPLOAD' => get_upload_menu_link()
- )
- );
+initialize_menu();
-//-------------------------------------------------------------- external links
-foreach ($conf['links'] as $url => $url_data)
+function initialize_menu()
{
- if (!is_array($url_data))
- {
- $url_data = array('label' => $url_data);
- }
+ global $page, $conf, $user, $template, $filter;
- if
- (
- (!isset($url_data['eval_visible']))
- or
- (eval($url_data['eval_visible']))
- )
- {
- $tpl_var = array(
- 'URL' => $url,
- 'LABEL' => $url_data['label']
- );
+ $menu = new BlockManager("menubar");
+ $menu->load_registered_blocks();
+ $menu->prepare_display();
- if (!isset($url_data['new_window']) or $url_data['new_window'])
+//--------------------------------------------------------------- external links
+ if ( ($block=$menu->get_block('mbLinks')) and !empty($conf['links']) )
+ {
+ $data = array();
+ foreach ($conf['links'] as $url => $url_data)
{
- $tpl_var['new_window'] =
- array(
- 'NAME' => (isset($url_data['nw_name']) ? $url_data['nw_name'] : ''),
- 'FEATURES' => (isset($url_data['nw_features']) ? $url_data['nw_features'] : '')
- );
+ if (!is_array($url_data))
+ {
+ $url_data = array('label' => $url_data);
+ }
+
+ if
+ (
+ (!isset($url_data['eval_visible']))
+ or
+ (eval($url_data['eval_visible']))
+ )
+ {
+ $tpl_var = array(
+ 'URL' => $url,
+ 'LABEL' => $url_data['label']
+ );
+
+ if (!isset($url_data['new_window']) or $url_data['new_window'])
+ {
+ $tpl_var['new_window'] =
+ array(
+ 'NAME' => (isset($url_data['nw_name']) ? $url_data['nw_name'] : ''),
+ 'FEATURES' => (isset($url_data['nw_features']) ? $url_data['nw_features'] : '')
+ );
+ }
+ $data[] = $tpl_var;
+ }
}
- $template->append('links', $tpl_var);
+ $block->template = 'menubar_links.tpl';
+ $block->data = $data;
}
-}
+//-------------------------------------------------------------- categories
+ $block = $menu->get_block('mbCategories');
//------------------------------------------------------------------------ filter
-if (!empty($conf['filter_pages']) and get_filter_page_value('used'))
-{
- if ($filter['enabled'])
+ if (!empty($conf['filter_pages']) and get_filter_page_value('used'))
{
- $template->assign(
- 'U_STOP_FILTER',
- add_url_params(make_index_url(array()), array('filter' => 'stop'))
- );
+ if ($filter['enabled'])
+ {
+ $template->assign(
+ 'U_STOP_FILTER',
+ add_url_params(make_index_url(array()), array('filter' => 'stop'))
+ );
+ }
+ else
+ {
+ $template->assign(
+ 'U_START_FILTER',
+ add_url_params(make_index_url(array()), array('filter' => 'start-recent-'.$user['recent_period']))
+ );
+ }
}
- else
+
+ if ( $block!=null )
{
- $template->assign(
- 'U_START_FILTER',
- add_url_params(make_index_url(array()), array('filter' => 'start-recent-'.$user['recent_period']))
- );
+ $block->data = array(
+ 'NB_PICTURE' => $user['nb_total_images'],
+ 'MENU_CATEGORIES_CONTENT' => get_categories_menu(),
+ 'U_CATEGORIES' => make_index_url(array('section' => 'categories')),
+ 'U_UPLOAD' => get_upload_menu_link()
+ );
+ $block->template = 'menubar_categories.tpl';
}
-}
//------------------------------------------------------------------------ tags
-if ('tags' == @$page['section'])
-{
- // display tags associated to currently tagged items, less current tags
- $tags = array();
- if ( !empty($page['items']) )
+ $block = $menu->get_block('mbTags');
+ if ( $block!=null and 'tags'==@$page['section'] and !empty($page['items']) )
{
$tags = get_common_tags($page['items'],
- $conf['menubar_tag_cloud_items_number'], $page['tag_ids']);
- }
+ $conf['menubar_tag_cloud_items_number'], $page['tag_ids']);
+ $tags = add_level_to_tags($tags);
- $tags = add_level_to_tags($tags);
+ foreach ($tags as $tag)
+ {
+ $block->data[] =
+ array_merge( $tag,
+ array(
+ 'URL' => make_index_url(
+ array(
+ 'tags' => array($tag)
+ )
+ ),
+ 'U_ADD' => make_index_url(
+ array(
+ 'tags' => array_merge(
+ $page['tags'],
+ array($tag)
+ )
+ )
+ ),
+ )
+ );
+ }
+ $block->template = 'menubar_tags.tpl';
+ }
- foreach ($tags as $tag)
+//----------------------------------------------------------- special categories
+ if ( ($block = $menu->get_block('mbSpecials')) != null )
{
- $template->append(
- 'related_tags',
- array_merge( $tag,
+ if ( !is_a_guest() )
+ {// favorites
+ $block->data['favorites'] =
array(
- 'URL' => make_index_url(
- array(
- 'tags' => array($tag)
- )
- ),
+ 'URL' => make_index_url(array('section' => 'favorites')),
+ 'TITLE' => l10n('favorite_cat_hint'),
+ 'NAME' => l10n('favorite_cat')
+ );
+ }
- 'U_ADD' => make_index_url(
- array(
- 'tags' => array_merge(
- $page['tags'],
- array($tag)
- )
- )
- ),
- )
- )
+ $block->data['most_visited'] =
+ array(
+ 'URL' => make_index_url(array('section' => 'most_visited')),
+ 'TITLE' => l10n('most_visited_cat_hint'),
+ 'NAME' => l10n('most_visited_cat')
);
- }
-}
-//---------------------------------------------------------- special categories
-// favorites categories
-if ( !is_a_guest() )
-{
- $template->append(
- 'special_categories',
- array(
- 'URL' => make_index_url(array('section' => 'favorites')),
- 'TITLE' => l10n('favorite_cat_hint'),
- 'NAME' => l10n('favorite_cat')
- ));
-}
-// most visited
-$template->append(
- 'special_categories',
- array(
- 'URL' => make_index_url(array('section' => 'most_visited')),
- 'TITLE' => l10n('most_visited_cat_hint'),
- 'NAME' => l10n('most_visited_cat')
- ));
-// best rated
-if ($conf['rate'])
-{
- $template->append(
- 'special_categories',
- array(
- 'URL' => make_index_url(array('section' => 'best_rated')),
- 'TITLE' => l10n('best_rated_cat_hint'),
- 'NAME' => l10n('best_rated_cat')
- )
- );
-}
-// random
-$template->append(
- 'special_categories',
- array(
- 'URL' => get_root_url().'random.php',
- 'TITLE' => l10n('random_cat_hint'),
- 'NAME' => l10n('random_cat'),
- 'REL'=> 'rel="nofollow"'
- ));
-// recent pics
-$template->append(
- 'special_categories',
- array(
- 'URL' => make_index_url(array('section' => 'recent_pics')),
- 'TITLE' => l10n('recent_pics_cat_hint'),
- 'NAME' => l10n('recent_pics_cat'),
- ));
-// recent cats
-$template->append(
- 'special_categories',
- array(
- 'URL' => make_index_url(array('section' => 'recent_cats')),
- 'TITLE' => l10n('recent_cats_cat_hint'),
- 'NAME' => l10n('recent_cats_cat'),
- ));
-
-// calendar
-$template->append(
- 'special_categories',
- array(
- 'URL' =>
- make_index_url(
+ if ($conf['rate'])
+ {
+ $block->data['best_rated'] =
array(
- 'chronology_field' => ($conf['calendar_datefield']=='date_available'
- ? 'posted' : 'created'),
- 'chronology_style'=> 'monthly',
- 'chronology_view' => 'calendar'
- )
- ),
- 'TITLE' => l10n('calendar_hint'),
- 'NAME' => l10n('calendar'),
- 'REL'=> 'rel="nofollow"'
- )
- );
-//--------------------------------------------------------------------- summary
+ 'URL' => make_index_url(array('section' => 'best_rated')),
+ 'TITLE' => l10n('best_rated_cat_hint'),
+ 'NAME' => l10n('best_rated_cat')
+ );
+ }
-if (is_a_guest())
-{
- $template->assign(
+ $block->data['random'] =
array(
- 'U_IDENTIFY' => get_root_url().'identification.php',
- 'AUTHORIZE_REMEMBERING' => $conf['authorize_remembering']
- )
- );
+ 'URL' => get_root_url().'random.php',
+ 'TITLE' => l10n('random_cat_hint'),
+ 'NAME' => l10n('random_cat'),
+ 'REL'=> 'rel="nofollow"'
+ );
- if ($conf['allow_user_registration'])
- {
- $template->assign( 'U_REGISTER', get_root_url().'register.php');
- }
-}
-else
-{
- $template->assign('USERNAME', $user['username']);
+ $block->data['recent_pics'] =
+ array(
+ 'URL' => make_index_url(array('section' => 'recent_pics')),
+ 'TITLE' => l10n('recent_pics_cat_hint'),
+ 'NAME' => l10n('recent_pics_cat'),
+ );
- if (is_autorize_status(ACCESS_CLASSIC))
- {
- $template->assign('U_PROFILE', get_root_url().'profile.php');
- }
+ $block->data['recent_cats'] =
+ array(
+ 'URL' => make_index_url(array('section' => 'recent_cats')),
+ 'TITLE' => l10n('recent_cats_cat_hint'),
+ 'NAME' => l10n('recent_cats_cat'),
+ );
- // the logout link has no meaning with Apache authentication : it is not
- // possible to logout with this kind of authentication.
- if (!$conf['apache_authentication'])
- {
- $template->assign('U_LOGOUT', get_root_url().'?act=logout');
+
+ $block->data['calendar'] =
+ array(
+ 'URL' =>
+ make_index_url(
+ array(
+ 'chronology_field' => ($conf['calendar_datefield']=='date_available'
+ ? 'posted' : 'created'),
+ 'chronology_style'=> 'monthly',
+ 'chronology_view' => 'calendar'
+ )
+ ),
+ 'TITLE' => l10n('calendar_hint'),
+ 'NAME' => l10n('calendar'),
+ 'REL'=> 'rel="nofollow"'
+ );
+ $block->template = 'menubar_specials.tpl';
}
- if (is_admin())
+
+//---------------------------------------------------------------------- summary
+ if ( ($block=$menu->get_block('mbMenu')) != null )
{
- $template->assign('U_ADMIN', get_root_url().'admin.php');
- }
-}
+ // tags link
+ $block->data['tags'] =
+ array(
+ 'TITLE' => l10n('See available tags'),
+ 'NAME' => l10n('Tags'),
+ 'URL'=> get_root_url().'tags.php',
+ );
-// tags link
-$template->append(
- 'summaries',
- array(
- 'TITLE' => l10n('See available tags'),
- 'NAME' => l10n('Tags'),
- 'U_SUMMARY'=> get_root_url().'tags.php',
- )
- );
+ // search link
+ $block->data['search'] =
+ array(
+ 'TITLE'=>l10n('hint_search'),
+ 'NAME'=>l10n('Search'),
+ 'URL'=> get_root_url().'search.php',
+ 'REL'=> 'rel="search"'
+ );
-// search link
-$template->append(
- 'summaries',
- array(
- 'TITLE'=>l10n('hint_search'),
- 'NAME'=>l10n('Search'),
- 'U_SUMMARY'=> get_root_url().'search.php',
- 'REL'=> 'rel="search"'
- )
- );
+ // comments link
+ $block->data['comments'] =
+ array(
+ 'TITLE'=>l10n('hint_comments'),
+ 'NAME'=>l10n('comments'),
+ 'URL'=> get_root_url().'comments.php',
+ );
-// comments link
-$template->append(
- 'summaries',
- array(
- 'TITLE'=>l10n('hint_comments'),
- 'NAME'=>l10n('comments'),
- 'U_SUMMARY'=> get_root_url().'comments.php',
- )
- );
+ // about link
+ $block->data['about'] =
+ array(
+ 'TITLE' => l10n('about_page_title'),
+ 'NAME' => l10n('About'),
+ 'URL' => get_root_url().'about.php',
+ );
-// about link
-$template->append(
- 'summaries',
- array(
- 'TITLE' => l10n('about_page_title'),
- 'NAME' => l10n('About'),
- 'U_SUMMARY' => get_root_url().'about.php',
- )
- );
+ // notification
+ $block->data['rss'] =
+ array(
+ 'TITLE'=>l10n('RSS feed'),
+ 'NAME'=>l10n('Notification'),
+ 'URL'=> get_root_url().'notification.php',
+ 'REL'=> 'rel="nofollow"'
+ );
+ $block->template = 'menubar_menu.tpl';
+ }
-// notification
-$template->append(
- 'summaries',
- array(
- 'TITLE'=>l10n('RSS feed'),
- 'NAME'=>l10n('Notification'),
- 'U_SUMMARY'=> get_root_url().'notification.php',
- 'REL'=> 'rel="nofollow"'
- )
- );
-trigger_action('loc_end_menubar');
-$template->assign_var_from_handle('MENUBAR', 'menubar');
+//--------------------------------------------------------------- identification
+ if (is_a_guest())
+ {
+ $template->assign(
+ array(
+ 'U_LOGIN' => get_root_url().'identification.php',
+ 'AUTHORIZE_REMEMBERING' => $conf['authorize_remembering']
+ )
+ );
+ if ($conf['allow_user_registration'])
+ {
+ $template->assign( 'U_REGISTER', get_root_url().'register.php');
+ }
+ }
+ else
+ {
+ $template->assign('USERNAME', $user['username']);
+ if (is_autorize_status(ACCESS_CLASSIC))
+ {
+ $template->assign('U_PROFILE', get_root_url().'profile.php');
+ }
+ // the logout link has no meaning with Apache authentication : it is not
+ // possible to logout with this kind of authentication.
+ if (!$conf['apache_authentication'])
+ {
+ $template->assign('U_LOGOUT', get_root_url().'?act=logout');
+ }
+ if (is_admin())
+ {
+ $template->assign('U_ADMIN', get_root_url().'admin.php');
+ }
+ }
+ if ( ($block=$menu->get_block('mbIdentification')) != null )
+ {
+ $block->template = 'menubar_identification.tpl';
+ }
+ $menu->apply('MENUBAR', 'menubar.tpl' );
+}
?>
diff --git a/index.php b/index.php
index 1f667130f..0cf3a11ca 100644
--- a/index.php
+++ b/index.php
@@ -157,8 +157,7 @@ else
);
}
// include menubar
-include(trigger_event('menubar_file',
- PHPWG_ROOT_PATH.'include/menubar.inc.php'));
+include( PHPWG_ROOT_PATH.'include/menubar.inc.php');
if ('search' == $page['section'])
{
diff --git a/install/config.sql b/install/config.sql
index 679535941..8b7a622f5 100644
--- a/install/config.sql
+++ b/install/config.sql
@@ -28,3 +28,4 @@ INSERT INTO piwigo_config (param,value,comment) VALUES ('c13y_ignore',null,'List
INSERT INTO piwigo_config (param,value,comment) VALUES ('upload_link_everytime','false','Show upload link every time');
INSERT INTO piwigo_config (param,value,comment) VALUES ('upload_user_access',2 /*ACCESS_CLASSIC*/,'User access level to upload');
INSERT INTO piwigo_config (param,value,comment) VALUES ('extents_for_templates','a:0:{}','Actived template-extension(s)');
+INSERT INTO piwigo_config (param,value,comment) VALUES ('blk_menubar','','Menubar options');
diff --git a/plugins/test_menu/index.php b/install/db/74-database.php
index db1eae0d9..834828f89 100755..100644
--- a/plugins/test_menu/index.php
+++ b/install/db/74-database.php
@@ -1,13 +1,10 @@
<?php
// +-----------------------------------------------------------------------+
-// | PhpWebGallery - a PHP based picture gallery |
-// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
-// | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net |
+// | Piwigo - a PHP based picture gallery |
// +-----------------------------------------------------------------------+
-// | file : $Id: index.php 1912 2007-03-16 06:30:07Z rub $
-// | last update : $Date: 2007-03-16 07:30:07 +0100 (ven, 16 mar 2007) $
-// | last modifier : $Author: rub $
-// | revision : $Revision: 1912 $
+// | Copyright(C) 2008 Piwigo Team http://piwigo.org |
+// | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |
+// | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |
// +-----------------------------------------------------------------------+
// | This program is free software; you can redistribute it and/or modify |
// | it under the terms of the GNU General Public License as published by |
@@ -24,10 +21,28 @@
// | USA. |
// +-----------------------------------------------------------------------+
-// Recursive call
-$url = '../';
-header( 'Request-URI: '.$url );
-header( 'Content-Location: '.$url );
-header( 'Location: '.$url );
-exit();
+if (!defined('PHPWG_ROOT_PATH'))
+{
+ die('Hacking attempt!');
+}
+
+$upgrade_description = 'Add blk_menubar config';
+
+include_once(PHPWG_ROOT_PATH.'include/constants.php');
+
+// +-----------------------------------------------------------------------+
+// | Upgrade content |
+// +-----------------------------------------------------------------------+
+
+$query = "
+INSERT INTO ".CONFIG_TABLE." (param,value,comment) VALUES ('blk_menubar','','Menubar options');
+";
+pwg_query($query);
+
+echo
+"\n"
+.'"'.$upgrade_description.'"'.' ended'
+."\n"
+;
+
?>
diff --git a/plugins/AMenuManager/admin/amm_linksconfig.tpl b/plugins/AMenuManager/admin/amm_linksconfig.tpl
index 25e6d75cc..4bce937fc 100644
--- a/plugins/AMenuManager/admin/amm_linksconfig.tpl
+++ b/plugins/AMenuManager/admin/amm_linksconfig.tpl
@@ -66,15 +66,6 @@
<table class="formtable">
<tr>
- <td>{'g002_setting_block_active'|@translate}</td>
- <td>
- <select name="famm_links_active" id="iamm_links_active">
- {html_options values=$datas.yesno_values output=$datas.yesno_labels selected=$datas.active_selected}
- </select>
- </td>
- </tr>
-
- <tr>
<td>{'g002_setting_block_title'|@translate}</td>
<td>
<input type="text" id="iamm_links_title" value="" maxlength="50" onkeyup="apply_changes('iamm_links_title');" onblur="apply_changes('iamm_links_title');"/>
diff --git a/plugins/AMenuManager/admin/amm_randompicconfig.tpl b/plugins/AMenuManager/admin/amm_randompicconfig.tpl
index df70311f0..b910c2f1c 100644
--- a/plugins/AMenuManager/admin/amm_randompicconfig.tpl
+++ b/plugins/AMenuManager/admin/amm_randompicconfig.tpl
@@ -66,15 +66,6 @@
<table class="formtable">
<tr>
- <td>{'g002_setting_block_active'|@translate}</td>
- <td>
- <select name="famm_randompicture_active" id="iamm_randompicture_active">
- {html_options values=$datas.yesno_values output=$datas.yesno_labels selected=$datas.active_selected}
- </select>
- </td>
- </tr>
-
- <tr>
<td>{'g002_setting_block_title'|@translate}</td>
<td>
<input type="text" id="iamm_randompicture_title" value="" maxlength="50" onkeyup="apply_changes('iamm_randompicture_title');" onblur="apply_changes('iamm_randompicture_title');"/>
diff --git a/plugins/AMenuManager/amm_aim.class.inc.php b/plugins/AMenuManager/amm_aim.class.inc.php
index 0556fd6b1..e100020d4 100755
--- a/plugins/AMenuManager/amm_aim.class.inc.php
+++ b/plugins/AMenuManager/amm_aim.class.inc.php
@@ -30,6 +30,7 @@ class AMM_AIM extends AMM_root
*/
function init_events()
{
+ parent::init_events();
add_event_handler('get_admin_plugin_menu_links', array(&$this, 'plugin_admin_menu') );
}
diff --git a/plugins/AMenuManager/amm_aip.class.inc.php b/plugins/AMenuManager/amm_aip.class.inc.php
index 9fd5ce1cb..5481fd030 100755
--- a/plugins/AMenuManager/amm_aip.class.inc.php
+++ b/plugins/AMenuManager/amm_aip.class.inc.php
@@ -189,7 +189,6 @@ class AMM_AIP extends AMM_root
*/
public function init_events()
{
- add_event_handler('menubar_file', array(&$this, 'plugin_public_menu') );
add_event_handler('loc_end_page_header', array(&$this->css, 'apply_CSS'));
}
@@ -237,10 +236,10 @@ class AMM_AIP extends AMM_root
break;
case 'setmenu_modspecial_sections_list':
- $result=$this->ajax_amm_setmenu_mod_section_list('amm_sections_modspecial');
+ $result=$this->ajax_amm_setmenu_mod_section_list('amm_sections_modspecials');
break;
case 'setmenu_modspecial_sections_showhide':
- $result=$this->ajax_amm_setmenu_mod_section_showhide('amm_sections_modspecial', $_REQUEST['fItem']);
+ $result=$this->ajax_amm_setmenu_mod_section_showhide('amm_sections_modspecials', $_REQUEST['fItem']);
break;
case 'personalised_list':
@@ -325,7 +324,6 @@ class AMM_AIP extends AMM_root
'lnk_list' => $this->page_link.'&amp;fAMM_tabsheet=links',
'AMM_AJAX_URL_LIST' => $this->page_link."&ajaxfct=",
'show_icons_selected' => $this->my_config['amm_links_show_icons'],
- 'active_selected' => $this->my_config['amm_links_active'],
'lang_selected' => $user['language'],
'fromlang' => substr($user['language'],0,2)
);
@@ -459,7 +457,6 @@ class AMM_AIP extends AMM_root
protected function action_links_modify_config()
{
$this->my_config['amm_links_show_icons']=$_POST['famm_links_show_icons'];
- $this->my_config['amm_links_active']=$_POST['famm_links_active'];
$languages=get_languages();
foreach($languages as $key => $val)
{
@@ -473,7 +470,6 @@ class AMM_AIP extends AMM_root
*/
protected function action_randompic_modify_config()
{
- $this->my_config['amm_randompicture_active']=$_POST['famm_randompicture_active'];
$this->my_config['amm_randompicture_showname']=$_POST['famm_randompicture_showname'];
$this->my_config['amm_randompicture_showcomment']=$_POST['famm_randompicture_showcomment'];
$languages=get_languages();
@@ -541,7 +537,6 @@ class AMM_AIP extends AMM_root
$template_datas=array(
'lnk_list' => $this->page_link.'&amp;fAMM_tabsheet=links',
- 'active_selected' => $this->my_config['amm_randompicture_active'],
'showname_selected' => $this->my_config['amm_randompicture_showname'],
'showcomment_selected' => $this->my_config['amm_randompicture_showcomment'],
'lang_selected' => $user['language'],
@@ -702,7 +697,7 @@ class AMM_AIP extends AMM_root
*/
protected function action_create_modify_personalised()
{
- global $menu, $user;
+ global $user;
if($_POST['famm_modeedit']=='create')
{
@@ -733,14 +728,6 @@ class AMM_AIP extends AMM_root
$this->modify_personalised($datas);
}
}
-
- if($_POST['famm_modeedit']=='create')
- {
- $menu->register('mbAMM_personalised'.$id, ($_POST['famm_personalised_nfo']=='')?$_POST['famm_personalised_title_'.$user['language']]:$_POST['famm_personalised_nfo'], 0, 'AMM');
- }
-
-
-
}
@@ -812,8 +799,8 @@ class AMM_AIP extends AMM_root
private function add_url($datas)
{
$numurl=$this->get_count_url();
- $sql="INSERT INTO ".$this->tables['urls']." (id, label, url, mode, icon, position, visible)
- VALUES ('', '".$datas['label']."', '".$datas['url']."', '".$datas['mode']."',
+ $sql="INSERT INTO ".$this->tables['urls']." (label, url, mode, icon, position, visible)
+ VALUES ('".$datas['label']."', '".$datas['url']."', '".$datas['mode']."',
'".$datas['icon']."', '".$numurl."', '".$datas['visible']."')";
return(pwg_query($sql));
}
@@ -1053,12 +1040,9 @@ class AMM_AIP extends AMM_root
// delete a section and returns a html formatted list
private function ajax_amm_personalised_delete($sectionid)
{
- global $menu;
-
if(!$this->adviser_abort())
{
$this->delete_personalised($sectionid);
- $menu->unregister('mbAMM_personalised'.$sectionid);
}
return($this->ajax_amm_personalised_list());
}
diff --git a/plugins/AMenuManager/amm_install.class.inc.php b/plugins/AMenuManager/amm_install.class.inc.php
index 2f2bb9e47..db1926a0a 100644
--- a/plugins/AMenuManager/amm_install.class.inc.php
+++ b/plugins/AMenuManager/amm_install.class.inc.php
@@ -47,7 +47,7 @@
`visible` char(1) NOT NULL default 'y',
PRIMARY KEY (`id`),
KEY `order_key` (`position`)
-) ENGINE=MyISAM DEFAULT CHARSET=latin1",
+)",
"CREATE TABLE `".$this->tables['personalised']."` (
`id` int(11) NOT NULL default '0',
@@ -57,10 +57,10 @@
`visible` char(1) NOT NULL default 'y',
`nfo` varchar(25) NOT NULL default '',
PRIMARY KEY (`id`,`lang`)
-) ENGINE=MyISAM DEFAULT CHARSET=latin1"
+)"
);
//$table_def array
-
+ $tables_def = create_table_add_character_set($tables_def);
$result=$this->tablef->create_tables($tables_def);
return($result);
}
diff --git a/plugins/AMenuManager/amm_pip.class.inc.php b/plugins/AMenuManager/amm_pip.class.inc.php
index dc34e1d84..6a195b052 100644
--- a/plugins/AMenuManager/amm_pip.class.inc.php
+++ b/plugins/AMenuManager/amm_pip.class.inc.php
@@ -38,44 +38,19 @@ class AMM_PIP extends AMM_root
*/
public function init_events()
{
- add_event_handler('loc_begin_menubar', array(&$this, 'modify_menu') );
+ //TODELETE: add_event_handler('loc_begin_menubar', array(&$this, 'modify_menu') );
+ parent::init_events();
+ add_event_handler('blockmanager_apply', array(&$this, 'blockmanager_apply') );
}
- /* ---------------------------------------------------------------------------
- protected classe functions
- --------------------------------------------------------------------------- */
- public function modify_menu()
+ public function blockmanager_apply( $menu_ref_arr )
{
- global $menu, $user;
-
-
- /*
- Add a new section (links)
- */
- $urls=$this->get_urls(true);
- if(($this->my_config['amm_links_active']=='y')and(count($urls)>0))
- {
- if($this->my_config['amm_links_show_icons']=='y')
- {
- for($i=0;$i<count($urls);$i++)
- {
- $urls[$i]['icon']=AMM_PATH."links_pictures/".$urls[$i]['icon'];
- }
- }
-
- $section = new Section('mbAMM_links', base64_decode($this->my_config['amm_links_title'][$user['language']]), dirname(__FILE__).'/menu_templates/menubar_links.tpl');
- $section->set_items(array(
- 'LINKS' => $urls,
- 'icons' => $this->my_config['amm_links_show_icons']
- ));
- $menu->add($section->get());
- }
-
+ $menu = & $menu_ref_arr[0];
/*
Add a new random picture section
*/
- if($this->my_config['amm_randompicture_active']=='y')
+ if ( ($block = $menu->get_block( 'mbAMM_randompict' ) ) != null )
{
$sql="SELECT i.id as image_id, i.file as image_file, i.comment, i.path, i.tn_ext, c.id as catid, c.name, c.permalink, RAND() as rndvalue, i.name as imgname
FROM ".CATEGORIES_TABLE." c, ".IMAGES_TABLE." i, ".IMAGE_CATEGORY_TABLE." ic
@@ -95,17 +70,43 @@ LIMIT 0,1
'name' => $nfo['name'],
'permalink' => $nfo['permalink']
);
-
- $section = new Section('mbAMM_randompict', base64_decode($this->my_config['amm_randompicture_title'][$user['language']]), dirname(__FILE__).'/menu_templates/menubar_randompic.tpl');
- $section->set_items(array(
+ global $user;
+ $block->set_title( base64_decode($this->my_config['amm_randompicture_title'][$user['language']]) );
+ $block->template = dirname(__FILE__).'/menu_templates/menubar_randompic.tpl';
+ $block->data = array(
'LINK' => make_picture_url($nfo),
'IMG' => get_thumbnail_url($nfo),
'IMGNAME' => $nfo['imgname'],
'IMGCOMMENT' => $nfo['comment'],
'SHOWNAME' => $this->my_config['amm_randompicture_showname'],
'SHOWCOMMENT' => $this->my_config['amm_randompicture_showcomment']
- ));
- $menu->add($section->get());
+ );
+ }
+ }
+
+ /*
+ Add a new section (links)
+ */
+ if ( ($block = $menu->get_block( 'mbAMM_links' ) ) != null )
+ {
+ $urls=$this->get_urls(true);
+ if ( count($urls)>0 )
+ {
+ if($this->my_config['amm_links_show_icons']=='y')
+ {
+ for($i=0;$i<count($urls);$i++)
+ {
+ $urls[$i]['icon']=get_root_url().'plugins/'.AMM_DIR."/links_pictures/".$urls[$i]['icon'];
+ }
+ }
+
+ $block->set_title( base64_decode($this->my_config['amm_links_title'][$user['language']]) );
+ $block->template = dirname(__FILE__).'/menu_templates/menubar_links.tpl';
+
+ $block->data = array(
+ 'LINKS' => $urls,
+ 'icons' => $this->my_config['amm_links_show_icons']
+ );
}
}
@@ -121,46 +122,34 @@ LIMIT 0,1
{
if(!isset($id_done[$val['id']]))
{
- $section = new Section('mbAMM_personalised'.$val['id'], $val['title'], dirname(__FILE__).'/menu_templates/menubar_personalised.tpl');
- $section->set_items(array(
- 'CONTENT' => stripslashes($val['content'])));
- $menu->add($section->get());
-
+ if ( ($block = $menu->get_block( 'mbAMM_personalised'.$val['id'] ) ) != null )
+ {
+ $block->set_title( $val['title'] );
+ $block->template = dirname(__FILE__).'/menu_templates/menubar_personalised.tpl';
+ $block->data = stripslashes($val['content']);
+ }
$id_done[$val['id']]="";
}
}
}
-
- /*
- Hide sections
- */
- foreach($this->my_config['amm_sections_visible'] as $key => $val)
- {
- if($val=='n')
- {
- $menu->remove($key);
- }
- }
-
/*
hide items from special & menu sections
*/
- foreach(array('mbMenu' => 'amm_sections_modmenu', 'mbSpecial' =>'amm_sections_modspecial') as $key0 => $val0)
+ foreach(array('mbMenu' => 'amm_sections_modmenu', 'mbSpecials' =>'amm_sections_modspecials') as $key0 => $val0)
{
- $section_menu=$menu->section($key0);
- foreach($this->my_config[$val0] as $key => $val)
+ if ( ($block = $menu->get_block( $key0 ) ) != null )
{
- if($val=='n')
+ foreach($this->my_config[$val0] as $key => $val)
{
- unset($section_menu['ITEMS'][$key]);
+ if($val=='n')
+ {
+ unset( $block->data[$key] );
+ }
}
}
- $menu->replace($section_menu);
}
-
- }
-
+ }
} // AMM_PIP class
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)
diff --git a/plugins/AMenuManager/main.inc.php b/plugins/AMenuManager/main.inc.php
index 766b478e8..79cbf674a 100755
--- a/plugins/AMenuManager/main.inc.php
+++ b/plugins/AMenuManager/main.inc.php
@@ -43,9 +43,9 @@ define('AMM_PATH' , PHPWG_PLUGINS_PATH . AMM_DIR . '/');
define('AMM_VERSION' , '1.0.0'); // => ne pas oublier la version dans l'entête !!
-global $prefixeTable, $menu;
+global $prefixeTable;
-if(basename($_SERVER["PHP_SELF"])=='admin.php')
+if(defined('IN_ADMIN'))
{
//AMM admin part loaded and active only if in admin page
include_once("amm_aim.class.inc.php");
diff --git a/plugins/AMenuManager/maintain.inc.php b/plugins/AMenuManager/maintain.inc.php
index 543ec5c1f..3c75083c9 100755
--- a/plugins/AMenuManager/maintain.inc.php
+++ b/plugins/AMenuManager/maintain.inc.php
@@ -5,8 +5,8 @@ if (!defined('PHPWG_ROOT_PATH')) { die('Hacking attempt!'); }
ini_set('error_reporting', E_ALL);
ini_set('display_errors', true);
-define('AMM_DIR' , basename(dirname(__FILE__)));
-define('AMM_PATH' , PHPWG_PLUGINS_PATH . AMM_DIR . '/');
+defined('AMM_DIR') || define('AMM_DIR' , basename(dirname(__FILE__)));
+defined('AMM_PATH') || define('AMM_PATH' , PHPWG_PLUGINS_PATH . AMM_DIR . '/');
@include_once(PHPWG_PLUGINS_PATH.'grum_plugins_classes-2/tables.class.inc.php');
@@ -23,11 +23,11 @@ load_language('plugin.lang', AMM_PATH);
function plugin_install($plugin_id, $plugin_version, &$errors)
{
- global $prefixeTable, $gpc_installed, $menu;
+ global $prefixeTable, $gpc_installed;
if($gpc_installed)
{
- $menu->register('mbAMM_links', 'Links', 0, 'AMM');
- $menu->register('mbAMM_randompict', 'Random pictures', 0, 'AMM');
+ //$menu->register('mbAMM_links', 'Links', 0, 'AMM');
+ //$menu->register('mbAMM_randompict', 'Random pictures', 0, 'AMM');
$amm=new AMM_install($prefixeTable, __FILE__);
$result=$amm->install();
}
@@ -47,18 +47,9 @@ function plugin_deactivate($plugin_id)
function plugin_uninstall($plugin_id)
{
- global $prefixeTable, $gpc_installed, $menu;
- if($gpc_installed)
- {
- $menu->unregister('mbAMM_links');
- $menu->unregister('mbAMM_randompict');
- $amm=new AMM_install($prefixeTable, __FILE__);
- $result=$amm->uninstall();
- }
- else
- {
- array_push($errors, l10n('Grum Plugin Classes is not installed'));
- }
+ global $prefixeTable;
+ $amm=new AMM_install($prefixeTable, __FILE__);
+ $result=$amm->uninstall();
}
diff --git a/plugins/AMenuManager/menu_templates/menubar_links.tpl b/plugins/AMenuManager/menu_templates/menubar_links.tpl
index 927a0f2cd..205e3b66e 100644
--- a/plugins/AMenuManager/menu_templates/menubar_links.tpl
+++ b/plugins/AMenuManager/menu_templates/menubar_links.tpl
@@ -1,13 +1,13 @@
<!-- links menu bar -->
-{if $section.NAME!=""}
- <dt>{$section.NAME|@translate}</dt>
+{if $block->get_title() !="" }
+ <dt>{$block->get_title()}</dt>
{/if}
<dd>
- <ul {if $section.ITEMS.icons=='y'}style="padding-left:4px;list-style:none;"{/if}>
- {foreach from=$section.ITEMS.LINKS item=link}
+ <ul {if $block->data.icons=='y'}style="padding-left:4px;list-style:none;"{/if}>
+ {foreach from=$block->data.LINKS item=link}
<li>
- {if $section.ITEMS.icons=='y'}<img src='{$link.icon}' style="position:relative;top:3px;"/>{/if}
+ {if $block->data.icons=='y'}<img src='{$link.icon}' style="position:relative;top:3px;"/>{/if}
<a href="{$link.url}"
{if $link.mode == 0} target = '_blank' {/if}>{$link.label}</a>
</li>
diff --git a/plugins/AMenuManager/menu_templates/menubar_personalised.tpl b/plugins/AMenuManager/menu_templates/menubar_personalised.tpl
index 93c3b860b..9fada74a2 100644
--- a/plugins/AMenuManager/menu_templates/menubar_personalised.tpl
+++ b/plugins/AMenuManager/menu_templates/menubar_personalised.tpl
@@ -1,8 +1,8 @@
<!-- personalised menu bar -->
-{if $section.NAME!=""}
- <dt>{$section.NAME|@translate}</dt>
+{if $block->get_title() !="" }
+ <dt>{$block->get_title()}</dt>
{/if}
<dd>
- {if $section.ITEMS.CONTENT!=""}{$section.ITEMS.CONTENT}{/if}
+ {$block->data}
</dd> \ No newline at end of file
diff --git a/plugins/AMenuManager/menu_templates/menubar_randompic.tpl b/plugins/AMenuManager/menu_templates/menubar_randompic.tpl
index a79206103..20d7a0bf8 100644
--- a/plugins/AMenuManager/menu_templates/menubar_randompic.tpl
+++ b/plugins/AMenuManager/menu_templates/menubar_randompic.tpl
@@ -1,14 +1,12 @@
<!-- random picture menu bar -->
-{if $section.NAME!=""}
- <dt>{$section.NAME|@translate}</dt>
-{/if}
+<dt>{$block->get_title()}</dt>
<dd>
<div class="illustration" style="text-align:center;padding:5px;font-size:85%;">
- {if $section.ITEMS.IMGNAME!="" and $section.ITEMS.SHOWNAME=="o"}{$section.ITEMS.IMGNAME}<br/>{/if}
- {if $section.ITEMS.IMGCOMMENT!="" and $section.ITEMS.SHOWCOMMENT=="o"}{$section.ITEMS.IMGCOMMENT}<br/>{/if}
- <a href="{$section.ITEMS.LINK}"><img src="{$section.ITEMS.IMG}"/></a>
- {if $section.ITEMS.IMGNAME!="" and $section.ITEMS.SHOWNAME=="u"}<br/>{$section.ITEMS.IMGNAME}{/if}
- {if $section.ITEMS.IMGCOMMENT!="" and $section.ITEMS.SHOWCOMMENT=="u"}<br/>{$section.ITEMS.IMGCOMMENT}{/if}
+ {if $block->data.IMGNAME!="" and $block->data.SHOWNAME=="o"}{$block->data.IMGNAME}<br/>{/if}
+ {if $block->data.IMGCOMMENT!="" and $block->data.SHOWCOMMENT=="o"}{$block->data.IMGCOMMENT}<br/>{/if}
+ <a href="{$block->data.LINK}"><img src="{$block->data.IMG}"/></a>
+ {if $block->data.IMGNAME!="" and $block->data.SHOWNAME=="u"}<br/>{$block->data.IMGNAME}{/if}
+ {if $block->data.IMGCOMMENT!="" and $block->data.SHOWCOMMENT=="u"}<br/>{$block->data.IMGCOMMENT}{/if}
</div>
</dd> \ No newline at end of file
diff --git a/plugins/test_menu/main.inc.php b/plugins/test_menu/main.inc.php
deleted file mode 100755
index 72abbe9e6..000000000
--- a/plugins/test_menu/main.inc.php
+++ /dev/null
@@ -1,53 +0,0 @@
-<?php
-/*
-Plugin Name: Test Menu
-Version: 1.0.0
-Description: Plugin pour montrer l'usage de la classe Menu / Plugin to show usage of the class Menu
-Plugin URI: http://phpwebgallery.net/ext/extension_view.php?eid=
-*/
-
-/*
---------------------------------------------------------------------------------
- Author : Grum
- email : grum@grum.dnsalias.com
- website : http://photos.grum.dnsalias.com
- PWG user : http://forum.phpwebgallery.net/profile.php?id=3706
-
- << May the Little SpaceFrog be with you ! >>
---------------------------------------------------------------------------------
-
-:: HISTORY
-
---------------------------------------------------------------------------------
-*/
-
-// pour faciliter le debug :o)
- ini_set('error_reporting', E_ALL);
- ini_set('display_errors', true);
-
-if(!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
-
-
-define('TEST_MENU_DIR' , basename(dirname(__FILE__)));
-define('TEST_MENU_PATH' , PHPWG_PLUGINS_PATH . TEST_MENU_DIR . '/');
-
-define('TEST_MENU_VERSION' , '1.0.0'); // => ne pas oublier la version dans l'entête !!
-
-global $prefixeTable, $menu;
-
-include_once("menu.class.inc.php");
-
-function filemenu()
-{
- return(TEST_MENU_PATH."menubar.inc.php");
-}
-
-$menu = new Menu();
-
-if(basename($_SERVER["PHP_SELF"])!='admin.php')
-{
- add_event_handler('menubar_file', 'filemenu');
-}
-
-
-?>
diff --git a/plugins/test_menu/maintain.inc.php b/plugins/test_menu/maintain.inc.php
deleted file mode 100644
index 5aa42e213..000000000
--- a/plugins/test_menu/maintain.inc.php
+++ /dev/null
@@ -1,44 +0,0 @@
-<?php
-
-if (!defined('PHPWG_ROOT_PATH')) { die('Hacking attempt!'); }
-
-ini_set('error_reporting', E_ALL);
-ini_set('display_errors', true);
-
-define('TEST_MENU_DIR' , basename(dirname(__FILE__)));
-define('TEST_MENU_PATH' , PHPWG_PLUGINS_PATH . TEST_MENU_DIR . '/');
-
-include_once("menu.class.inc.php");
-
-function plugin_install($plugin_id, $plugin_version, &$errors)
-{
-/* -[note]----------------------------------------------------------------------
-In normal case, piwigo's registered items of the $menu object are not
-initialized by a plugin, but by piwigo (while the install process).
-Piwigo's default registered items are initialized here to give a "how to"
-example of the classe
------------------------------------------------------------------------------ */
- $menu=new Menu();
- $menu->register('mbLinks', 'Links', 1, 'piwigo');
- $menu->register('mbCategories', 'Categories', 2, 'piwigo');
- $menu->register('mbTags', 'Related tags', 3, 'piwigo');
- $menu->register('mbSpecial', 'special_categories', 4, 'piwigo');
- $menu->register('mbMenu', 'title_menu', 5, 'piwigo');
- $menu->register('mbIdentification', 'identification', 6, 'piwigo');
-}
-
-function plugin_activate($plugin_id, $plugin_version, &$errors)
-{
-}
-
-function plugin_deactivate($plugin_id)
-{
-}
-
-function plugin_uninstall($plugin_id)
-{
-}
-
-
-
-?>
diff --git a/plugins/test_menu/menu.class.inc.php b/plugins/test_menu/menu.class.inc.php
deleted file mode 100644
index 7eece66bd..000000000
--- a/plugins/test_menu/menu.class.inc.php
+++ /dev/null
@@ -1,511 +0,0 @@
-<?php
-
-/* -----------------------------------------------------------------------------
- classes names : menu, section
- class version : 1.0
- date : 2008-07-25
-
- ------------------------------------------------------------------------------
- Author : Grum
- email : grum@grum.dnsalias.com
- website : http://photos.grum.dnsalias.com
- PWG user : http://forum.phpwebgallery.net/profile.php?id=3706
-
- << May the Little SpaceFrog be with you ! >>
- ------------------------------------------------------------------------------
-
- this classes provides base functions to manage the public gallery menu
-
- ** The Section class **
- This class allows you to easily make a section block for the menu
- Public methods
- get_id()
- get_name()
- get_template()
- get_position()
- get_tag()
- get_items()
- set_name($value)
- set_template($value)
- set_tag($value)
- set_items($value)
- items_count()
- get()
- Constructor
- $id : section's id have to be unique in the menu
- $name : section's name is displayed on the menu
- $template : name of smarty template file ; if file doesn't exist, use of the
- generic template
- $tag : a facultative data ; use it as you want !
- $items : items of the menu : no specfic structure because it depends of
- the template model
-
- ** The Menu class **
- This class allows to easily manage the menu
- Public methods
- add($section_datas)
- remove($id)
- replace($section_datas)
- clear()
- section($id)
- sections()
- ids()
- count()
- register($id, $name, $position, $owner)
- register_position($id, $position)
- unregister($id)
- registered()
- apply()
- get_registered_filename()
-
- How to use Menu class :
- 1/ create an instance
- $menu = new Menu();
- instance have to be created by piwigo, plugin have to use of a global
- variable
-
- 2/ register your menu section
- register a section allows to know sections even if $menu is not loaded
- register a section allows to manage position into menu
- register function only reference some information about section, it does
- not create the section of menu (an only registered section is not
- displayed in menu)
- best place to register a section : when plugin is activated
- when deactivate plugin, unregister the section
-
- 3/ add section to menu
- add a section allows to really create section into menu
-
-
-
-
- ------------------------------------------------------------------------------
- :: HISTORY
-
- 1.0.0 - 2008-07-25
- first lines of code...
-
- --------------------------------------------------------------------------- */
-
-// theses constant ave to be adapted for a piwigo's integration
-define('MENU_TEMPLATES_DIR' , dirname(__FILE__));
-define('MENU_TEMPLATES_PATH' , MENU_TEMPLATES_DIR . '/menu_templates/');
-define('MENU_REGISTERED_PATH' ,
- PHPWG_PLUGINS_PATH . basename(dirname(__FILE__)) . '/');
-
-
-class Menu
-{
- protected $sections=array(); //array key is unique ID of sections
- protected $registered_sections=array();
- protected $registered_file="registered.dat";
-
- public function Menu($registered_path='')
- {
- if($registered_path!='')
- {
- $this->registered_file=$registered_path.$this->registered_file;
- }
- $this->load_registered();
- }
-
- /*
- public functions
- */
- public function get_registered_filename()
- {
- // return filename of file for maintain of registered sections
- return($this->registered_file);
- }
-
- public function add($section_datas)
- {
- // add a section to the menu ; datas can be made with the Section class
- if($this->section_is_valid($section_datas) and
- !isset($this->sections[$section_datas['ID']]) )
- {
- $this->sections[$section_datas['ID']]=$section_datas;
-
- if(isset($this->registered_sections[$section_datas['ID']]))
- {
- $this->sections[$section_datas['ID']]['POSITION']=$this->registered_sections[$section_datas['ID']]['POSITION'];
- }
- else
- {
- $this->sections[$section_datas['ID']]['POSITION']=0;
- }
- return(true);
- }
- return(false);
- }
-
- public function remove($id)
- {
- // remove a section from the menu
- unset($this->sections[$id]);
- }
-
- public function replace($section_datas)
- {
- // replace an existing section description by another one
- if($this->section_is_valid($section_datas) and
- isset($this->sections[$section_datas['ID']]) )
- {
- $this->sections[$section_datas['ID']]=$section_datas;
- return(true);
- }
- return(false);
- }
-
- public function clear()
- {
- // clear all sections of the menu
- $this->sections=array();
- }
-
- public function section($id)
- {
- //return a section structure or false if requested ID not exists
- if(isset($this->sections[$id]))
- {
- return($this->sections[$id]);
- }
- return(false);
- }
-
- public function sections()
- {
- //return all sections
- return($this->sections);
- }
-
- public function ids()
- {
- //return all section's ids
- return(array_keys($this->sections));
- }
-
- public function count()
- {
- //return number of sections
- return(count($this->sections));
- }
-
- public function register($id, $name, $position, $owner)
- {
- /*
- register section for menu ; register a section allows to know sections list
- even if menu is not made (ie: we are in admin interface)
-
- register a section is not adding a section : it's just for making a list of
- potential sections.
- you can add in the menu a section who is not registered
-
- $id : section id
- $name : name of section
- $position : position of section
- $owner : owner of section (piwigo or plugin's name)
- */
- if(!isset($this->registered_sections[$id]))
- {
- if($position<1)
- {
- $position=1;
- }
- $this->registered_sections[$id]=array(
- 'NAME' => $name,
- 'POSITION'=>$position,
- 'OWNER' => $owner
- );
- $this->register_position($id, $position);
- //$this->save_registered(); ==> made with register_position
- return(true);
- }
- return(false);
- }
-
- public function unregister($id)
- {
- // just unregister a section from menu
- if(isset($this->registered_sections[$id]))
- {
- unset($this->registered_sections[$id]);
- $this->registered_sections=$this->renum_position($this->registered_sections);
- $this->save_registered();
- return(true);
- }
- return(false);
- }
-
- public function register_position($id, $position)
- {
- // register a new position for section
- // if a section already have the same position, all section are shifted
-
- // sort registered sections by position
- $this->sort_registered();
- //preparing sections
- $incpos=false;
- foreach($this->registered_sections as $key => $val)
- {
- if(($val['POSITION']==$position)and($key!=$id))
- {
- $incpos=true;
- }
- if(($incpos)and($key!=$id))
- {
- $this->registered_sections[$key]['POSITION']++;
- }
- }
- //affect new position
- $this->registered_sections[$id]['POSITION']=$position;
- //sort
- $this->sort_registered();
- //renum positions
- $this->registered_sections=$this->renum_position($this->registered_sections);
- $this->save_registered();
- }
-
- public function registered()
- {
- // return list of registered sections
- return($this->registered_sections);
- }
-
- public function apply()
- {
- //apply datas on the template
- global $template;
-
- $template->set_filenames(
- array('menubar' => MENU_TEMPLATES_PATH.'menubar_main.tpl')
- );
-
- trigger_action('loc_begin_menubar');
- $this->sort();
- $template->assign('sections', $this->sections);
- trigger_action('loc_end_menubar');
-
- $template->assign_var_from_handle('MENUBAR', 'menubar');
- }
-
- /*
- protected functions
- */
- protected function section_is_valid($section_datas)
- {
- if(is_array($section_datas) and
- isset($section_datas['ID']) and
- isset($section_datas['NAME']) and
- isset($section_datas['TEMPLATE']) and
- isset($section_datas['ITEMS']) and
- isset($section_datas['TAG']))
- {
- return(true);
- }
- return(false);
- }
-
- protected function load_registered()
- {
- //load registered sections : database or file ??
- $this->registered_sections=array();
-
- $filename=MENU_REGISTERED_PATH.$this->registered_file;
-
- if(file_exists($filename))
- {
- $fhandle=fopen($filename, "r");
- if($fhandle)
- {
- $datas=fread($fhandle, filesize($filename));
- fclose($fhandle);
- $this->registered_sections=unserialize($datas);
- return(true);
- }
- }
- return(false);
- }
-
- protected function save_registered()
- {
- //save registered sections : database or file ??
- $filename=MENU_REGISTERED_PATH.$this->registered_file;
-
- $fhandle=fopen($filename, "w");
- if($fhandle)
- {
- $written=fwrite($fhandle, serialize($this->registered_sections));
- fclose($fhandle);
- return($written);
- }
- return(false);
- }
-
-
- protected function sort()
- {
- $tmp=$this->sections;
- uksort($tmp, array(&$this, 'sort_sections_cmpfct'));
- $this->sections=$tmp;
- }
-
- protected function sort_registered()
- {
- $tmp=$this->registered_sections;
- uksort($tmp, array(&$this, 'sort_registered_cmpfct'));
- $this->registered_sections=$tmp;
- }
-
-
- private function sort_sections_cmpfct($a, $b)
- {
- if($this->sections[$a]['POSITION']==$this->sections[$b]['POSITION'])
- {
- return(($this->sections[$a]['ID']<$this->sections[$b]['ID'])?-1:1);
- }
- return(($this->sections[$a]['POSITION']<$this->sections[$b]['POSITION'])?-1:1);
- }
-
- private function sort_registered_cmpfct($a, $b)
- {
- return(($this->registered_sections[$a]['POSITION']<$this->registered_sections[$b]['POSITION'])?-1:1);
- }
-
- private function renum_position($datas)
- {
- $i=1;
- foreach($datas as $key => $val)
- {
- $datas[$key]['POSITION']=$i;
- $i+=1;
- }
- return($datas);
- }
-
-
-
-
-} // class Menu
-
-
-
-
-
-class Section
-{
- protected $name;
- protected $template="generic.tpl";
- protected $id;
- protected $tag;
- protected $items=array();
-
- public function Section($id, $name, $template="", $tag="")
- {
- $this->id = $id;
- $this->tag = $tag;
- $this->set_name($name);
- if(!$this->set_template($template))
- {
- $this->template=MENU_TEMPLATES_PATH."generic.tpl";
- }
-
- } // constructor
-
- /*
- public functions
- */
- public function get()
- {
- //this method returns a data structure ready to be used with the Menu class
- return(
- array(
- 'ID' => $this->id,
- 'NAME' => $this->name,
- 'TEMPLATE' => $this->template,
- 'ITEMS' => $this->items,
- 'TAG' => $this->tag
- )
- );
- }
-
- public function get_id()
- {
- return($this->id);
- }
-
- public function get_name()
- {
- return($this->name);
- }
-
- public function get_template()
- {
- return($this->template);
- }
-
- public function get_tag()
- {
- return($this->tag);
- }
-
- public function get_items()
- {
- return($this->items);
- }
-
- public function set_name($value)
- {
- $this->name=$value;
- }
-
- public function set_template($value)
- {
- if($this->is_template($value))
- {
- $this->template=$value;
- return(true);
- }
- return(false);
- }
-
- public function set_tag($value)
- {
- $this->tag=$value;
- }
-
- public function set_items($value)
- {
- $this->items=$value;
- }
-
- public function items_count()
- {
- if(is_array($this->items))
- {
- return(count($this->items));
- }
- else
- {
- return(-1);
- }
- }
-
- /*
- protected functions
- */
- protected function is_template($templatename)
- {
- if(file_exists($templatename) and (preg_match('/.+\.tpl$/i',$templatename)))
- {
- return(true);
- }
- return(false);
- } // is_template
-
-} //class Section
-
-
-
-
-?> \ No newline at end of file
diff --git a/plugins/test_menu/menu_templates/menubar_categories.tpl b/plugins/test_menu/menu_templates/menubar_categories.tpl
deleted file mode 100644
index 050f503c3..000000000
--- a/plugins/test_menu/menu_templates/menubar_categories.tpl
+++ /dev/null
@@ -1,24 +0,0 @@
-
-<!-- categories menu bar -->
-
-<dt>
- {if isset($section.ITEMS.U_START_FILTER)}
- <a href="{$section.ITEMS.U_START_FILTER}" title="{'start_filter_hint'|@translate}" rel="nofollow"><img src="{$ROOT_URL}{$themeconf.icon_dir}/start_filter.png" class="button" alt="start filter"></a>
- {/if}
- {if isset($section.ITEMS.U_STOP_FILTER)}
- <a href="{$section.ITEMS.U_STOP_FILTER}" title="{'stop_filter_hint'|@translate}"><img src="{$ROOT_URL}{$themeconf.icon_dir}/stop_filter.png" class="button" alt="stop filter"></a>
- {/if}
-
- <a href="{$section.ITEMS.U_CATEGORIES}">{$section.NAME|@translate}</a>
-</dt>
-<dd>
- {$section.ITEMS.MENU_CATEGORIES_CONTENT}
- {if isset($section.ITEMS.U_UPLOAD)}
- <ul>
- <li>
- <a href="{$section.ITEMS.U_UPLOAD}">{'upload_picture'|@translate}</a>
- </li>
- </ul>
- {/if}
- <p class="totalImages">{$pwg->l10n_dec('%d element', '%d elements', $section.ITEMS.NB_PICTURE)}</p>
-</dd>
diff --git a/plugins/test_menu/menu_templates/menubar_generic.tpl b/plugins/test_menu/menu_templates/menubar_generic.tpl
deleted file mode 100644
index e9991c280..000000000
--- a/plugins/test_menu/menu_templates/menubar_generic.tpl
+++ /dev/null
@@ -1,10 +0,0 @@
-
-<!-- generic menu bar -->
-<dt>{$section.NAME|@translate}</dt>
-<dd>
- <ul>
- {foreach from=$section.ITEMS item=item}
- <li><a href="{$item.URL}" title="{$item.TITLE}">{$item.NAME}</a></li>
- {/foreach}
- </ul>
-</dd>
diff --git a/plugins/test_menu/menu_templates/menubar_identification.tpl b/plugins/test_menu/menu_templates/menubar_identification.tpl
deleted file mode 100644
index c0c3891fe..000000000
--- a/plugins/test_menu/menu_templates/menubar_identification.tpl
+++ /dev/null
@@ -1,67 +0,0 @@
-
-<!-- identification menu bar -->
-<dt>{$section.NAME|@translate}</dt>
-<dd>
- {if isset($section.ITEMS.USERNAME)}
- <p>{'hello'|@translate}&nbsp;{$section.ITEMS.USERNAME}&nbsp;!</p>
- {/if}
-
-<ul>
- {if isset($section.ITEMS.U_REGISTER)}
- <li><a href="{$section.ITEMS.U_REGISTER}" title="{'Create a new account'|@translate}" rel="nofollow">{'Register'|@translate}</a></li>
- {/if}
-
- {if isset($section.ITEMS.U_IDENTIFY)}
- <li><a href="{$section.ITEMS.U_IDENTIFY}" rel="nofollow">{'Connection'|@translate}</a></li>
- {/if}
-
- {if isset($section.ITEMS.U_LOGOUT)}
- <li><a href="{$section.ITEMS.U_LOGOUT}">{'logout'|@translate}</a></li>
- {/if}
-
- {if isset($section.ITEMS.U_PROFILE)}
- <li><a href="{$section.ITEMS.U_PROFILE}" title="{'hint_customize'|@translate}">{'customize'|@translate}</a></li>
- {/if}
-
- {if isset($section.ITEMS.U_ADMIN)}
- <li><a href="{$section.ITEMS.U_ADMIN}" title="{'hint_admin'|@translate}">{'admin'|@translate}</a></li>
- {/if}
-</ul>
-
-{if isset($section.ITEMS.U_IDENTIFY)}
-<form method="post" action="{$section.ITEMS.U_IDENTIFY}" class="filter" id="quickconnect">
-<fieldset>
- <legend>{'Quick connect'|@translate}</legend>
-
- <label>
- {'Username'|@translate}
- <input type="text" name="username" size="15" value="" id="iusername">
- </label>
-
- <label>
- {'Password'|@translate}
- <input type="password" name="password" size="15" id="ipassword">
- </label>
-
- {if $section.ITEMS.AUTHORIZE_REMEMBERING}
- <label>
- {'remember_me'|@translate}
- <input type="checkbox" name="remember_me" value="1" id="iremember_me">
- </label>
- {/if}
- <p>
- <input class="submit" type="submit" name="login" value="{'Submit'|@translate}">
- </p>
-
- <ul class="actions">
- <li><a href="{$section.ITEMS.U_LOST_PASSWORD}" title="{'Forgot your password?'|@translate}" rel="nofollow"><img src="{$ROOT_URL}{$themeconf.icon_dir}/lost_password.png" class="button" alt="{'Forgot your password?'|@translate}"></a></li>
- {if isset($section.ITEMS.U_REGISTER)}
- <li><a href="{$section.ITEMS.U_REGISTER}" title="{'Create a new account'|@translate}" rel="nofollow"><img src="{$ROOT_URL}{$themeconf.icon_dir}/register.png" class="button" alt="{'Register'|@translate}"/></a></li>
- {/if}
- </ul>
-
-</fieldset>
-</form>
- {/if}
-
-</dd>
diff --git a/plugins/test_menu/menu_templates/menubar_links.tpl b/plugins/test_menu/menu_templates/menubar_links.tpl
deleted file mode 100644
index 87862f1d6..000000000
--- a/plugins/test_menu/menu_templates/menubar_links.tpl
+++ /dev/null
@@ -1,17 +0,0 @@
-
-<!-- links menu bar -->
-
-<dt>{$section.NAME|@translate}</dt>
-<dd>
- <ul>
- {foreach from=$section.ITEMS item=link}
- <li>
- <a href="{$link.URL}"
- {if isset($link.new_window) }onclick="window.open(this.href, '{$link.new_window.NAME|@escape:'javascript'}','{$link.new_window.FEATURES|@escape:'javascript'}'); return false;"{/if}
- >
- {$link.LABEL}
- </a>
- </li>
- {/foreach}
- </ul>
-</dd> \ No newline at end of file
diff --git a/plugins/test_menu/menu_templates/menubar_main.tpl b/plugins/test_menu/menu_templates/menubar_main.tpl
deleted file mode 100644
index 82d7cb208..000000000
--- a/plugins/test_menu/menu_templates/menubar_main.tpl
+++ /dev/null
@@ -1,15 +0,0 @@
-
-<!-- main menu bar -->
-
-{if isset($sections) and count($sections)}
- <div id="menubar">
- {foreach from=$sections key=name item=section}
- {if not(empty($section.ITEMS))}
- <dl id="{$section.ID}">
-
- {include file=$section.TEMPLATE section=$section}
- </dl>
- {/if}
- {/foreach}
- </div>
-{/if} \ No newline at end of file
diff --git a/plugins/test_menu/menu_templates/menubar_menu.tpl b/plugins/test_menu/menu_templates/menubar_menu.tpl
deleted file mode 100644
index 7b80881ed..000000000
--- a/plugins/test_menu/menu_templates/menubar_menu.tpl
+++ /dev/null
@@ -1,21 +0,0 @@
-
-<!-- menu menu bar -->
-<dt>{$section.NAME|@translate}</dt>
-<dd>
- {if isset($section.ITEMS.qsearch) and $section.ITEMS.qsearch=='y'}
- <form action="{$ROOT_URL}qsearch.php" method="get" id="quicksearch">
- <p>
- <input type="text" name="q" id="qsearchInput" onfocus="if (value==qsearch_prompt) value='';" onblur="if (value=='') value=qsearch_prompt;" />
- </p>
- </form>
- <script type="text/javascript">var qsearch_prompt="{'qsearch'|@translate|@escape:'javascript'}"; document.getElementById('qsearchInput').value=qsearch_prompt;</script>
- {/if}
-
- <ul>
- {foreach from=$section.ITEMS item=sum}
- {if is_array($sum)}
- <li><a href="{$sum.U_SUMMARY}" title="{$sum.TITLE}" {if isset($sum.REL)}{$sum.REL}{/if}>{$sum.NAME}</a></li>
- {/if}
- {/foreach}
- </ul>
-</dd>
diff --git a/plugins/test_menu/menu_templates/menubar_special.tpl b/plugins/test_menu/menu_templates/menubar_special.tpl
deleted file mode 100644
index 0bc9588ee..000000000
--- a/plugins/test_menu/menu_templates/menubar_special.tpl
+++ /dev/null
@@ -1,10 +0,0 @@
-
-<!-- special menu bar -->
-<dt>{$section.NAME|@translate}</dt>
-<dd>
- <ul>
- {foreach from=$section.ITEMS item=cat}
- <li><a href="{$cat.URL}" title="{$cat.TITLE}" {if isset($cat.REL)}{$cat.REL}{/if}>{$cat.NAME}</a></li>
- {/foreach}
- </ul>
-</dd>
diff --git a/plugins/test_menu/menu_templates/menubar_tags.tpl b/plugins/test_menu/menu_templates/menubar_tags.tpl
deleted file mode 100644
index b0fd9cf04..000000000
--- a/plugins/test_menu/menu_templates/menubar_tags.tpl
+++ /dev/null
@@ -1,19 +0,0 @@
-
-<!-- tags menu bar -->
-<dt>{$section.NAME|@translate}</dt>
-<dd>
- <ul id="menuTagCloud">
- {foreach from=$section.ITEMS item=tag}
- <li>
- {if !empty($tag.U_ADD) }
- <a href="{$tag.U_ADD}"
- title="{$pwg->l10n_dec('%d element are also linked to current tags', '%d elements are also linked to current tags', $tag.counter)}"
- rel="nofollow">
- <img src="{$ROOT_URL}{$themeconf.icon_dir}/add_tag.png" alt="+" />
- </a>
- {/if}
- <a href="{$tag.URL}" class="tagLevel{$tag.level}" title="{'See elements linked to this tag only'|@translate}">{$tag.name}</a>
- </li>
- {/foreach}
- </ul>
-</dd>
diff --git a/plugins/test_menu/menubar.inc.php b/plugins/test_menu/menubar.inc.php
deleted file mode 100644
index 45da0dc13..000000000
--- a/plugins/test_menu/menubar.inc.php
+++ /dev/null
@@ -1,320 +0,0 @@
-<?php
-/*
- to use Menu class in piwigo, just replace the original menubar.inc.php file by
- this one
-*/
-
-
-$datas=array();
-
-//-------------------------------------------------------------- categories
-$datas['categories']=array(
- 'NB_PICTURE' => $user['nb_total_images'],
- 'MENU_CATEGORIES_CONTENT' => get_categories_menu(),
- 'U_CATEGORIES' => make_index_url(array('section' => 'categories')),
- 'U_UPLOAD' => get_upload_menu_link()
-);
-
-//------------------------------------------------------------------------ filter
-if (!empty($conf['filter_pages']) and get_filter_page_value('used'))
-{
- if ($filter['enabled'])
- {
- $datas['categories']['U_STOP_FILTER']=
- add_url_params(make_index_url(array()), array('filter' => 'stop'));
- }
- else
- {
- $datas['categories']['U_START_FILTER']=
- add_url_params(make_index_url(array()), array('filter' => 'start-recent-'.$user['recent_period']));
- }
-}
-
-
-
-//-------------------------------------------------------------- external links
-$datas['links']=array();
-foreach ($conf['links'] as $url => $url_data)
-{
- if (!is_array($url_data))
- {
- $url_data = array('label' => $url_data);
- }
-
- if
- (
- (!isset($url_data['eval_visible']))
- or
- (eval($url_data['eval_visible']))
- )
- {
- $tpl_var = array(
- 'URL' => $url,
- 'LABEL' => $url_data['label']
- );
-
- if (!isset($url_data['new_window']) or $url_data['new_window'])
- {
- $tpl_var['new_window'] =
- array(
- 'NAME' => (isset($url_data['nw_name']) ? $url_data['nw_name'] : ''),
- 'FEATURES' => (isset($url_data['nw_features']) ? $url_data['nw_features'] : '')
- );
- }
- $datas['links'][]=$tpl_var;
- }
-}
-
-
-
-
-
-//------------------------------------------------------------------------ tags
-$datas['tags']=array();
-if ('tags' == @$page['section'])
-{
- // display tags associated to currently tagged items, less current tags
- $tags = array();
- if ( !empty($page['items']) )
- {
- $tags = get_common_tags($page['items'],
- $conf['menubar_tag_cloud_items_number'], $page['tag_ids']);
- }
-
- $tags = add_level_to_tags($tags);
-
- foreach ($tags as $tag)
- {
- $datas['tags'][]=
- array_merge( $tag,
- array(
- 'URL' => make_index_url(
- array(
- 'tags' => array($tag)
- )
- ),
-
- 'U_ADD' => make_index_url(
- array(
- 'tags' => array_merge(
- $page['tags'],
- array($tag)
- )
- )
- ),
- )
- );
- }
-}
-
-
-
-//---------------------------------------------------------- special categories
-/*
- ** note for usage with Menu class **
- items of Special section are defined with a named key rather than a
- numeric key
-
- Example :
- $datas['special']=array(
- 'favorite_cat' => array( ... ),
- 'most_visited_cat' => array( ... ),
- 'best_rated_cat' => array( ... ),
- [...]
- );
-
- This permits to easily find datas and modify content with a callback on the
- 'loc_begin_menubar' event.
-
- Example :
- $section_special=$menu->section('mbSpecial');
- unset($section['ITEMS']['favorite_cat']);
- $menu->replace($section_special);
-
- this code permit to remove the items "favorite_cat" from the
- section "mbSpecial"
-*/
-$datas['special']=array();
-if ( !is_a_guest() )
-{
- $datas['special']['favorite_cat']=array(
- 'URL' => make_index_url(array('section' => 'favorites')),
- 'TITLE' => l10n('favorite_cat_hint'),
- 'NAME' => l10n('favorite_cat')
- );
-}
-// most visited
- $datas['special']['most_visited_cat']=array(
- 'URL' => make_index_url(array('section' => 'most_visited')),
- 'TITLE' => l10n('most_visited_cat_hint'),
- 'NAME' => l10n('most_visited_cat')
- );
-// best rated
-if ($conf['rate'])
-{
- $datas['special']['best_rated_cat']=array(
- 'URL' => make_index_url(array('section' => 'best_rated')),
- 'TITLE' => l10n('best_rated_cat_hint'),
- 'NAME' => l10n('best_rated_cat')
- );
-}
-// random
- $datas['special']['random_cat']=array(
- 'URL' => get_root_url().'random.php',
- 'TITLE' => l10n('random_cat_hint'),
- 'NAME' => l10n('random_cat'),
- 'REL'=> 'rel="nofollow"'
- );
-
-// recent pics
- $datas['special']['recent_pics_cat']=array(
- 'URL' => make_index_url(array('section' => 'recent_pics')),
- 'TITLE' => l10n('recent_pics_cat_hint'),
- 'NAME' => l10n('recent_pics_cat'),
- );
-// recent cats
- $datas['special']['recent_cats_cat']=array(
- 'URL' => make_index_url(array('section' => 'recent_cats')),
- 'TITLE' => l10n('recent_cats_cat_hint'),
- 'NAME' => l10n('recent_cats_cat'),
- );
-
-// calendar
- $datas['special']['calendar']=array(
- 'URL' =>
- make_index_url(
- array(
- 'chronology_field' => ($conf['calendar_datefield']=='date_available'
- ? 'posted' : 'created'),
- 'chronology_style'=> 'monthly',
- 'chronology_view' => 'calendar'
- )
- ),
- 'TITLE' => l10n('calendar_hint'),
- 'NAME' => l10n('calendar'),
- 'REL'=> 'rel="nofollow"'
- );
-
-
-
-//--------------------------------------------------------------- identification
-$datas['identification']=array();
-if (is_a_guest())
-{
- $datas['identification']=array(
- 'U_IDENTIFY' => get_root_url().'identification.php',
- 'AUTHORIZE_REMEMBERING' => $conf['authorize_remembering'],
- 'U_LOST_PASSWORD' => get_root_url().'password.php',
- );
-
- if ($conf['allow_user_registration'])
- {
- $datas['identification']['U_REGISTER']=get_root_url().'register.php';
- }
-}
-else
-{
- $datas['identification']['USERNAME']= $user['username'];
-
- if (is_autorize_status(ACCESS_CLASSIC))
- {
- $datas['identification']['U_PROFILE']=get_root_url().'profile.php';
- }
-
- // the logout link has no meaning with Apache authentication : it is not
- // possible to logout with this kind of authentication.
- if (!$conf['apache_authentication'])
- {
- $datas['identification']['U_LOGOUT']= get_root_url().'?act=logout';
- }
-
- if (is_admin())
- {
- $datas['identification']['U_ADMIN']= get_root_url().'admin.php';
- }
-}
-
-
-//--------------------------------------------------------------- menu summaries
-/*
- ** note for usage with Menu class **
- items of menu section are defined with a named key rather than a numeric key
-
- see notes from "sepcial categories" for more informations
-*/
-$datas['menu']=array();
-//qsearch input zone visible y/n ; if set to 'n' the qsearch zone isn't visible
-$datas['menu']['qsearch']='y';
-
-// tags link
-$datas['menu']['Tags']=array(
- 'TITLE' => l10n('See available tags'),
- 'NAME' => l10n('Tags'),
- 'U_SUMMARY'=> get_root_url().'tags.php',
- );
-
-// search link
-$datas['menu']['Search']=array(
- 'TITLE'=>l10n('hint_search'),
- 'NAME'=>l10n('Search'),
- 'U_SUMMARY'=> get_root_url().'search.php',
- 'REL'=> 'rel="search"'
- );
-
-// comments link
-$datas['menu']['comments']=array(
- 'TITLE'=>l10n('hint_comments'),
- 'NAME'=>l10n('comments'),
- 'U_SUMMARY'=> get_root_url().'comments.php',
- );
-
-// about link
-$datas['menu']['About']=array(
- 'TITLE' => l10n('about_page_title'),
- 'NAME' => l10n('About'),
- 'U_SUMMARY' => get_root_url().'about.php',
- );
-
-// notification
-$datas['menu']['Notification']=array(
- 'TITLE'=>l10n('RSS feed'),
- 'NAME'=>l10n('Notification'),
- 'U_SUMMARY'=> get_root_url().'notification.php',
- 'REL'=> 'rel="nofollow"'
- );
-
-
-
-
-$section = new Section('mbLinks', 'Links', MENU_TEMPLATES_PATH.'menubar_links.tpl');
-$section->set_items($datas['links']);
-$menu->add($section->get());
-
-
-$section = new Section('mbTags', 'Related tags', MENU_TEMPLATES_PATH.'menubar_tags.tpl');
-$section->set_items($datas['tags']);
-$menu->add($section->get());
-
-$section = new Section('mbSpecial', 'special_categories', MENU_TEMPLATES_PATH.'menubar_special.tpl');
-$section->set_items($datas['special']);
-$menu->add($section->get());
-
-$section = new Section('mbMenu', 'title_menu', MENU_TEMPLATES_PATH.'menubar_menu.tpl');
-$section->set_items($datas['menu']);
-$menu->add($section->get());
-
-$section = new Section('mbIdentification', 'identification', MENU_TEMPLATES_PATH.'menubar_identification.tpl');
-$section->set_items($datas['identification']);
-$menu->add($section->get());
-
-$section = new Section('mbCategories', 'Categories', MENU_TEMPLATES_PATH.'menubar_categories.tpl');
-$section->set_items($datas['categories']);
-$menu->add($section->get());
-
-
-$menu->apply();
-
-
-
-
-?>
diff --git a/template/yoga/menubar.tpl b/template/yoga/menubar.tpl
index 4dcb6bb45..73259376e 100644
--- a/template/yoga/menubar.tpl
+++ b/template/yoga/menubar.tpl
@@ -1,164 +1,15 @@
-{* $Id$ *}
-
+{if !empty($blocks) }
<div id="menubar">
-{if not empty($links)}
-<dl id="mbLinks">
- <dt>{'Links'|@translate}</dt>
- <dd>
- <ul>
- {foreach from=$links item=link}
- <li>
- <a href="{$link.URL}"
- {if isset($link.new_window) }onclick="window.open(this.href, '{$link.new_window.NAME|@escape:'javascript'}','{$link.new_window.FEATURES|@escape:'javascript'}'); return false;"{/if}
- >
- {$link.LABEL}
- </a>
- </li>
- {/foreach}{*links*}
- </ul>
- </dd>
-</dl>
-{/if}{*links*}
-
- {if isset($U_START_FILTER)}
- <a href="{$U_START_FILTER}" title="{'start_filter_hint'|@translate}" rel="nofollow"><img src="{$ROOT_URL}{$themeconf.icon_dir}/start_filter.png" class="button" alt="start filter"></a>
- {/if}
- {if isset($U_STOP_FILTER)}
- <a href="{$U_STOP_FILTER}" title="{'stop_filter_hint'|@translate}"><img src="{$ROOT_URL}{$themeconf.icon_dir}/stop_filter.png" class="button" alt="stop filter"></a>
- {/if}
-
-<dl id="mbCategories">
- <dt><a href="{$U_CATEGORIES}">{'Categories'|@translate}</a></dt>
- <dd>
- {$MENU_CATEGORIES_CONTENT}
- {if isset($U_UPLOAD)}
- <ul><li>
- <a href="{$U_UPLOAD}">{'upload_picture'|@translate}</a>
- </li></ul>
- {/if}
- <p class="totalImages">{$pwg->l10n_dec('%d element', '%d elements', $NB_PICTURE)}</p>
- </dd>
-</dl>
-
-
-{if not empty($related_tags)}
-<dl id="mbTags">
- <dt>{'Related tags'|@translate}</dt>
- <dd>
- <ul id="menuTagCloud">
- {foreach from=$related_tags item=tag}
- <li>
- {if !empty($tag.U_ADD) }
- <a href="{$tag.U_ADD}"
- title="{$pwg->l10n_dec('%d element are also linked to current tags', '%d elements are also linked to current tags', $tag.counter)}"
- rel="nofollow">
- <img src="{$ROOT_URL}{$themeconf.icon_dir}/add_tag.png" alt="+" />
- </a>
- {/if}
- <a href="{$tag.URL}" class="tagLevel{$tag.level}" title="{'See elements linked to this tag only'|@translate}">{$tag.name}</a>
- </li>
- {/foreach}
- </ul>
- </dd>
-</dl>
-{/if}
-
-
-<dl id="mbSpecial">
- <dt>{'special_categories'|@translate}</dt>
- <dd>
- <ul>
- {foreach from=$special_categories item=cat}
- <li><a href="{$cat.URL}" title="{$cat.TITLE}" {if isset($cat.REL)}{$cat.REL}{/if}>{$cat.NAME}</a></li>
- {/foreach}
- </ul>
- </dd>
-</dl>
-
-
-<dl id="mbMenu">
- <dt>{'title_menu'|@translate}</dt>
- <dd>
- <form action="{$ROOT_URL}qsearch.php" method="get" id="quicksearch">
- <p style="margin:0;padding:0"> {*this <p> is for html validation only - does not affect positioning*}
- <input type="text" name="q" id="qsearchInput" onfocus="if (value==qsearch_prompt) value='';" onblur="if (value=='') value=qsearch_prompt;" style="width:90%"/>
- </p>
- </form>
- <script type="text/javascript">var qsearch_prompt="{'qsearch'|@translate|@escape:'javascript'}"; document.getElementById('qsearchInput').value=qsearch_prompt;</script>
-
- <ul>
- {foreach from=$summaries item=sum}
- <li><a href="{$sum.U_SUMMARY}" title="{$sum.TITLE}" {if isset($sum.REL)}{$sum.REL}{/if}>{$sum.NAME}</a></li>
- {/foreach}
- </ul>
- </dd>
-</dl>
-
-
-<dl id="mbIdentification">
- <dt>{'identification'|@translate}</dt>
- <dd>
- {if isset($USERNAME)}
- <p>{'hello'|@translate}&nbsp;{$USERNAME}&nbsp;!</p>
- {/if}
-
- <ul>
- {if isset($U_REGISTER)}
- <li><a href="{$U_REGISTER}" title="{'Create a new account'|@translate}" rel="nofollow">{'Register'|@translate}</a></li>
- {/if}
-
- {if isset($U_IDENTIFY)}
- <li><a href="{$U_IDENTIFY}" rel="nofollow">{'Connection'|@translate}</a></li>
- {/if}
-
- {if isset($U_LOGOUT)}
- <li><a href="{$U_LOGOUT}">{'logout'|@translate}</a></li>
- {/if}
-
- {if isset($U_PROFILE)}
- <li><a href="{$U_PROFILE}" title="{'hint_customize'|@translate}">{'customize'|@translate}</a></li>
- {/if}
-
- {if isset($U_ADMIN)}
- <li><a href="{$U_ADMIN}" title="{'hint_admin'|@translate}">{'admin'|@translate}</a></li>
- {/if}
- </ul>
-
- {if isset($U_IDENTIFY)}
- <form method="post" action="{$U_IDENTIFY}" id="quickconnect">
- <fieldset>
- <legend>{'Quick connect'|@translate}</legend>
- <div>
- <label for="username">{'Username'|@translate}</label><br/>
- <input type="text" name="username" id="username" value="" style="width:99%">
- </div>
-
- <div><label for="password">{'Password'|@translate}</label>
- <br/>
- <input type="password" name="password" id="password" style="width:99%">
- </div>
-
- {if $AUTHORIZE_REMEMBERING}
- <div><label>
- {'remember_me'|@translate}
- <input type="checkbox" name="remember_me" value="1">
- </label></div>
+ {foreach from=$blocks key=id item=block}
+ {if ( not empty($block->template) or not empty($block->raw_content) )}
+ <dl id="{$id}">
+ {if not empty($block->template)}
+ {include file=$block->template }
+ {else}
+ {$block->raw_content|@default}
{/if}
-
- <div>
- <ul class="actions">
- <li><a href="{$U_LOST_PASSWORD}" title="{'Forgot your password?'|@translate}" rel="nofollow"><img src="{$ROOT_URL}{$themeconf.icon_dir}/lost_password.png" class="button" alt="{'Forgot your password?'|@translate}"></a></li>
- {if isset($U_REGISTER)}
- <li><a href="{$U_REGISTER}" title="{'Create a new account'|@translate}" rel="nofollow"><img src="{$ROOT_URL}{$themeconf.icon_dir}/register.png" class="button" alt="{'Register'|@translate}"/></a></li>
- {/if}
- </ul>
- <input class="submit" type="submit" name="login" value="{'Submit'|@translate}">
- </div>
-
- </fieldset>
- </form>
- {/if}
-
- </dd>
-</dl>
-</div> <!-- menubar -->
+ </dl>
+ {/if}
+ {/foreach}
+</div>
+{/if} \ No newline at end of file
diff --git a/template/yoga/menubar_categories.tpl b/template/yoga/menubar_categories.tpl
new file mode 100644
index 000000000..eb09ec914
--- /dev/null
+++ b/template/yoga/menubar_categories.tpl
@@ -0,0 +1,22 @@
+{if isset($U_START_FILTER)}
+<a href="{$U_START_FILTER}" title="{'start_filter_hint'|@translate}" rel="nofollow"><img src="{$ROOT_URL}{$themeconf.icon_dir}/start_filter.png" class="button" alt="start filter"></a>
+{/if}
+{if isset($U_STOP_FILTER)}
+<a href="{$U_STOP_FILTER}" title="{'stop_filter_hint'|@translate}"><img src="{$ROOT_URL}{$themeconf.icon_dir}/stop_filter.png" class="button" alt="stop filter"></a>
+{/if}
+
+<dt>
+ <a href="{$block->data.U_CATEGORIES}">{'Categories'|@translate}</a>
+</dt>
+<dd>
+ {$block->data.MENU_CATEGORIES_CONTENT}
+ {if isset($block->data.U_UPLOAD)}
+ <ul>
+ <li>
+ <a href="{$block->data.U_UPLOAD}">{'upload_picture'|@translate}</a>
+ </li>
+ </ul>
+ {/if}
+ <p class="totalImages">{$pwg->l10n_dec('%d element', '%d elements', $block->data.NB_PICTURE)}</p>
+</dd>
+
diff --git a/template/yoga/menubar_identification.tpl b/template/yoga/menubar_identification.tpl
new file mode 100644
index 000000000..49d2732a9
--- /dev/null
+++ b/template/yoga/menubar_identification.tpl
@@ -0,0 +1,64 @@
+<dt>{$block->get_title()|@translate}</dt>
+<dd>
+ {if isset($USERNAME)}
+ <p>{'hello'|@translate}&nbsp;{$USERNAME}&nbsp;!</p>
+ {/if}
+
+ <ul>
+ {if isset($U_REGISTER)}
+ <li><a href="{$U_REGISTER}" title="{'Create a new account'|@translate}" rel="nofollow">{'Register'|@translate}</a></li>
+ {/if}
+
+ {if isset($U_LOGIN)}
+ <li><a href="{$U_LOGIN}" rel="nofollow">{'Connection'|@translate}</a></li>
+ {/if}
+
+ {if isset($U_LOGOUT)}
+ <li><a href="{$U_LOGOUT}">{'logout'|@translate}</a></li>
+ {/if}
+
+ {if isset($U_PROFILE)}
+ <li><a href="{$U_PROFILE}" title="{'hint_customize'|@translate}">{'customize'|@translate}</a></li>
+ {/if}
+
+ {if isset($U_ADMIN)}
+ <li><a href="{$U_ADMIN}" title="{'hint_admin'|@translate}">{'admin'|@translate}</a></li>
+ {/if}
+ </ul>
+
+ {if isset($U_LOGIN)}
+ <form method="post" action="{$U_LOGIN}" id="quickconnect">
+ <fieldset>
+ <legend>{'Quick connect'|@translate}</legend>
+ <div>
+ <label for="username">{'Username'|@translate}</label><br/>
+ <input type="text" name="username" id="username" value="" style="width:99%">
+ </div>
+
+ <div><label for="password">{'Password'|@translate}</label>
+ <br/>
+ <input type="password" name="password" id="password" style="width:99%">
+ </div>
+
+ {if $AUTHORIZE_REMEMBERING}
+ <div><label>
+ {'remember_me'|@translate}
+ <input type="checkbox" name="remember_me" value="1">
+ </label></div>
+ {/if}
+
+ <div>
+ <ul class="actions">
+ <li><a href="{$U_LOST_PASSWORD}" title="{'Forgot your password?'|@translate}" rel="nofollow"><img src="{$ROOT_URL}{$themeconf.icon_dir}/lost_password.png" class="button" alt="{'Forgot your password?'|@translate}"></a></li>
+ {if isset($U_REGISTER)}
+ <li><a href="{$U_REGISTER}" title="{'Create a new account'|@translate}" rel="nofollow"><img src="{$ROOT_URL}{$themeconf.icon_dir}/register.png" class="button" alt="{'Register'|@translate}"/></a></li>
+ {/if}
+ </ul>
+ <input class="submit" type="submit" name="login" value="{'Submit'|@translate}">
+ </div>
+
+ </fieldset>
+ </form>
+ {/if}
+</dd>
+
diff --git a/template/yoga/menubar_links.tpl b/template/yoga/menubar_links.tpl
new file mode 100644
index 000000000..9de94ff7d
--- /dev/null
+++ b/template/yoga/menubar_links.tpl
@@ -0,0 +1,15 @@
+<dt>{$block->get_title()|@translate}</dt>
+<dd>
+ <ul>
+ {foreach from=$block->data item=link}
+ <li>
+ <a href="{$link.URL}"
+ {if isset($link.new_window) }onclick="window.open(this.href, '{$link.new_window.NAME|@escape:'javascript'}','{$link.new_window.FEATURES|@escape:'javascript'}'); return false;"{/if}
+ >
+ {$link.LABEL}
+ </a>
+ </li>
+ {/foreach}
+ </ul>
+</dd>
+
diff --git a/template/yoga/menubar_menu.tpl b/template/yoga/menubar_menu.tpl
new file mode 100644
index 000000000..b9d26376b
--- /dev/null
+++ b/template/yoga/menubar_menu.tpl
@@ -0,0 +1,18 @@
+<dt>{$block->get_title()|@translate}</dt>
+<dd>
+ <form action="{$ROOT_URL}qsearch.php" method="get" id="quicksearch">
+ <p style="margin:0;padding:0"{*this <p> is for html validation only - does not affect positioning*}>
+ <input type="text" name="q" id="qsearchInput" onfocus="if (value==qsearch_prompt) value='';" onblur="if (value=='') value=qsearch_prompt;" style="width:90%"/>
+ </p>
+ </form>
+ <script type="text/javascript">var qsearch_prompt="{'qsearch'|@translate|@escape:'javascript'}"; document.getElementById('qsearchInput').value=qsearch_prompt;</script>
+
+ <ul>
+ {foreach from=$block->data item=link}
+ {if is_array($link)}
+ <li><a href="{$link.URL}" title="{$link.TITLE}" {if isset($link.REL)}{$link.REL}{/if}>{$link.NAME}</a></li>
+ {/if}
+ {/foreach}
+ </ul>
+</dd>
+
diff --git a/template/yoga/menubar_specials.tpl b/template/yoga/menubar_specials.tpl
new file mode 100644
index 000000000..8bda68402
--- /dev/null
+++ b/template/yoga/menubar_specials.tpl
@@ -0,0 +1,9 @@
+<dt>{$block->get_title()|@translate}</dt>
+<dd>
+ <ul>
+ {foreach from=$block->data item=link}
+ <li><a href="{$link.URL}" title="{$link.TITLE}" {if isset($link.REL)}{$link.REL}{/if}>{$link.NAME}</a></li>
+ {/foreach}
+ </ul>
+</dd>
+
diff --git a/template/yoga/menubar_tags.tpl b/template/yoga/menubar_tags.tpl
new file mode 100644
index 000000000..0200eb5b7
--- /dev/null
+++ b/template/yoga/menubar_tags.tpl
@@ -0,0 +1,18 @@
+<dt>{$block->get_title()|@translate}</dt>
+<dd>
+ <ul id="menuTagCloud">
+ {foreach from=$block->data item=tag}
+ <li>
+ {if !empty($tag.U_ADD) }
+ <a href="{$tag.U_ADD}"
+ title="{$pwg->l10n_dec('%d element are also linked to current tags', '%d elements are also linked to current tags', $tag.counter)}"
+ rel="nofollow">
+ <img src="{$ROOT_URL}{$themeconf.icon_dir}/add_tag.png" alt="+" />
+ </a>
+ {/if}
+ <a href="{$tag.URL}" class="tagLevel{$tag.level}" title="{'See elements linked to this tag only'|@translate}">{$tag.name}</a>
+ </li>
+ {/foreach}
+ </ul>
+</dd>
+