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 = vartrue($_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']) || vartrue($_GET['id'])) { $this->menuId = (isset($_POST['menu_id'])) ? intval($_POST['menu_id']) : intval($_GET['id']); } if (/*$menu_act == "sv" || */isset($_POST['class_submit'])) { $this->menuSaveVisibility(); } elseif(isset($_POST['parms_submit'])) { $this->menuSaveParameters(); } if (vartrue($_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(vartrue($_POST['menuActivate'])) { $this->menuActivateLoc = key($_POST['menuActivate']); $this->menuActivateIds = $_POST['menuselect']; $this->menuActivate(); } if(vartrue($_POST['menuSetCustomPages'])) { $this->menuSetCustomPages($_POST['custompages']); } if(isset($_POST['menuUsePreset']) && $_POST['curLayout']) { $this->menuSetPreset(); } $this->menuSetConfigList(); // Update Active MenuConfig List. } // ------------------------------------------------------------------------- function menuRenderIframe($url='') { $ns = e107::getRender(); $sql = e107::getDb(); if(!$url) { $url = e_SELF."?configure=".$this->curLayout; } // $cnt = $sql->select("menus", "*", "menu_location > 0 AND menu_layout = '$curLayout' ORDER BY menu_name "); // calculate height to remove vertical scroll-bar. // $text = ""; $text = ""; return $text; } function menuRenderMessage() { // return $this->menuMessage; $text = e107::getMessage()->render('menuUi'); // $text .= "ID = ".$this->menuId; return $text; } function menuAddMessage($message, $type = E_MESSAGE_INFO, $session = false) { e107::getMessage()->add(array($message, 'menuUi'), $type, $session); } // ------------------------------------------------------------------------- function menuGrabLayout() { global $HEADER,$FOOTER,$CUSTOMHEADER,$CUSTOMFOOTER,$LAYOUT; if(isset($LAYOUT) && is_array($LAYOUT)) // $LAYOUT is a combined $HEADER,$FOOTER. { foreach($LAYOUT as $key=>$template) { list($hd,$ft) = explode("{---}",$template); $HEADER[$key] = isset($LAYOUT['_header_']) ? $LAYOUT['_header_'] . $hd : $hd; $FOOTER[$key] = isset($LAYOUT['_footer_']) ? $ft . $LAYOUT['_footer_'] : $ft ; } unset($hd,$ft); } 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($CUSTOMFOOTER[$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'].'&iframe=1'; /* 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 $admin_log; $pref = e107::getPref(); $sql = e107::getDb(); $ns = e107::getRender(); $menu_act = ""; if (isset($_POST['menuAct'])) { foreach ($_POST['menuAct'] as $k => $v) { if (trim($v)) { $this->menuId = intval($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->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."' "); e107::getLog()->add('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}' "); e107::getLog()->add('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."' "); e107::getLog()->add('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."' "); e107::getLog()->add('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 $location,$admin_log; $pref = e107::getPref(); $sql = e107::getDb(); if(!$menuAreas = $this->getMenuPreset()) { e107::getMessage()->addDebug("No Menu Preset Found"); return FALSE; } $sql->db_Update("menus", "menu_location='0' WHERE menu_layout = '".$this->dbLayout."' "); // Clear All existing. foreach($menuAreas as $val) { if($sql->select("menus", 'menu_name, menu_path' , "menu_name = '".$val['menu_name']."' LIMIT 1")) { $row=$sql->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' => intval($val['menu_class']), 'menu_pages' => '', 'menu_path' => $row['menu_path'], 'menu_layout' => $this->dbLayout, 'menu_parms' => '' ); $sql->insert("menus",$insert); e107::getLog()->add('MENU_01',$row['menu_name'].'[!br!]'.$location.'[!br!]'.$menu_count.'[!br!]'.$row['menu_path'],E_LOG_INFORMATIVE,''); } } } return $menuAreas; } // ---------------------------------------------------------------------------- function menuScanMenus() { global $sql2; $sql = e107::getDb(); $efile = new e_file; $efile->dirFilter = array('/', 'CVS', '.svn', 'languages'); $efile->fileFilter[] = '^e_menu\.php$'; $fileList = $efile->get_files(e_PLUGIN,"_menu\.php$",'standard',2); // $this->menuAddMessage('Scanning for new menus', E_MESSAGE_DEBUG); e107::getDebug()->log("Scanning for new menus",E107_DBG_BASIC); $menuList = array(); // existing menus in table. if($result = $sql->retrieve('menus', 'menu_name', null, true)) { foreach($result as $mn) { if($mn['menu_name']) { $menuList[] = $mn['menu_name']; } } } //v2.x Scan Custom Page Menus. $pageMenus = $sql->retrieve('page','page_id, menu_name, menu_title',"menu_name !='' ", true); foreach($pageMenus as $row) { if(!in_array($row['menu_name'],$menuList)) { $insert = array( 'menu_id' => 0, 'menu_name' => $row['menu_name'], 'menu_location' => 0, 'menu_order' => 0, 'menu_class' => 0, 'menu_pages' => '', 'menu_path' => $row['page_id'], 'menu_layout' => '', 'menu_parms' => '' ); if($sql->insert("menus",$insert)) { $this->menuAddMessage(MENLAN_10." - ".$row['menu_name'], E_MESSAGE_DEBUG); } } } 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 = in_array($file['fname'], $menuList); // $sql->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->insert("menus",$insert)) { // Could do admin logging here - but probably not needed $message .= MENLAN_10." - ".$file['fname']."
"; //FIXME } else { $this->menuAddMessage("Couldn't add menu: ".$file['fname']." to table ", E_MESSAGE_DEBUG); } } } } //Reorder all menus into 1...x order if (!is_object($sql2)) $sql2 = new db; // Shouldn't be needed if (!is_object($sql3)) $sql3 = new db; $location_count = $sql3->select("menus", "menu_location", "menu_location>0 GROUP BY menu_location"); while ($location_count) { if ($sql->select("menus", "menu_id", "menu_location={$location_count} ORDER BY menu_order ASC")) { $c = 1; while ($row = $sql->fetch()) { $sql2->db_Update("menus", "menu_order={$c} WHERE menu_id=".$row['menu_id']); $c++; } } $location_count--; } $sql->select("menus", "*", "menu_path NOT REGEXP('[0-9]+') "); while (list($menu_id, $menu_name, $menu_location, $menu_order) = $sql->fetch('num')) { if (stristr($menustr, $menu_name) === FALSE) { $sql2->db_Delete("menus", "menu_name='$menu_name'"); $message .= MENLAN_11." - ".$menu_name."
"; } } $this->menuAddMessage(vartrue($message), E_MESSAGE_DEBUG); } // --------------------------------------------------------------------------- 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; } /** * This one will be greatly extended, allowing menus to offer UI and us * settings per instance later ($parm variable available for menus - same as shortcode's $parm) */ function menuInstanceParameters() { if(!vartrue($_GET['parmsId'])) return; $id = intval($_GET['parmsId']); $frm = e107::getForm(); $sql = e107::getDb(); if(!$sql->select("menus", "*", "menu_id=".$id)) { $this->menuAddMessage("Couldn't Load Menu",E_MESSAGE_ERROR); return; }; $row = $sql->fetch(); $text = "
".MENLAN_44." ".$row['menu_name']." "; if(file_exists(e_PLUGIN.$row['menu_path']."e_menu.php")) // v2.x new e_menu.php { $plug = rtrim($row['menu_path'],'/'); $obj = e107::getAddon($plug,'e_menu'); if(!is_object($obj)) { $text .= ""; } else { $menuName = substr($row['menu_name'],0,-5); } $fields = e107::callMethod($obj,'config',$menuName); if(!$form = e107::getAddon($plug,'e_menu',$plug."_menu_form")) { $form = $frm; } $value = e107::unserialize($row['menu_parms']); if(!empty($fields)) { foreach($fields as $k=>$v) { $text .= ""; // $v['writeParms']['class'] = 'e-save'; $i = $k; if(!empty($v['multilan'])) { $i = $k.'['.e_LANGUAGE.']'; if(isset($value[$k][e_LANGUAGE])) { $value[$k] = varset($value[$k][e_LANGUAGE],''); } } if(!empty($v['help'])) { $v['writeParms']['title'] = e107::getParser()->toAttribute($v['help']); } $text .= ""; } } else { $text .= ""; } } else { $text .= ""; } $text .= "
{$plug} object not found. Try re-scanning plugin directories in Tools > Database.
".$v['title']."".$form->renderElement($i, $value[$k], $v); $text .= "
No Fields Set in ".$row['menu_path']."e_menu.php
".MENLAN_45." ".$frm->text('menu_parms', $row['menu_parms'], 900, 'class=e-save&size=xxlarge')."
"; /* $text .= "
"; $text .= $frm->admin_button('parms_submit', LAN_SAVE, 'update'); $text .= "
"; */ $text .= $frm->hidden('mode','parms'); $text .= $frm->hidden('menu_id',$id); $text .= "
"; return $text; } function menuVisibilityOptions() { if(!vartrue($_GET['vis'])) return; $sql = e107::getDb(); $ns = e107::getRender(); $frm = e107::getForm(); $tp = e107::getParser(); require_once(e_HANDLER."userclass_class.php"); if(!$sql->select("menus", "*", "menu_id=".intval($_GET['vis']))) { $this->menuAddMessage("Couldn't Load Menu",E_MESSAGE_ERROR); return; } $row = $sql->fetch(); $listtype = substr($row['menu_pages'], 0, 1); $menu_pages = substr($row['menu_pages'], 2); $menu_pages = str_replace("|", "\n", $menu_pages); $text = "
". MENLAN_7." ".$row['menu_name']."
".MENLAN_4." ". $frm->userclass('menu_class', $row['menu_class'], 'dropdown', array('options'=>"public,member,guest,admin,main,classes,nobody", 'class'=>'e-save'))."
"; $checked = ($listtype == 1) ? " checked='checked' " : ""; $text .= $frm->radio('listtype', 1, $checked, array('label'=>$tp->toHtml(MENLAN_26,true), 'class'=> 'e-save')); $text .= "
"; // $text .= " ".MENLAN_26."
"; $checked = ($listtype == 2) ? " checked='checked' " : ""; $text .= $frm->radio('listtype', 2, $checked, array('label'=> $tp->toHtml(MENLAN_27,true), 'class'=> 'e-save')); // $text .= " ".MENLAN_27."
"; $text .= "
".MENLAN_28."
"; $text .= $frm->hidden('mode','visibility'); $text .= $frm->hidden('menu_id',intval($_GET['vis'])); // ""; /* $text .= "
"; $text .= $frm->admin_button('class_submit', MENLAN_6, 'update');
"; */ $text .= "
"; return $text; //$caption = MENLAN_7." ".$row['menu_name']; //$ns->tablerender($caption, $text); //echo $text; } // ----------------------------------------------------------------------------- function menuActivate() // Activate Multiple Menus. { global $admin_log; $pref = e107::getPref(); $sql = e107::getDb(); $location = $this->menuActivateLoc; $menu_count = $sql->count("menus", "(*)", " WHERE menu_location=".$location." AND menu_layout = '".$this->dbLayout."' "); $menu_count++; // Need to add 1 to create NEW order number. foreach($this->menuActivateIds as $sel_mens) { //Get info from menu being activated if($sql->select("menus", 'menu_name, menu_path' , "menu_id = ".intval($sel_mens)." ")) { $row=$sql->fetch(); //If menu is not already activated in that area, add the record. //$query = "SELECT menu_name,menu_path FROM #menus WHERE menu_name='".$row['menu_name']."' AND menu_layout = '".$this->dbLayout."' AND menu_location = ".$location." LIMIT 1 "; //if(!$sql->gen($query, $this->debug)) { $insert = array( 'menu_id' => 0, 'menu_name' => $row['menu_name'], 'menu_location' => $location, 'menu_order' => $menu_count, 'menu_class' => intval($row['menu_class']), 'menu_pages' => '', 'menu_path' => $row['menu_path'], 'menu_layout' => $this->dbLayout, 'menu_parms' => '' ); $sql->insert("menus",$insert, $this->debug); e107::getLog()->add('MENU_01',$row['menu_name'].'[!br!]'.$location.'[!br!]'.$menu_count.'[!br!]'.$row['menu_path'],E_LOG_INFORMATIVE,''); $menu_count++; } } } } // ----------------------------------------------------------------------------- function menuSetCustomPages($array) { $pref = e107::getPref(); $key = key($array); $pref['sitetheme_custompages'][$key] = array_filter(explode(" ",$array[$key])); save_prefs(); } // ------------------------------------------------------------------------------ function getMenuPreset() { $pref = e107::getPref(); $layout = $this->curLayout; if(!isset($pref['sitetheme_layouts'][$layout]['menuPresets'])) { e107::getMessage()->addDebug(print_a($pref['sitetheme_layouts'],true)); return FALSE; } $areas = $pref['sitetheme_layouts'][$layout]['menuPresets']['area']; foreach($areas as $area => $menus) { $areaID = $menus['@attributes']['id']; foreach($menus['menu'] as $k=>$v) { $menuArea[] = array( 'menu_location' => $areaID, 'menu_order' => $k, 'menu_name' => $v['@attributes']['name']."_menu", 'menu_class' => $this->menuPresetPerms($v['@attributes']['perm']) ); } } if(E107_DEBUG_LEVEL > 0) { // e107::getMessage()->addDebug(print_a($menuArea,true)); } return $menuArea; } // ------------------------------------------------------------------------------ function checkMenuPreset($array,$name) { if(!is_array($array)) { return; } foreach($array as $key=>$val) { if($val['menu_name']==$name) { return $val['menu_location']; } } return FALSE; } // -------------------------------------------------------------------------- function menuSaveParameters() { $sql = e107::getDb(); $id = intval($_POST['menu_id']); if(isset($_POST['menu_parms'])) { $parms = $sql->escape(strip_tags($_POST['menu_parms'])); } else { unset($_POST['menu_id'], $_POST['mode'], $_POST['menuActivate'], $_POST['menuSetCustomPages']); $parms = $sql->escape(e107::serialize($_POST)); if(e_DEBUG == true) { // return array('msg'=>print_r($_POST,true),'error'=>true); } } $check = $sql->update("menus", "menu_parms=\"".$parms."\" WHERE menu_id=".$id.""); if($check) { return array('msg'=>'All Okay','error'=>false); // FIXME - menu log //e107::getLog()->add('MENU_02',$_POST['menu_parms'].'[!br!]'.$parms.'[!br!]'.$this->menuId,E_LOG_INFORMATIVE,''); // $this->menuAddMessage(LAN_SAVED,E_MESSAGE_SUCCESS); } elseif(false === $check) { return array('msg'=>LAN_UPDATED_FAILED,'error'=>true); } else { return array('msg'=>'No Changes Made','error'=>false); // $this->menuAddMessage(LAN_NOCHANGE_NOTSAVED,E_MESSAGE_INFO); } } // -------------------------------------------------------------------------- function menuSaveVisibility() // Used by Ajax { $sql = e107::getDb(); $pagelist = explode("\r\n", $_POST['pagelist']); for ($i = 0 ; $i < count($pagelist) ; $i++) { $pagelist[$i] = trim($pagelist[$i]); } $plist = implode("|", $pagelist); $pageparms = $_POST['listtype'].'-'.$plist; $pageparms = preg_replace("#\|$#", "", $pageparms); $pageparms = (trim($_POST['pagelist']) == '') ? '' : $pageparms; if($sql->update("menus", "menu_class='".intval($_POST['menu_class'])."', menu_pages='{$pageparms}' WHERE menu_id=".intval($_POST['menu_id']))) { e107::getLog()->add('MENU_02',$_POST['menu_class'].'[!br!]'.$pageparms.'[!br!]'.$this->menuId,E_LOG_INFORMATIVE,''); return array('msg'=>LAN_UPDATED, 'error'=> false); //$this->menuAddMessage($message,E_MESSAGE_SUCCESS); } else { return array('msg'=>LAN_UPDATED_FAILED, 'error'=> true, 'posted'=>$_POST); // $this->menuAddMessage($message,E_MESSAGE_ERROR); } } function setMenuId($id) { $this->menuId = intval($id); } // ----------------------------------------------------------------------- function menuDeactivate() { $sql = e107::getDb(); $sql2 = e107::getDb(); //echo "FOUND= ".$this->menuId; $error = false; $message = ''; if($sql->gen('SELECT menu_name, menu_location, menu_order FROM #menus WHERE menu_id = '.$this->menuId.' LIMIT 1')) { $row = $sql->fetch(); //Check to see if there is already a menu with location = 0 (to maintain BC) if($sql2->select('menus', 'menu_id', "menu_name='{$row['menu_name']}' AND menu_location = 0 AND menu_layout ='".$this->dbLayout."' LIMIT 1")) { //menu_location=0 already exists, we can just delete this record if(!$sql2->db_Delete('menus', 'menu_id='.$this->menuId)) { $message = "Deletion Failed"; $error = true; } } else { //menu_location=0 does NOT exist, let's just convert this to it if(!$sql2->update("menus", "menu_location=0, menu_order=0, menu_class=0, menu_pages='' WHERE menu_id=".$this->menuId)) { $message = "FAILED"; $error = true; } } //Move all menus up (reduces order number) that have a higher menu order number than one deactivated, in the selected location. $sql->update("menus", "menu_order=menu_order-1 WHERE menu_location={$row['menu_location']} AND menu_order > {$row['menu_order']} AND menu_layout = '".$this->dbLayout."' "); e107::getLog()->add('MENU_04',$row['menu_name'].'[!br!]'.$row['menu_location'].'[!br!]'.$row['menu_order'].'[!br!]'.$this->menuId,E_LOG_INFORMATIVE,''); } else { $message = "NO CHANGES MADE : ".$this->menuId; $error = true; } return array('msg'=>$message,'error'=>$error); } // ---------------------------------------------------------------------- /** * Move a Menu */ function menuMove() {// Get current menu name $sql = e107::getDb(); if($sql->select('menus', 'menu_name', 'menu_id='.$this->menuId, 'default')) { $row = $sql->fetch(); //Check to see if menu is already active in the new area, if not then move it if(!$sql->select('menus', 'menu_id', "menu_name='{$row['menu_name']}' AND menu_location = ".$this->menuNewLoc." AND menu_layout='".$this->dbLayout ."' LIMIT 1")) { $menu_count = $sql->count("menus", "(*)", " WHERE menu_location=".$this->menuNewLoc); $sql->db_Update("menus", "menu_location='{$this->menuNewLoc}', menu_order=".($menu_count+1)." WHERE menu_id=".$this->menuId); $sql->db_Update("menus", "menu_order=menu_order-1 WHERE menu_location='{$location}' AND menu_order > {$position} AND menu_layout='".$this->dbLayout ."' "); } e107::getLog()->add('MENU_03',$row['menu_name'].'[!br!]'.$this->menuNewLoc.'[!br!]'.$this->menuId,E_LOG_INFORMATIVE,''); } } // =----------------------------------------------------------------------------- function renderOptionRow($row) { $sql = e107::getDb(); $tp = e107::getParser(); $ns = e107::getRender(); $frm = e107::getForm(); $text = ""; $pdeta = ""; $color = ($color == "white") ? "#DDDDDD" : "white"; if($row['menu_pages'] == "dbcustom") { $pdeta = MENLAN_42; } else { $row['menu_name'] = preg_replace("#_menu$#i", "", $row['menu_name']); if($pnum = $this->checkMenuPreset($menuPreset,$row['menu_name'].'_menu')) { $pdeta = MENLAN_39." {$pnum}"; } } if(!$this->dragDrop) { $menuInf = (!is_numeric($row['menu_path'])) ? ' ('.substr($row['menu_path'],0,-1).')' : " ( #".$row['menu_path']." )"; // $menuInf = $row['menu_path']; $text .= " "; $text .= $frm->checkbox('menuselect[]',$row['menu_id'],'',array('label'=>$row['menu_name'].$menuInf)); $text .= "   ".$pdeta."  \n"; } else { // Menu Choices box. $text .= "
"; $text .= $this->menuRenderMenu($row, $menu_count,true); $text .= "
\n"; } return $text; } function menuRenderPage() { global $HEADER, $FOOTER, $rs; $pref = e107::getPref(); $sql = e107::getDb(); $tp = e107::getParser(); $ns = e107::getRender(); $frm = e107::getForm(); //FIXME - XHTML cleanup, front-end standards (elist, forms etc) echo "
"; $this->parseheader($HEADER); // $layouts_str; $layout = ($this->curLayout); $menuPreset = $this->getMenuPreset($layout); echo "
"; echo $rs->form_open("post", e_SELF."?configure=".$this->curLayout, "menuActivation"); $text = ""; $text .= ""; $text .= ""; $text .= "
".MENLAN_36."... ...".MENLAN_37."
"; if(!$this->dragDrop) { $text .= "
"; $text .= "\n"; } else { // $text .= "
\n"; } $color = ""; $pageMenu = array(); $pluginMenu = array(); $sql->select("menus", "menu_name, menu_id, menu_pages, menu_path", "1 GROUP BY menu_name ORDER BY menu_name ASC"); while ($row = $sql->fetch()) { if(is_numeric($row['menu_path'])) { $pageMenu[] = $row; } else { $pluginMenu[] = $row; } } $text .= "
"; foreach($pageMenu as $row) { $text .= $this->renderOptionRow($row); } $text .= ""; foreach($pluginMenu as $row) { $text .= $this->renderOptionRow($row); } $text .= (!$this->dragDrop) ? "
Your Menus
Plugin Menus
" : ""; $text .= "
"; $text .= "
"; if(!count($this->menu_areas)) { $text = "
"; $text .= "This layout does NOT contain any dynamic {MENU} areas.
"; if(count($this->customMenu)) { $text .= "

It DOES contain the following custom menus:

  • ".implode("
  • ",$this->customMenu)."

"; $text .= "

Go to Custom-Menu area

"; } $text .= "
"; } // $ns -> tablerender(MENLAN_22.'blabla', $text); echo $this->renderPanel(MENLAN_22, $text); echo $rs->form_close(); echo "
"; $this->parseheader($FOOTER); if($this->debug) { echo "
 
"; } echo "
"; } //------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------// function menuSelectLayout() { global $rs; $pref = e107::getPref(); // onchange=\"urljump(this.options[selectedIndex].value);\" $text = "
"; $text .= "
Theme Layout: "; $text .= "
".MENLAN_30."
"; // $text .= "
Something here
"; return $text; } //------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------// function parseheader($LAYOUT, $check = FALSE) { // $tmp = explode("\n", $LAYOUT); // Split up using the same function as the shortcode handler $tmp = preg_split('#(\{\S[^\x02]*?\S\})#', $LAYOUT, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE); $str = array(); for($c = 0; $c < count($tmp); $c++) { if(preg_match("/[\{|\}]/", $tmp[$c])) { if($check) { if(strstr($tmp[$c], "{MENU=")) { $matches = array(); // Match all menu areas, menu number is limited to tinyint(3) preg_match_all("/\{MENU=([\d]{1,3})(:[\w\d]*)?\}/", $tmp[$c], $matches); $this->menuSetCode($matches, $str); } } else { $this->checklayout($tmp[$c]); } } else { if(!$check) { echo $tmp[$c]; } } } if($check) { return $str; } } function menuSetCode($matches, &$ret) { if(!$matches || !vartrue($matches[1])) { return; } foreach ($matches[1] as $match) { $ret[] = $match; } } function renderPanel($caption,$text) { $plugtext = ""; return $plugtext; } function checklayout($str) { // Displays a basic representation of the theme global $PLUGINS_DIRECTORY, $rs, $sc_style, $menu_order, $style; // global $style required. $PLUGINS_DIRECTORY = e107::getFolder('PLUGINS'); $pref = e107::getPref(); $tp = e107::getParser(); $ns = e107::getRender(); $menuLayout = ($this->curLayout != $pref['sitetheme_deflayout']) ? $this->curLayout : ""; // if(strstr($str, "LOGO")) // { // echo $tp->parseTemplate("{LOGO}"); // } if(strstr($str, "SETSTYLE")) { $style = preg_replace("/\{SETSTYLE=(.*?)\}/si", "\\1", $str); $this->style = $style; $ns->setStyle($style); } /*elseif(strstr($str, "SITENAME")) { echo "[SiteName]"; }*/ /*elseif(strstr($str, "SITETAG")) { echo "
[SiteTag]
"; }*/ // elseif(strstr($str, "SITELINKS")) // { // echo "[SiteLinks]"; // } elseif(strstr($str, "NAVIGATION")) { $cust = preg_replace("/\W*\{NAVIGATION(.*?)(\+.*)?\}\W*/si", "\\1", $str); $tp->parseTemplate("{NAVIGATION".$cust."}",true); // echo "Navigation Area"; } elseif(strstr($str, "ALERT")) { //echo "[Navigation Area]"; } elseif(strstr($str, "LANGUAGELINKS")) { echo "
[Language]
"; } elseif(strstr($str, "CUSTOM")) { $cust = preg_replace("/\W*\{CUSTOM=(.*?)(\+.*)?\}\W*/si", "\\1", $str); echo "
[" . $cust . "]
"; } elseif(strstr($str, "CMENU")) { $cust = preg_replace("/\W*\{CMENU=(.*?)(\+.*)?\}\W*/si", "\\1", $str); $this->customMenu[] = $cust; echo $tp->parseTemplate("{CMENU=".$cust."}",true); // echo $this->renderPanel('Embedded Custom Menu',$cust); } elseif(strstr($str, "SETIMAGE")) { $cust = preg_replace("/\W*\{SETIMAGE(.*?)(\+.*)?\}\W*/si", "\\1", $str); echo $tp->parseTemplate("{SETIMAGE".$cust."}",true); // echo $this->renderPanel('Embedded Custom Menu',$cust); } /*elseif(strstr($str, "{WMESSAGE")) { echo "
[Welcome Message Area]
"; // echo $this->renderPanel('Embedded Custom Menu',$cust); }*/ elseif(strstr($str, "{FEATUREBOX")) { echo "
[Featurebox Area]
"; // echo $this->renderPanel('Embedded Custom Menu',$cust); } // Display embedded Plugin information. else if(strstr($str, "PLUGIN")) { $plug = preg_replace("/\{PLUGIN=(.*?)\}/si", "\\1", $str); $plug = trim($plug); if(file_exists((e_PLUGIN . "{$plug}/{$plug}_config.php"))) { $link = e_PLUGIN . "{$plug}/{$plug}_config.php"; } if(file_exists((e_PLUGIN . $plug . "/config.php"))) { $link = e_PLUGIN . $plug . "/config.php"; } // $plugtext = ""; echo "
"; echo $this->renderPanel($plug, $plugtext); // $ns->tablerender($plug, $plugtext); } else if(strstr($str, "MENU")) { $matches = array(); if(preg_match_all("/\{MENU=([\d]{1,3})(:[\w\d]*)?\}/", $str, $matches)) { $menuText = ""; foreach($matches[1] as $menu) { $menu = preg_replace("/\{MENU=(.*?)(:.*?)?\}/si", "\\1", $str); if(isset($sc_style['MENU']['pre']) && strpos($str, 'ret') !== false) { $menuText .= $sc_style['MENU']['pre']; } // --------------- $menuText .= "\n\n"; $menuText .= "\n\n"; // --------------- if(isset($sc_style['MENU']['post']) && strpos($str, 'ret') !== false) { $menuText .= $sc_style['MENU']['post']; } } } $ns->tablerender('', $menuText); } //. else if(strstr($str, "SITEDISCLAIMER")) //{ // echo "[Sitedisclaimer]"; // } else { echo $tp->parseTemplate($str,true); } } //------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------// function menuRenderMenu($row,$menu_count,$rep = FALSE) { global $rs,$menu,$menu_info,$menu_act, $style; $ns = e107::getRender(); $style = $this->style; // $menu_count is empty in here //FIXME extract extract($row); if(!$menu_id){ return; } $menu_name = preg_replace("#_menu#i", "", $menu_name); //TODO we need a CSS class for this $vis = ($menu_class || strlen($menu_pages) > 1) ? " " : ""; //DEBUG div not allowed in final tags $caption = "
{$menu_name}{$vis}
"; // use theme render style instead // Undocumented special parameter 'admin_title' $menuParms = array(); if(!empty($row['menu_parms'])) parse_str($row['menu_parms'], $menuParms); if(isset($menuParms['admin_title']) && $menuParms['admin_title']) { $caption = deftrue($menuParms['admin_title'], $menuParms['admin_title']).$vis; } elseif(isset($menuParms['title']) && $menuParms['title']) { $caption = deftrue($menuParms['title'], $menuParms['title']).$vis; } else $caption = $menu_name.$vis; $menu_info = "{$menu_location}.{$menu_order}"; $text = ""; $conf = ''; if (file_exists(e_PLUGIN.$menu_path.$menu_name.'_menu_config.php')) { $conf = $menu_path.$menu_name.'_menu_config'; } if($conf == '' && file_exists(e_PLUGIN."{$menu_path}config.php")) { $conf = "{$menu_path}config"; } // // $text = "
"; $text .= ' '; $text .= ($rep == true) ? "
" : ""; // $text .= ""; if(!$this->dragDrop) { return "".$caption."
". $text; // return; // return $ns->tablerender($caption, $text,'', true); Theme style too unpredictable. } else { return "
".$caption."
".$text."
"; } } function menuSaveAjax($mode = null) { if($mode == 'visibility') { $ret = $this->menuSaveVisibility(); // echo json_encode($ret); return; } if($mode == 'delete') { list($tmp,$area) = explode("-",$_POST['area']); if($_POST['area'] == 'remove') { list($tmp,$deleteID) = explode("-",$_POST['removeid']); $this->menuId = $deleteID; $ret = $this->menuDeactivate(); // echo json_encode($ret); return; } } if($mode == 'parms') { $ret = $this->menuSaveParameters(); if(!empty($ret['error'])) { echo json_encode($ret); } return; } // print_r($_POST); return; $this->debug = TRUE; $sql = e107::getDb(); // Allow deletion by ajax, but not the rest when drag/drop disabled. if(!$this->dragDrop){ return; } $this -> dbLayout = $_POST['layout']; list($tmp,$insertID) = explode("-",$_POST['insert']); $insert[] = $insertID; if($_POST['mode'] == 'insert' && count($insert) && $area) // clear out everything before rewriting everything to db. { $this->menuActivateLoc = $area; // location $this->menuActivateIds = $insert; // array of ids, in order. $this->menuActivate(); } elseif($_POST['mode'] == 'update') { $sql->update("menus","menu_location = ".intval($area)." WHERE menu_id = ".intval($insertID)."",$this->debug); } $c = 0; if(count($_POST['list'])<2) { return; } // resort the menus in this 'Area" foreach($_POST['list'] as $val) { list($b,$id) = explode("-",$val); $order[] = $id; $sql->update("menus","menu_order = ".$c." WHERE menu_id = ".intval($id)."",$this->debug); $c++; } // same for delete etc. // echo "
"; } function menuSetConfigList() { e107::getMessage()->addDebug("Scanning for Menu config files"); $sql = e107::getDb(); $pref = e107::getPref(); $prev_name = ''; $search = array('_menu','_'); $sql -> select("menus", "*", "menu_location != 0 ORDER BY menu_path,menu_name"); while($row = $sql-> fetch()) { $link = ""; $id = substr($row['menu_path'],0,-1); if (file_exists(e_PLUGIN."{$row['menu_path']}{$row['menu_name']}_menu_config.php")) { $link = $row['menu_path'].$row['menu_name']."_menu_config.php"; } if($row['menu_path'] == 'news/') { $row['menu_path'] = "blogcalendar_menu/"; } if(file_exists(e_PLUGIN.$row['menu_path']."config.php")) { $link = $row['menu_path']."config.php"; } if($link) { $tmp[$id]['name'] = ucwords(str_replace($search,"",$row['menu_name'])); // remove _ if(vartrue($prev) == $id && ($tmp[$id]['name'] != $prev_name)) { $tmp[$id]['name'] .= ":".$prev_name; } $tmp[$id]['link'] = $link; $prev = $id; $prev_name = $tmp[$id]['name']; } } $pref['menuconfig_list'] = vartrue($tmp); e107::getConfig()->setPref($pref)->save(false,true,false); } } // end of Class.