mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-05-08 19:42:15 +09:00
issue 2364 develop menu copy function with module copy
git-svn-id: http://xe-core.googlecode.com/svn/branches/maserati@11230 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
3fe93908c5
commit
0e3d957f99
3 changed files with 319 additions and 88 deletions
|
|
@ -22,6 +22,7 @@
|
||||||
<action name="procMenuAdminDeleteItem" type="controller" standalone="true" />
|
<action name="procMenuAdminDeleteItem" type="controller" standalone="true" />
|
||||||
<action name="procMenuAdminMakeXmlFile" type="controller" standalone="true" />
|
<action name="procMenuAdminMakeXmlFile" type="controller" standalone="true" />
|
||||||
<action name="procMenuAdminMoveItem" type="controller" standalone="true" />
|
<action name="procMenuAdminMoveItem" type="controller" standalone="true" />
|
||||||
|
<action name="procMenuAdminCopyItem" type="controller" standalone="true" />
|
||||||
<action name="procMenuAdminArrangeItem" type="controller" standalone="true" />
|
<action name="procMenuAdminArrangeItem" type="controller" standalone="true" />
|
||||||
|
|
||||||
<action name="procMenuAdminUploadButton" type="controller" standalone="true" />
|
<action name="procMenuAdminUploadButton" type="controller" standalone="true" />
|
||||||
|
|
|
||||||
|
|
@ -171,9 +171,15 @@
|
||||||
* Add an item to the menu
|
* Add an item to the menu
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function procMenuAdminInsertItem() {
|
function procMenuAdminInsertItem($source_args = NULL)
|
||||||
|
{
|
||||||
|
$isProc = false;
|
||||||
// List variables to insert
|
// List variables to insert
|
||||||
|
if(!$source_args)
|
||||||
|
{
|
||||||
|
$isProc = true;
|
||||||
$source_args = Context::getRequestVars();
|
$source_args = Context::getRequestVars();
|
||||||
|
}
|
||||||
|
|
||||||
unset($source_args->module);
|
unset($source_args->module);
|
||||||
unset($source_args->act);
|
unset($source_args->act);
|
||||||
|
|
@ -189,6 +195,20 @@
|
||||||
if($source_args->cType == 'CREATE') $source_args->menu_url = $source_args->create_menu_url;
|
if($source_args->cType == 'CREATE') $source_args->menu_url = $source_args->create_menu_url;
|
||||||
else if($source_args->cType == 'SELECT') $source_args->menu_url = $source_args->select_menu_url;
|
else if($source_args->cType == 'SELECT') $source_args->menu_url = $source_args->select_menu_url;
|
||||||
|
|
||||||
|
// Check if already exists
|
||||||
|
$isInsert = false;
|
||||||
|
$oMenuModel = &getAdminModel('menu');
|
||||||
|
if($source_args->menu_item_srl)
|
||||||
|
{
|
||||||
|
$item_info = $oMenuModel->getMenuItemInfo($source_args->menu_item_srl);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!$source_args->menu_item_srl || $item_info->menu_item_srl != $source_args->menu_item_srl)
|
||||||
|
{
|
||||||
|
$source_args->menu_item_srl = getNextSequence();
|
||||||
|
$isInsert = true;
|
||||||
|
}
|
||||||
|
|
||||||
// upload button
|
// upload button
|
||||||
$btnOutput = $this->_uploadButton($source_args);
|
$btnOutput = $this->_uploadButton($source_args);
|
||||||
|
|
||||||
|
|
@ -217,6 +237,22 @@
|
||||||
if($btnOutput['active_btn']) $args->active_btn = $btnOutput['active_btn'];
|
if($btnOutput['active_btn']) $args->active_btn = $btnOutput['active_btn'];
|
||||||
$args->group_srls = $source_args->group_srls;
|
$args->group_srls = $source_args->group_srls;
|
||||||
|
|
||||||
|
if(!$isProc)
|
||||||
|
{
|
||||||
|
if($source_args->normal_btn)
|
||||||
|
{
|
||||||
|
$args->normal_btn = $this->_changeMenuItemSrlInButtonPath($source_args->normal_btn, $source_args->menu_srl, $source_args->menu_item_srl, 'normal');
|
||||||
|
}
|
||||||
|
if($source_args->hover_btn)
|
||||||
|
{
|
||||||
|
$args->hover_btn = $this->_changeMenuItemSrlInButtonPath($source_args->hover_btn, $source_args->menu_srl, $source_args->menu_item_srl, 'hover');
|
||||||
|
}
|
||||||
|
if($source_args->active_btn)
|
||||||
|
{
|
||||||
|
$args->active_btn = $this->_changeMenuItemSrlInButtonPath($source_args->active_btn, $source_args->menu_srl, $source_args->menu_item_srl, 'active');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// if cType is CREATE, create module
|
// if cType is CREATE, create module
|
||||||
if($source_args->cType == 'CREATE' || $source_args->cType == 'SELECT')
|
if($source_args->cType == 'CREATE' || $source_args->cType == 'SELECT')
|
||||||
{
|
{
|
||||||
|
|
@ -264,10 +300,6 @@
|
||||||
if(!$output->toBool()) return new Object(-1, $output->message);
|
if(!$output->toBool()) return new Object(-1, $output->message);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if already exists
|
|
||||||
$oMenuModel = &getAdminModel('menu');
|
|
||||||
$item_info = $oMenuModel->getMenuItemInfo($args->menu_item_srl);
|
|
||||||
|
|
||||||
// button is deleted, db delete
|
// button is deleted, db delete
|
||||||
if($source_args->isNormalDelete == 'Y') $args->normal_btn = '';
|
if($source_args->isNormalDelete == 'Y') $args->normal_btn = '';
|
||||||
if($source_args->isHoverDelete == 'Y') $args->hover_btn = '';
|
if($source_args->isHoverDelete == 'Y') $args->hover_btn = '';
|
||||||
|
|
@ -275,13 +307,15 @@
|
||||||
|
|
||||||
$message = '';
|
$message = '';
|
||||||
// Update if exists
|
// Update if exists
|
||||||
if(!empty($args->menu_item_srl) && $item_info->menu_item_srl == $args->menu_item_srl) {
|
if(!$isInsert)
|
||||||
|
{
|
||||||
$output = executeQuery('menu.updateMenuItem', $args);
|
$output = executeQuery('menu.updateMenuItem', $args);
|
||||||
if(!$output->toBool()) return $output;
|
if(!$output->toBool()) return $output;
|
||||||
$message = 'success_updated';
|
$message = 'success_updated';
|
||||||
|
}
|
||||||
// Insert if not exist
|
// Insert if not exist
|
||||||
} else {
|
else
|
||||||
if(!$args->menu_item_srl) $args->menu_item_srl = getNextSequence();
|
{
|
||||||
$args->listorder = -1*$args->menu_item_srl;
|
$args->listorder = -1*$args->menu_item_srl;
|
||||||
$output = executeQuery('menu.insertMenuItem', $args);
|
$output = executeQuery('menu.insertMenuItem', $args);
|
||||||
if(!$output->toBool()) return $output;
|
if(!$output->toBool()) return $output;
|
||||||
|
|
@ -318,9 +352,12 @@
|
||||||
|
|
||||||
$this->setMessage($message, 'info');
|
$this->setMessage($message, 'info');
|
||||||
|
|
||||||
|
if($isProc)
|
||||||
|
{
|
||||||
$returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'module', 'admin', 'act', 'dispMenuAdminSiteMap', 'menu_srl', $args->menu_srl);
|
$returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'module', 'admin', 'act', 'dispMenuAdminSiteMap', 'menu_srl', $args->menu_srl);
|
||||||
$this->setRedirectUrl($returnUrl);
|
$this->setRedirectUrl($returnUrl);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete menu item(menu of the menu)
|
* Delete menu item(menu of the menu)
|
||||||
|
|
@ -397,7 +434,9 @@
|
||||||
* Move menu items
|
* Move menu items
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function procMenuAdminMoveItem() {
|
function procMenuAdminMoveItem()
|
||||||
|
{
|
||||||
|
//TODO 클라이언트가 넘기는 값을 그냥 사용하면 됨. parent_srl(부모), source_srl(같은 계층의 menu_item_srl), target_srl(나 자신의 menu_item_srl)
|
||||||
$menu_srl = Context::get('menu_srl');
|
$menu_srl = Context::get('menu_srl');
|
||||||
$mode = Context::get('mode');
|
$mode = Context::get('mode');
|
||||||
$parent_srl = Context::get('parent_srl');
|
$parent_srl = Context::get('parent_srl');
|
||||||
|
|
@ -408,6 +447,139 @@
|
||||||
$this->moveMenuItem($menu_srl,$parent_srl,$source_srl,$target_srl,$mode);
|
$this->moveMenuItem($menu_srl,$parent_srl,$source_srl,$target_srl,$mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* cop menu item
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function procMenuAdminCopyItem()
|
||||||
|
{
|
||||||
|
$menuSrl = Context::get('menu_srl');
|
||||||
|
$parentSrl = Context::get('parent_srl');
|
||||||
|
$menuItemSrl = Context::get('menu_item_srl');
|
||||||
|
|
||||||
|
// get menu properies with child menu
|
||||||
|
$phpFile = sprintf("./files/cache/menu/%s.php", $menuSrl);
|
||||||
|
$originMenu = NULL;
|
||||||
|
if(is_readable(FileHandler::getRealPath($phpFile)))
|
||||||
|
{
|
||||||
|
@include($phpFile);
|
||||||
|
|
||||||
|
if(is_array($menu->list))
|
||||||
|
{
|
||||||
|
$this->_searchMenu($menu->list, $menuItemSrl, $originMenu);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// copy the menu item with recursively
|
||||||
|
if(is_array($originMenu))
|
||||||
|
{
|
||||||
|
$this->_copyMenu($menuSrl, $parentSrl, $originMenu);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* search menu_item in full menu with recursively
|
||||||
|
* @param $menuList menu list
|
||||||
|
* @param $menuItemSrl current menu item serial number
|
||||||
|
* @param $originMenu find result menu
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
private function _searchMenu(&$menuList, $menuItemSrl, &$originMenu)
|
||||||
|
{
|
||||||
|
if(array_key_exists($menuItemSrl, $menuList))
|
||||||
|
{
|
||||||
|
$originMenu = $menuList[$menuItemSrl];
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach($menuList AS $key=>$value)
|
||||||
|
{
|
||||||
|
if(count($value['list']) > 0)
|
||||||
|
{
|
||||||
|
$this->_searchMenu($value['list'], $menuItemSrl, $originMenu);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function _copyMenu($menuSrl, $parentSrl, &$originMenu)
|
||||||
|
{
|
||||||
|
$oMenuAdminModel = &getAdminModel('menu');
|
||||||
|
$menuItemInfo = $oMenuAdminModel->getMenuItemInfo($originMenu['node_srl']);
|
||||||
|
|
||||||
|
// default argument setting
|
||||||
|
$args->menu_srl = $menuSrl;
|
||||||
|
$args->parent_srl = $parentSrl;
|
||||||
|
$args->menu_name_key = $originMenu['text'];
|
||||||
|
$args->menu_name = $originMenu['text'];
|
||||||
|
$args->menu_open_window = $originMenu['open_window'];
|
||||||
|
$args->expand = $originMenu['expand'];
|
||||||
|
$args->normal_btn = $menuItemInfo->normal_btn;
|
||||||
|
$args->hover_btn = $menuItemInfo->hover_btn;
|
||||||
|
$args->active_btn = $menuItemInfo->active_btn;
|
||||||
|
|
||||||
|
// if menu have a reference of module instance
|
||||||
|
$isModuleCopySuccess = false;
|
||||||
|
if(!preg_match('/^http/i', $originMenu['url']))
|
||||||
|
{
|
||||||
|
$oModuleModel = &getModel('module');
|
||||||
|
$moduleInfo = $oModuleModel->getModuleInfoByMid($originMenu['url']);
|
||||||
|
|
||||||
|
$args->cType = 'SELECT';
|
||||||
|
$args->module_type = $moduleInfo->module;
|
||||||
|
$args->select_menu_url = $moduleInfo->mid.'_copy';
|
||||||
|
$args->layout_srl = $moduleInfo->layout_srl;
|
||||||
|
|
||||||
|
$oModuleAdminController = &getAdminController('module');
|
||||||
|
$copyArg->module_srl = $moduleInfo->module_srl;
|
||||||
|
$copyArg->mid_1 = $args->select_menu_url;
|
||||||
|
$copyArg->browser_title_1 = $moduleInfo->browser_title;
|
||||||
|
$copiedModuleSrl = $oModuleAdminController->procModuleAdminCopyModule($copyArg);
|
||||||
|
|
||||||
|
$args->module_srl = $copiedModuleSrl;
|
||||||
|
|
||||||
|
if($copiedModuleSrl)
|
||||||
|
{
|
||||||
|
$isModuleCopySuccess = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// if menu type is url
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$args->module_type = 'url';
|
||||||
|
$isModuleCopySuccess = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if($isModuleCopySuccess)
|
||||||
|
{
|
||||||
|
// if have a group permission
|
||||||
|
if($menuItemInfo->group_srls)
|
||||||
|
{
|
||||||
|
$args->group_srls = $menuItemInfo->group_srls;
|
||||||
|
}
|
||||||
|
|
||||||
|
// copy
|
||||||
|
$output = $this->procMenuAdminInsertItem($args);
|
||||||
|
if($output && !$output->toBool())
|
||||||
|
{
|
||||||
|
return $output;
|
||||||
|
}
|
||||||
|
|
||||||
|
// if have a button, copy a button image also
|
||||||
|
$insertedMenuItemSrl = $this->get('menu_item_srl');
|
||||||
|
if($menuItemInfo->normal_btn || $menuItemInfo->hover_btn || $menuItemInfo->active_btn)
|
||||||
|
{
|
||||||
|
$this->_copyButton($insertedMenuItemSrl, $menuItemInfo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// if have a child menu, copy child menu also
|
||||||
|
$childMenu = array_shift($originMenu['list']);
|
||||||
|
if(count($childMenu) > 0)
|
||||||
|
{
|
||||||
|
$this->_copyMenu($menuSrl, $insertedMenuItemSrl, $childMenu);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Arrange menu items
|
* Arrange menu items
|
||||||
* @return void|object
|
* @return void|object
|
||||||
|
|
@ -1111,5 +1283,47 @@
|
||||||
}
|
}
|
||||||
return $returnArray;
|
return $returnArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* When copy a menu, button copied also.
|
||||||
|
* @param $args menuItemInfo with button values
|
||||||
|
*/
|
||||||
|
private function _copyButton($insertedMenuItemSrl, &$menuItemInfo)
|
||||||
|
{
|
||||||
|
//normal_btn
|
||||||
|
if($menuItemInfo->normal_btn)
|
||||||
|
{
|
||||||
|
$originFile = FileHandler::getRealPath($menuItemInfo->normal_btn);
|
||||||
|
$targetFile = $this->_changeMenuItemSrlInButtonPath($menuItemInfo->normal_btn, $menuItemInfo->menu_srl, $insertedMenuItemSrl, 'normal');
|
||||||
|
|
||||||
|
FileHandler::copyFile($originFile, $targetFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
//hover_btn
|
||||||
|
if($menuItemInfo->hover_btn)
|
||||||
|
{
|
||||||
|
$originFile = FileHandler::getRealPath($menuItemInfo->hover_btn);
|
||||||
|
$targetFile = $this->_changeMenuItemSrlInButtonPath($menuItemInfo->hover_btn, $menuItemInfo->menu_srl, $insertedMenuItemSrl, 'hover');
|
||||||
|
|
||||||
|
FileHandler::copyFile($originFile, $targetFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
//active_btn
|
||||||
|
if($menuItemInfo->active_btn)
|
||||||
|
{
|
||||||
|
$originFile = FileHandler::getRealPath($menuItemInfo->active_btn);
|
||||||
|
$targetFile = $this->_changeMenuItemSrlInButtonPath($menuItemInfo->active_btn, $menuItemInfo->menu_srl, $insertedMenuItemSrl, 'active');
|
||||||
|
|
||||||
|
FileHandler::copyFile($originFile, $targetFile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function _changeMenuItemSrlInButtonPath($buttonPath, $menuSrl, $menuItemSrl, $mode)
|
||||||
|
{
|
||||||
|
$path = sprintf('./files/attach/menu_button/%d/', $menuSrl);
|
||||||
|
$tmp_arr = explode('.', $buttonPath);
|
||||||
|
$ext = $tmp_arr[count($tmp_arr)-1];
|
||||||
|
return sprintf('%s%d.%s.%s', $path, $menuItemSrl, 'menu_'.$mode.'_btn', $ext);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
|
|
@ -73,14 +73,25 @@
|
||||||
/**
|
/**
|
||||||
* @brief Copy Module
|
* @brief Copy Module
|
||||||
**/
|
**/
|
||||||
function procModuleAdminCopyModule()
|
function procModuleAdminCopyModule($args = NULL)
|
||||||
{
|
{
|
||||||
|
$isProc = false;
|
||||||
|
if(!$args)
|
||||||
|
{
|
||||||
|
$isProc = true;
|
||||||
// Get information of the target module to copy
|
// Get information of the target module to copy
|
||||||
$module_srl = Context::get('module_srl');
|
$module_srl = Context::get('module_srl');
|
||||||
|
$args = Context::getRequestVars();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$module_srl = $args->module_srl;
|
||||||
|
}
|
||||||
|
|
||||||
if(!$module_srl) return;
|
if(!$module_srl) return;
|
||||||
|
|
||||||
// Get module name to create and browser title
|
// Get module name to create and browser title
|
||||||
$clones = array();
|
$clones = array();
|
||||||
$args = Context::getAll();
|
|
||||||
for($i=1;$i<=10;$i++) {
|
for($i=1;$i<=10;$i++) {
|
||||||
$mid = trim($args->{"mid_".$i});
|
$mid = trim($args->{"mid_".$i});
|
||||||
if(!$mid) continue;
|
if(!$mid) continue;
|
||||||
|
|
@ -206,6 +217,8 @@
|
||||||
$this->setMessage('success_registed');
|
$this->setMessage('success_registed');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if($isProc)
|
||||||
|
{
|
||||||
if(!in_array(Context::getRequestMethod(),array('XMLRPC','JSON'))) {
|
if(!in_array(Context::getRequestMethod(),array('XMLRPC','JSON'))) {
|
||||||
global $lang;
|
global $lang;
|
||||||
htmlHeader();
|
htmlHeader();
|
||||||
|
|
@ -218,6 +231,9 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return $module_srl;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Save the module permissions
|
* @brief Save the module permissions
|
||||||
**/
|
**/
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue