diff --git a/e107_admin/menus.php b/e107_admin/menus.php index e756e73ab..45289ac9a 100644 --- a/e107_admin/menus.php +++ b/e107_admin/menus.php @@ -26,6 +26,10 @@ if(isset($_GET['configure'])) error_reporting(0); } +else +{ + define('e_ADMIN_AREA', true); +} require_once("../class2.php"); if (!getperms("2")) @@ -69,6 +73,8 @@ top: 60px; .menu-selector { height:400px; display:block; padding-bottom:50px; overflow-y:scroll; margin-bottom:10px } + ul.dropdown-menu.e-mm-selector { padding: 10px; margin-top: -2px; margin-right:-2px; } + "); @@ -606,111 +612,30 @@ if($_SERVER['E_DEV_MENU'] == 'true') // if($_SERVER['E_DEV_MENU'] == 'true') //{ + + function countThemeMenus() + { + + + + + + } + + + + + + function e_help() { - if(e_DEBUG === false) + if(e_DEBUG_MENUMANAGER !== true) { return null; } - - // $p = e107::getPref('e_menu_list'); // new storage for xxxxx_menu.php list. - $sql = e107::getDb(); - $frm = e107::getForm(); - - $done = array(); - - $pageMenu = array(); - $pluginMenu = array(); - - $sql->select("menus", "menu_name, menu_id, menu_pages, menu_path", "1 ORDER BY menu_name ASC"); - while ($row = $sql->fetch()) - { - - if(in_array($row['menu_name'],$done)) - { - continue; - } - - $done[] = $row['menu_name']; - - if(is_numeric($row['menu_path'])) - { - $pageMenu[] = $row; - } - else - { - $pluginMenu[] = $row; - } - - } - - $tab1 = ''; - - $tab2 = ''; - - $tabs = array( - 'custom' => array('caption'=>MENLAN_49, 'text'=>$tab1), - 'plugin' => array('caption'=>ADLAN_CL_7, 'text'=>$tab2) - - ); - - - $text = '
'; - - - //TODO FIXME parse the theme file (or store it somewhere) to get the number of menu areas for each layout. ie. $menu_areas below. - - $text .= ' - - '; - - - $text .= $frm->tabs($tabs); - - - - - - $text .= '
'; - - return array('caption'=>MENLAN_22,'text'=>$text); - - - + return e_menu_layout::menuSelector(); @@ -791,6 +716,264 @@ if($_SERVER['E_DEV_MENU'] == 'true') } //} +// new v2.1.4 +class e_menu_layout +{ + function __construct() + { + + } + + static function getLayouts($theme=null) + { + if(empty($theme)) + { + $theme = e107::pref('core','sitetheme'); + } + + $HEADER = null; + $FOOTER = null; + $LAYOUT = null; + $CUSTOMHEADER = null; + $CUSTOMFOOTER = null; + + $file = e_THEME.$theme."/theme.php"; + + if(!is_readable($file)) + { + return false; + } + + require($file); + + + $head = array(); + $foot = array(); + + + if(isset($LAYOUT) && is_array($LAYOUT)) // $LAYOUT is a combined $HEADER,$FOOTER. + { + foreach($LAYOUT as $key=>$template) + { + if($key == '_header_' || $key == '_footer_' || $key == '_modal_') + { + continue; + } + + if(strpos($template,'{---}') !==false) + { + list($hd,$ft) = explode("{---}",$template); + $head[$key] = isset($LAYOUT['_header_']) ? $LAYOUT['_header_'] . $hd : $hd; + $foot[$key] = isset($LAYOUT['_footer_']) ? $ft . $LAYOUT['_footer_'] : $ft ; + } + else + { + e107::getMessage()->addDebug('Missing "{---}" in $LAYOUT["'.$key.'"] '); + } + } + unset($hd,$ft); + } + + + if(is_string($CUSTOMHEADER)) + { + $head['legacyCustom'] = $CUSTOMHEADER; + } + elseif(is_array($CUSTOMHEADER)) + { + foreach($CUSTOMHEADER as $k=>$v) + { + $head[$k] = $v; + } + } + + if(is_string($HEADER)) + { + $head['legacyDefault'] = $HEADER; + } + elseif(is_array($HEADER)) + { + foreach($HEADER as $k=>$v) + { + $head[$k] = $v; + } + + } + + if(is_string($CUSTOMFOOTER)) + { + $foot['legacyCustom'] = $CUSTOMFOOTER; + } + elseif(is_array($CUSTOMFOOTER)) + { + foreach($CUSTOMFOOTER as $k=>$v) + { + $foot[$k] = $v; + } + } + + + if(is_string($FOOTER)) + { + $foot['legacyDefault'] = $FOOTER; + } + elseif(is_array($FOOTER)) + { + foreach($FOOTER as $k=>$v) + { + $foot[$k] = $v; + } + } + + $layout = array(); + + foreach($head as $k=>$v) + { + $template = $head[$k]."\n{---}".$foot[$k]; + $layout['templates'][$k] = $template; + $layout['menus'][$k] = self::countMenus($template); + } + + + return $layout; + + + } + + + private static function countMenus($template) + { + if(preg_match_all("/\{MENU=([\d]{1,3})(:[\w\d]*)?\}/", $template, $matches)) + { + sort($matches[1]); + return $matches[1]; + } + + return array(); + } + + + + static function menuSelector() + { + + // $p = e107::getPref('e_menu_list'); // new storage for xxxxx_menu.php list. + $sql = e107::getDb(); + $frm = e107::getForm(); + + $done = array(); + + $pageMenu = array(); + $pluginMenu = array(); + + $sql->select("menus", "menu_name, menu_id, menu_pages, menu_path", "1 ORDER BY menu_name ASC"); + while ($row = $sql->fetch()) + { + + if(in_array($row['menu_name'],$done)) + { + continue; + } + + $done[] = $row['menu_name']; + + if(is_numeric($row['menu_path'])) + { + $pageMenu[] = $row; + } + else + { + $pluginMenu[] = $row; + } + + } + + $tab1 = ''; + + $tab2 = ''; + + $tabs = array( + 'custom' => array('caption'=>MENLAN_49, 'text'=>$tab1), + 'plugin' => array('caption'=>ADLAN_CL_7, 'text'=>$tab2) + + ); + + + $defLayout =e107::getRegistry('core/e107/menu-manager/curLayout');; + + $text = '
'; + + $text .= ""; + + + //TODO FIXME parse the theme file (or store it somewhere) to get the number of menu areas for each layout. ie. $menu_areas below. + + $layouts = self::getLayouts(); + + // $text .= print_a($layouts['menus'],true); + + $text .= ' + + '; + + + $text .= $frm->tabs($tabs); + + + + + + $text .= '
'; + + return array('caption'=>MENLAN_22,'text'=>$text); + + + + + + + } + + + +} + + // XXX Menu Manager Re-Write with drag and drop and multi-dimensional array as storage. ($pref) // TODO Get Drag & Drop Working with the iFrame @@ -890,7 +1073,7 @@ class e_layout */ $this->curLayout = vartrue($_GET['configure'], $pref['sitetheme_deflayout']); - $this->renderLayout($this->curLayout); + $this->renderLayout($this->curLayout); diff --git a/e107_core/shortcodes/batch/admin_shortcodes.php b/e107_core/shortcodes/batch/admin_shortcodes.php index a43bb2db4..dc566ab39 100644 --- a/e107_core/shortcodes/batch/admin_shortcodes.php +++ b/e107_core/shortcodes/batch/admin_shortcodes.php @@ -1892,7 +1892,7 @@ Inverse 10 10 $var[$key]['link'] = '#'.$key; $var[$key]['link_class'] = ' menuManagerSelect'; $var[$key]['active'] = ($key==$pref['sitetheme_deflayout']) ? true: false; - $var[$key]['include'] = "data-url='". e_SELF."?configure=".$key."'"; + $var[$key]['include'] = " data-url='". e_SELF."?configure=".$key."' data-layout='".$key."' "; } $action = $pref['sitetheme_deflayout']; @@ -1900,7 +1900,9 @@ Inverse 10 10 $var = array($defLayout => $var[$defLayout]) + $var; - e107::getNav()->admin(ADLAN_6,$action, $var); + e107::setRegistry('core/e107/menu-manager/curLayout',$action); + + return e107::getNav()->admin(ADLAN_6,$action, $var); diff --git a/e107_handlers/menumanager_class.php b/e107_handlers/menumanager_class.php index dbd72d998..e4e924044 100644 --- a/e107_handlers/menumanager_class.php +++ b/e107_handlers/menumanager_class.php @@ -116,9 +116,7 @@ class e_menuManager { $this->menuModify(); - $this->loadMenuData(); - - if(vartrue($_POST['menuActivate'])) + if(!empty($_POST['menuActivate'])) { $menuActivate = $tp->filter($_POST['menuActivate']); $this->menuActivateLoc = key($menuActivate); @@ -127,6 +125,8 @@ class e_menuManager { } + $this->loadMenuData(); + if(vartrue($_POST['menuSetCustomPages'])) { $custompages = $tp->filter($_POST['custompages']); @@ -204,7 +204,7 @@ class e_menuManager { // $cnt = $sql->select("menus", "*", "menu_location > 0 AND menu_layout = '$curLayout' ORDER BY menu_name "); // calculate height to remove vertical scroll-bar. // $text = ""; - $text = ""; + $text = ""; return $text; } @@ -1140,7 +1140,7 @@ class e_menuManager { $sql = e107::getDb(); $tp = e107::getParser(); - + //FIXME - XHTML cleanup, front-end standards (elist, forms etc) echo "
"; @@ -1255,7 +1255,16 @@ class e_menuManager { $text .= "
"; } // $ns -> tablerender(MENLAN_22.'blabla', $text); - echo $this->renderPanel(MENLAN_22, $text); + if(e_DEBUG_MENUMANAGER === true) + { + echo ""; + } + else + { + echo $this->renderPanel(MENLAN_22, $text); + } + + // echo $rs->form_close(); echo ""; diff --git a/e107_web/js/core/admin.jquery.js b/e107_web/js/core/admin.jquery.js index d3ef60c4c..1eb0edb89 100644 --- a/e107_web/js/core/admin.jquery.js +++ b/e107_web/js/core/admin.jquery.js @@ -641,6 +641,12 @@ $(document).ready(function() var link = $(this).attr('data-url'); + var layout= $(this).attr('data-layout'); + + $('#curLayout').val(layout); + $('ul.e-mm-selector').hide(); + $('form#e-mm-selector').attr('action',link); + var text = $(this).text(); $(this).html(text + ' '); @@ -663,10 +669,33 @@ $(document).ready(function() }); $('#menu_iframe').load(function() { - this.style.height = this.contentWindow.document.body.offsetHeight + 100 + 'px'; + this.style.height = this.contentWindow.document.body.offsetHeight + 400 + 'px'; + + + // alert(this.style.height); + // this.style.height = '100vh'; }); + + $("a.e-mm-selector").click(function(e){ + + var hash = $('#curLayout').val(); + // alert(hash); + + var selector = 'ul.dropdown-menu.e-mm-selector.' + hash; + $(selector).toggle(); + + $(e).preventDefault(); + }); + + + $(".e-mm-selector li input").click(function(e){ + + $("ul.dropdown-menu.e-mm-selector").css('display','none'); + + }); + $(".e-shake" ).effect("shake",{times: 10, distance: 2},20);