';
$text .= "
";
if($sql->select('page','*',"menu_name !='' ORDER BY menu_name"))
{
$text .= "";
}
$text .= "
";
return array('caption'=>'DragNDrop Items','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
// TODO Sorting, visibility, parameters and delete.
// TODO Get THIS http://jsbin.com/odiqi3 working with iFrames!! XXX XXX
class e_layout
{
private $menuData = array();
private $iframe = false;
private $cnt = 0;
function __construct()
{
$pref = e107::getPref();
$ns = e107::getRender();
// $this->convertMenuTable();
$this->menuData = e107::getPref('menu_layouts');
if(e_AJAX_REQUEST)
{
if(varset($_POST['data']))
{
$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;
}
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);
require_once(e_CORE."templates/admin_icons_template.php");
/*
e107::js('inline', "
win = document.getElementById('menu_iframe').contentWindow;
win.jQuery(dragelement,parent.document).draggable({
connectToSortable : $('#sortable')
});
",'jquery');
*/
$this->curLayout = vartrue($_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")
//$("iframe").contents().find(".sortable")
/*
e107::js('inline','
$(function()
{
$( ".sortable" ).sortable({
revert: true
});
$("iframe").load(function(){
var frameid = $("#iframe-default").contents().find(".sortable").attr("id")
$( ".draggable" ).draggable({
connectToSortable: "#" + frameid,
helper: "clone",
revert: "invalid",
cursor: "move",
iframeFix: true
});
});
// $( "ul, li" ).disableSelection();
});
','jquery');
*/
$this->scanForNew();
$this->renderInterface();
}
}
/**
* Save Menu Pref
*/
protected function processPost()
{
$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[] = $v;
}
// $save[$layout][$area] = $_POST['data']['layout']['area'];
echo "\nLAYOUT=".$layout."\n";
echo "AREA=".$area."\n";
//print_r($save);
e107::getConfig('core')->setPref('menu_layouts/'.$layout."/".$area, $save)->save();
}
/**
* Substitute all {MENU=X} and Render output.
*/
private function renderLayout($layout='')
{
$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 "';
foreach($layouts as $title)
{
$text .= '
';
$active = '';
}
$text .= '
';
// $ns->frontend = false;
$ns->tablerender("Menu Layout",$text);
}
private function getHeadFoot()
{
$H = array();
$F = array();
if(is_string($this->HEADER))
{
$H['default'] = $this->HEADER;
$F['default'] = $this->FOOTER;
}
else
{
$H = $this->HEADER;
$F = $this->FOOTER;
}
// 0.6 / 0.7-1.x
if(isset($this->CUSTOMHEADER) && isset($this->CUSTOMHEADER))
{
if(!is_array($this->CUSTOMHEADER))
{
$H['legacyCustom'] = $this->CUSTOMHEADER;
$F['legacyCustom'] = $this->CUSTOMFOOTER;
}
else
{
foreach($this->CUSTOMHEADER as $k=>$v)
{
$H[$k] = $v;
}
foreach($this->CUSTOMFOOTER as $k=>$v)
{
$F[$k] = $v;
}
}
}
return array('HEADER'=>$H, 'FOOTER'=>$F);
}
//$ns = e107::getRender();
}
//include_lan(e_LANGUAGEDIR.e_LANGUAGE.'/admin/lan_'.e_PAGE);
// FIXME - quick temporarry fix for missing icons on menu administration. We need different core style to be included (forced) here - e.g. e107_web/css/admin/sprite.css
if(e_IFRAME) //<-- Check config and delete buttons if modifying
{
//e107::js('core','bootstrap/js/bootstrap.min.js');
//e107::css('core','bootstrap/css/bootstrap.min.css');
e107::css('url','{e_THEME}/bootstrap3/admin_style.css');
}
$e_sub_cat = 'menus';
require_once(e_HANDLER."file_class.php");
require_once(e_HANDLER."menumanager_class.php");
$rs = new form;
$frm = e107::getForm();
$men = new e_menuManager(0); // use 1 for dragdrop.
$mes = e107::getMessage();
if(e_AJAX_REQUEST)
{
if(vartrue($_GET['enc']))
{
$string = base64_decode($_GET['enc']);
parse_str($string,$_GET);
// print_a($_GET);
}
// print_a($_POST);
if(vartrue($_GET['vis']))
{
$text = $men->menuVisibilityOptions();
}
// print_a($_GET);
if(vartrue($_GET['parmsId']))
{
$text = $men->menuInstanceParameters();
}
if(vartrue($_POST['mode']))
{
// print_r($_POST);
// $men->setMenuId($this->menuId);
$text = $men->menuSaveAjax($_POST['mode']);
}
echo $text;
exit;
}
if(isset($_GET['configure']) || isset($_GET['iframe']))
{
//No layout parse when in iframe mod
define('e_IFRAME', true);
}
require_once("auth.php");
if($_POST)
{
e107::getCache()->clear_sys("menus_");
}
//FIXME still used in e_HANDLER.menumanager_class.php
if (vartrue($message) != "")
{
echo $ns -> tablerender('Updated', "