mirror of
https://github.com/e107inc/e107.git
synced 2025-08-01 20:30:39 +02:00
Introducing e_menu front-end class
This commit is contained in:
44
class2.php
44
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();
|
||||
}
|
||||
|
||||
|
||||
|
@@ -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']))
|
||||
|
@@ -1,151 +1,9 @@
|
||||
<?php
|
||||
/* $Id: menu.php,v 1.5 2009-08-14 22:33:35 e107coders Exp $ */
|
||||
/* $Id: menu.php,v 1.6 2009-08-16 16:30:56 secretr Exp $ */
|
||||
|
||||
function menu_shortcode($parm)
|
||||
{
|
||||
global $sql, $ns, $tp, $sc_style;
|
||||
global $eMenuList, $error_handler;
|
||||
$e107 = e107::getInstance();
|
||||
|
||||
$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
|
||||
{
|
||||
//$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<!-- Menu Start: ".$mname." -->\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<!-- Menu End: ".$mname." -->\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);
|
||||
}
|
||||
|
||||
|
||||
|
@@ -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
|
||||
*
|
||||
|
File diff suppressed because it is too large
Load Diff
1187
e107_handlers/menumanager_class.php
Normal file
1187
e107_handlers/menumanager_class.php
Normal file
File diff suppressed because it is too large
Load Diff
@@ -10,9 +10,9 @@
|
||||
| GNU General Public License (http://gnu.org).
|
||||
|
|
||||
| $Source: /cvs_backup/e107_0.8/e107_handlers/theme_handler.php,v $
|
||||
| $Revision: 1.42 $
|
||||
| $Date: 2009-08-06 22:27:47 $
|
||||
| $Author: e107coders $
|
||||
| $Revision: 1.43 $
|
||||
| $Date: 2009-08-16 16:30:56 $
|
||||
| $Author: secretr $
|
||||
+----------------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
@@ -103,8 +103,8 @@ class themeHandler{
|
||||
{
|
||||
$key = key($_POST['setMenuPreset']);
|
||||
include_lan(e_LANGUAGEDIR.e_LANGUAGE."/admin/lan_menus.php");
|
||||
require_once(e_HANDLER."menu_class.php");
|
||||
$men = new menuManager();
|
||||
require_once(e_HANDLER."menumanager_class.php");
|
||||
$men = new e_menuManager();
|
||||
$men->curLayout = $key;
|
||||
$men->dbLayout = ($men->curLayout !=$pref['sitetheme_deflayout']) ? $men->curLayout : ""; //menu_layout is left blank when it's default.
|
||||
|
||||
|
Reference in New Issue
Block a user