From f546088ee8e463879c9f5bc71cd190677be27797 Mon Sep 17 00:00:00 2001 From: Deltik Date: Sat, 4 May 2013 11:24:14 -0500 Subject: [PATCH 01/24] [security] Unobtrusive way to stop most spambots for user_template --- .../shortcodes/batch/user_shortcodes.php | 31 +++++++++++++++++-- e107_core/templates/user_template.php | 4 +-- 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/e107_core/shortcodes/batch/user_shortcodes.php b/e107_core/shortcodes/batch/user_shortcodes.php index a43d74dbb..133cfaa24 100644 --- a/e107_core/shortcodes/batch/user_shortcodes.php +++ b/e107_core/shortcodes/batch/user_shortcodes.php @@ -226,7 +226,9 @@ class user_shortcodes extends e_shortcode function sc_user_email_link($parm) { $tp = e107::getParser(); - return ($this->var['user_hideemail'] && !ADMIN) ? "".LAN_USER_35."" : $tp->parseTemplate("{email={$this->var['user_email']}-link}"); + return /* Condition */ ($this->var['user_hideemail'] && !ADMIN) ? + /* Hidden and Not Admin */ "".LAN_USER_35."" : + /* Not Hidden or Admin */ $tp->parseTemplate("{email={$this->var['user_email']}-link}"); } @@ -234,7 +236,30 @@ class user_shortcodes extends e_shortcode function sc_user_email($parm) { $tp = e107::getParser(); - return ($this->var['user_hideemail'] && !ADMIN) ? "".LAN_USER_35."" : $tp->toHTML($this->var['user_email'],"no_replace"); + return /* Condition */ ($this->var['user_hideemail'] && !ADMIN) ? + /* Hidden and Not Admin */ "".LAN_USER_35."" : + /* Not Hidden or Admin */ "" . strrev($tp->toHTML($this->var['user_email'],"no_replace")) . ""; + ######################################################## + # Security Note - 04 May 2013 # + ######################################################## + # # + # The CSS code direction rtl is an effective way to # + # prevent spam bots from scraping emails that are # + # not hidden. # + # # + # You can find empirical support for this method at # + # . # + # # + # {e_CORE}templates/user_template.php was modified to # + # support this code. In $USER_FULL_TEMPLATE, the # + # LAN_USER_60 value {USER_EMAIL_LINK} was changed to # + # {USER_EMAIL}. I couldn't figure out how the two # + # shortcodes were different, so I took precautions in # + # hopes that the CSS direction won't break actual HTML # + # tags. # + # # + # -- Deltik # + ######################################################## } @@ -745,4 +770,4 @@ class user_shortcodes extends e_shortcode } -?> \ No newline at end of file +?> diff --git a/e107_core/templates/user_template.php b/e107_core/templates/user_template.php index 1b8455441..1e9513ee0 100644 --- a/e107_core/templates/user_template.php +++ b/e107_core/templates/user_template.php @@ -142,7 +142,7 @@ $USER_FULL_TEMPLATE = "{SETIMAGE: w=250}
{USER_EMAIL_ICON} ".LAN_USER_60."
-
{USER_EMAIL_LINK}
+
{USER_EMAIL}
@@ -213,4 +213,4 @@ $USER_EMBED_USERPROFILE_TEMPLATE = " {USER_EMBED_USERPROFILE_CAPTION} {USER_EMBED_USERPROFILE_TEXT}"; -?> \ No newline at end of file +?> From 0cdbd2ee2563708424b59cc97d0848f68109a7d2 Mon Sep 17 00:00:00 2001 From: Nicholas Liu Date: Tue, 7 May 2013 08:43:47 -0500 Subject: [PATCH 02/24] Typo correction on README.md --- README.md | 62 +++++++++++++++++++++++++++---------------------------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/README.md b/README.md index bcedebe3a..4358011d0 100644 --- a/README.md +++ b/README.md @@ -1,31 +1,31 @@ -## e107 [Content Management System][1] (CMS) - v2 - -### What is e107? -e107 is a free (open-source) content management system which allows you to easily manage and publish your content online. Developers can save time in building websites and powerful online applications. Users can avoid programming completely! Blogs, Websites, Intranets - e107 does it all. - -### Requirements - -* PHP v5.3 or higher -* MySQL 4.x or higher - -### Installation - -* Point your browser to the *http://localhost/YOUR FOLDER/install.php* (depending on your webserver setup) -* Follow the installation wizard - -### Reporting Bugs - -Be sure you are using the most recent version prior to reporting an issue. -Your may report any bugs or feature requests on Github (https://github.com/e107inc/e107/issues) - -### Pull-Requests - -* Please submit 1 pull-request for each Github #issue you may work on. -* Make sure that only the lines you have changed actually show up in a file-comparison (diff) ie. some text-editors alter every line so this should be avoided. - -### License - -* e107 is released under the terms and conditions of the GNU General Public License (http://www.gnu.org/licenses/gpl.txt) - - [1]: http://e107.org - [2]: http://www.e107.org +## e107 [Content Management System][1] (CMS) - v2 + +### What is e107? +e107 is a free (open-source) content management system which allows you to easily manage and publish your content online. Developers can save time in building websites and powerful online applications. Users can avoid programming completely! Blogs, Websites, Intranets - e107 does it all. + +### Requirements + +* PHP v5.3 or higher +* MySQL 4.x or higher + +### Installation + +* Point your browser to the *http://localhost/YOUR FOLDER/install.php* (depending on your webserver setup) +* Follow the installation wizard + +### Reporting Bugs + +Be sure you are using the most recent version prior to reporting an issue. +You may report any bugs or feature requests on GitHub (https://github.com/e107inc/e107/issues) + +### Pull-Requests + +* Please submit 1 pull-request for each Github #issue you may work on. +* Make sure that only the lines you have changed actually show up in a file-comparison (diff) ie. some text-editors alter every line so this should be avoided. + +### License + +* e107 is released under the terms and conditions of the GNU General Public License (http://www.gnu.org/licenses/gpl.txt) + + [1]: http://e107.org + [2]: http://www.e107.org From f9c157817aaef73e4b760cbf7293cd92d9b02d59 Mon Sep 17 00:00:00 2001 From: Cameron Date: Thu, 9 May 2013 03:27:32 -0700 Subject: [PATCH 03/24] Updated to use "SetEnv E_DEV_MENU true" in .htaccess - Experimental code. --- e107_admin/menus.php | 14 ++++++++++---- e107_core/shortcodes/batch/admin_shortcodes.php | 3 +-- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/e107_admin/menus.php b/e107_admin/menus.php index 837594301..cd5e66ed1 100644 --- a/e107_admin/menus.php +++ b/e107_admin/menus.php @@ -310,7 +310,7 @@ if(strpos(e_QUERY, 'configure') !== FALSE || vartrue($_GET['enc'])) -if($_SERVER['E_ENV_MENUS'] == 'developer') +if($_SERVER['E_DEV_MENU'] == 'true') { if(isset($_GET['configure']) || isset($_GET['iframe'])) { @@ -325,10 +325,16 @@ if($_SERVER['E_ENV_MENUS'] == 'developer') exit; } -if($_SERVER['E_ENV_MENUS'] == 'developer') -{ +// if($_SERVER['E_DEV_MENU'] == 'true') +//{ function e_help() { + if($_SERVER['E_DEV_MENU'] != 'true') + { + return false; + } + + $p = e107::getPref('e_menu_list'); // new storage for xxxxx_menu.php list. $sql = e107::getDb(); @@ -370,7 +376,7 @@ if($_SERVER['E_ENV_MENUS'] == 'developer') return array('caption'=>'Menu Items','text'=>$text); } -} +//} // XXX Menu Manager Re-Write with drag and drop and multi-dimensional array as storage. ($pref) diff --git a/e107_core/shortcodes/batch/admin_shortcodes.php b/e107_core/shortcodes/batch/admin_shortcodes.php index ee8554026..5f522dd60 100644 --- a/e107_core/shortcodes/batch/admin_shortcodes.php +++ b/e107_core/shortcodes/batch/admin_shortcodes.php @@ -61,9 +61,8 @@ class admin_shortcodes $ns = e107::getRender(); $pref = e107::getPref(); - if(function_exists('e_help')) // new in v2.x for non-admin-ui admin pages. + if(function_exists('e_help') && ($tmp = e_help())) // new in v2.x for non-admin-ui admin pages. { - $tmp = e_help(); return $ns->tablerender($tmp['caption'],$tmp['text'],'e_help',true); } From 72e7040284531caf00d2355b4c4a157cac607921 Mon Sep 17 00:00:00 2001 From: Cameron Date: Thu, 9 May 2013 04:22:42 -0700 Subject: [PATCH 04/24] A little closer to drag and drop functioning as intended. --- e107_admin/menus.php | 65 ++++++++++++++++++++++++++++++-------------- 1 file changed, 45 insertions(+), 20 deletions(-) diff --git a/e107_admin/menus.php b/e107_admin/menus.php index cd5e66ed1..f2771a930 100644 --- a/e107_admin/menus.php +++ b/e107_admin/menus.php @@ -396,6 +396,39 @@ class e_layout if(vartrue($_GET['configure'])) //ie Inside the IFRAME. { + + e107::js('url',"http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.1/jquery-ui.min.js"); + e107::js('url', "http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.1/themes/base/jquery-ui.css"); + + + e107::js('inline',' + $(function() + { + + $( "#sortable" ).sortable({ + revert: true + }); + + }); + '); + + + + + e107::js('inline', " + + win = document.getElementById('menu_iframe').contentWindow; + win.jQuery(dragelement,parent.document).draggable({ + connectToSortable : $('#sortable') + }); + + ",'jquery'); + + + + + + $this->curLayout = varsettrue($_GET['configure'], $pref['sitetheme_deflayout']); $this->renderLayout($this->curLayout); } @@ -404,17 +437,19 @@ class e_layout // XXX HELP _ i don't work with iFrames. - e107::js('inline',' - $(function() { + e107::js('inline',' + $(function() + { $( "#sortable" ).sortable({ revert: true }); + $( ".draggable" ).draggable({ - connectToSortable: "#sortable", + connectToSortable: $("#sortable"), helper: "clone", revert: "invalid", cursor: "move", - // iframeFix: true, + iframeFix: true, start: function(ev,ui) { @@ -429,23 +464,12 @@ class e_layout } }); - $( "ul, li" ).disableSelection(); + $( "ul, li" ).disableSelection(); - // Not Working. - $("#menu_iframe").load(function(){ - $("#menu_iframe").contents().find("#sortable").droppable({ - accept: ".drag", - drop: function( event, ui ) { - var html = "
"+ ui.draggable.html() + "
"; - //alert(html); - $(this).append(html); - } - }); + - }); - - }); - '); + }); + ','jquery'); $this->scanForNew(); @@ -472,6 +496,7 @@ class e_layout $this->menuData = ($data); + // print_a($this->menuData); } @@ -540,7 +565,7 @@ class e_layout private function renderMenu($row) { // return print_a($row,true); - $TEMPLATE = '
  • '.$row['name'].'
  • '; // TODO perhaps a simple counter for the id + $TEMPLATE = '
  • '.$row['name'].'
  • '; // TODO perhaps a simple counter for the id return $TEMPLATE; From cf8269dd92e07d284d618968ec523f9360aed5f0 Mon Sep 17 00:00:00 2001 From: Cameron Date: Thu, 9 May 2013 17:51:06 -0700 Subject: [PATCH 05/24] More menu manager work --- e107_admin/menus.php | 183 ++++++++++++++++++++++++++++++++++++------- 1 file changed, 153 insertions(+), 30 deletions(-) diff --git a/e107_admin/menus.php b/e107_admin/menus.php index f2771a930..9e37839e3 100644 --- a/e107_admin/menus.php +++ b/e107_admin/menus.php @@ -382,6 +382,7 @@ if($_SERVER['E_DEV_MENU'] == 'true') // XXX Menu Manager Re-Write with drag and drop and multi-dimensional array as storage. ($pref) // TODO Get Drag & Drop Working with the iFrame // TODO Sorting, visibility, parameters and delete. +// TODO Get THIS http://jsbin.com/odiqi3 working with iFrames!! XXX XXX class e_layout { @@ -394,6 +395,34 @@ class e_layout $this->convertMenuTable(); + + + if(e_AJAX_REQUEST) + { + if(varset($_POST['data'])) + { + $_SESSION['menuData'] = $_POST['data']; + + $cnf = e107::getConfig('core'); + $existing = $cnf->get('menu_layouts'); + // print_r($existing); + // $data = array_merge($existing,$_POST['data']); + $data = $_POST['data']; + print_r($data); + + e107::getConfig('core')->set('menu_layouts', $data)->save(); + + } + + exit; + + } + + + + + + if(vartrue($_GET['configure'])) //ie Inside the IFRAME. { @@ -405,15 +434,36 @@ class e_layout $(function() { - $( "#sortable" ).sortable({ - revert: true - }); + $( ".sortable" ).sortable({ + + revert: true, + cursor: "move", + distance: 20, + containment: "parent", + update: function(ev,ui) + { + var areaid = $(this).attr("id"); + var formid = "#form-" + areaid; + var form = $(formid); + var data = form.serialize(); + + $.ajax({ + type: "POST", + url: "menus.php", + data: data + + }).done(function( msg ) + { + alert(" Updated in DB "+ msg ); + }); + } + }); }); '); - + /* e107::js('inline', " @@ -425,7 +475,7 @@ class e_layout ",'jquery'); - + */ @@ -436,41 +486,55 @@ class e_layout { // XXX HELP _ i don't work with iFrames. - + // $("#sortable") + //$("iframe").contents().find(".sortable") + + /* e107::js('inline',' $(function() { - $( "#sortable" ).sortable({ + $( ".sortable" ).sortable({ revert: true }); $( ".draggable" ).draggable({ - connectToSortable: $("#sortable"), + connectToSortable: $(".sortable"), helper: "clone", revert: "invalid", cursor: "move", - iframeFix: true, + iframeFix: true - start: function(ev,ui) - { - }, - drag: function(ev,ui) - { - - }, - stop: function(ev, ui) - { - - } + }); $( "ul, li" ).disableSelection(); - + + + $("#menu_frame").load(function(){ + $("#menu_frame").contents().find("#sortable").droppable({ + accept: ".drag", + drop: function( event, ui ) { + var html = "
    "+ ui.draggable.html() + "
    "; + //alert(html); + $(this).append(html); + } + }); + + }); + + + }); + + + + ','jquery'); + */ + $this->scanForNew(); $this->renderInterface(); @@ -483,6 +547,14 @@ class e_layout */ function convertMenuTable() { + if(isset($_SESSION['menuData'])) + { + $this->menuData = $_SESSION['menuData']; + return; + } + + + $sql = e107::getDb(); $sql->select('menus','*','menu_location !=0 ORDER BY menu_location,menu_order'); $data = array(); @@ -533,22 +605,23 @@ class e_layout */ private function renderMenuArea($matches) { - + $frm = e107::getForm(); $area = $matches[1]; // return print_a($this->menuData,true); $text = ""; + // $text .= $frm->button('submit','submit','submit','submit'); + + $text .= $frm->close(); + return $text; } - private function renderMenu($row) + private function renderMenu($row, $area, $count) { // return print_a($row,true); - $TEMPLATE = '
  • '.$row['name'].'
  • '; // TODO perhaps a simple counter for the id + $TEMPLATE = '
  • '.$this->renderMenuOptions($row, $area,$count).'
  • + '; // TODO perhaps a simple counter for the id return $TEMPLATE; } + + + + + private function renderMenuOptions($row,$area,$c) + { + $frm = e107::getForm(); + + $text = $row['name']; + + //TODO Delete, Config etc. + + //$data[$layout][$location][] = array('name'=>$row['menu_name'],'class'=>$row['menu_class'],'path'=>$row['menu_path'],'pages'=>$row['menu_pages'],'parms'=>$row['menu_parms']); + // $area = 'area_'.$area; + + $text .= $frm->hidden('data['.THEME_LAYOUT.']['.$area.']['.$c.'][name]',$row['name'] ); + $text .= $frm->hidden('data['.THEME_LAYOUT.']['.$area.']['.$c.'][class]',$row['class'] ); + $text .= $frm->hidden('data['.THEME_LAYOUT.']['.$area.']['.$c.'][path]',$row['path'] ); + $text .= $frm->hidden('data['.THEME_LAYOUT.']['.$area.']['.$c.'][pages]',$row['pages'] ); + $text .= $frm->hidden('data['.THEME_LAYOUT.']['.$area.']['.$c.'][parms]',$row['parms'] ); + + return $text; + + } + + /** * Scan Plugin folders for new _menu files. @@ -610,11 +714,30 @@ class e_layout { $ns = e107::getRender(); $tp = e107::getParser(); + $frm = e107::getForm(); $TEMPL = $this->getHeadFoot(); $layouts = array_keys($TEMPL['HEADER']); + e107::js('inline',' + $(function() + { + $(".draggable").draggable({ + connectToSortable: $(".sortable"), + helper: "clone", + revert: "invalid", + cursor: "move", + iframeFix: true, + refreshPositions: true + + }); + })' + ); + + + + $text = '"; } + else // Empty Menu. + { + $text .= "
      +
    •  
    • +
    "; + + } $text .= ""; // $text .= $frm->button('submit','submit','submit','submit'); - + + $text .= $frm->hidden('layout',THEME_LAYOUT); + $text .= $frm->hidden('area',$area); $text .= $frm->close(); return $text; @@ -686,7 +711,7 @@ class e_layout private function renderMenu($row, $layout, $area, $count) { // return print_a($row,true); - $TEMPLATE = '
  • '.$this->renderMenuOptions($row, $layout, $area,$count).'
  • + $TEMPLATE = '
  • '.$this->renderMenuOptions($row, $layout, $area,$count).'
  • '; // TODO perhaps a simple counter for the id return $TEMPLATE; @@ -707,20 +732,28 @@ class e_layout $frm = e107::getForm(); $text = str_replace("_menu","",$row['name']); - - - + // $layout = 'layout'; + // $area = 'area'; //TODO Delete, Config etc. //$data[$layout][$location][] = array('name'=>$row['menu_name'],'class'=>$row['menu_class'],'path'=>$row['menu_path'],'pages'=>$row['menu_pages'],'parms'=>$row['menu_parms']); // $area = 'area_'.$area; - $text .= $frm->hidden('data['.$layout.']['.$area.']['.$c.'][name]',$row['name'] ); - $text .= $frm->hidden('data['.$layout.']['.$area.']['.$c.'][class]',$row['class'] ); - $text .= $frm->hidden('data['.$layout.']['.$area.']['.$c.'][path]',$row['path'] ); - $text .= $frm->hidden('data['.$layout.']['.$area.']['.$c.'][pages]',$row['pages'] ); - $text .= $frm->hidden('data['.$layout.']['.$area.']['.$c.'][parms]',$row['parms'] ); - + // 'layout' and 'area' will later be substituted. + $text .= $frm->hidden('data[layout][area]['.$c.'][name]',$row['name'] ); + $text .= $frm->hidden('data[layout][area]['.$c.'][class]',$row['class'] ); + $text .= $frm->hidden('data[layout][area]['.$c.'][path]',$row['path'] ); + $text .= $frm->hidden('data[layout][area]['.$c.'][pages]',$row['pages'] ); + $text .= $frm->hidden('data[layout][area]['.$c.'][parms]',$row['parms'] ); + + + if(vartrue($_GET['configure'])) // Iframe Mode. + { + $text .= "×"; // $('.hello').remove(); + } + + + return $text; } @@ -742,7 +775,7 @@ class e_layout { $path = trim(str_replace(e_PLUGIN,"",$file['path']),"/"); - if(e107::isInstalled($path)) + // if(e107::isInstalled($path) ) { $fname = str_replace(".php","",$file['fname']); $data[$fname] = $path; diff --git a/e107_handlers/menu_class.php b/e107_handlers/menu_class.php index b766428b2..5910bbcf9 100644 --- a/e107_handlers/menu_class.php +++ b/e107_handlers/menu_class.php @@ -63,45 +63,24 @@ class e_menu return; } - $menu_layout_field = THEME_LAYOUT!=e107::getPref('sitetheme_deflayout') ? THEME_LAYOUT : ""; - - // e107::getCache()->CachePageMD5 = md5(e_LANGUAGE.$menu_layout_field); // Disabled by line 93 of Cache class. - //FIXME add a function to the cache class for this. - - $menu_data = e107::getCache()->retrieve_sys("menus_".USERCLASS_LIST."_".md5(e_LANGUAGE.$menu_layout_field)); - // $menu_data = e107::getCache()->retrieve_sys("menus_".USERCLASS_LIST); - $menu_data = e107::getArrayStorage()->ReadArray($menu_data); - - - - $eMenuArea = array(); - // $eMenuList = array(); - // $eMenuActive = array(); // DEPRECATED - if(!is_array($menu_data)) + // print_a($eMenuArea); + if($_SERVER['E_DEV_MENU'] == 'true') + { + $layouts = e107::getPref('menu_layouts'); + if(!is_array($layouts)) { - $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(e107::getDb()->db_Select_gen($menu_qry)) - { - while($row = e107::getDb()->db_Fetch()) - { - $eMenuArea[$row['menu_location']][] = $row; - } - } - $menu_data['menu_area'] = $eMenuArea; - $menuData = e107::getArrayStorage()->WriteArray($menu_data, false); - // e107::getCache()->set_sys('menus_'.USERCLASS_LIST, $menuData); - e107::getCache()->set_sys('menus_'.USERCLASS_LIST.'_'.md5(e_LANGUAGE.$menu_layout_field), $menuData); - } - else - { - $eMenuArea = $menu_data['menu_area']; + $converted = $this->convertMenuTable(); + e107::getConfig('core')->set('menu_layouts', $converted)->save(); } + $eMenuArea = $this->getData(THEME_LAYOUT); + } + //print_a($eMenuArea); + //$eMenuArea = $this->getDataLegacy(); + // print_a($eMenuArea); - // $eMenuArea = $this->getData(THEME_LAYOUT); - $total = array(); foreach($eMenuArea as $area => $val) @@ -128,7 +107,25 @@ class e_menu e107::getRender()->eMenuTotal = $total; } - + /** + * Convert from v1.x e107_menu table to v2.x $pref format. + */ + function convertMenuTable() + { + $sql = e107::getDb(); + + $sql->select('menus','*','menu_location !=0 ORDER BY menu_location,menu_order'); + $data = array(); + + while($row = $sql->fetch()) + { + $layout = vartrue($row['menu_layout'],'default'); + $location = $row['menu_location']; + $data[$layout][$location][] = array('name'=>$row['menu_name'],'class'=>$row['menu_class'],'path'=>$row['menu_path'],'pages'=>$row['menu_pages'],'parms'=>$row['menu_parms']); + } + + return $data; + } @@ -143,7 +140,7 @@ class e_menu foreach($pref[$layout] as $area=>$v); { - $c = 0; + $c = 1; foreach($v as $val) { @@ -155,7 +152,7 @@ class e_menu } $ret[$area][] = array( - + 'menu_id' => $c, 'menu_name' => $val['name'], 'menu_location' => $area, 'menu_class' => $class, @@ -179,6 +176,57 @@ class e_menu + + /** + * @DEPRECATED + * Legacy Function to retrieve Menu data from tables. - ie. the old v1.x method. + */ + private function getDataLegacy() + { + $sql = e107::getDb(); + $menu_layout_field = THEME_LAYOUT!=e107::getPref('sitetheme_deflayout') ? THEME_LAYOUT : ""; + + // e107::getCache()->CachePageMD5 = md5(e_LANGUAGE.$menu_layout_field); // Disabled by line 93 of Cache class. + //FIXME add a function to the cache class for this. + + $menu_data = e107::getCache()->retrieve_sys("menus_".USERCLASS_LIST."_".md5(e_LANGUAGE.$menu_layout_field)); + // $menu_data = e107::getCache()->retrieve_sys("menus_".USERCLASS_LIST); + $menu_data = e107::getArrayStorage()->ReadArray($menu_data); + + $eMenuArea = array(); + // $eMenuList = array(); + // $eMenuActive = array(); // DEPRECATED + + + 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->gen($menu_qry)) + { + while($row = $sql->fetch()) + { + $eMenuArea[$row['menu_location']][] = $row; + } + } + + $menu_data['menu_area'] = $eMenuArea; + + $menuData = e107::getArrayStorage()->WriteArray($menu_data, false); + + // e107::getCache()->set_sys('menus_'.USERCLASS_LIST, $menuData); + e107::getCache()->set_sys('menus_'.USERCLASS_LIST.'_'.md5(e_LANGUAGE.$menu_layout_field), $menuData); + + } + else + { + $eMenuArea = $menu_data['menu_area']; + } + + + + return $eMenuArea; + } From 17bc8896c872d8f59da1bbb77192845a6127c3cd Mon Sep 17 00:00:00 2001 From: Cameron Date: Thu, 9 May 2013 23:14:45 -0700 Subject: [PATCH 09/24] Fix for menu-pref saving. --- e107_admin/menus.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/e107_admin/menus.php b/e107_admin/menus.php index 0765a3795..4c12fb243 100644 --- a/e107_admin/menus.php +++ b/e107_admin/menus.php @@ -628,8 +628,8 @@ class e_layout print_r($save); // return; - - e107::getConfig('core')->set('menu_layouts', $save)->save(); //TODO Save directly into multi-dimensional array. ie. $layout / $area / array. + e107::getConfig('core')->setPref('menu_layouts/'.$layout, $save)->save(); + // e107::getConfig('core')->set('menu_layouts', $save)->save(); //TODO Save directly into multi-dimensional array. ie. $layout / $area / array. } From 94ae8bcd1d7a79753c7bc5032278d8219b6b7f42 Mon Sep 17 00:00:00 2001 From: Cameron Date: Thu, 9 May 2013 23:51:34 -0700 Subject: [PATCH 10/24] Fix for broken banner-menu when no template found in theme folder. --- e107_plugins/banner/banner_menu.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/e107_plugins/banner/banner_menu.php b/e107_plugins/banner/banner_menu.php index c6b8f0d16..5e5eb0b96 100644 --- a/e107_plugins/banner/banner_menu.php +++ b/e107_plugins/banner/banner_menu.php @@ -38,8 +38,9 @@ if(file_exists(THEME.'banner_template.php')) } else { - require_once (e_THEME.'templates/banner_template.php'); + require_once (e_PLUGIN.'banner/banner_template.php'); } + $menu_pref = e107::getConfig('menu')->getPref(''); if(isset($campaign)) From 534861c94956c6225a1740dd370f710b86f1b09f Mon Sep 17 00:00:00 2001 From: Cameron Date: Thu, 9 May 2013 23:52:05 -0700 Subject: [PATCH 11/24] Menu-Manager Drag and Drop fixes. --- e107_admin/menus.php | 14 +++++++++----- e107_handlers/menu_class.php | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/e107_admin/menus.php b/e107_admin/menus.php index 4c12fb243..70c8f2414 100644 --- a/e107_admin/menus.php +++ b/e107_admin/menus.php @@ -499,7 +499,9 @@ class e_layout helper: "clone", appendTo: ".sortable", // "#area-1", //FIXME Needs to be a specific area. revert: true, - + containment: "parent", + delay: 0, + revertDuration: 100, cursor: "move", iframeFix: true, containment: false, @@ -620,7 +622,7 @@ class e_layout $save = array(); foreach($_POST['data']['layout']['area'] as $v) // reset key values. { - $save[$layout][$area][] = $v; + $save[$area][] = $v; } // $save[$layout][$area] = $_POST['data']['layout']['area']; @@ -711,7 +713,9 @@ class e_layout private function renderMenu($row, $layout, $area, $count) { // return print_a($row,true); - $TEMPLATE = '
  • '.$this->renderMenuOptions($row, $layout, $area,$count).'
  • + $uniqueId = "menu_".$row['path'].'_'.$count; + + $TEMPLATE = '
  • '.$this->renderMenuOptions($row, $layout, $area,$count,$uniqueId).'
  • '; // TODO perhaps a simple counter for the id return $TEMPLATE; @@ -727,7 +731,7 @@ class e_layout * @param number $area as in {MENU=x} * @param incrementor number. */ - public function renderMenuOptions($row, $layout, $area, $c) + public function renderMenuOptions($row, $layout, $area, $c, $uniqueId) { $frm = e107::getForm(); @@ -749,7 +753,7 @@ class e_layout if(vartrue($_GET['configure'])) // Iframe Mode. { - $text .= "×"; // $('.hello').remove(); + $text .= "×"; // $('.hello').remove(); } diff --git a/e107_handlers/menu_class.php b/e107_handlers/menu_class.php index 5910bbcf9..4b01f392a 100644 --- a/e107_handlers/menu_class.php +++ b/e107_handlers/menu_class.php @@ -121,7 +121,7 @@ class e_menu { $layout = vartrue($row['menu_layout'],'default'); $location = $row['menu_location']; - $data[$layout][$location][] = array('name'=>$row['menu_name'],'class'=>$row['menu_class'],'path'=>$row['menu_path'],'pages'=>$row['menu_pages'],'parms'=>$row['menu_parms']); + $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']); } return $data; From d1780270eb3980424669c1462c010e4b1a084451 Mon Sep 17 00:00:00 2001 From: Cameron Date: Thu, 9 May 2013 23:59:37 -0700 Subject: [PATCH 12/24] Menu-Manager delete-menu fix. --- e107_admin/menus.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/e107_admin/menus.php b/e107_admin/menus.php index 70c8f2414..6392ed32e 100644 --- a/e107_admin/menus.php +++ b/e107_admin/menus.php @@ -521,9 +521,15 @@ class e_layout { var deleteId = $(this).attr("data-delete"); var area = $(this).attr("data-area"); - $("#"+deleteId).hide("slow"); - $("#"+deleteId).remove(); + $("#"+deleteId).hide("slow", function(){ + $("#"+deleteId).remove(); + }); + + + // $("#"+deleteId).remove(); // alert(deleteId + " " + area); + + saveData(area); }); @@ -713,7 +719,8 @@ class e_layout private function renderMenu($row, $layout, $area, $count) { // return print_a($row,true); - $uniqueId = "menu_".$row['path'].'_'.$count; + $frm = e107::getForm(); + $uniqueId = "menu_".$frm->name2id($row['path']).'_'.$count; $TEMPLATE = '
  • '.$this->renderMenuOptions($row, $layout, $area,$count,$uniqueId).'
  • '; // TODO perhaps a simple counter for the id From b61b3cd4bd8c76ab0354ce50d46d71245e0c6b52 Mon Sep 17 00:00:00 2001 From: Cameron Date: Fri, 10 May 2013 00:13:32 -0700 Subject: [PATCH 13/24] Fix for custom menus and better filtering on available menus. --- e107_admin/menus.php | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/e107_admin/menus.php b/e107_admin/menus.php index 6392ed32e..f88b81726 100644 --- a/e107_admin/menus.php +++ b/e107_admin/menus.php @@ -383,7 +383,13 @@ if($_SERVER['E_DEV_MENU'] == 'true') $text .= "
  • "; // $text .= $row['menu_name']; - $text .= e_layout::renderMenuOptions($row); + $defaults = array( + 'name' => $row['menu_name'], + 'path' => $row['page_id'], + 'class' => '0' + ); + + $text .= e_layout::renderMenuOptions($defaults,'layout','area',$c); $text .= "
  • "; } @@ -784,9 +790,23 @@ class e_layout foreach($files as $file) { - $path = trim(str_replace(e_PLUGIN,"",$file['path']),"/"); + $valid_menu = false; - // if(e107::isInstalled($path) ) + if (file_exists($file['path'].'/plugin.xml') || file_exists($file['path'].'/plugin.php')) + { + if (e107::isInstalled($parent_dir)) + { + $valid_menu = TRUE; // Whether new or existing, include in list + } + } + else // Just add the menu anyway + { + $valid_menu = TRUE; + } + + $path = trim(str_replace(e_PLUGIN,"",$file['path']),"/"); + + if($valid_menu) { $fname = str_replace(".php","",$file['fname']); $data[$fname] = $path; From 16af1a3b11a2f7ed62ac1fcae2c53d7a356bf135 Mon Sep 17 00:00:00 2001 From: Cameron Date: Fri, 10 May 2013 02:46:09 -0700 Subject: [PATCH 14/24] Removed commented-out code. --- e107_handlers/menu_class.php | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/e107_handlers/menu_class.php b/e107_handlers/menu_class.php index 4b01f392a..65dba9f55 100644 --- a/e107_handlers/menu_class.php +++ b/e107_handlers/menu_class.php @@ -65,22 +65,23 @@ class e_menu - // print_a($eMenuArea); - if($_SERVER['E_DEV_MENU'] == 'true') - { - $layouts = e107::getPref('menu_layouts'); - if(!is_array($layouts)) + // print_a($eMenuArea); + if($_SERVER['E_DEV_MENU'] == 'true') // New in v2.x { - $converted = $this->convertMenuTable(); - e107::getConfig('core')->set('menu_layouts', $converted)->save(); + $layouts = e107::getPref('menu_layouts'); + if(!is_array($layouts)) + { + $converted = $this->convertMenuTable(); + e107::getConfig('core')->set('menu_layouts', $converted)->save(); + } + + $eMenuArea = $this->getData(THEME_LAYOUT); } - - $eMenuArea = $this->getData(THEME_LAYOUT); - } - //print_a($eMenuArea); - //$eMenuArea = $this->getDataLegacy(); - - // print_a($eMenuArea); + else // the old v1.x way. + { + $eMenuArea = $this->getDataLegacy(); + } + $total = array(); foreach($eMenuArea as $area => $val) From b74aff7458c99dbf8220a256426304d0f3e56e86 Mon Sep 17 00:00:00 2001 From: Cameron Date: Fri, 10 May 2013 04:38:04 -0700 Subject: [PATCH 15/24] More Menu-Manager work. --- e107_admin/menus.php | 174 +++++++++++++++++++++-------------- e107_handlers/menu_class.php | 6 ++ 2 files changed, 109 insertions(+), 71 deletions(-) diff --git a/e107_admin/menus.php b/e107_admin/menus.php index f88b81726..b807bf408 100644 --- a/e107_admin/menus.php +++ b/e107_admin/menus.php @@ -301,6 +301,18 @@ if(strpos(e_QUERY, 'configure') !== FALSE || vartrue($_GET['enc'])) color: white; } + + ul.unstyled, ol.unstyled { + margin-left: 0px; + list-style: none outside none; + } + + .pull-right { float: right } + .pull-left { float: left } + + .menuOption { display: none } + + .ui-draggable { background-color: rgb(245, 245, 245); min-width:100px;} ",'jquery'); @@ -308,6 +320,10 @@ if(strpos(e_QUERY, 'configure') !== FALSE || vartrue($_GET['enc'])) } + + + + if($_SERVER['E_DEV_MENU'] == 'true') @@ -422,17 +438,11 @@ class e_layout $ns = e107::getRender(); // $this->convertMenuTable(); - - - $this->menuData = e107::getPref('menu_layouts'); - if(e_AJAX_REQUEST) { - - - + if(varset($_POST['data'])) { $this->processPost(); @@ -442,14 +452,25 @@ class e_layout } - + if(vartrue($_GET['configure'])) //ie Inside the IFRAME. { - + + global $HEADER,$FOOTER,$CUSTOMHEADER,$CUSTOMFOOTER,$style; + + $this->HEADER = $HEADER; + $this->FOOTER = $FOOTER; + $this->CUSTOMHEADER = $CUSTOMHEADER; + $this->CUSTOMFOOTER = $CUSTOMFOOTER; + $this->style = $style; + + + unset($HEADER,$FOOTER,$CUSTOMHEADER,$CUSTOMFOOTER,$style); + + e107::js('url',"http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.1/jquery-ui.min.js"); e107::js('url', "http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.1/themes/base/jquery-ui.css"); - - + e107::js('inline',' $(function() { @@ -467,7 +488,8 @@ class e_layout data: data }).done(function( msg ) { - // alert("POSTED: "+ msg ); + $(".menuOption").show(); + alert("POSTED: "+ msg ); }); } @@ -477,11 +499,11 @@ class e_layout $(".sortable").sortable({ - + connectWith: $("#area-1,#area-2,#area-3,#area-4,#area-5"), revert: true, cursor: "move", distance: 20, - containment: "parent", + // containment: $(".sortable"), update: function(ev,ui) { var areaid = $(this).attr("id"); @@ -503,8 +525,8 @@ class e_layout $( ".draggable", window.top.document).draggable({ connectToSortable: ".sortable", helper: "clone", - appendTo: ".sortable", // "#area-1", //FIXME Needs to be a specific area. - revert: true, + appendTo: $(this), // ".sortable", // "#area-1", //FIXME Needs to be a specific area. + revert: "invalid", containment: "parent", delay: 0, revertDuration: 100, @@ -514,7 +536,7 @@ class e_layout stop: function(e, ui) { //TODO Rename layout and area in the hidden fields to that of the where the menu was dropped. // Figure out positioning magic to determine if e.ui.position is in the iframe // var what = $(this).parent().attr("id"); - + // $(".sortable").draggable( "disable" ); // alert(what); } @@ -559,14 +581,30 @@ class e_layout */ - - - + $this->curLayout = varsettrue($_GET['configure'], $pref['sitetheme_deflayout']); $this->renderLayout($this->curLayout); + + + + } else // Parent - ie. main admin page. { + e107::css('inline'," + .menuOption { display: none } + + "); + + + $theme = e107::getPref('sitetheme'); + require_once(e_THEME.$theme."/theme.php"); + + $this->HEADER = $HEADER; + $this->FOOTER = $FOOTER; + $this->CUSTOMHEADER = $CUSTOMHEADER; + $this->CUSTOMFOOTER = $CUSTOMFOOTER; + $this->style = $style; // XXX HELP _ i don't work with iFrames. // $("#sortable") @@ -606,9 +644,7 @@ class e_layout ','jquery'); */ - - $this->scanForNew(); @@ -617,34 +653,32 @@ class e_layout } - + /** + * Save Menu Pref + */ protected function processPost() { - $cnf = e107::getConfig('core'); - $existing = $cnf->get('menu_layouts'); - - // print_r($existing); - // $data = array_merge($existing,$_POST['data']); - - $data = $_POST['data']; + $cnf = e107::getConfig('core'); + $existing = $cnf->get('menu_layouts'); + $data = $_POST['data']; $layout = $_POST['layout']; $area = $_POST['area']; $save = array(); + + foreach($_POST['data']['layout']['area'] as $v) // reset key values. { - $save[$area][] = $v; + $save[] = $v; } // $save[$layout][$area] = $_POST['data']['layout']['area']; print_r($save); - // return; - - e107::getConfig('core')->setPref('menu_layouts/'.$layout, $save)->save(); - // e107::getConfig('core')->set('menu_layouts', $save)->save(); //TODO Save directly into multi-dimensional array. ie. $layout / $area / array. + e107::getConfig('core')->setPref('menu_layouts/'.$layout."/".$area, $save)->save(); + } @@ -654,15 +688,21 @@ class e_layout * Substitute all {MENU=X} and Render output. */ private function renderLayout($layout='') - { - - global $HEADER,$FOOTER,$style; // included by theme file in class2. + { + $ALL = $this->getHeadFoot(); + + $HEADER = $ALL['HEADER']; + $FOOTER = $ALL['FOOTER']; $tp = e107::getParser(); - + $head = preg_replace_callback("/\{MENU=([\d]{1,3})(:[\w\d]*)?\}/", array($this, 'renderMenuArea'), $HEADER[THEME_LAYOUT]); $foot = preg_replace_callback("/\{MENU=([\d]{1,3})(:[\w\d]*)?\}/", array($this, 'renderMenuArea'), $FOOTER[THEME_LAYOUT]); + global $style; + + $style = $this->style; + echo $tp->parsetemplate($head); // echo "
    MAIN CONTENT
    "; echo $tp->parsetemplate($foot); @@ -685,7 +725,7 @@ class e_layout // return print_a($this->menuData,true); $text = "