function fnHelperFindMenuUser($view = "home", $layout = "") { $YiiMenu = YiiMenu::getInstance(); $menuItem = $YiiMenu->getMenuApp("users"); $found = false; $itemid = false; //echo '<meta charset="utf-8">'; foreach ($menuItem as $item) { $params = $item['params']; $_view = isset($params->view) ? $params->view : ""; $_layout = isset($params->layout) ? $params->layout : ""; if ($_view == "home") { $_view = ""; } if ($_layout == "display") { $_layout = ""; } if ($_view == $view and $_layout == $layout) { return $item['id']; } else { if ($layout == "" and $view == $_view) { $itemid = $item['id']; } else { } } } return $itemid; }
function fnHelperFindMenuArticlesHome() { $YiiMenu = YiiMenu::getInstance(); $menuItem = $YiiMenu->getMenuApp("articles"); foreach ($menuItem as $item) { $params = $item['params']; if ($params->view == "home") { return $item['id']; } } return false; }
function getItems($menutype) { $obj_menu = YiiMenu::getInstance(); $arr_menu = $obj_menu->getMenu($menutype); if (is_array($arr_menu) and count($arr_menu)) { $arr_menu = json_encode($arr_menu); $arr_menu = json_decode($arr_menu); $childs = array(); foreach ($arr_menu as $menu) { $childs[$menu->parentID][$menu->id] = $menu; } foreach ($arr_menu as $menu) { if (isset($childs[$menu->id])) { $menu->data_child = $childs[$menu->id]; } } $arr_menu = $childs[1]; } return $arr_menu; }
function copyitem($cid) { global $mainframe, $user; if (!$user->isSuperAdmin()) { YiiMessage::raseNotice("Your account not have permission to modify menu item"); return false; } $obj_menu = YiiMenu::getInstance(); $tbl_menu = $obj_menu->loadItem($cid); $tbl_menu->id = 0; $tbl_menu->title = $tbl_menu->title . " copy"; $tbl_menu->alias = $tbl_menu->alias . "-copy"; $tbl_menu->status = 0; $tbl_menu->_ordering = $tbl_menu->ordering; $tbl_menu->_old_parent = $tbl_menu->parentID; $tbl_menu->store(); return array($tbl_menu->menuID, $tbl_menu->id); }
function getListEdit() { $moduleID = Request::getInt('id', ""); $list = array(); $obj_menu = YiiMenu::getInstance(); $obj_module = YiiModule::getInstance(); $items = $obj_menu->loadMenus(); $items_xref = $obj_module->loadXrefMenu($moduleID); $str_html = '<select id="selection-menu" class="inputbox" multiple="multiple" size="15" name="selection-menu[]">'; foreach ($items as $item) { $str_html .= '<optgroup label="' . $item['title'] . '">'; $_items = $item["_items"]; foreach ($_items as $_item) { $str = str_repeat(" ", $_item['level'] - 1); if (in_array($_item['id'], $items_xref)) { $str_html .= '<option value="' . $_item['id'] . '" selected ="">' . $str . $_item['title'] . '</option>'; } else { $str_html .= '<option value="' . $_item['id'] . '">' . $str . $_item['title'] . '</option>'; } } $str_html .= '</optgroup>'; } $str_html .= "</select>"; $list['selection-menu'] = $str_html; return $list; }
function getListEdit($mainItem) { $moduleID = Request::getInt('cid', ""); $lists = array(); $obj_menu = YiiMenu::getInstance(); $obj_module = YiiModule::getInstance(); $items = $obj_menu->loadMenus(); $items_xref = $obj_module->loadXrefMenu($moduleID); $attr = ""; $meu_seletec = "selected"; if ($mainItem->menu == "none") { $attr = 'disabled="disabled"'; } else { if ($mainItem->menu == "all") { $attr = 'disabled="disabled"'; } } $str_html = '<select id="selection-menu" class="inputbox" multiple="multiple" ' . $attr . ' size="15" name="selection-menu[]" style="min-width: 180px;">'; foreach ($items as $item) { $str_html .= '<optgroup label="' . $item['title'] . '">'; $_items = $item["_items"]; foreach ($_items as $_item) { $str = str_repeat(" ", $_item['level'] - 1); if ($mainItem->menu == "all") { $str_html .= '<option value="' . $_item['id'] . '" selected ="">' . $str . $_item['title'] . '</option>'; } else { if ($mainItem->menu == "none") { $str_html .= '<option value="' . $_item['id'] . '">' . $str . $_item['title'] . '</option>'; } else { if (in_array($_item['id'], $items_xref)) { $str_html .= '<option value="' . $_item['id'] . '" selected ="">' . $str . $_item['title'] . '</option>'; } else { $str_html .= '<option value="' . $_item['id'] . '">' . $str . $_item['title'] . '</option>'; } } } } $str_html .= '</optgroup>'; } $str_html .= "</select>"; $lists['selection-menu'] = $str_html; // position $tbl_MP = YiiTables::getInstance(TBL_MODULE_POSITION); $items = $tbl_MP->loads("temp, position", null, " temp DESC"); $str_html = '<div style="position: relative;">'; $str_html .= '<select id="combobox-position" class="form-control" style="width: 180px; height: 25px;">' . "\r\n"; $cur_temp = ""; foreach ($items as $k => $item) { if ($cur_temp != $item['temp']) { if ($cur_temp != "") { $str_html .= '</optgroup>' . "\r\n"; } $str_html .= '<optgroup label="' . $item['temp'] . '">' . "\r\n"; $cur_temp = $item['temp']; } if ($mainItem->position == $item['position']) { $str_html .= '<option value="' . $item['position'] . '" selected ="">' . $item['position'] . '</option>' . "\r\n"; } else { $str_html .= '<option value="' . $item['position'] . '">' . $item['position'] . '</option>' . "\r\n"; } if ($k == count($items) - 1) { $str_html .= '</optgroup>' . "\r\n"; } } $str_html .= "</select>"; $str_html .= '<input id="position" class="form-control" type="text" value="' . $mainItem->position . '" name="position" style="position: absolute; z-index: 1000; left: 0px; top: 0px; width: 162px; height: 25px; padding: 3px;">' . "\r\n"; $str_html .= '</div>'; $str_html .= '<script> $(window).ready(function($) { $("#combobox-position").change(function(){ var cur_pos = $("#combobox-position").val(); $("#position").val(cur_pos); }); });</script>'; $lists['position'] = $str_html; $items = array(); $items[] = array("value" => 0, "text" => "Unpublish"); $items[] = array("value" => 1, "text" => "Publish"); $items[] = array("value" => -1, "text" => "Hidden"); $lists['status'] = buildHtml::select($items, $mainItem->status, "status"); return $lists; }
function changeStatus($cid, $value) { global $mainframe, $user; if (!$user->isSuperAdmin()) { YiiMessage::raseNotice("Your account not have permission to modify menu item"); $this->redirect(Router::buildLink("menus", array("view" => 'menutype'))); } $obj_menu = YiiMenu::getInstance(); $obj_tblMenu = $obj_menu->loadItem($cid, "*", false); $obj_tblMenu->status = $value; $obj_tblMenu->store(); }
static function buildLink($app, $query = null) { $app_router = PATH_APPS_FRONT . "{$app}/router.php"; $functionName = $app . "BuildRoute"; // link mac dinh, neu khong su dung den router cua app $enable_sef = isset(Yii::app()->params->sef) ? Yii::app()->params->sef : 1; $enable_sefsuffix = isset(Yii::app()->params->sef_suffix) ? Yii::app()->params->sef_suffix : 1; $sefsuffix = isset(Yii::app()->params->sef_urlsuffix) ? Yii::app()->params->sef_urlsuffix : ".html"; if ($enable_sef == 1) { if (!isset($query['view']) or isset($query['view']) and $query['view'] == 'home') { $query['view'] = ""; } if (!isset($query['layout']) or isset($query['layout']) and $query['layout'] == 'display') { $query['layout'] = ""; } $link = "/app/{$app}/"; if (file_exists($app_router)) { require_once $app_router; if (function_exists($functionName)) { $segments = $functionName($query); if (isset($query['menuID']) and $query['menuID'] != 0) { $YiiMenu = YiiMenu::getInstance(); $item = $YiiMenu->getItem($query['menuID']); $link = $item['url'] . "/"; unset($query['menuID']); } if (count($segments)) { $link .= implode("/", $segments) . "/"; } } } if (isset($query['view'])) { if ($query['view'] != "" and $query['view'] != "home") { $link .= $query['view'] . "/"; } unset($query['view']); } if (isset($query['layout'])) { if ($query['layout'] != "" and $query['layout'] != "display") { $link .= $query['layout'] . "/"; } unset($query['layout']); } } else { $link = "/index.php?app={$app}"; } $arr_query = array(); if (count($query)) { foreach ($query as $key => $_query) { $arr_query[] = "{$key}={$_query}"; } } if ($enable_sef == 1 and $enable_sefsuffix == 1) { $link = rtrim($link, "/"); $link .= $sefsuffix; } if (count($arr_query)) { $link .= "?" . implode("&", $arr_query); } return $link; }