42 private $homeModuleMid = NULL;
47 private $homeMenuCacheFile =
'files/cache/menu/homeSitemap.php';
59 $this->homeMenuCacheFile =
_XE_PATH_ . $this->homeMenuCacheFile;
74 $this->
add(
'menu_srl',
$output->get(
'menuSrl'));
88 public function addMenu($title, $siteSrl = 0)
90 $args =
new stdClass();
91 $args->site_srl = $siteSrl;
92 $args->title = $title;
109 $unlinked_modules =
false;
110 $args =
new stdClass;
115 $unlinked_modules =
$output->data;
118 if($unlinked_modules)
132 if($moduleConfig->unlinked_menu_srl)
134 $menuArgs =
new stdClass;
135 $menuArgs->menu_srl = $moduleConfig->unlinked_menu_srl;
137 if(!$menuOutput->data)
139 unset($moduleConfig->unlinked_menu_srl);
143 if(!$moduleConfig->unlinked_menu_srl)
148 $moduleConfig->unlinked_menu_srl =
$output->get(
'menuSrl');
158 return $moduleConfig->unlinked_menu_srl;
171 if(!$moduleInfos || !is_array($moduleInfos) || count($moduleInfos) == 0 ||
$menuSrl == 0)
173 return new BaseObject(-1,
'msg_invalid_request');
179 $args =
new stdClass;
180 $args->url = $moduleInfo->mid;
181 $args->site_srl = $moduleInfo->site_srl;
182 $args->is_shortcut =
'N';
188 $moduleInfo->menu_srl =
$output->data->menu_srl;
194 $item_args->url = $moduleInfo->mid;
195 $item_args->name = $moduleInfo->mid;
197 $item_args->listorder = -1*$item_args->menu_item_srl;
213 if($oCacheHandler->isSupport())
215 $oCacheHandler->invalidateGroupKey(
'site_and_module');
233 $args =
new stdClass();
255 $menuInfo = $oMenuAdminModel->getMenu($menu_srl);
258 if($menuInfo->title == $oAdmin->getAdminMenuName())
259 return new BaseObject(-1,
'msg_adminmenu_cannot_delete');
262 $phpFile = sprintf(
"./files/cache/menu/%s.php", $menu_srl);
274 $isStartmenuInclude =
false;
276 if(is_array($menu->list))
278 foreach($menu->list AS $key=>$value)
280 $originMenu = $value;
281 $this->_checkHomeMenuInOriginMenu($originMenu, $siteInfo->mid, $isStartmenuInclude);
283 if($isStartmenuInclude)
288 if($isStartmenuInclude)
290 return new BaseObject(-1,
'msg_cannot_delete_homemenu');
314 $args =
new stdClass();
315 $args->menu_srl = $menu_srl;
318 $menuInfo = $oMenuAdminModel->getMenu(
$args->menu_srl);
330 foreach(
$output->data as $itemInfo)
332 if($itemInfo->is_shortcut !=
'Y' && strncasecmp(
'http', $itemInfo->url, 4) !== 0)
364 if(count($cache_list))
366 foreach($cache_list as $cache_file)
368 $pos = strpos($cache_file, $menu_srl.
'.');
373 $image_path = sprintf(
'./files/attach/menu_button/%s', $menu_srl);
394 if(!$request->parent_srl || !$request->menu_name)
396 return new BaseObject(-1,
'msg_invalid_request');
399 $this->_setMenuSrl($request->parent_srl, $request->menu_srl);
400 if(!$request->menu_srl)
402 return new BaseObject(-1,
'msg_invalid_request');
405 if($request->is_shortcut ==
'Y')
407 $result = $this->_insertShortcut($request);
411 $result = $this->_insertMenu($request, $isProc);
414 if($result->error < 0)
416 return new BaseObject($result->error, $result->message);
424 return $this->
get(
'menu_item_srl');
428 private function _setMenuSrl(&$parent_srl, &$menu_srl)
432 $itemInfo = $oMenuAdminModel->getMenuItemInfo($parent_srl);
434 if($itemInfo->menu_srl)
436 $menu_srl = $itemInfo->menu_srl;
441 $output = $oMenuAdminModel->getMenu($parent_srl);
442 if(
$output->menu_srl == $parent_srl)
450 private function _insertShortcut(&$request)
456 if(strncasecmp(
'http', $request->shortcut_target, 4) === 0 || preg_match(
'/^(\.\/|\.\.\/|\/).*$/', $request->shortcut_target))
459 $args =
new stdClass();
460 $args->menu_srl = $request->menu_srl;
461 $args->parent_srl = $request->parent_srl;
462 $args->open_window = $request->menu_open_window;
463 $args->expand = $request->menu_expand;
464 $args->is_shortcut = $request->is_shortcut;
465 $args->url = $request->shortcut_target;
467 if(!
$args->open_window)
$args->open_window =
'N';
469 if(!
$args->is_shortcut)
$args->is_shortcut =
'Y';
471 if($request->menu_name_key)
$args->name = $request->menu_name_key;
472 else $args->name = $request->menu_name;
475 else if(is_numeric($request->shortcut_target))
479 $itemInfo = $oMenuAdminModel->getMenuItemInfo($request->shortcut_target);
480 if(!$itemInfo->menu_item_srl)
482 return new BaseObject(-1,
'msg_invalid_request');
484 unset($itemInfo->normal_btn, $itemInfo->hover_btn, $itemInfo->active_btn);
487 if(count(
$args->group_srls) == 0)
489 unset(
$args->group_srls);
491 $args->menu_srl = $request->menu_srl;
492 $args->name = $request->menu_name;
493 $args->parent_srl = $request->parent_srl;
494 $args->is_shortcut = $request->is_shortcut;
499 $args =
new stdClass();
500 $args->menu_srl = $request->menu_srl;
501 $args->name = $request->menu_name;
502 $args->parent_srl = $request->parent_srl;
503 $args->is_shortcut = $request->is_shortcut;
507 if($request->menu_desc)
$args->desc = $request->menu_desc;
508 else $args->desc =
'';
517 $this->
add(
'menu_item_srl',
$args->menu_item_srl);
518 $this->
setMessage(
'success_registed',
'info');
521 private function _insertMenu(&$request, $isProc)
527 $args =
new stdClass();
528 $args->menu_srl = $request->menu_srl;
529 $args->parent_srl = $request->parent_srl;
530 $args->open_window = $request->menu_open_window;
531 $args->expand = $request->menu_expand;
532 $args->expand = $request->menu_expand;
533 $args->is_shortcut = $request->is_shortcut;
535 if(!
$args->open_window)
$args->open_window =
'N';
537 if(!
$args->is_shortcut)
$args->is_shortcut =
'N';
539 if($request->menu_name_key)
$args->name = $request->menu_name_key;
540 else $args->name = $request->menu_name;
542 if($request->menu_desc)
$args->desc = $request->menu_desc;
543 else $args->desc =
'';
545 if($request->module_id && strncasecmp(
'http', $request->module_id, 4) === 0)
547 return new BaseObject(-1,
'msg_invalid_request');
553 $result = $this->_insertModule($request,
$args);
554 if(!$result->toBool())
561 if($request->normal_btn)
$args->normal_btn = $request->normal_btn;
562 if($request->hover_btn)
$args->hover_btn = $request->hover_btn;
563 if($request->active_btn)
$args->active_btn = $request->active_btn;
565 if(!$request->module_id)
567 return new BaseObject(-1,
'msg_invalid_request');
570 $args->url = $request->module_id;
578 $this->
add(
'menu_item_srl',
$args->menu_item_srl);
579 $this->
setMessage(
'success_registed',
'info');
588 private function _insertModule(&$request, &
$args)
590 $cmArgs =
new stdClass();
591 switch ($request->module_type)
596 $cmArgs->module =
'page';
597 $cmArgs->page_type = $request->module_type;
600 $cmArgs->module = $request->module_type;
601 unset($cmArgs->page_type);
606 $cmArgs->site_srl = (int)$site_module_info->site_srl;
607 $cmArgs->browser_title =
$args->name;
608 $cmArgs->menu_srl = $request->menu_srl;
609 $cmArgs->layout_srl = -1;
610 $cmArgs->mlayout_srl = -1;
611 $cmArgs->is_skin_fix =
'N';
612 $cmArgs->is_mskin_fix =
'N';
616 $cmArgs->use_mobile =
'Y';
620 if(!$request->module_id)
622 $randomMid = $this->_makeRandomMid();
623 $request->module_id = $cmArgs->module.
'_'.$randomMid;
625 $cmArgs->mid = $request->module_id;
632 return new BaseObject(-1,
'msg_module_name_exists');
649 if(!$request->menu_item_srl || !$request->menu_name)
651 return new BaseObject(-1,
'msg_invalid_request');
655 if($request->menu_open_window !=
"Y") $request->menu_open_window =
"N";
656 if($request->menu_expand !=
"Y") $request->menu_expand =
"N";
660 $itemInfo = $oMenuAdminModel->getMenuItemInfo($request->menu_item_srl);
664 if($itemInfo->is_shortcut ==
'Y')
667 if(strncasecmp(
'http', $request->shortcut_target, 4) === 0 || preg_match(
'/^(\.\/|\.\.\/|\/).*$/', $request->shortcut_target))
669 $args->url = $request->shortcut_target;
672 else if(is_numeric($request->shortcut_target))
675 $newItemInfo = $oMenuAdminModel->getMenuItemInfo($request->shortcut_target);
676 if(!$newItemInfo->menu_item_srl)
678 return new BaseObject(-1,
'msg_invalid_request');
681 $args->url = $newItemInfo->url;
682 $args->is_shortcut =
'Y';
693 if($request->module_id != $itemInfo->url)
698 return new BaseObject(-1,
'msg_module_name_exists');
706 return new BaseObject(-1,
'msg_invalid_request');
710 if($request->browser_title)
712 $moduleInfo->browser_title = $request->browser_title;
716 $args->url = $request->module_id;
719 if($request->menu_name_key)
721 $args->name = $request->menu_name_key;
725 $args->name = $request->menu_name;
728 if($request->menu_desc)
$args->desc = $request->menu_desc;
729 else $args->desc =
'';
731 unset(
$args->group_srls);
732 $args->open_window = $request->menu_open_window;
733 $args->expand = $request->menu_expand;
738 $this->
add(
'menu_item_srl',
$args->menu_item_srl);
751 $item_info = $oMenuAdminModel->getMenuItemInfo(
$args->menu_item_srl);
752 $args->menu_srl = $item_info->menu_srl;
756 if($btnOutput[
'normal_btn'])
758 $this->
add(
'normal_btn', $btnOutput[
'normal_btn']);
759 $item_info->normal_btn = $btnOutput[
'normal_btn'];
761 if($btnOutput[
'hover_btn'])
763 $this->
add(
'hover_btn', $btnOutput[
'hover_btn']);
764 $item_info->hover_btn = $btnOutput[
'hover_btn'];
766 if($btnOutput[
'active_btn'])
768 $this->
add(
'active_btn', $btnOutput[
'active_btn']);
769 $item_info->active_btn = $btnOutput[
'active_btn'];
773 if(count($item_info->group_srls) == 0)
775 unset($item_info->group_srls);
779 if(!$btnOutput[
'normal_btn'] &&
$args->isNormalDelete ==
'Y')
781 $item_info->normal_btn =
'';
783 if(!$btnOutput[
'hover_btn'] &&
$args->isHoverDelete ==
'Y')
785 $item_info->hover_btn =
'';
787 if(!$btnOutput[
'active_btn'] &&
$args->isActiveDelete ==
'Y')
789 $item_info->active_btn =
'';
821 $args =
new stdClass();
827 if(is_object($returnObj))
852 $itemInfo = $oMenuAdminModel->getMenuItemInfo(
$args->menu_item_srl);
853 $args->menu_srl = $itemInfo->menu_srl;
856 if(
$args->is_force !=
'Y')
862 return new BaseObject(-1001,
'msg_cannot_delete_for_child');
867 $menuInfo = $oMenuAdminModel->getMenu(
$args->menu_srl);
868 $menu_title = $menuInfo->title;
872 if($menu_title == $oAdmin->getAdminMenuName() && $itemInfo->parent_srl == 0)
874 return $this->
stop(
'msg_cannot_delete_for_admin_topmenu');
877 if($itemInfo->parent_srl) $parent_srl = $itemInfo->parent_srl;
880 $phpFile = sprintf(
"./files/cache/menu/%s.php",
$args->menu_srl);
887 if(is_array($menu->list))
889 $this->_searchMenu($menu->list,
$args->menu_item_srl, $originMenu);
895 $isStartmenuInclude =
false;
896 $this->_checkHomeMenuInOriginMenu($originMenu, $siteInfo->mid, $isStartmenuInclude);
897 if($isStartmenuInclude)
899 return new BaseObject(-1,
'msg_cannot_delete_homemenu');
905 $this->_recursiveDeleteMenuItem($oDB, $menuInfo, $originMenu);
912 $this->
add(
'xml_file', $xml_file);
913 $this->
add(
'menu_title', $menu_title);
914 $this->
add(
'menu_item_srl', $parent_srl);
919 private function _checkHomeMenuInOriginMenu($originMenu, $startMid, &$isStartmenuInclude)
921 if($originMenu[
'is_shortcut'] !=
'Y' && $originMenu[
'url'] == $startMid)
923 $isStartmenuInclude =
true;
926 if(!$isStartmenuInclude && is_array($originMenu[
'list']))
928 foreach($originMenu[
'list'] AS $key=>$value)
930 $this->_checkHomeMenuInOriginMenu($value, $startMid, $isStartmenuInclude);
935 private function _deleteMenuItem(&$oDB, &$menuInfo, $node)
938 $args =
new stdClass();
940 $args->menu_item_srl = $node[
'node_srl'];
956 if($node[
'is_shortcut'] !=
'Y' && strncasecmp(
'http', $node[
'url'], 4) !== 0)
962 $args->url = $node[
'url'];
963 $args->site_srl = $menuInfo->site_srl;
964 $args->is_shortcut =
'Y';
966 if(
$output->data->menu_item_srl)
969 $referenceItem =
$output->data;
992 private function _recursiveDeleteMenuItem(&$oDB, &$menuInfo, $node)
994 $output = $this->_deleteMenuItem($oDB, $menuInfo, $node);
1000 if(is_array($node[
'list']))
1002 foreach($node[
'list'] AS $key=>$value)
1004 $this->_recursiveDeleteMenuItem($oDB, $menuInfo, $value);
1020 if(!$mode || !$parent_srl || !$target_srl)
return new BaseObject(-1,
'msg_invalid_request');
1025 $originalItemInfo = $oMenuAdminModel->getMenuItemInfo($target_srl);
1026 if(!$originalItemInfo->menu_item_srl)
1028 return new BaseObject(-1,
'msg_empty_menu_item');
1032 $phpFile = sprintf(
_XE_PATH_ .
"files/cache/menu/%s.php", $originalItemInfo->menu_srl);
1039 if(is_array($menu->list))
1041 $this->_searchMenu($menu->list, $originalItemInfo->menu_item_srl, $originMenu);
1046 $targetMenuItemInfo = $oMenuAdminModel->getMenuItemInfo($parent_srl);
1048 if($targetMenuItemInfo->menu_item_srl)
1050 $menu_srl = $targetMenuItemInfo->menu_srl;
1055 $targetMenuInfo = $oMenuAdminModel->getMenu($parent_srl);
1056 $menu_srl = $targetMenuInfo->menu_srl;
1060 if(!$this->homeModuleMid)
1064 $columnList = array(
'modules.mid',);
1068 $this->homeModuleMid =
$output->mid;
1072 $this->
moveMenuItem($menu_srl, $parent_srl, $source_srl, $target_srl, $mode, $originMenu[
'is_shortcut'], $originMenu[
'url']);
1073 if(count($originMenu[
'list']) > 0)
1075 $this->_recursiveUpdateMenuItem($originMenu[
'list'], $menu_srl);
1079 $xml_file = $this->
makeXmlFile($originalItemInfo->menu_srl);
1085 private function _recursiveUpdateMenuItem($node, $menu_srl)
1089 foreach($node AS $key=>$node)
1091 $args =
new stdClass();
1092 $args->menu_srl = $menu_srl;
1093 $args->menu_item_srl = $node[
'node_srl'];
1097 if($node[
'is_shortcut'] ==
'N' && !empty($node[
'url']))
1109 if(count($node[
'list']) > 0)
1111 $this->_recursiveUpdateMenuItem($node[
'list'], $menu_srl);
1127 $itemInfo = $oMenuModel->getMenuItemInfo($menuItemSrl);
1138 if(is_array($menu->list))
1140 $this->_searchMenu($menu->list, $menuItemSrl, $originMenu);
1145 if(is_array($originMenu))
1147 $this->_copyMenu(
$menuSrl, $parentSrl, $originMenu);
1149 $this->
add(
'insertedMenuItemSrlList', $this->insertedMenuItemSrlList);
1159 private function _searchMenu(&$menuList, $menuItemSrl, &$originMenu)
1161 if(array_key_exists($menuItemSrl, $menuList))
1163 $originMenu = $menuList[$menuItemSrl];
1167 foreach($menuList AS $key=>$value)
1169 if(count($value[
'list']) > 0)
1171 $this->_searchMenu($value[
'list'], $menuItemSrl, $originMenu);
1176 private function _copyMenu(
$menuSrl, $parentSrl, &$originMenu)
1179 $menuItemInfo = $oMenuAdminModel->getMenuItemInfo($originMenu[
'node_srl']);
1182 $args =
new stdClass();
1185 else $args->parent_srl = $parentSrl;
1186 $args->menu_name_key = $originMenu[
'text'];
1187 $args->menu_name = $originMenu[
'text'];
1188 $args->menu_open_window = $originMenu[
'open_window'];
1189 $args->menu_expand = $originMenu[
'expand'];
1190 $args->normal_btn = $menuItemInfo->normal_btn;
1191 $args->hover_btn = $menuItemInfo->hover_btn;
1192 $args->active_btn = $menuItemInfo->active_btn;
1193 $args->is_shortcut = $menuItemInfo->is_shortcut;
1195 $isModuleCopySuccess =
false;
1197 if($menuItemInfo->is_shortcut ==
'N' && strncasecmp(
'http', $originMenu[
'url'], 4) !== 0 )
1203 $randomMid = $this->_makeRandomMid();
1208 $copyArg =
new stdClass();
1210 $copyArg->mid_1 =
$args->module_id;
1211 $copyArg->browser_title_1 =
$moduleInfo->browser_title;
1212 $copyArg->isMenuCreate = FALSE;
1213 $copiedModuleSrl = $oModuleAdminController->procModuleAdminCopyModule($copyArg);
1215 $args->module_srl = $copiedModuleSrl;
1217 if($copiedModuleSrl)
1219 $isModuleCopySuccess =
true;
1223 else if($menuItemInfo->is_shortcut ==
'Y')
1225 $args->shortcut_target = $originMenu[
'url'];
1226 $isModuleCopySuccess =
true;
1229 if($isModuleCopySuccess)
1232 if($menuItemInfo->group_srls)
1234 $args->group_srls = $menuItemInfo->group_srls;
1245 $insertedMenuItemSrl = $this->
get(
'menu_item_srl');
1246 if($menuItemInfo->normal_btn || $menuItemInfo->hover_btn || $menuItemInfo->active_btn)
1249 $update_item_info = $oMenuAdminModel->getMenuItemInfo($insertedMenuItemSrl);
1250 $copied_info = $this->_copyButton($insertedMenuItemSrl,$update_item_info->menu_srl, $menuItemInfo);
1251 if(count($update_item_info->group_srls) == 0)
1253 unset($update_item_info->group_srls);
1255 $update_item_info->normal_btn = $copied_info[
'normal_btn'];
1256 $update_item_info->hover_btn = $copied_info[
'hover_btn'];
1257 $update_item_info->active_btn = $copied_info[
'active_btn'];
1260 $this->insertedMenuItemSrlList[] = $insertedMenuItemSrl;
1264 $childMenu = array_shift($originMenu[
'list']);
1265 if(count($childMenu) > 0)
1267 $this->_copyMenu(
$menuSrl, $insertedMenuItemSrl, $childMenu);
1271 private function _makeRandomMid()
1273 $time = $_SERVER[
'REQUEST_TIME'];
1278 if($case) $doc = rand(65, 90);
1279 else $doc = rand(97, 122);
1281 $randomString .= chr($doc);
1284 return $randomString.substr($time, -2);
1294 $args =
new stdClass();
1304 $this->map = array();
1305 if(is_array($parentKeyList))
1307 foreach($parentKeyList as $no=>$srl)
1309 if($srl === 0)
continue;
1310 if(!is_array($this->map[$srl]))$this->map[$srl] = array();
1311 $this->map[$srl][] = $no;
1316 if(is_array($this->itemKeyList))
1318 foreach($this->itemKeyList as $srl)
1320 if(!$this->checked[$srl])
1322 $target =
new stdClass();
1323 $this->checked[$srl] = 1;
1324 $target->node = $srl;
1325 $target->child= array();
1327 while(count($this->map[$srl]))
1329 $this->
_setParent($srl, array_shift($this->map[$srl]), $target);
1331 $result[] = $target;
1336 if(is_array($result))
1339 foreach($result AS $key=>$node)
1341 $this->
moveMenuItem($this->menuSrl, 0, $i, $node->node,
'move');
1347 $this->
setMessage(
'success_updated',
'info');
1362 $child_srl = $this->itemKeyList[$child_index];
1363 $this->checked[$child_srl] = 1;
1365 $child_node =
new stdClass();
1366 $child_node->node = $child_srl;
1367 $child_node->parent_node = $parent_srl;
1368 $child_node->child = array();
1369 $target->child[] = $child_node;
1371 while(count($this->map[$child_srl]))
1373 $this->
_setParent($child_srl, array_shift($this->map[$child_srl]), $child_node);
1386 while(count($result->child))
1389 $node = array_shift($result->child);
1391 $this->
moveMenuItem($this->menuSrl, $node->parent_node, $i, $node->node,
'move');
1406 function moveMenuItem($menu_srl, $parent_srl, $source_srl, $target_srl, $mode, $isShortcut=
'Y', $url=NULL)
1411 $target_item = $oMenuAdminModel->getMenuItemInfo($target_srl);
1412 if($target_item->menu_item_srl != $target_srl)
return new BaseObject(-1,
'msg_invalid_request');
1416 $args =
new stdClass();
1417 $args->parent_srl = $parent_srl;
1418 $args->menu_srl = $menu_srl;
1422 $source_item = $oMenuAdminModel->getMenuItemInfo($source_srl);
1423 if($source_item->menu_item_srl != $source_srl)
return new BaseObject(-1,
'msg_invalid_request');
1424 $args->listorder = $source_item->listorder-1;
1433 $args->parent_srl = $parent_srl;
1437 $args->parent_srl = $parent_srl;
1438 $args->menu_item_srl = $target_srl;
1443 if($isShortcut ==
'N' && !empty($url))
1455 if($url == $this->homeModuleMid)
1457 if(file_exists($this->homeMenuCacheFile))
1459 include($this->homeMenuCacheFile);
1461 if(!$homeMenuSrl || $homeMenuSrl != $menu_srl)
1469 elseif($mode ==
'insert')
1471 $args->menu_item_srl = $target_srl;
1472 $args->parent_srl = $parent_srl;
1495 $menu_info = $oMenuAdminModel->getMenu($menu_srl);
1496 $menu_title = $menu_info->title;
1500 $this->
add(
'menu_title',$menu_title);
1501 $this->
add(
'xml_file',$xml_file);
1515 if(!$menu_srl || !$menu_item_srl)
1520 else if(!$target_file || !is_uploaded_file($target_file[
'tmp_name']) || !preg_match(
'/\.(gif|jpeg|jpg|png)$/i',$target_file[
'name']) || !
checkUploadedFile($target_file[
'tmp_name']))
1528 $tmp_arr = explode(
'.',$target_file[
'name']);
1529 $ext = $tmp_arr[count($tmp_arr)-1];
1531 $path = sprintf(
'./files/attach/menu_button/%d/', $menu_srl);
1532 $filename = sprintf(
'%s%d.%s.%s', $path, $menu_item_srl, $target, $ext);
1536 move_uploaded_file($target_file[
'tmp_name'], $filename);
1556 $this->
add(
'target', $target);
1566 $installed_module_list =
$oModuleModel->getModulesXmlInfo();
1567 if(is_array($installed_module_list))
1570 $menuList = array();
1571 foreach($installed_module_list AS $key=>$value)
1574 if($info->menu) $menuList[$value->module] = $info->menu;
1578 $this->
add(
'menuList', $menuList);
1588 $tmpMenuName = explode(
':', $requestArgs->menu_name);
1589 $moduleName = $tmpMenuName[0];
1590 $menuName = $tmpMenuName[1];
1595 $oMemberModel =
getModel(
'member');
1598 $groupSrlList = $oMemberModel->getMemberGroups(
$logged_info->member_srl);
1606 if(empty($url)) $url =
getNotEncodedFullUrl(
'',
'module',
'admin',
'act', $info->admin_index_act);
1610 $args =
new stdClass();
1611 $args->menu_item_srl = (!$requestArgs->menu_item_srl) ?
getNextSequence() : $requestArgs->menu_item_srl;
1612 $args->parent_srl = $requestArgs->parent_srl;
1613 $args->menu_srl = $requestArgs->menu_srl;
1614 $args->name = sprintf(
'{$lang->menu_gnb_sub[\'%s\']}', $menuName);
1616 if(strpos($url,
'https') !==
false)
1618 $args->url = str_replace(
'https'.substr($dbInfo->default_url, 4),
'', $url);
1622 $args->url = str_replace($dbInfo->default_url,
'', $url);
1624 $args->open_window =
'N';
1625 $args->expand =
'N';
1626 $args->normal_btn =
'';
1627 $args->hover_btn =
'';
1628 $args->active_btn =
'';
1629 $args->group_srls = implode(
',', array_keys($groupSrlList));
1634 $item_info = $oMenuModel->getMenuItemInfo(
$args->menu_item_srl);
1636 if($item_info->menu_item_srl ==
$args->menu_item_srl)
1649 $menu_info = $oMenuModel->getMenu(
$args->menu_srl);
1650 $menu_title = $menu_info->title;
1669 $itemInfo = $oMenuModel->getMenuItemInfo($menuItemSrl);
1676 $args->group_srls =
'';
1680 $exposure = explode(
',', $exposure);
1681 if(in_array($exposure, array(
'-1',
'-3')))
1683 $args->group_srls = $exposure;
1686 if($exposure)
$args->group_srls = implode(
',', $exposure);
1698 $menuInfo = $oMenuAdminModel->getMenu($itemInfo->menu_srl);
1704 if($itemInfo->is_shortcut ===
'Y')
1706 $moduleGrnatsArgs =
new stdClass;
1707 $moduleGrnatsArgs->module_srl =
$moduleInfo->module_srl;
1710 $moduleGrnats =
new stdClass();
1711 foreach(
$output->data as $grant)
1713 $moduleGrnats->{$grant->name}[] = $grant->group_srl;
1717 $grantList = $xml_info->grant;
1718 if(!$grantList) $grantList =
new stdClass;
1720 $grantList->access =
new stdClass();
1721 $grantList->access->default =
'guest';
1722 $grantList->manager =
new stdClass();
1723 $grantList->manager->default =
'manager';
1725 $grant =
new stdClass();
1726 foreach($grantList AS $grantName=>$grantInfo)
1728 if($htPerm[$grantName])
1730 $htPerm[$grantName] = explode(
',', $htPerm[$grantName]);
1733 if(is_array($htPerm[$grantName]))
1735 $grant->{$grantName} = $htPerm[$grantName];
1741 $grant->{$grantName}[] = $htPerm[$grantName];
1745 else if($itemInfo->is_shortcut ===
'Y')
1747 if(isset($moduleGrnats) && $moduleGrnats->{$grantName}) $grant->{$grantName} = $moduleGrnats->{$grantName};
1758 $this->makeXmlFile($itemInfo->menu_srl);
1769 if(!$menu_srl)
return;
1771 $args =
new stdClass();
1772 $args->menu_srl = $menu_srl;
1775 $site_srl = (int)
$output->data->site_srl;
1780 $columnList = array(
'sites.domain');
1781 $site_info =
$oModuleModel->getSiteInfo($site_srl, $columnList);
1782 $domain = $site_info->domain;
1785 $args->menu_srl = $menu_srl;
1786 $args->sort_index =
'listorder';
1788 if(!
$output->toBool())
return;
1790 $xml_file = sprintf(
_XE_PATH_ .
"files/cache/menu/%s.xml.php", $menu_srl);
1791 $php_file = sprintf(
_XE_PATH_ .
"files/cache/menu/%s.php", $menu_srl);
1796 $xml_buff =
"<root />";
1802 if(!is_array($list)) $list = array($list);
1804 $list_count = count($list);
1805 for($i=0;$i<$list_count;$i++)
1808 $menu_item_srl = $node->menu_item_srl;
1809 $parent_srl = $node->parent_srl;
1811 $tree[$parent_srl][$menu_item_srl] = $node;
1815 '$lang_type = Context::getLangType(); '.
1816 '$is_logged = Context::get(\'is_logged\'); '.
1817 '$logged_info = Context::get(\'logged_info\'); '.
1818 '$site_srl = '.$site_srl.
';'.
1819 '$site_admin = false;'.
1821 '$oModuleModel = getModel(\'module\');'.
1822 '$site_module_info = $oModuleModel->getSiteInfo($site_srl); '.
1823 'if($site_module_info) Context::set(\'site_module_info\',$site_module_info);'.
1824 'else $site_module_info = Context::get(\'site_module_info\');'.
1825 '$grant = $oModuleModel->getGrant($site_module_info, $logged_info); '.
1826 'if($grant->manager ==1) $site_admin = true;'.
1829 'if($logged_info->is_admin=="Y") $is_admin = true; '.
1830 'else $is_admin = false; '.
1831 '$group_srls = array_keys($logged_info->group_list); '.
1833 '$is_admin = false; '.
1834 '$group_srls = array(); '.
1837 $xml_buff = sprintf(
1839 'define(\'__XE__\', true); '.
1843 'header(
"Content-Type: text/xml; charset=UTF-8");
'.
1844 'header(
"Expires: Mon, 26 Jul 1997 05:00:00 GMT");
'.
1845 'header(
"Last-Modified: " . gmdate(
"D, d M Y H:i:s") .
" GMT");
'.
1846 'header(
"Cache-Control: no-store, no-cache, must-revalidate");
'.
1847 'header(
"Cache-Control: post-check=0, pre-check=0",
false);
'.
1848 'header(
"Pragma: no-cache");
'.
1854 $this->getXmlTree($tree[0], $tree, $site_srl, $domain)
1856 // Create php cache file
1857 $php_output = $this->getPhpCacheCode($tree[0], $tree, $site_srl, $domain);
1858 $php_buff = sprintf(
1860 'if(!defined(
"__XE__")) exit();
'.
1861 '$menu =
new stdClass();
' .
1864 '$menu->list = array(%s);
'.
1869 $php_output['name
'],
1873 FileHandler::writeFile($xml_file, $xml_buff);
1874 FileHandler::writeFile($php_file, $php_buff);
1888 function getXmlTree($source_node, $tree, $site_srl, $domain)
1890 if(!$source_node) return;
1892 $oMenuAdminModel = getAdminModel('menu');
1894 foreach($source_node as $menu_item_srl => $node)
1897 // Get data of the child nodes
1898 if($menu_item_srl&&$tree[$menu_item_srl]) $child_buff = $this->getXmlTree($tree[$menu_item_srl], $tree, $site_srl, $domain);
1900 $names = $oMenuAdminModel->getMenuItemNames($node->name, $site_srl);
1901 foreach($names as $key => $val)
1903 $name_arr_str .= sprintf('"%s"=>%s,
',$key, var_export($val, true));
1905 $name_str = sprintf('$_names = array(%s); print $_names[$lang_type];
', $name_arr_str);
1907 $url = str_replace(array('&
','"','<','>'),array('&','"','<','>'),$node->url);
1908 $desc = str_replace(array('&','"',"'"),array('&','"','\\\''),$node->desc);
1909 if(preg_match('/^([0-9a-zA-Z\_\-]+)$/', $node->url))
1911 $href = "getSiteUrl(
'$domain',
'',
'mid',
'$node->url')
";
1913 else $href = var_export($url, true);
1914 $is_shortcut = ($node->is_shortcut) ? $node->is_shortcut : '';
1915 $open_window = ($node->open_window) ? $node->open_window : '';
1916 $expand = ($node->expand) ? $node->expand : '';
1918 $normal_btn = ($node->normal_btn) ? $node->normal_btn : '';
1919 if($normal_btn && strncasecmp('./files/attach/menu_button', $normal_btn, 26) === 0) $normal_btn = str_replace(array('&','"','<
','>
'),array('&
','"
','<
','>
'),$normal_btn);
1920 else $normal_btn = '';
1921 $hover_btn = ($node->hover_btn) ? $node->hover_btn : '';
1922 if($hover_btn && strncasecmp('./files/attach/menu_button
', $hover_btn, 26) === 0) $hover_btn = str_replace(array('&
','"','<','>'),array('&','"','<','>'),$hover_btn);
1923 else $hover_btn = '';
1924 $active_btn = ($node->active_btn) ? $node->active_btn : '';
1925 if($active_btn && strncasecmp('./files/attach/menu_button', $active_btn, 26) === 0) $active_btn = str_replace(array('&','"','<
','>
'),array('&
','"
','<
','>
'),$active_btn);
1926 else $active_btn = '';
1928 $group_srls = ($node->group_srls) ? $node->group_srls : '';
1932 if($hover_btn) $hover_str = sprintf('onmouseover="this.src=\
'%s\'"', $hover_btn);
else $hover_str =
'';
1933 if($active_btn) $active_str = sprintf(
'onmousedown="this.src=\'%s\'"', $active_btn);
else $active_str =
'';
1934 $link = sprintf(
'<img src="%s" onmouseout="this.src=\'%s\'" alt="<?php print htmlspecialchars($_names[$lang_type], ENT_COMPAT | ENT_HTML401, \'UTF-8\', false) ?>" %s %s />', $normal_btn, $normal_btn, $hover_str, $active_str);
1938 $link =
'<?php print $_names[$lang_type]; ?>';
1943 $group_check_code = sprintf(
'($is_admin==true||(is_array($group_srls)&&count(array_intersect($group_srls, array(%s))))||($is_logged&&%s))',$group_srls,$group_srls == -1?1:0);
1947 $group_check_code =
"true";
1950 $attribute = sprintf(
1951 'node_srl="%d" parent_srl="%d" menu_name_key=%s text="<?php if(%s) { %s }?>" url="<?php print(%s?%s:"")?>" href="<?php print(%s?%s:"")?>" is_shortcut=%s desc=%s open_window=%s expand=%s normal_btn=%s hover_btn=%s active_btn=%s link="<?php if(%s) {?>%s<?php }?>"',
1953 ($node->parent_srl) ? $node->parent_srl :
'',
1954 var_export(($node->name) ? $node->name :
'',
true),
1958 var_export($url,
true),
1961 var_export($is_shortcut,
true),
1962 var_export($desc,
true),
1963 var_export($open_window,
true),
1964 var_export($expand,
true),
1965 var_export($normal_btn,
true),
1966 var_export($hover_btn,
true),
1967 var_export($active_btn,
true),
1972 if($child_buff) $buff .= sprintf(
'<node %s>%s</node>', $attribute, $child_buff);
1973 else $buff .= sprintf(
'<node %s />', $attribute);
1991 $output = array(
"buff"=>
"",
"url_list"=>array());
1992 if(!$source_node)
return $output;
1996 foreach($source_node as $menu_item_srl => $node)
1999 if($menu_item_srl&&$tree[$menu_item_srl]) $child_output = $this->getPhpCacheCode($tree[$menu_item_srl], $tree, $site_srl, $domain);
2000 else $child_output = array(
"buff"=>
"",
"url_list"=>array());
2003 $names = $oMenuAdminModel->getMenuItemNames($node->name, $site_srl);
2004 unset($name_arr_str);
2005 foreach($names as $key => $val)
2007 if(preg_match(
'/\{\$lang->menu_gnb(?:_sub)?\[\'([a-zA-Z_]?[a-zA-Z_0-9]*)\'\]\}/', $val) === 1)
2009 $name_arr_str .= sprintf(
'"%s"=>"%s",', $key, $val);
2013 $name_arr_str .= sprintf(
'"%s"=>\'%s\',', $key, str_replace(array(
'\\',
'\''), array(
'\\\\',
'\\\''),
removeHackTag($val)));
2016 $name_str = sprintf(
'$_menu_names[%d] = array(%s); %s', $node->menu_item_srl, $name_arr_str, $child_output[
'name']);
2019 if($node->url) $child_output[
'url_list'][] = $node->url;
2020 $output[
'url_list'] = array_merge(
$output[
'url_list'], $child_output[
'url_list']);
2022 if($node->group_srls)$group_check_code = sprintf(
'($is_admin==true||(is_array($group_srls)&&count(array_intersect($group_srls, array(%s))))||($is_logged && %s))',$node->group_srls,$node->group_srls == -1?1:0);
2023 else $group_check_code =
"true";
2026 $href = str_replace(array(
'&',
'"',
'<',
'>'),array(
'&',
'"',
'<',
'>'),$node->href);
2027 $url = str_replace(array(
'&',
'"',
'<',
'>'),array(
'&',
'"',
'<',
'>'),$node->url);
2028 $desc = str_replace(array(
'&',
'"',
"'"),array(
'&',
'"',
'\\\''),$node->desc);
2029 if(preg_match(
'/^([0-9a-zA-Z\_\-]+)$/i', $node->url))
2031 $href =
"getSiteUrl('$domain', '','mid','$node->url')";
2033 else $href = var_export($url,
true);
2034 $is_shortcut = $node->is_shortcut;
2035 $open_window = $node->open_window;
2036 $normal_btn = str_replace(array(
'&',
'"',
'<',
'>'),array(
'&',
'"',
'<',
'>'),$node->normal_btn);
2037 $hover_btn = str_replace(array(
'&',
'"',
'<',
'>'),array(
'&',
'"',
'<',
'>'),$node->hover_btn);
2038 $active_btn = str_replace(array(
'&',
'"',
'<',
'>'),array(
'&',
'"',
'<',
'>'),$node->active_btn);
2040 foreach($child_output[
'url_list'] as $key =>$val)
2042 $child_output[
'url_list'][$key] = addslashes($val);
2045 $selected =
'"'.implode(
'","',$child_output[
'url_list']).
'"';
2046 $child_buff = $child_output[
'buff'];
2047 $expand = $node->expand;
2049 $normal_btn = $node->normal_btn;
2050 if($normal_btn && strncasecmp(
'./files/attach/menu_button', $normal_btn, 26) === 0) $normal_btn = str_replace(array(
'&',
'"',
'<',
'>'),array(
'&',
'"',
'<',
'>'),$normal_btn);
2051 else $normal_btn =
'';
2053 $hover_btn = $node->hover_btn;
2054 if($hover_btn && strncasecmp(
'./files/attach/menu_button', $hover_btn, 26) === 0) $hover_btn = str_replace(array(
'&',
'"',
'<',
'>'),array(
'&',
'"',
'<',
'>'),$hover_btn);
2055 else $hover_btn =
'';
2057 $active_btn = $node->active_btn;
2058 if($active_btn && strncasecmp(
'./files/attach/menu_button', $active_btn, 26) === 0) $active_btn = str_replace(array(
'&',
'"',
'<',
'>'),array(
'&',
'"',
'<',
'>'),$active_btn);
2059 else $active_btn =
'';
2062 $group_srls = $node->group_srls;
2066 if($hover_btn) $hover_str = sprintf(
'onmouseover=\"this.src=\'%s\'\"', $hover_btn);
else $hover_str =
'';
2067 if($active_btn) $active_str = sprintf(
'onmousedown=\"this.src=\'%s\'\"', $active_btn);
else $active_str =
'';
2068 $link = sprintf(
'"<img src=\"%s\" onmouseout=\"this.src=\'%s\'\" alt=\"".$_menu_names[%d][$lang_type]."\" %s %s />"', $normal_btn, $normal_btn, $node->menu_item_srl, $hover_str, $active_str);
2069 if($active_btn) $link_active = sprintf(
'"<img src=\"%s\" onmouseout=\"this.src=\'%s\'\" alt=\"".$_menu_names[%d][$lang_type]."\" %s />"', $active_btn, $active_btn, $node->menu_item_srl, $hover_str);
2070 else $link_active = $link;
2074 $link_active = $link = sprintf(
'$_menu_names[%d][$lang_type]', $node->menu_item_srl);
2077 $attribute = sprintf(
2078 '"node_srl" => %d, "parent_srl" => %d, "menu_name_key" => %s, "isShow" => (%s ? true : false), "text" => (%s ? $_menu_names[%d][$lang_type] : ""), "href" => (%s ? %s : ""), "url" => (%s ? %s : ""), "is_shortcut" => %s, "desc" => %s, "open_window" => %s, "normal_btn" => %s, "hover_btn" => %s, "active_btn" => %s, "selected" => (array(%s) && in_array(Context::get("mid"), array(%s)) ? 1 : 0), "expand" => %s, "list" => array(%s), "link" => (%s ? (array(%s) && in_array(Context::get("mid"), array(%s)) ? %s : %s) : ""),',
2079 $node->menu_item_srl,
2081 var_export($node->name,
true),
2084 $node->menu_item_srl,
2088 var_export($url,
true),
2089 var_export($is_shortcut,
true),
2090 var_export($desc,
true),
2091 var_export($open_window,
true),
2092 var_export($normal_btn,
true),
2093 var_export($hover_btn,
true),
2094 var_export($active_btn,
true),
2097 var_export($expand,
true),
2107 $output[
'buff'] .= sprintf(
'%s=>array(%s),', $node->menu_item_srl, $attribute);
2121 if(!count($menu_srl_list))
return;
2123 $args->menu_srls = implode(
',',$menu_srl_list);
2129 for($i=0;$i<count($menu_srl_list);$i++)
2131 $args->menu_srl = $menu_srl_list[$i];
2145 $path = sprintf(
'./files/attach/menu_button/%d/',
$args->menu_srl);
2146 if(
$args->menu_normal_btn ||
$args->menu_hover_btn ||
$args->menu_active_btn && !is_dir($path))
2151 if(
$args->isNormalDelete ==
'Y' ||
$args->isHoverDelete ==
'Y' ||
$args->isActiveDelete ==
'Y')
2154 $itemInfo = $oMenuModel->getMenuItemInfo(
$args->menu_item_srl);
2161 $returnArray = array();
2162 $date = date(
'YmdHis');
2164 if(
$args->menu_normal_btn)
2166 $tmp_arr = explode(
'.',
$args->menu_normal_btn[
'name']);
2167 $ext = $tmp_arr[count($tmp_arr)-1];
2169 $filename = sprintf(
'%s%d.%s.%s.%s', $path,
$args->menu_item_srl, $date,
'menu_normal_btn', $ext);
2173 move_uploaded_file (
$args->menu_normal_btn [
'tmp_name'], $filename );
2174 $returnArray [
'normal_btn'] = $filename;
2179 if(
$args->menu_hover_btn)
2181 $tmp_arr = explode(
'.',
$args->menu_hover_btn[
'name']);
2182 $ext = $tmp_arr[count($tmp_arr)-1];
2184 $filename = sprintf(
'%s%d.%s.%s.%s', $path,
$args->menu_item_srl, $date,
'menu_hover_btn', $ext);
2188 move_uploaded_file(
$args->menu_hover_btn[
'tmp_name'], $filename);
2189 $returnArray[
'hover_btn'] = $filename;
2194 if(
$args->menu_active_btn)
2196 $tmp_arr = explode(
'.',
$args->menu_active_btn[
'name']);
2197 $ext = $tmp_arr[count($tmp_arr)-1];
2199 $filename = sprintf(
'%s%d.%s.%s.%s', $path,
$args->menu_item_srl, $date,
'menu_active_btn', $ext);
2203 move_uploaded_file(
$args->menu_active_btn[
'tmp_name'], $filename);
2204 $returnArray[
'active_btn'] = $filename;
2208 return $returnArray;
2215 private function _copyButton($insertedMenuItemSrl, $insertedMenuSrl, &$menuItemInfo)
2217 $copied_info = array(
2223 if($menuItemInfo->normal_btn)
2226 $targetFile = $this->_changeMenuItemSrlInButtonPath($menuItemInfo->normal_btn, $insertedMenuSrl, $insertedMenuItemSrl,
'normal');
2229 $copied_info[
'normal_btn'] = $targetFile;
2233 if($menuItemInfo->hover_btn)
2236 $targetFile = $this->_changeMenuItemSrlInButtonPath($menuItemInfo->hover_btn, $insertedMenuSrl, $insertedMenuItemSrl,
'hover');
2239 $copied_info[
'hover_btn'] = $targetFile;
2243 if($menuItemInfo->active_btn)
2246 $targetFile = $this->_changeMenuItemSrlInButtonPath($menuItemInfo->active_btn, $insertedMenuSrl, $insertedMenuItemSrl,
'active');
2249 $copied_info[
'active_btn'] = $targetFile;
2251 return $copied_info;
2254 private function _changeMenuItemSrlInButtonPath($buttonPath, $menuSrl, $menuItemSrl, $mode)
2256 $path = sprintf(
'./files/attach/menu_button/%d/', $menuSrl);
2257 $tmp_arr = explode(
'.', $buttonPath);
2258 $ext = $tmp_arr[count($tmp_arr)-1];
2259 $date = date(
"YmdHis");
2260 return sprintf(
'%s%d.%s.%s.%s', $path, $menuItemSrl,$date,
'menu_'.$mode.
'_btn', $ext);
2265 $cacheBuff .= sprintf(
'<?php if(!defined("__XE__")) exit();');
2266 $cacheBuff .= sprintf(
'$homeMenuSrl = %d;', $menuSrl);
2273 return $this->homeMenuCacheFile;
setTemplateFile($filename)
setMessage($message= 'success', $type=NULL)
getController($module_name)
recurciveExposureCheck(&$menu)
& getInstance($target= 'object', $info=null, $always_use_file=false)
set($key, $val, $set_to_get_vars=0)
writeFile($filename, $buff, $mode="w")
$oContext
Include the necessary configuration files.
setRedirectUrl($url= './', $output=NULL)
getAdminModel($module_name)
getInstance($db_type=NULL)
copyFile($source, $target, $force= 'Y')
executeQueryArray($query_id, $args=NULL, $arg_columns=NULL)
getAdminController($module_name)
readDir($path, $filter= '', $to_lower=FALSE, $concat_prefix=FALSE)
executeQuery($query_id, $args=NULL, $arg_columns=NULL)