From a0d29ff0dca7713288309b58f0917d0771262dbf Mon Sep 17 00:00:00 2001 From: Cameron Date: Thu, 16 May 2013 16:23:24 -0700 Subject: [PATCH] More menu-manager work. --- e107_admin/menus.php | 221 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 214 insertions(+), 7 deletions(-) diff --git a/e107_admin/menus.php b/e107_admin/menus.php index b7615b0b1..fc6756de6 100644 --- a/e107_admin/menus.php +++ b/e107_admin/menus.php @@ -77,9 +77,12 @@ if(strpos(e_QUERY, 'configure') !== FALSE || vartrue($_GET['enc'])) var target = window.parent.$('#e-save-form').attr('action'); var data = window.parent.$('#e-save-form').serialize(); + + alert(data); $.post(target, data ,function(ret) { + alert('Posted: '+ret); var a = $.parseJSON(ret); if(a.error) @@ -94,7 +97,7 @@ if(strpos(e_QUERY, 'configure') !== FALSE || vartrue($_GET['enc'])) window.parent.$('#uiModal').modal('show'); - + return false; }) ; @@ -118,6 +121,7 @@ if(strpos(e_QUERY, 'configure') !== FALSE || vartrue($_GET['enc'])) }).done(function( data ) { + var a = $.parseJSON(data); if(a.error) @@ -470,6 +474,39 @@ class e_layout $this->processPost(); } + + if(vartrue($_GET['enc'])) + { + $string = base64_decode($_GET['enc']); + parse_str($string,$_GET); + } + + if(vartrue($_GET['vis'])) + { + $text = $this->renderVisibilityOptions(); + } + + // print_a($_GET); + + if(vartrue($_GET['parmsId'])) + { + $text = $this->renderInstanceParameters(); + } + + if(vartrue($_POST['mode'])) + { + print_r($_POST); + // $men->setMenuId($this->menuId); + $text = $this->menuSaveAjax($_POST['mode']); + } + + + + echo $text; + + + + exit; } @@ -816,13 +853,16 @@ class e_layout // $area = 'area_'.$area; // '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'] ); + + + + $text .= $frm->hidden('data[layout][area]['.$c.'][name]',$row['name'],array('id'=>'name-'.$area.'-'.$c) ); + $text .= $frm->hidden('data[layout][area]['.$c.'][class]',$row['class'], array('id'=>'class-'.$area.'-'.$c) ); + $text .= $frm->hidden('data[layout][area]['.$c.'][path]',$row['path'], array('id'=>'path-'.$area.'-'.$c) ); + $text .= $frm->hidden('data[layout][area]['.$c.'][pages]',$row['pages'], array('id'=>'pages-'.$area.'-'.$c) ); + $text .= $frm->hidden('data[layout][area]['.$c.'][parms]',$row['parms'], array('id'=>'parms-'.$area.'-'.$c) ); - $visibilityLink = e_SELF."?enc=".base64_encode('lay='.$layout.'&vis='.$c.'&iframe=1'); + $visibilityLink = e_SELF."?enc=".base64_encode('lay='.$layout.'&vis='.$area.'-'.$c.'&iframe=1&class='.$row['class'].'&pages='.$row['pages']); $text .= "×"; // $('.hello').remove(); @@ -863,7 +903,35 @@ class e_layout } + + function menuSaveAjax($mode = null) + { + print_r($_POST); + return; + + if($mode == 'visibility') + { + + $ret = $this->menuSaveVisibility(); + echo json_encode($ret); + return; + } + + + if($mode == 'parms') + { + $ret = $this->menuSaveParameters(); + echo json_encode($ret); + return; + } + + + + print_r($_POST); + return; + + } /** * Scan Plugin folders for new _menu files. @@ -907,9 +975,148 @@ class e_layout } + private function renderVisibilityOptions() + { + if(!vartrue($_GET['vis'])) return; + + // print_a($_GET); + + + $sql = e107::getDb(); + $ns = e107::getRender(); + $frm = e107::getForm(); + + 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($_GET['pages'], 0, 1); + $menu_pages = substr($_GET['pages'], 2); + $menu_pages = str_replace("|", "\n", $menu_pages); + + $text = "
+
+
+ ". MENLAN_7." ".$row['menu_name']." + + + + + +
+ ".MENLAN_4." ". + r_userclass('menu_class', intval($_GET['class']), "off", "public,member,guest,admin,main,classes,nobody")." +
+ "; + + $checked = ($listtype == 1) ? " checked='checked' " : ""; + + $text .= $frm->radio('listtype', 1, $checked, array('label'=>MENLAN_26, 'class'=> 'e-save')); + $text .= "
"; + // $text .= " ".MENLAN_26."
"; + $checked = ($listtype == 2) ? " checked='checked' " : ""; + + $text .= $frm->radio('listtype', 2, $checked, array('label'=>MENLAN_27, 'class'=> 'e-save')); + + + // $text .= " ".MENLAN_27."
"; + + $text .= "
+
+ +
+ + +
+
".MENLAN_28."
+
"; + + $text .= $frm->hidden('mode','visibility'); + $text .= $frm->hidden('menu_id',$_GET['vis']); // is NOT an integer + + /* + $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; + } + + /** + * 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) + */ + private function renderInstanceParameters() + { + 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(); + + // TODO lan + $text = "
+
+
+ Menu parameters ".$row['menu_name']." + + + + +
+ Parameters (query string format): + ".$frm->text('menu_parms', $row['menu_parms'], 900, 'class=e-save span7')." +
"; + /* + + $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; + + } + /** * Render the main area with TABS and iframes. */