mirror of
https://github.com/e107inc/e107.git
synced 2025-08-16 11:36:08 +02:00
Code cleanup and optimization
This commit is contained in:
@@ -61,7 +61,7 @@ class e_menu
|
||||
* Constructor
|
||||
*
|
||||
*/
|
||||
function __construct()
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -80,13 +80,13 @@ class e_menu
|
||||
}
|
||||
|
||||
// print_a($eMenuArea);
|
||||
if(varset($_SERVER['E_DEV_MENU']) == 'true') // New in v2.x Experimental
|
||||
if(varset($_SERVER['E_DEV_MENU']) === 'true') // New in v2.x Experimental
|
||||
{
|
||||
$layouts = e107::getPref('menu_layouts');
|
||||
if(!is_array($layouts))
|
||||
{
|
||||
$converted = $this->convertMenuTable();
|
||||
e107::getConfig('core')->set('menu_layouts', $converted)->save();
|
||||
e107::getConfig()->set('menu_layouts', $converted)->save();
|
||||
}
|
||||
|
||||
$eMenuArea = $this->getData(THEME_LAYOUT);
|
||||
@@ -145,7 +145,7 @@ class e_menu
|
||||
{
|
||||
$layout = vartrue($row['menu_layout'],'default');
|
||||
$location = $row['menu_location'];
|
||||
$data[$layout][$location][] = array('name'=>$row['menu_name'],'class'=> intval($row['menu_class']),'path'=>$row['menu_path'],'pages'=>$row['menu_pages'],'parms'=>$row['menu_parms']);
|
||||
$data[$layout][$location][] = array('name'=>$row['menu_name'],'class'=> (int)$row['menu_class'],'path'=>$row['menu_path'],'pages'=>$row['menu_pages'],'parms'=>$row['menu_parms']);
|
||||
}
|
||||
|
||||
return $data;
|
||||
@@ -203,6 +203,8 @@ class e_menu
|
||||
{
|
||||
return array();
|
||||
}
|
||||
|
||||
$ret = array();
|
||||
|
||||
foreach($mpref[$layout] as $area=>$v)
|
||||
{
|
||||
@@ -210,7 +212,7 @@ class e_menu
|
||||
|
||||
foreach($v as $val)
|
||||
{
|
||||
$class = intval($val['class']);
|
||||
$class = (int)$val['class'];
|
||||
|
||||
if(!check_class($class))
|
||||
{
|
||||
@@ -255,7 +257,7 @@ class e_menu
|
||||
public function setParms($plugin, $menu, $parms=array(), $location = 'all')
|
||||
{
|
||||
$qry = 'menu_parms="'.e107::serialize($parms).'" WHERE menu_parms="" AND menu_path="'.$plugin.'/" AND menu_name="'.$menu.'" ';
|
||||
$qry .= ($location != 'all') ? 'menu_location='.intval($location) : '';
|
||||
$qry .= ($location !== 'all') ? 'menu_location='. (int)$location : '';
|
||||
|
||||
return e107::getDb()->update('menus', $qry);
|
||||
}
|
||||
@@ -414,7 +416,7 @@ class e_menu
|
||||
* Returns true if a menu is currently active.
|
||||
* @param string $menuname (without the '_menu.php' )
|
||||
*/
|
||||
function isLoaded($menuname)
|
||||
public function isLoaded($menuname)
|
||||
{
|
||||
if(empty($menuname))
|
||||
{
|
||||
@@ -440,12 +442,7 @@ class e_menu
|
||||
|
||||
protected function isFrontPage()
|
||||
{
|
||||
if(e_REQUEST_SELF == SITEURL)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return e_REQUEST_SELF == SITEURL;
|
||||
}
|
||||
|
||||
|
||||
@@ -481,7 +478,7 @@ class e_menu
|
||||
|
||||
foreach($pagelist as $p)
|
||||
{
|
||||
if($p == 'FRONTPAGE' && $this->isFrontPage())
|
||||
if($p === 'FRONTPAGE' && $this->isFrontPage())
|
||||
{
|
||||
$show_menu = true;
|
||||
break;
|
||||
@@ -508,7 +505,7 @@ class e_menu
|
||||
$show_menu = true;
|
||||
foreach($pagelist as $p)
|
||||
{
|
||||
if($p == 'FRONTPAGE' && $this->isFrontPage())
|
||||
if($p === 'FRONTPAGE' && $this->isFrontPage())
|
||||
{
|
||||
$show_menu = false;
|
||||
break;
|
||||
@@ -516,7 +513,7 @@ class e_menu
|
||||
|
||||
|
||||
$p = $tp->replaceConstants($p, 'full');
|
||||
if(substr($p, -1)=='!')
|
||||
if(substr($p, -1) === '!')
|
||||
{
|
||||
$p = substr($p, 0, -1);
|
||||
if(substr($check_url, strlen($p)*-1) == $p)
|
||||
@@ -558,7 +555,7 @@ class e_menu
|
||||
$buffer_output = (E107_DBG_INCLUDES) ? false : true; // Turn off when trouble-shooting includes. Default - return all output.
|
||||
|
||||
|
||||
if(isset($tmp[1])&&$tmp[1]=='echo')
|
||||
if(isset($tmp[1])&&$tmp[1] === 'echo')
|
||||
{
|
||||
$buffer_output = false;
|
||||
}
|
||||
@@ -580,9 +577,7 @@ class e_menu
|
||||
e107::getRender()->eMenuArea = null;
|
||||
if($buffer_output)
|
||||
{
|
||||
$ret = ob_get_contents();
|
||||
ob_end_clean();
|
||||
return $ret;
|
||||
return ob_get_clean();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -631,7 +626,7 @@ class e_menu
|
||||
|
||||
if(is_numeric($mpath) || ($mname === false)) // Custom Page/Menu
|
||||
{
|
||||
$query = ($mname === false) ? "menu_name = '".$mpath."' " : "page_id=".intval($mpath)." "; // load by ID or load by menu-name (menu_name)
|
||||
$query = ($mname === false) ? "menu_name = '".$mpath."' " : "page_id=". (int)$mpath ." "; // load by ID or load by menu-name (menu_name)
|
||||
|
||||
$sql->select("page", "*", $query);
|
||||
$page = $sql->fetch();
|
||||
@@ -659,7 +654,7 @@ class e_menu
|
||||
// echo "TEMPLATE= ($mpath)".$page['menu_template'];
|
||||
|
||||
$ns->setUniqueId('cmenu-'.$page['menu_name']);
|
||||
$caption .= e107::getForm()->instantEditButton(e_ADMIN_ABS."cpage.php?mode=menu&action=edit&tab=2&id=".intval($page['page_id']),'J');
|
||||
$caption .= e107::getForm()->instantEditButton(e_ADMIN_ABS."cpage.php?mode=menu&action=edit&tab=2&id=". (int)$page['page_id'],'J');
|
||||
|
||||
$ns->tablerender($caption, $text, 'cmenu-'.$page['menu_template']);
|
||||
}
|
||||
@@ -705,9 +700,7 @@ class e_menu
|
||||
|
||||
if($return)
|
||||
{
|
||||
$ret = ob_get_contents();
|
||||
ob_end_clean();
|
||||
return $ret;
|
||||
return ob_get_clean();
|
||||
}
|
||||
|
||||
unset($pref);
|
||||
|
Reference in New Issue
Block a user