debug = FALSE;
$this->dragDrop = $dragdrop;
if($this->dragDrop)
{
$this->debug = TRUE;
}
if ($NEWSHEADER)
{
$HEADER .= $NEWSHEADER;
}
if(isset($_POST['custom_select']))
{
$this->curLayout = $_POST['custom_select'];
}
elseif(isset($_GET['lay']))
{
$this->curLayout = $_GET['lay'];
}
else
{
$this->curLayout = varsettrue($_GET['configure'], $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)
{
if ($menu_value != $menu_check)
{
$this->menu_areas[] = $menu_value;
}
$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."?id=".$_GET['id'];
/*
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 (!isset($_GET['configure']))
{ // 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 "))
{
$insert = array(
'menu_id' => 0,
'menu_name' => $val['menu_name'],
'menu_location' => $val['menu_location'],
'menu_order' => $val['menu_order'],
'menu_class' => $val['menu_class'],
'menu_pages' => '',
'menu_path' => $row['menu_path'],
'menu_layout' => $this->dbLayout,
'menu_parms' => ''
);
$sql->db_Insert("menus",$insert);
$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 (e107::isInstalled($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
{
$insert = array(
'menu_id' => 0,
'menu_name' => $file['fname'],
'menu_location' => 0,
'menu_order' => 0,
'menu_class' => 0,
'menu_pages' => '',
'menu_path' => $file['path'],
'menu_layout' => '',
'menu_parms' => ''
);
if($sql->db_Insert("menus",$insert))
{
// Could do admin logging here - but probably not needed
$message .= MENLAN_10." - ".$file['fname']."
";
}
}
}
}
//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"))
{
$c = 1;
while ($row = $sql->db_Fetch())
{
$sql2->db_Update("menus", "menu_order={$c} WHERE menu_id=".$row['menu_id']);
$c++;
}
}
}
$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)
{
$sql2->db_Delete("menus", "menu_name='$menu_name'");
$message .= MENLAN_11." - ".$menu_name."
";
}
}
$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'])))
{
$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 .= "