aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/test_menu
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-xplugins/test_menu/index.php33
-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.php500
-rw-r--r--plugins/test_menu/menu_templates/menubar.tpl165
-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.tpl17
-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.php288
14 files changed, 1262 insertions, 0 deletions
diff --git a/plugins/test_menu/index.php b/plugins/test_menu/index.php
new file mode 100755
index 000000000..db1eae0d9
--- /dev/null
+++ b/plugins/test_menu/index.php
@@ -0,0 +1,33 @@
+<?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 |
+// +-----------------------------------------------------------------------+
+// | 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 $
+// +-----------------------------------------------------------------------+
+// | 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. |
+// +-----------------------------------------------------------------------+
+
+// Recursive call
+$url = '../';
+header( 'Request-URI: '.$url );
+header( 'Content-Location: '.$url );
+header( 'Location: '.$url );
+exit();
+?>
diff --git a/plugins/test_menu/main.inc.php b/plugins/test_menu/main.inc.php
new file mode 100755
index 000000000..72abbe9e6
--- /dev/null
+++ b/plugins/test_menu/main.inc.php
@@ -0,0 +1,53 @@
+<?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
new file mode 100644
index 000000000..5aa42e213
--- /dev/null
+++ b/plugins/test_menu/maintain.inc.php
@@ -0,0 +1,44 @@
+<?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
new file mode 100644
index 000000000..d37a8345e
--- /dev/null
+++ b/plugins/test_menu/menu.class.inc.php
@@ -0,0 +1,500 @@
+<?php
+
+/* -----------------------------------------------------------------------------
+ class name: menu, blocks
+ 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()
+
+ 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()
+ {
+ $this->load_registered();
+ }
+
+ /*
+ public functions
+ */
+ 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.tpl b/plugins/test_menu/menu_templates/menubar.tpl
new file mode 100644
index 000000000..0bc538e87
--- /dev/null
+++ b/plugins/test_menu/menu_templates/menubar.tpl
@@ -0,0 +1,165 @@
+{* $Id: menubar.tpl 2409 2008-07-01 02:09:21Z rvelices $ *}
+
+<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>
+ <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>
+
+ <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}" class="filter" id="quickconnect">
+ <fieldset>
+ <legend>{'Quick connect'|@translate}</legend>
+
+ <label>
+ {'Username'|@translate}
+ <input type="text" name="username" size="15" value="">
+ </label>
+
+ <label>
+ {'Password'|@translate}
+ <input type="password" name="password" size="15">
+ </label>
+
+ {if $AUTHORIZE_REMEMBERING}
+ <label>
+ {'remember_me'|@translate}
+ <input type="checkbox" name="remember_me" value="1">
+ </label>
+ {/if}
+ <p>
+ <input class="submit" type="submit" name="login" value="{'Submit'|@translate}">
+ </p>
+
+ <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>
+
+ </fieldset>
+ </form>
+ {/if}
+
+ </dd>
+</dl>
+</div> <!-- menubar -->
diff --git a/plugins/test_menu/menu_templates/menubar_categories.tpl b/plugins/test_menu/menu_templates/menubar_categories.tpl
new file mode 100644
index 000000000..050f503c3
--- /dev/null
+++ b/plugins/test_menu/menu_templates/menubar_categories.tpl
@@ -0,0 +1,24 @@
+
+<!-- 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
new file mode 100644
index 000000000..e9991c280
--- /dev/null
+++ b/plugins/test_menu/menu_templates/menubar_generic.tpl
@@ -0,0 +1,10 @@
+
+<!-- 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
new file mode 100644
index 000000000..a09f12425
--- /dev/null
+++ b/plugins/test_menu/menu_templates/menubar_identification.tpl
@@ -0,0 +1,67 @@
+
+<!-- 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="">
+ </label>
+
+ <label>
+ {'Password'|@translate}
+ <input type="password" name="password" size="15">
+ </label>
+
+ {if $section.ITEMS.AUTHORIZE_REMEMBERING}
+ <label>
+ {'remember_me'|@translate}
+ <input type="checkbox" name="remember_me" value="1">
+ </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
new file mode 100644
index 000000000..87862f1d6
--- /dev/null
+++ b/plugins/test_menu/menu_templates/menubar_links.tpl
@@ -0,0 +1,17 @@
+
+<!-- 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
new file mode 100644
index 000000000..82d7cb208
--- /dev/null
+++ b/plugins/test_menu/menu_templates/menubar_main.tpl
@@ -0,0 +1,15 @@
+
+<!-- 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
new file mode 100644
index 000000000..9d42eeea5
--- /dev/null
+++ b/plugins/test_menu/menu_templates/menubar_menu.tpl
@@ -0,0 +1,17 @@
+
+<!-- menu menu bar -->
+<dt>{$section.NAME|@translate}</dt>
+<dd>
+ <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>
+
+ <ul>
+ {foreach from=$section.ITEMS 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>
diff --git a/plugins/test_menu/menu_templates/menubar_special.tpl b/plugins/test_menu/menu_templates/menubar_special.tpl
new file mode 100644
index 000000000..0bc9588ee
--- /dev/null
+++ b/plugins/test_menu/menu_templates/menubar_special.tpl
@@ -0,0 +1,10 @@
+
+<!-- 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
new file mode 100644
index 000000000..b0fd9cf04
--- /dev/null
+++ b/plugins/test_menu/menu_templates/menubar_tags.tpl
@@ -0,0 +1,19 @@
+
+<!-- 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
new file mode 100644
index 000000000..0bcca0a08
--- /dev/null
+++ b/plugins/test_menu/menubar.inc.php
@@ -0,0 +1,288 @@
+<?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
+// favorites categories
+$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
+$datas['menu']=array();
+// 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();
+
+
+
+
+?>