mirror of
https://github.com/e107inc/e107.git
synced 2025-08-04 21:57:51 +02:00
More menu manager work
This commit is contained in:
@@ -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)
|
// 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 Get Drag & Drop Working with the iFrame
|
||||||
// TODO Sorting, visibility, parameters and delete.
|
// TODO Sorting, visibility, parameters and delete.
|
||||||
|
// TODO Get THIS http://jsbin.com/odiqi3 working with iFrames!! XXX XXX
|
||||||
|
|
||||||
class e_layout
|
class e_layout
|
||||||
{
|
{
|
||||||
@@ -394,6 +395,34 @@ class e_layout
|
|||||||
$this->convertMenuTable();
|
$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.
|
if(vartrue($_GET['configure'])) //ie Inside the IFRAME.
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -405,15 +434,36 @@ class e_layout
|
|||||||
$(function()
|
$(function()
|
||||||
{
|
{
|
||||||
|
|
||||||
$( "#sortable" ).sortable({
|
$( ".sortable" ).sortable({
|
||||||
revert: true
|
|
||||||
|
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', "
|
e107::js('inline', "
|
||||||
|
|
||||||
@@ -425,7 +475,7 @@ class e_layout
|
|||||||
",'jquery');
|
",'jquery');
|
||||||
|
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -436,41 +486,55 @@ class e_layout
|
|||||||
{
|
{
|
||||||
|
|
||||||
// XXX HELP _ i don't work with iFrames.
|
// XXX HELP _ i don't work with iFrames.
|
||||||
|
// $("#sortable")
|
||||||
|
//$("iframe").contents().find(".sortable")
|
||||||
|
|
||||||
|
/*
|
||||||
e107::js('inline','
|
e107::js('inline','
|
||||||
$(function()
|
$(function()
|
||||||
{
|
{
|
||||||
$( "#sortable" ).sortable({
|
$( ".sortable" ).sortable({
|
||||||
revert: true
|
revert: true
|
||||||
});
|
});
|
||||||
|
|
||||||
$( ".draggable" ).draggable({
|
$( ".draggable" ).draggable({
|
||||||
connectToSortable: $("#sortable"),
|
connectToSortable: $(".sortable"),
|
||||||
helper: "clone",
|
helper: "clone",
|
||||||
revert: "invalid",
|
revert: "invalid",
|
||||||
cursor: "move",
|
cursor: "move",
|
||||||
iframeFix: true,
|
iframeFix: true
|
||||||
|
|
||||||
start: function(ev,ui)
|
|
||||||
{
|
|
||||||
},
|
|
||||||
drag: function(ev,ui)
|
|
||||||
{
|
|
||||||
|
|
||||||
},
|
|
||||||
stop: function(ev, ui)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
$( "ul, li" ).disableSelection();
|
$( "ul, li" ).disableSelection();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$("#menu_frame").load(function(){
|
||||||
|
$("#menu_frame").contents().find("#sortable").droppable({
|
||||||
|
accept: ".drag",
|
||||||
|
drop: function( event, ui ) {
|
||||||
|
var html = "<div class=\"droptrue\">"+ ui.draggable.html() + "</div>";
|
||||||
|
//alert(html);
|
||||||
|
$(this).append(html);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
','jquery');
|
','jquery');
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
$this->scanForNew();
|
$this->scanForNew();
|
||||||
|
|
||||||
$this->renderInterface();
|
$this->renderInterface();
|
||||||
@@ -483,6 +547,14 @@ class e_layout
|
|||||||
*/
|
*/
|
||||||
function convertMenuTable()
|
function convertMenuTable()
|
||||||
{
|
{
|
||||||
|
if(isset($_SESSION['menuData']))
|
||||||
|
{
|
||||||
|
$this->menuData = $_SESSION['menuData'];
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$sql = e107::getDb();
|
$sql = e107::getDb();
|
||||||
$sql->select('menus','*','menu_location !=0 ORDER BY menu_location,menu_order');
|
$sql->select('menus','*','menu_location !=0 ORDER BY menu_location,menu_order');
|
||||||
$data = array();
|
$data = array();
|
||||||
@@ -533,22 +605,23 @@ class e_layout
|
|||||||
*/
|
*/
|
||||||
private function renderMenuArea($matches)
|
private function renderMenuArea($matches)
|
||||||
{
|
{
|
||||||
|
$frm = e107::getForm();
|
||||||
$area = $matches[1];
|
$area = $matches[1];
|
||||||
|
|
||||||
// return print_a($this->menuData,true);
|
// return print_a($this->menuData,true);
|
||||||
$text = "<div class='menu-panel'>";
|
$text = "<div class='menu-panel'>";
|
||||||
$text .= "<div class='menu-panel-header' title=\"".MENLAN_34."\">Area ".$area."</div>";
|
$text .= "<div class='menu-panel-header' title=\"".MENLAN_34."\">Area ".$area."</div>\n";
|
||||||
|
$text .= $frm->open('form-area-'.$area,'post',e_SELF);
|
||||||
|
|
||||||
|
$count = 0;
|
||||||
if(vartrue($this->menuData[THEME_LAYOUT]) && is_array($this->menuData[THEME_LAYOUT][$area]))
|
if(vartrue($this->menuData[THEME_LAYOUT]) && is_array($this->menuData[THEME_LAYOUT][$area]))
|
||||||
{
|
{
|
||||||
$text .= "<ul id='sortable' class='unstyled'>";
|
$text .= "<ul id='area-".$area."' class='sortable unstyled'>";
|
||||||
|
|
||||||
foreach($this->menuData[THEME_LAYOUT][$area] as $val)
|
foreach($this->menuData[THEME_LAYOUT][$area] as $val)
|
||||||
{
|
{
|
||||||
$text .= $this->renderMenu($val);
|
$text .= $this->renderMenu($val,$area,$count);
|
||||||
|
$count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
$text .= "</ul>";
|
$text .= "</ul>";
|
||||||
@@ -556,22 +629,53 @@ class e_layout
|
|||||||
|
|
||||||
$text .= "</div>";
|
$text .= "</div>";
|
||||||
|
|
||||||
|
// $text .= $frm->button('submit','submit','submit','submit');
|
||||||
|
|
||||||
|
$text .= $frm->close();
|
||||||
|
|
||||||
return $text;
|
return $text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private function renderMenu($row)
|
private function renderMenu($row, $area, $count)
|
||||||
{
|
{
|
||||||
// return print_a($row,true);
|
// return print_a($row,true);
|
||||||
$TEMPLATE = '<li class="regularMenu" id="block-'.$row['name'].'"> '.$row['name'].' </li>'; // TODO perhaps a simple counter for the id
|
$TEMPLATE = '<li class="regularMenu" id="'.$row['name'].'"> '.$this->renderMenuOptions($row, $area,$count).' </li>
|
||||||
|
'; // TODO perhaps a simple counter for the id
|
||||||
|
|
||||||
return $TEMPLATE;
|
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.
|
* Scan Plugin folders for new _menu files.
|
||||||
*/
|
*/
|
||||||
@@ -610,11 +714,30 @@ class e_layout
|
|||||||
{
|
{
|
||||||
$ns = e107::getRender();
|
$ns = e107::getRender();
|
||||||
$tp = e107::getParser();
|
$tp = e107::getParser();
|
||||||
|
$frm = e107::getForm();
|
||||||
|
|
||||||
$TEMPL = $this->getHeadFoot();
|
$TEMPL = $this->getHeadFoot();
|
||||||
|
|
||||||
$layouts = array_keys($TEMPL['HEADER']);
|
$layouts = array_keys($TEMPL['HEADER']);
|
||||||
|
|
||||||
|
e107::js('inline','
|
||||||
|
$(function()
|
||||||
|
{
|
||||||
|
$(".draggable").draggable({
|
||||||
|
connectToSortable: $(".sortable"),
|
||||||
|
helper: "clone",
|
||||||
|
revert: "invalid",
|
||||||
|
cursor: "move",
|
||||||
|
iframeFix: true,
|
||||||
|
refreshPositions: true
|
||||||
|
|
||||||
|
});
|
||||||
|
})'
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$text = '<ul class="nav nav-tabs">';
|
$text = '<ul class="nav nav-tabs">';
|
||||||
|
|
||||||
$active = ' class="active" ';
|
$active = ' class="active" ';
|
||||||
@@ -635,7 +758,7 @@ class e_layout
|
|||||||
{
|
{
|
||||||
$text .= '
|
$text .= '
|
||||||
<div class="tab-pane '.$active.'" id="'.$title.'">
|
<div class="tab-pane '.$active.'" id="'.$title.'">
|
||||||
<iframe id="menu_iframe" class="well" width="100%" scrolling="no" style="width: 100%; height: 6933px; border: 0px none;" src="'.e_ADMIN_ABS.'menus.php?configure='.$title.'"></iframe>
|
<iframe id="iframe-'.$frm->name2id($title).'" class="well" width="100%" scrolling="no" style="width: 100%; height: 6933px; border: 0px none;" src="'.e_ADMIN_ABS.'menus.php?configure='.$title.'"></iframe>
|
||||||
</div>';
|
</div>';
|
||||||
|
|
||||||
$active = '';
|
$active = '';
|
||||||
|
Reference in New Issue
Block a user