issue 70 site map admin developement.

but not yet completed. should be javascript drwaing menu


git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.0@9027 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
ovclas 2011-09-05 07:41:43 +00:00
parent 0c48f083d2
commit 3a7b0a4b64
3 changed files with 69 additions and 54 deletions

View file

@ -6,6 +6,10 @@
**/
class menuAdminController extends menu {
var $menuSrl = null;
var $itemKeyList = array();
var $map = array();
var $checked = array();
/**
* @brief Initialization
@ -247,70 +251,47 @@
**/
function procMenuAdminArrangeItem()
{
$menuSrl = Context::get('menu_srl');
$this->menuSrl = Context::get('menu_srl');
$args->title = Context::get('title');
$parentKeyList = Context::get('parent_key');
$itemKeyList = Context::get('item_key');
debugPrint($parentKeyList);
debugPrint($itemKeyList);
$this->itemKeyList = Context::get('item_key');
// menu name update
/*$args->menu_srl = $menuSrl;
/*$args->menu_srl = $this->menuSrl;
$output = executeQuery('menu.updateMenu', $args);
if(!$output->toBool()) return $output;*/
if(is_array($parentKeyList))
$this->map = array();
foreach($parentKeyList as $no=>$srl)
{
$menuList = array();
foreach($parentKeyList AS $key=>$value)
{
if($value == 0) $menuList[$itemKeyList[$key]] = array();
if ($srl === 0) continue;
if (!is_array($this->map[$srl]))$this->map[$srl] = array();
$this->map[$srl][] = $no;
}
$result = array();
foreach($this->itemKeyList as $srl)
{
if (!$this->checked[$srl]){
unset($target);
$this->checked[$srl] = 1;
$target->node = $srl;
$target->child= array();
while(count($this->map[$srl])){
$this->_setParent($srl, array_shift($this->map[$srl]), $target);
}
$result[] = $target;
}
}
debugPrint($menuList);
exit;
if(is_array($itemKeyList))
if(is_array($result))
{
foreach($itemKeyList AS $key=>$value)
foreach($result AS $key=>$node)
{
if($parentKeyList[$key] != 0)
{
$menuList[$parentKeyList[$key]][$value] = true;
}
$this->_recursiveMoveMenuItem($node);
}
}
debugPrint($menuList);
exit;
// menu item sorting
if(is_array($childKeyList))
{
$menuList = array();
foreach($childKeyList AS $key=>$value)
{
preg_match('/BEGIN_([0-9]*.)/is', $value, $m);
if($m)
{
$menuList[$m[1]] = array();
$parentSrl = $m[1];
}
else $menuList[$parentSrl][$value] = true;
}
/*foreach($menuList AS $key=>$value)
{
if(count($value) > 0)
{
$sourceSrl = 0;
foreach($value AS $key2=>$value2)
{
$this->moveMenuItem($menuSrl, $key, $sourceSrl, $key2, 'move');
$sourceSrl = $key2;
}
}
}*/
}
$this->setMessage('success_updated', 'info');
if(!in_array(Context::getRequestMethod(),array('XMLRPC','JSON'))) {
@ -320,6 +301,34 @@
}
}
function _setParent($parent_srl, $child_index, &$target)
{
$child_srl = $this->itemKeyList[$child_index];
$this->checked[$child_srl] = 1;
$child_node->node = $child_srl;
$child_node->parent_node = $parent_srl;
$child_node->child = array();
$target->child[] = $child_node;
while(count($this->map[$child_srl])){
$this->_setParent($child_srl, array_shift($this->map[$child_srl]), $child_node);
}
//return $target;
}
function _recursiveMoveMenuItem($result)
{
while(count($result->child))
{
unset($node);
$node = array_shift($result->child);
$this->moveMenuItem($this->menuSrl, $node->parent_node, 0, $node->node, 'move');
$this->_recursiveMoveMenuItem($node);
}
}
function moveMenuItem($menu_srl,$parent_srl,$source_srl,$target_srl,$mode){
// Get the original menus
$oMenuAdminModel = &getAdminModel('menu');

View file

@ -103,6 +103,8 @@
{
$oMenuAdminModel = &getAdminModel('menu');
$output = $oMenuAdminModel->getMenus();
$menuList = array();
if(is_array($output))
{
$columnList = array('menu_item_srl', 'parent_srl', 'menu_srl', 'name');
@ -111,12 +113,16 @@
if($value->title == '__XE_ADMIN__') unset($output[$key]);
else
{
$menuItems = $oMenuAdminModel->getMenuItems($value->menu_srl, null, $columnList);
$value->menuItems = $this->_arrangeMenuItem($menuItems->data);
unset($menu);
$value->xml_file = sprintf('./files/cache/menu/%s.xml.php',$value->menu_srl);
//$value->php_file = sprintf('./files/cache/menu/%s.php',$value->menu_srl);
//if(file_exists($value->php_file)) @include($value->php_file);
array_push($menuList, $value->xml_file);
}
}
}
Context::set('menu_list', $output);
Context::set('menu_url_list', $menuList);
// get installed module list
$oModuleModel = &getModel('module');

View file

@ -20,13 +20,13 @@
<li loop="$value->menuItems=>$key2,$value2">
<input type="hidden" name="parent_key[]" value="0" class="_parent_key" />
<input type="hidden" name="item_key[]" value="{$key2}" class="_item_key" />
<a href="#" class="ms">{$value2['name']}</a> <a href="#" class="wPreview" target="_blank">Preview</a>
<a href="#" class="ms">{$value2['name']}</a> {$key2} <a href="#" class="wPreview" target="_blank">Preview</a>
<span class="side"><a href="#editMenu" class="modalAnchor _edit">Edit...</a> | <a href="#delete" class="_delete">Delete</a></span>
<ul cond="$value2['subMenu']>0">
<li loop="$value2['subMenu']=>$key3,$value3">
<input type="hidden" name="parent_key[]" value="{$key2}" class="_parent_key" />
<input type="hidden" name="item_key[]" value="{$key3}" class="_item_key" />
{$value3->name} <a href="#" class="wPreview" target="_blank">Preview</a> <span class="side"><a href="#editMenu" class="modalAnchor _edit">Edit...</a> | <a href="#delete" class="_delete">Delete</a></span>
{$value3->name} {$key3} <a href="#" class="wPreview" target="_blank">Preview</a> <span class="side"><a href="#editMenu" class="modalAnchor _edit">Edit...</a> | <a href="#delete" class="_delete">Delete</a></span>
</li>
</ul>
</li>