diff --git a/class2.php b/class2.php
index cc72d61ff..082cccf9a 100644
--- a/class2.php
+++ b/class2.php
@@ -9,9 +9,9 @@
* General purpose file
*
* $Source: /cvs_backup/e107_0.8/class2.php,v $
-* $Revision: 1.127 $
-* $Date: 2009-08-14 22:31:08 $
-* $Author: e107coders $
+* $Revision: 1.128 $
+* $Date: 2009-08-16 16:30:56 $
+* $Author: secretr $
*
*/
//
@@ -1164,43 +1164,7 @@ if(!defined("THEME_LAYOUT"))
$sql->db_Mark_Time('Start: Get menus');
if(!isset($_E107['no_menus']))
{
- $menu_layout_field = (THEME_LAYOUT != $pref['sitetheme_deflayout']) ? THEME_LAYOUT : "";
- $menu_data = $e107cache->retrieve_sys("menus_".USERCLASS_LIST."_".md5(e_LANGUAGE.$menu_layout_field));
- $menu_data = $eArrayStorage->ReadArray($menu_data);
- $eMenuList = array();
- $eMenuActive = array();
- $eMenuArea = array();
-
- if(!is_array($menu_data))
- {
-
- $menu_qry = 'SELECT * FROM #menus WHERE menu_location > 0 AND menu_class IN ('.USERCLASS_LIST.') AND menu_layout = "'.$menu_layout_field.'" ORDER BY menu_location,menu_order';
- if ($sql->db_Select_gen($menu_qry))
- {
- while ($row = $sql->db_Fetch())
- {
- $eMenuList[$row['menu_location']][] = $row;
- $eMenuArea[$row['menu_location']][$row['menu_name']] = 1;
- $eMenuActive[$row['menu_name']] = $row['menu_name'];
- }
- }
- $menu_data['menu_area'] = $eMenuArea;
- $menu_data['menu_list'] = $eMenuList;
- $menu_data['menu_active'] = $eMenuActive;
- $menu_data = $eArrayStorage->WriteArray($menu_data, false);
- $e107cache->set_sys('menus_'.USERCLASS_LIST.'_'.md5(e_LANGUAGE), $menu_data);
-
- unset($menu_data,$menu_layout_field,$menu_qry);
- }
- else
- {
- $eMenuArea = $menu_data['menu_area'];
- $eMenuList = $menu_data['menu_list'];
- $eMenuActive = $menu_data['menu_active'];
- unset($menu_data);
- }
-
-
+ e107::getMenu()->init();
}
diff --git a/e107_admin/menus.php b/e107_admin/menus.php
index 8eb8f9522..db8dcf170 100644
--- a/e107_admin/menus.php
+++ b/e107_admin/menus.php
@@ -10,9 +10,9 @@
| GNU General Public License (http://gnu.org).
|
| $Source: /cvs_backup/e107_0.8/e107_admin/menus.php,v $
-| $Revision: 1.31 $
-| $Date: 2009-07-17 02:28:49 $
-| $Author: e107coders $
+| $Revision: 1.32 $
+| $Date: 2009-08-16 16:30:56 $
+| $Author: secretr $
+----------------------------------------------------------------------------+
*/
require_once("../class2.php");
@@ -27,12 +27,12 @@ $e_sub_cat = 'menus';
require_once(e_HANDLER."file_class.php");
require_once(e_HANDLER."form_handler.php");
require_once (e_HANDLER.'message_handler.php');
-require_once(e_HANDLER."menu_class.php");
+require_once(e_HANDLER."menumanager_class.php");
$rs = new form;
$frm = new e_form();
- $men = new menuManager(); // use 1 for dragdrop.
+ $men = new e_menuManager(); // use 1 for dragdrop.
if(isset($_GET['ajax']))
diff --git a/e107_files/shortcode/menu.php b/e107_files/shortcode/menu.php
index 555d20f5b..7015f5075 100644
--- a/e107_files/shortcode/menu.php
+++ b/e107_files/shortcode/menu.php
@@ -1,151 +1,9 @@
eMenuArea = $tmp[0];
-
-
- foreach($eMenuList[$tmp[0]] as $row)
- {
- $pkey = str_replace("/","",$row['menu_path']);
- $show_menu[$pkey] = $row['menu_name'];
-
- if($row['menu_pages'])
- {
- list($listtype, $listpages) = explode('-', $row['menu_pages'], 2);
- $pagelist = explode('|',$listpages);
- $check_url = e_SELF.(e_QUERY ? '?'.e_QUERY : '');
-
- if($listtype == '1') //show menu
- {
- //$show_menu[$pkey] = FALSE;
- unset($show_menu[$pkey]);
- foreach($pagelist as $p)
- {
- if(substr($p, -1) == '!')
- {
- $p = substr($p, 0, -1);
- if(substr($check_url, strlen($p)*-1) == $p)
- {
- // $show_menu[$pkey] = TRUE;
- $show_menu[$pkey] = $row['menu_name'];
- }
- }
- else
- {
- if(strpos($check_url,$p) !== FALSE)
- {
- // $show_menu[$pkey] = TRUE;
- $show_menu[$pkey] = $row['menu_name'];
- }
- }
- }
- }
- elseif($listtype == '2') //hide menu
- {
- // $show_menu[$pkey] = TRUE;
- $show_menu[$pkey] = $row['menu_name'];
- foreach($pagelist as $p) {
- if(substr($p, -1) == '!')
- {
- $p = substr($p, 0, -1);
- if(substr($check_url, strlen($p)*-1) == $p)
- {
- // $show_menu[$pkey] = FALSE;
- unset($show_menu[$pkey]);
- }
- }
- else
- {
- if(strpos($check_url, $p) !== FALSE)
- {
- // $show_menu[$pkey] = FALSE;
- unset($show_menu[$pkey]);
- }
- }
- }
- }
- }
- }
-
- e107::getRender()->eMenuTotal = count($show_menu);
-
- foreach($show_menu as $mpath=>$mname)
- {
- // $mname = $row['menu_name'];
- if($error_handler->debug == true)
- {
- echo "\n\n";
- }
- $sql->db_Mark_Time($mname);
- if(is_numeric($mpath))
- {
- $sql -> db_Select("page", "*", "page_id='".$mpath."' ");
- $page = $sql -> db_Fetch();
- $caption = $e107->tp->toHTML($page['page_title'], TRUE, 'parse_sc, constants');
- $text = $e107->tp->toHTML($page['page_text'], TRUE, 'parse_sc, constants');
- e107::getRender()->tablerender($caption, $text);
- }
- else
- {
- if (is_readable(e_PLUGIN.$mpath."/languages/".e_LANGUAGE.".php"))
- {
- include_once(e_PLUGIN.$mpath."/languages/".e_LANGUAGE.".php");
- }
- elseif (is_readable(e_PLUGIN.$mpath."/languages/".e_LANGUAGE."/".e_LANGUAGE.".php"))
- {
- include_once(e_PLUGIN.$mpath."/languages/".e_LANGUAGE."/".e_LANGUAGE.".php");
- }
- elseif (is_readable(e_PLUGIN.$mpath."/languages/English.php"))
- {
- include_once(e_PLUGIN.$mpath."/languages/English.php");
- }
- elseif (is_readable(e_PLUGIN.$mpath."/languages/English/English.php"))
- {
- include_once(e_PLUGIN.$mpath."/languages/English/English.php");
- }
-
- if(file_exists(e_PLUGIN.$mpath."/".$mname.".php"))
- {
- include_once(e_PLUGIN.$mpath."/".$mname.".php");
- }
- }
- $sql->db_Mark_Time("(After ".$mname.")");
- if ($error_handler->debug == true)
- {
- echo "\n\n";
- }
- unset($caption,$text); // clear variables for proceeding menus.
- }
-
-
- e107::getRender()->eMenuCount = 0;
- e107::getRender()->eMenuArea = null;
-
-
- if ($buffer_output)
- {
- $ret = ob_get_contents();
- ob_end_clean();
- return $ret;
- }
+ return e107::getMenu()->render($parm);
}
diff --git a/e107_handlers/e107_class.php b/e107_handlers/e107_class.php
index d2b276f23..76b05a7c8 100644
--- a/e107_handlers/e107_class.php
+++ b/e107_handlers/e107_class.php
@@ -9,8 +9,8 @@
* e107 Main
*
* $Source: /cvs_backup/e107_0.8/e107_handlers/e107_class.php,v $
- * $Revision: 1.34 $
- * $Date: 2009-08-05 19:56:48 $
+ * $Revision: 1.35 $
+ * $Date: 2009-08-16 16:30:56 $
* $Author: secretr $
*/
@@ -217,8 +217,12 @@ class e107
* @param string $regpath additional registry path
* @return Object
*/
- public static function getSingleton($class_name, $path = null, $regpath = '')
+ public static function getSingleton($class_name, $path = true, $regpath = '')
{
+ if(true === $path)
+ {
+ //TODO All handler class names in array (lazy loading)
+ }
$id = 'core/e107/singleton/'.$class_name.$regpath;
if(!e107::getRegistry($id))
{
@@ -488,6 +492,16 @@ class e107
return self::getSingleton('ArrayData', e_HANDLER.'arraystorage_class.php');
}
+ /**
+ * Retrieve menu handler singleton object
+ *
+ * @return e_menu
+ */
+ public static function getMenu()
+ {
+ return self::getSingleton('e_menu', e_HANDLER.'menu_class.php');
+ }
+
/**
* Retrieve URL singleton object
*
diff --git a/e107_handlers/menu_class.php b/e107_handlers/menu_class.php
index 8915ff245..ac4f17c45 100644
--- a/e107_handlers/menu_class.php
+++ b/e107_handlers/menu_class.php
@@ -10,1177 +10,221 @@
| GNU General Public License (http://gnu.org).
|
| $Source: /cvs_backup/e107_0.8/e107_handlers/menu_class.php,v $
-| $Revision: 1.7 $
-| $Date: 2009-08-03 20:17:12 $
-| $Author: marj_nl_fr $
+| $Revision: 1.8 $
+| $Date: 2009-08-16 16:30:56 $
+| $Author: secretr $
+----------------------------------------------------------------------------+
*/
-if (!defined('e107_INIT')) { exit; }
+if(!defined('e107_INIT'))
+{
+ exit();
+}
-
-class menuManager{
-
-
- var $menu_areas = array();
- var $curLayout;
- var $menuId;
- var $menuNewLoc;
- var $dragDrop;
- var $menuActivateLoc;
- var $menuActivateIds;
- var $debug;
- var $menuMessage;
-
- function menuManager($dragdrop=FALSE)
+class e_menu
+{
+ public $eMenuArea;
+ public $eMenuList;
+ public $eMenuActive;
+
+ function __construct()
+ {
+
+ }
+
+ /**
+ * Init
+ *
+ */
+ public function init()
+ {
+ $menu_layout_field = THEME_LAYOUT != e107::getPref('sitetheme_deflayout') ? THEME_LAYOUT : "";
+ $menu_data = e107::getCache()->retrieve_sys("menus_".USERCLASS_LIST."_".md5(e_LANGUAGE.$menu_layout_field));
+ $menu_data = e107::getArrayStorage()->ReadArray($menu_data);
+ $eMenuList = array();
+ $eMenuActive = array();
+ $eMenuArea = array();
+
+ if(!is_array($menu_data))
{
- global $pref, $HEADER,$FOOTER, $NEWSHEADER;
-
-
- $this->debug = FALSE;
-
-
- $this->dragDrop = $dragdrop;
-
-
-
- if($this->dragDrop)
+
+ $menu_qry = 'SELECT * FROM #menus WHERE menu_location > 0 AND menu_class IN ('.USERCLASS_LIST.') AND menu_layout = "'.$menu_layout_field.'" ORDER BY menu_location,menu_order';
+ if (e107::getDb()->db_Select_gen($menu_qry))
+ {
+ while ($row = e107::getDb()->db_Fetch())
{
- $this->debug = TRUE;
+ $eMenuList[$row['menu_location']][] = $row;
+ $eMenuArea[$row['menu_location']][$row['menu_name']] = 1;
+ $eMenuActive[$row['menu_name']] = $row['menu_name'];
}
+ }
+ $menu_data['menu_area'] = $eMenuArea;
+ $menu_data['menu_list'] = $eMenuList;
+ $menu_data['menu_active'] = $eMenuActive;
+ $menu_data = e107::getArrayStorage()->WriteArray($menu_data, false);
+ e107::getCache()->set_sys('menus_'.USERCLASS_LIST.'_'.md5(e_LANGUAGE), $menu_data);
+
+ unset($menu_data,$menu_layout_field,$menu_qry);
+ }
+ else
+ {
+ $eMenuArea = $menu_data['menu_area'];
+ $eMenuList = $menu_data['menu_list'];
+ $eMenuActive = $menu_data['menu_active'];
+ unset($menu_data);
+ }
- if ($NEWSHEADER)
+ $this->eMenuActive = $eMenuActive;
+ $this->eMenuArea = $eMenuArea;
+ $this->eMenuList = $eMenuList;
+ }
+
+ function render($parm = '')
+ {
+
+ global $sql, $ns, $tp, $sc_style;
+ global $error_handler;
+ $e107 = e107::getInstance();
+
+ $eMenuList = $this->eMenuList;
+
+ $tmp = explode(':',$parm);
+
+ $buffer_output = true; // Default - return all output.
+ if (isset($tmp[1]) && $tmp[1] == 'echo') { $buffer_output = false; }
+
+ if (!array_key_exists($tmp[0], $eMenuList)) { return; }
+
+ if ($buffer_output)
+ {
+ ob_start();
+ }
+
+ e107::getRender()->eMenuArea = $tmp[0];
+
+
+ foreach($eMenuList[$tmp[0]] as $row)
+ {
+ $pkey = str_replace("/","",$row['menu_path']);
+ $show_menu[$pkey] = $row['menu_name'];
+
+ if($row['menu_pages'])
+ {
+ list($listtype, $listpages) = explode('-', $row['menu_pages'], 2);
+ $pagelist = explode('|',$listpages);
+ $check_url = e_SELF.(e_QUERY ? '?'.e_QUERY : '');
+
+ if($listtype == '1') //show menu
{
- $HEADER .= $NEWSHEADER;
- }
-
-
- if(isset($_POST['custom_select']))
- {
- $this->curLayout = $_POST['custom_select'];
- }
- elseif($_GET['lay'])
- {
- $this->curLayout = $_GET['lay'];
- }
- else
- {
- $tmp = explode('.', e_QUERY);
- $this->curLayout = ($tmp[1]) ? $tmp[1] : $pref['sitetheme_deflayout'];
- }
-
- $this->dbLayout = ($this->curLayout !=$pref['sitetheme_deflayout']) ? $this->curLayout : ""; //menu_layout is left blank when it's default.
-
- if(isset($_POST['menu_id']) || $_GET['id'])
- {
- $this->menuId = (isset($_POST['menu_id'])) ? intval($_POST['menu_id']) : $_GET['id'];
- }
-
- if ($menu_act == "sv" || isset($_POST['class_submit']))
- {
-
- $this->menuSaveVisibility();
-
- }
-
- if ($_GET['mode'] == "deac")
- {
- $this->menuDeactivate();
- }
-
- if ($_GET['mode'] == "conf")
- {
- $this->menuGoConfig();
- }
-
- $this->menuGrabLayout();
-
- $menu_array = $this->parseheader($HEADER.$FOOTER, 'check');
-
- if($menu_array)
- {
- sort($menu_array, SORT_NUMERIC);
- $menu_check = 'set';
- foreach ($menu_array as $menu_value)
+ //$show_menu[$pkey] = FALSE;
+ unset($show_menu[$pkey]);
+ foreach($pagelist as $p)
{
- if ($menu_value != $menu_check)
+ if(substr($p, -1) == '!')
{
- $this->menu_areas[] = $menu_value;
+ $p = substr($p, 0, -1);
+ if(substr($check_url, strlen($p)*-1) == $p)
+ {
+ // $show_menu[$pkey] = TRUE;
+ $show_menu[$pkey] = $row['menu_name'];
+ }
}
- $menu_check = $menu_value;
- }
- }
-
- $this->menuModify();
-
- if($_POST['menuActivate'])
- {
- $this->menuActivateLoc = key($_POST['menuActivate']);
- $this->menuActivateIds = $_POST['menuselect'];
- $this->menuActivate();
-
- }
-
- if($_POST['menuSetCustomPages'])
- {
- $this->menuSetCustomPages($_POST['custompages']);
- }
-
- if(isset($_POST['menuUsePreset']) && $_POST['curLayout'])
- {
-
- $this->menuSetPreset();
- }
-
- $this->menuSetConfigList(); // Update Active MenuConfig List.
-
- }
-
-// -------------------------------------------------------------------------
-
- function menuRenderIframe($url='')
- {
- global $ns,$sql;
- if(!$url)
- {
- $url = e_SELF."?configure.".$this->curLayout;
- }
-
- $cnt = $sql->db_Select("menus", "*", "menu_location > 0 AND menu_layout = '$curLayout' ORDER BY menu_name "); // calculate height to remove vertical scroll-bar.
-
- $text .= "";
-
- return $text;
- }
-
-
- function menuRenderMessage()
- {
- // return $this->menuMessage;
- $emessage = &eMessage::getInstance();
-
- $text = $emessage->render($message);
- // $text .= "ID = ".$this->menuId;
- return $text;
-
- }
-
-
- function menuAddMessage($message, $type = E_MESSAGE_INFO, $session = false)
- {
- $emessage = &eMessage::getInstance();
- $emessage->add($message, $type, $session);
- }
-
- // -------------------------------------------------------------------------
-
- function menuGrabLayout()
- {
- global $HEADER,$FOOTER,$CUSTOMHEADER,$CUSTOMFOOTER;
-
- if(($this->curLayout == 'legacyCustom' || $this->curLayout=='legacyDefault') && (isset($CUSTOMHEADER) || isset($CUSTOMFOOTER)) ) // 0.6 themes.
- {
- if($this->curLayout == 'legacyCustom')
- {
- $HEADER = ($CUSTOMHEADER) ? $CUSTOMHEADER : $HEADER;
- $FOOTER = ($CUSTOMFOOTER) ? $CUSTOMFOOTER : $FOOTER;
- }
- }
- elseif($this->curLayout && $this->curLayout != "legacyCustom" && (isset($CUSTOMHEADER[$this->curLayout]) || isset($CUSTOMHEADER[$this->curLayout]))) // 0.7 themes
- {
- // echo " MODE 0.7 ".$this->curLayout;
- $HEADER = ($CUSTOMHEADER[$this->curLayout]) ? $CUSTOMHEADER[$this->curLayout] : $HEADER;
- $FOOTER = ($CUSTOMFOOTER[$this->curLayout]) ? $CUSTOMFOOTER[$this->curLayout] : $FOOTER;
- }
- elseif($this->curLayout && is_array($HEADER) && isset($HEADER[$this->curLayout]) && isset($FOOTER[$this->curLayout])) // 0.8 themes - we use only $HEADER and $FOOTER arrays.
- {
- // echo " MODE 0.8 ".$this->curLayout;
-
- $HEADER = $HEADER[$this->curLayout];
- $FOOTER = $FOOTER[$this->curLayout];
-
- }
-
- // Almost the same code as found in templates/header_default.php ---------
-
- }
-
- function menuGoConfig()
- {
- if(!$_GET['path'] || ($_GET['mode'] != "conf"))
- {
- return;
- }
-
- $file = urldecode($_GET['path']).".php";
- $newurl = e_PLUGIN_ABS.$file;
-
- /*
-
-
-
- return "";
-
-*/
- header("Location: ".$newurl);
- exit;
- // echo "URL = ".$newurl;
- // $newurl = $PLUGINS_DIRECTORY.$location."/{$position}{$this->menuNewLoc}.php";
- // $newurl = SITEURL.str_replace("//", "/", $newurl);
- // echo " ";
- // exit;
-
-
- }
-
- // -----------------------------------------------------------------------------
-
- function menuModify()
- {
- global $pref,$sql,$admin_log,$ns;
-
- $menu_act = "";
-
- if (isset($_POST['menuAct']))
- {
- foreach ($_POST['menuAct'] as $k => $v)
- {
- if (trim($v))
- {
- $this->menuId = $k;
- list($menu_act, $location, $position, $this->menuNewLoc) = explode(".", $_POST['menuAct'][$k]);
- }
- }
- }
-
-
- if ($menu_act == "move")
- {
- $this->menuMove();
- }
-
-
-
- if ($menu_act == "bot")
- {
- $menu_count = $sql->db_Count("menus", "(*)", " WHERE menu_location='{$location}' AND menu_layout = '".$this->dbLayout."' ");
- $sql->db_Update("menus", "menu_order=".($menu_count+1)." WHERE menu_order='{$position}' AND menu_location='{$location}' AND menu_layout = '$this->dbLayout' ");
- $sql->db_Update("menus", "menu_order=menu_order-1 WHERE menu_location='{$location}' AND menu_order > {$position} AND menu_layout = '".$this->dbLayout."' ");
- $admin_log->log_event('MENU_06',$location.'[!br!]'.$position.'[!br!]'.$this->menuId,E_LOG_INFORMATIVE,'');
- }
-
- if ($menu_act == "top")
- {
- $sql->db_Update("menus", "menu_order=menu_order+1 WHERE menu_location='{$location}' AND menu_order < {$position} AND menu_layout = '".$this->dbLayout."' ",$this->debug);
- $sql->db_Update("menus", "menu_order=1 WHERE menu_id='{$this->menuId}' ");
- $admin_log->log_event('MENU_05',$location.'[!br!]'.$position.'[!br!]'.$this->menuId,E_LOG_INFORMATIVE,'');
- }
-
- if ($menu_act == "dec")
- {
- $sql->db_Update("menus", "menu_order=menu_order-1 WHERE menu_order='".($position+1)."' AND menu_location='{$location}' AND menu_layout = '".$this->dbLayout."' ",$this->debug);
- $sql->db_Update("menus", "menu_order=menu_order+1 WHERE menu_id='{$this->menuId}' AND menu_location='{$location}' AND menu_layout = '".$this->dbLayout."' ",TRUE);
- $admin_log->log_event('MENU_08',$location.'[!br!]'.$position.'[!br!]'.$this->menuId,E_LOG_INFORMATIVE,'');
- }
-
- if ($menu_act == "inc")
- {
- $sql->db_Update("menus", "menu_order=menu_order+1 WHERE menu_order='".($position-1)."' AND menu_location='{$location}' AND menu_layout = '".$this->dbLayout."' ",$this->debug);
- $sql->db_Update("menus", "menu_order=menu_order-1 WHERE menu_id='{$this->menuId}' AND menu_location='{$location}' AND menu_layout = '".$this->dbLayout."' ");
- $admin_log->log_event('MENU_07',$location.'[!br!]'.$position.'[!br!]'.$this->menuId,E_LOG_INFORMATIVE,'');
- }
-
- if (strpos(e_QUERY, 'configure') === FALSE)
- { // Scan plugin directories to see if menus to add
- $this->menuScanMenus();
- }
- }
-
-
-
-
-
-
- // ----------------------------------------------------------------------------
-
- function menuSetPreset()
- {
- global $pref,$sql,$location,$admin_log;
-
- if(!$menuAreas = $this->getMenuPreset())
- {
- return FALSE;
- }
-
-
- $sql->db_Update("menus", "menu_location='0' WHERE menu_layout = '".$this->dbLayout."' "); // Clear All existing.
- foreach($menuAreas as $val)
- {
-
- if($sql->db_Select("menus", 'menu_name, menu_path' , "menu_name = '".$val['menu_name']."' LIMIT 1"))
- {
- $row=$sql->db_Fetch();
-
- if(!$sql->db_Update('menus', "menu_order='{$val['menu_order']}', menu_location = ".$val['menu_location'].", menu_class= ".$val['menu_class']." WHERE menu_name='".$val['menu_name']."' AND menu_layout = '".$this->dbLayout."' LIMIT 1 "))
- {
- $qry = "
- INSERT into #menus
- (`menu_name`, `menu_location`, `menu_order`, `menu_pages`,`menu_class`, `menu_path`, `menu_layout`)
- VALUES ('{$val['menu_name']}', {$val['menu_location']}, {$val['menu_order']}, '', '{$val['menu_class']}', '{$row['menu_path']}', '".$this->dbLayout."')
- ";
- $sql->db_Select_gen($qry,$this->debug);
- $admin_log->log_event('MENU_01',$row['menu_name'].'[!br!]'.$location.'[!br!]'.$menu_count.'[!br!]'.$row['menu_path'],E_LOG_INFORMATIVE,'');
-
- }
- }
- }
-
- return $menuAreas;
-
- }
-
-
- // ----------------------------------------------------------------------------
-
- function menuScanMenus()
- {
- global $sql, $sql2;
-
- $efile = new e_file;
- $efile->dirFilter = array('/', 'CVS', '.svn', 'languages');
- $fileList = $efile->get_files(e_PLUGIN,"_menu\.php$",'standard',2);
- foreach($fileList as $file)
- {
- list($parent_dir) = explode('/',str_replace(e_PLUGIN,"",$file['path']));
- $file['path'] = str_replace(e_PLUGIN,"",$file['path']);
- $file['fname'] = str_replace(".php","",$file['fname']);
- $valid_menu = FALSE;
- $existing_menu = $sql->db_Count("menus", "(*)", "WHERE menu_name='{$file['fname']}'");
- if (file_exists(e_PLUGIN.$parent_dir.'/plugin.xml') || file_exists(e_PLUGIN.$parent_dir.'/plugin.php'))
- {
- if (plugInstalled($parent_dir))
- { // Its a 'new style' plugin with a plugin.php file, or an even newer one with plugin.xml file - only include if plugin installed
- $valid_menu = TRUE; // Whether new or existing, include in list
-// echo "Include {$parent_dir}:{$file['fname']}
";
- }
- }
- else
- { // Just add the menu anyway
- $valid_menu = TRUE;
-// echo "Default Include {$parent_dir}:{$file['fname']}
";
- }
- if ($valid_menu)
- {
- $menustr .= "&".str_replace(".php", "", $file['fname']);
- if (!$existing_menu)
- { // New menu to add to list
- if($sql->db_Insert("menus", " 0, '{$file['fname']}', 0, 0, 0, '' ,'{$file['path']}', ''"))
+ else
{
- // Could do admin logging here - but probably not needed
- $message .= MENLAN_10." - ".$file['fname']."
";
+ if(strpos($check_url,$p) !== FALSE)
+ {
+ // $show_menu[$pkey] = TRUE;
+ $show_menu[$pkey] = $row['menu_name'];
+ }
+ }
+ }
+ }
+ elseif($listtype == '2') //hide menu
+ {
+ // $show_menu[$pkey] = TRUE;
+ $show_menu[$pkey] = $row['menu_name'];
+ foreach($pagelist as $p) {
+ if(substr($p, -1) == '!')
+ {
+ $p = substr($p, 0, -1);
+ if(substr($check_url, strlen($p)*-1) == $p)
+ {
+ // $show_menu[$pkey] = FALSE;
+ unset($show_menu[$pkey]);
+ }
+ }
+ else
+ {
+ if(strpos($check_url, $p) !== FALSE)
+ {
+ // $show_menu[$pkey] = FALSE;
+ unset($show_menu[$pkey]);
+ }
}
}
}
}
-
- //Reorder all menus into 1...x order
- if (!is_object($sql2)) $sql2 = new db; // Shouldn't be needed
- foreach ($this->menu_areas as $menu_act)
- {
- if ($sql->db_Select("menus", "menu_id", "menu_location={$menu_act} ORDER BY menu_order ASC"))
+ }
+
+ e107::getRender()->eMenuTotal = count($show_menu);
+
+ foreach($show_menu as $mpath=>$mname)
+ {
+ // $mname = $row['menu_name'];
+ if($error_handler->debug == true)
{
- $c = 1;
- while ($row = $sql->db_Fetch())
+ echo "\n\n";
+ }
+ $sql->db_Mark_Time($mname);
+ if(is_numeric($mpath))
+ {
+ $sql -> db_Select("page", "*", "page_id='".$mpath."' ");
+ $page = $sql -> db_Fetch();
+ $caption = $e107->tp->toHTML($page['page_title'], TRUE, 'parse_sc, constants');
+ $text = $e107->tp->toHTML($page['page_text'], TRUE, 'parse_sc, constants');
+ e107::getRender()->tablerender($caption, $text);
+ }
+ else
+ {
+ if (is_readable(e_PLUGIN.$mpath."/languages/".e_LANGUAGE.".php"))
{
- $sql2->db_Update("menus", "menu_order={$c} WHERE menu_id=".$row['menu_id']);
- $c++;
+ include_once(e_PLUGIN.$mpath."/languages/".e_LANGUAGE.".php");
+ }
+ elseif (is_readable(e_PLUGIN.$mpath."/languages/".e_LANGUAGE."/".e_LANGUAGE.".php"))
+ {
+ include_once(e_PLUGIN.$mpath."/languages/".e_LANGUAGE."/".e_LANGUAGE.".php");
+ }
+ elseif (is_readable(e_PLUGIN.$mpath."/languages/English.php"))
+ {
+ include_once(e_PLUGIN.$mpath."/languages/English.php");
+ }
+ elseif (is_readable(e_PLUGIN.$mpath."/languages/English/English.php"))
+ {
+ include_once(e_PLUGIN.$mpath."/languages/English/English.php");
+ }
+
+ if(file_exists(e_PLUGIN.$mpath."/".$mname.".php"))
+ {
+ include_once(e_PLUGIN.$mpath."/".$mname.".php");
}
}
- }
-
- $sql->db_Select("menus", "*", "menu_path NOT REGEXP('[0-9]+') ");
- while (list($menu_id, $menu_name, $menu_location, $menu_order) = $sql->db_Fetch(MYSQL_NUM))
- {
- if (stristr($menustr, $menu_name) === FALSE)
+ $sql->db_Mark_Time("(After ".$mname.")");
+ if ($error_handler->debug == true)
{
- $sql2->db_Delete("menus", "menu_name='$menu_name'");
- $message .= MENLAN_11." - ".$menu_name."
";
+ echo "\n\n";
}
+ unset($caption,$text); // clear variables for proceeding menus.
}
-
- $this->menuAddMessage($message, E_MESSAGE_INFO);
-
- }
-
- // ---------------------------------------------------------------------------
-
-
- function menuPresetPerms($val)
- {
- $link_class = strtolower(trim($val));
- $menu_perm['everyone'] = e_UC_PUBLIC;
- $menu_perm['guest'] = e_UC_GUEST;
- $menu_perm['member'] = e_UC_MEMBER;
- $menu_perm['mainadmin'] = e_UC_MAINADMIN;
- $menu_perm['admin'] = e_UC_ADMIN;
- $menu_perm['nobody'] = e_UC_NOBODY;
- $link_class = ($menu_perm[$link_class]) ? $menu_perm[$link_class] : e_UC_PUBLIC;
-
- return $link_class;
- }
-
-
-
-
-
-
- function menuVisibilityOptions()
- {
- if(!$_GET['vis']) return;
-
- global $sql,$ns,$frm;
- require_once(e_HANDLER."userclass_class.php");
- if(!$sql->db_Select("menus", "*", "menu_id=".intval($_GET['vis'])))
+
+
+ e107::getRender()->eMenuCount = 0;
+ e107::getRender()->eMenuArea = null;
+
+
+ if ($buffer_output)
{
- $this->menuAddMessage("Couldn't Load Menu",E_MESSAGE_ERROR);
- return;
- };
- $row = $sql->db_Fetch();
- $listtype = substr($row['menu_pages'], 0, 1);
- $menu_pages = substr($row['menu_pages'], 2);
- $menu_pages = str_replace("|", "\n", $menu_pages);
-
- $text = "
".MENLAN_36."... | ...".MENLAN_37." | ||
";
-
- $sql->db_Select("menus", "menu_name, menu_id, menu_pages, menu_path", "1 GROUP BY menu_name ORDER BY menu_name ASC");
-
- if(!$this->dragDrop)
- {
- $text .= " ";
- $text .= " ";
-
- $text .= "
| "; - foreach ($this->menu_areas as $menu_act) - { - $text .= " \n"; - } - - - if($layout) - { - if(isset($pref['sitetheme_layouts'][$layout]['menuPresets'])) - { - $text .= "toJS(MENLAN_41)."')\" /> \n"; // Use Menu Presets - $text .= ""; - } - $text .= ""; - } - - $text .= " | ";
-
- $text .= "