/** * * 过滤器 * @param unknown_type $filterChain */ public function filterCheckAdmin($filterChain) { //未登录,跳转 if (!($uid = $this->isAdmin())) { $this->redirect(Yii::app()->baseUrl . "/"); } //获取用户详细资料 $adminModel = new AdminModel(); $this->_userInfo = $adminModel->getInfoByUid($uid); $this->username = $this->_userInfo['username']; $this->hospital = $this->_userInfo['hospital']; $this->role = $this->_userInfo['role']; //账号错误 if (!$this->_userInfo) { $this->_output("302", 'access deny', 'text'); } $roleModel = new RoleModel(); $role = $roleModel->getInfoByCode($this->_userInfo['role']); if ($role && $role['permission']) { $permission = explode(',', $role['permission']); //生成菜单 $menuModel = new MenuModel(); $this->menus = $menuModel->getInfoByGroup($permission); foreach ($this->menus as $key => $value) { $this->menuGroup[$value['group']] = $value['group']; } } else { header("HTTP/1.1 401"); exit; } $filterChain->run(); }
/** * Create or update new page * @param boolean $new */ public function actionUpdate($new = false) { if ($new === true) { $model = new Page(); } else { $model = Page::model()->cache($this->cacheTime)->language(Yii::app()->language->active)->findByPk($_GET['id']); } $this->breadcrumbs = array(Yii::t('PagesModule.default', 'MODULE_NAME') => $this->createUrl('index'), $model->isNewRecord ? $model->t('PAGE_TITLE', 0) : CHtml::encode($model->title)); $this->pageName = $model->isNewRecord ? $model->t('PAGE_TITLE', 0) : $model->t('PAGE_TITLE', 1); if (!$model) { throw new CHttpException(404); } if (Yii::app()->request->isPostRequest) { $model->attributes = $_POST['Page']; if ($model->validate()) { $model->save(); if ($model->in_menu == 1) { $isset = MenuModel::model()->findByAttributes(array('url' => '/page/' . $model->seo_alias)); if (!isset($isset)) { $menu = new MenuModel(); $menu->label = $model->title; $menu->url = '/page/' . $model->seo_alias; if ($menu->validate()) { $menu->save(false, false); } } } $this->redirect(array('index')); } } $this->render('update', array('model' => $model)); }
public function __construct() { $this->catmenu = new MenuCategoriesModel(); // Создаем класс меню и запрашиваем вывод меню шапки и подвала $menu = new MenuModel(); $this->top_menu = $menu->getMenu('top'); // Меню подвала $menu->sql_params = array('name' => 'category', 'value' => 'footer'); $this->footer_menu = $menu->findAllParams()[1]; }
/** * 区块添加菜单 */ function add() { //得到名字 $block_name = $_GET['blockname']; $this->assign('block_name', $block_name); //缓存名字 $_SESSION['block_name'] = $block_name; //查询出所有已启用的菜单项 $menu = new MenuModel(); $list = $menu->where('published=1')->select(); $this->assign("menus", $list); $this->display(); }
public function LoadMenu($params = null) { $current_url = \Av\DispatcherController::GetCurrentUrl()->GetCurrentUrlLocale(); $oMenuMapper = new MenuModel(); $this->_menu_collection = $oMenuMapper->LoadMenu($params); if ($this->_menu_collection instanceof \Av\Component\Menu\MenuCollectionContainer) { $this->_menu_collection_array = array(); foreach ($this->_menu_collection->GetCollection() as $tag => $menu_x_y) { foreach ($menu_x_y as $x => $menu_y) { foreach ($menu_y as $y => $oMenu) { if ($oMenu instanceof \Av\Component\Menu\MenuContainer) { /** * 1. check if selected */ $currentRes = $oMenu->GetMenuRes(array(\Av\Component\Menu\MenuContainer::TYPE => self::TYPE_LINK)); $bSelected = false; if ($currentRes instanceof \Av\Res\ResContainer) { $value = $currentRes->GetResValue(); $bSelected = $value == $current_url; } $oMenu->SetSelected(array(self::MENU_SELECTED => $bSelected)); /** * 2. build if dynamic */ if (($oMenuDynamic = $oMenu->GetMenuDynamic()) instanceof \Av\Component\Menu\MenuClassMapContainer) { $dynamic_class = $oMenuDynamic->GetMenuClassName(); $dynamic_method = $oMenuDynamic->GetMenuMethodName(); $dynamicparams = $oMenuDynamic->GetMenuMethodParams(); if ($dynamic_class !== false && $dynamic_method !== false) { if (PHP_MAJOR_VERSION <= 5 && PHP_MINOR_VERSION < 4) { $oClass = new $dynamic_class($oMenu); $oMenuDinamicCollection = $oClass->{$dynamic_method}($dynamicparams); } else { $oMenuDinamicCollection = (new $dynamic_class($oMenu))->{$dynamic_method}($dynamicparams); } if ($oMenuDinamicCollection !== false) { $this->_menu_collection->ReplaceInCollection($tag, $x, $y, $oMenuDinamicCollection); } } } /* * 3. fill menu data as array */ $this->_menu_collection_array[$tag][$x][$y] = self::ResourceAsArray($oMenu); } } } } } // $this->AddDebugAsObject($this->_menu_collection_array, __METHOD__ . " # " . __LINE__ . "Menu Array: "); }
public function getTree($wechatId) { $sql = "select m.name,m.id,m.type,m.parentId,a.action,a.responseId,a.id as actionId from " . MenuModel::model()->tableName() . " m left join " . MenuactionModel::model()->tableName() . " a on m.id=a.menuId where m.wechatId=" . $wechatId . " order by m.id desc"; $command = Yii::app()->db->createCommand($sql); $data = $command->queryAll(); $tree = new Tree($data); return $tree->get_tree_list(); }
public function delete() { $id = request('id'); if (MenuModel::delete($id)) { $this->success('/admin/menu'); } else { $this->error(); } }
public function init() { $model = MenuModel::model()->enabled()->findAll(); $result = array(); foreach ($model as $item) { $result[] = array('label' => $item->label, 'url' => $item->url, 'active' => $this->isActive($item->url)); } $this->items = CMap::mergeArray($result, $this->items); parent::init(); }
/** * Constructor that will create a Smarty object and configure it according * to what's been specified in config.inc. */ public function __construct() { /* Create a Smarty object. */ $this->_smarty = new Smarty(); # Stick it globally so we could refer the translations global $Smarty; $Smarty = $this->_smarty; global $lang; global $available_languages; /* Configure smarty. */ $this->_smarty->compile_dir = SMARTY_DIR_COMPILE; $this->_smarty->cache_dir = SMARTY_DIR_CACHE; $this->_smarty->config_dir = SMARTY_DIR_CONFIG; $this->_smarty->request_use_auto_globals = SMARTY_USE_GLOBALS; $this->_smarty->caching = SMARTY_CACHING_ENABLE; $this->_smarty->cache_lifetime = SMARTY_CACHING_LIFETIME; $this->_smarty->compile_check = SMARTY_CACHING_COMPILE_CHECK; $this->_smarty->force_recheck = SMARTY_CACHING_FORCE_RECHECK; $this->_smarty->template_dir = array("templates_{$lang}", 'templates'); $this->_smarty->compile_id = $lang; $this->_smarty->config_dir = "."; # First we read English, so al defaults are there $this->_smarty->config_load(DIR_LANG . "/lang.ini"); # Now we try to read translations if (is_file($fname = DIR_LANG . "/lang.{$lang}.ini") && is_readable($fname)) { $this->_smarty->config_load($fname); } setlocale(LC_TIME, $Smarty->_config[0]['vars']['locale']); /** * Add a output-filter to make sure ampersands are properly encoded to * HTML-entities. */ $this->_smarty->register_outputfilter(array(&$this, 'outputFilter')); /* Give Smarty-template access to date(). */ $this->_smarty->register_modifier('date_f', array(&$this, 'date_f')); $this->_smarty->register_modifier('date_localized', array(&$this, 'date_localized')); /* Give Smarty-templates access to the ampersandEntity() function. */ $this->_smarty->register_modifier('escapeAmpersand', array(&$this, 'ampersandEntity')); $this->_title = ''; $this->_css_files = array(); $this->_js_files = array(); $this->_show_intro = false; $this->_content_title = ''; $this->_content = ''; /* The menus have caused an exception, need to skip them. */ if (!ExceptionHandler::skipMenus()) { $menus = MenuModel::getAllMenus(); } # Construct lang URL $pageurl = preg_replace('/\\?lang=[a-z]*$/', '', $_SERVER['REQUEST_URI']); /* Set up the common variables before displaying. */ $vars = array('release' => RELEASE, 'baseurl' => URL_BASE, 'heroes_num' => HEROES_NUM, 'menus' => $menus, 'pageurl' => $pageurl, 'available_languages' => $available_languages); $this->_smarty->assign($vars); }
public function run() { $menus = MenuModel::model()->enabled()->findAll(); $req = Yii::app()->request->hostInfo . Yii::app()->request->requestUri; foreach ($menus as $item) { $url = Yii::app()->request->hostInfo . $item['url']; $active = $url == $req ? true : false; // $active = (preg_match('#'.$url.'#ui', $req))?true:false; $this->items[] = array('label' => $item['label'], 'active' => $active, 'url' => $item['url'], 'visible' => $this->checkVisible($item['switch'])); } $this->renderMenu($this->items); }
private function breadCrumbsArray($alias_array = array()) { $menuModel = new MenuModel(); $data = $menuModel->getMainMenu(Router::getLanguage()); $data_menu_key_alias = array(); foreach ($data as $k => $v) { $data_menu_key_alias[$v['alias_menu']] = $v; } $bread_crumbs_arr = array(); foreach ($alias_array as $val) { if (Router::getLanguage() != Config::get('default_language')) { $k = str_replace(Router::getLanguage() . '/', '', $val); } else { $k = $val; } if (isset($data_menu_key_alias[$k])) { $bread_crumbs_arr[] = array('name' => $data_menu_key_alias[$k]['name'], 'alias' => $val); } } return $bread_crumbs_arr; }
function _initialize() { //如果是非法登录 if (!$_SESSION['username']) { $this->assign("jumpUrl", __APP__ . "/Index/index"); $this->error('请登录'); } //开启SESSION session_start(); //设置输出字符集 header("Content-Type:text/html; charset=utf-8"); //可能用户直接点击叉叉关闭页面,所以通过传个HIDDEN表单在top.html中用ajax传值给logout方法 //这个功能有点不好想,因为不知道调用哪个函数 现在搞定了 //主要调用的页面有 top.html 方法 logout $this->assign('record_id', $_SESSION['record_id']); //分配当前模块名 MODULE_NAME 用法在 left.html $this->assign('current_module', MODULE_NAME); //查找出子菜单,并且显示分配在左侧菜单中 ,用法在 left.html 显示子菜单 $menus = new MenuModel(); $menu_list = $menus->select(); $this->assign('menulist', $menu_list); }
private function _init() { if (!isset($_GET['m']) || !is_numeric($_GET['m'])) { $this->_model->mid = 1; } else { $this->_model->mid = $_GET['m']; } $this->_tpl->assign('mid', $this->_model->mid); $getParam = $this->_model->getParam(); $num = 0; foreach ($getParam as $key => $value) { if (!$value) { $getParam->{$key} = '参数' . ++$num; } } $this->_tpl->assign('getParam', $getParam); $_module = new MenuModel(); $_module->mid = $this->_model->mid; $_module_name = $_module->getOneModule(); if ($_module_name->module_name == '下载中心') { $this->_tpl->assign('download', true); } }
public function actionUpdate($new = false) { $model = $new === true ? new MenuModel() : MenuModel::model()->findByPk($_GET['id']); if (isset($model)) { $this->pageName = Yii::t('app', 'ENGINE_MENU'); $this->breadcrumbs = array($this->pageName => Yii::app()->createUrl('admin/core/menu'), $new === true ? Yii::t('app', 'CREATE', 1) : Yii::t('app', 'UPDATE', 1)); if (isset($_POST['MenuModel'])) { $model->attributes = $_POST['MenuModel']; if ($model->validate()) { $model->save(); $this->redirect(array('index')); } } $this->render('update', array('model' => $model)); } else { throw new CHttpException(404); } }
public static function init() { if (!self::ifUserLogined()) { Error::halt(10001, '???δ???'); return false; } if (self::isAdmin()) { return true; } else { self::getAuthInfo(); //???????????????? Sys::D('Menu'); $menu_id = MenuModel::getIdByActionAndModule(ACTION, MODULE); if ($menu_id) { return self::checkMenuAuth($menu_id); } Sys::D('GlobalRule'); $menu_id = GlobalRuleModel::getIdByActionAndModule(ACTION, MODULE); return self::checkGlobalAuth($menu_id); } }
function _menuList() { $menuLit = MenuModel::getList(); $tree = array(); $this->mkTree($menuLit, $tree); $menus = array(); if ($this->userInfo['group']['permission']['type'] == 'super') { $menus = $tree; } else { $permissionList = is_array($this->userInfo['group']['permission']['list']) ? $this->userInfo['group']['permission']['list'] : array(); foreach ($tree as $item) { if (in_array($item['url'], $permissionList)) { if ($item['pid'] && !isset($menus[$item['pid']])) { $menus[$item['pid']] = $tree[$item['pid']]; } if (!isset($menus[$item['id']])) { $menus[$item['id']] = $item; } } } } $this->assign('menuList', $menus); }
/** * Constructor that will create a Smarty object and configure it according * to what's been specified in config.inc. */ public function __construct() { /* Create a Smarty object. */ $this->_smarty = new Smarty(); /* Configure smarty. */ $this->_smarty->template_dir = SMARTY_DIR_TEMPLATE; $this->_smarty->compile_dir = SMARTY_DIR_COMPILE; $this->_smarty->cache_dir = SMARTY_DIR_CACHE; $this->_smarty->config_dir = SMARTY_DIR_CONFIG; $this->_smarty->request_use_auto_globals = SMARTY_USE_GLOBALS; $this->_smarty->caching = SMARTY_CACHING_ENABLE; $this->_smarty->cache_lifetime = SMARTY_CACHING_LIFETIME; $this->_smarty->compile_check = SMARTY_CACHING_COMPILE_CHECK; $this->_smarty->force_recheck = SMARTY_CACHING_FORCE_RECHECK; /** * Add a output-filter to make sure ampersands are properly encoded to * HTML-entities. */ $this->_smarty->register_outputfilter(array(&$this, 'outputFilter')); /* Give Smarty-template access to date(). */ $this->_smarty->register_modifier('date_f', array(&$this, 'date_f')); /* Give Smarty-templates access to the ampersandEntity() function. */ $this->_smarty->register_modifier('escapeAmpersand', array(&$this, 'ampersandEntity')); $this->_title = ''; $this->_css_files = array(); $this->_js_files = array(); $this->_show_intro = false; $this->_content_title = ''; $this->_content = ''; /* The menus have caused an exception, need to skip them. */ if (!ExceptionHandler::skipMenus()) { $menus = MenuModel::getAllMenus(); } /* Set up the common variables before displaying. */ $vars = array('release' => RELEASE, 'baseurl' => URL_BASE, 'heroes_num' => HEROES_NUM, 'menus' => $menus); $this->_smarty->assign($vars); }
<ul class="dropdown-menu" role="menu"> <li><a href="<?php echo Helpers\Uri::makeRouteUri('back.articles.add'); ?> ">Add</a></li> <li><a href="<?php echo Helpers\Uri::makeRouteUri('back.categories.list'); ?> ">List</a></li> </ul> </li> <li class="dropdown"> <a aria-expanded="false" role="button" data-toggle="dropdown" class="dropdown-toggle" href="#">Menus <span class="caret"></span></a> <ul role="menu" class="dropdown-menu"> <?php foreach (MenuModel::all() as $item) { ?> <li><a href="<?php echo Helpers\Uri::makeUri('Admin/Menus/List') . '/' . $item->id . App::URI_EXT; ?> "><?php echo $item->title; ?> </a></li> <?php } ?> </ul> </li> <li class="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Entities Translation <span class="caret"></span></a>
/** public static function menu_recurs($array = array(), $dropdown_menu='') { $menu_class = isset($dropdown_menu)? $dropdown_menu : 'nav navbar-nav'; echo '<ul class="'.$menu_class.'">'; $lang = ''; if (Router::getLanguage() != Config::get('default_language')) { $lang = Router::getLanguage() . '/'; } foreach ($array as $v) { if (isset($v['child'])) { echo '<li class="dropdown"> <a href="/' . $lang . $v['alias_menu'] . '" class="dropdown-toggle" data-toggle="dropdown">' . $v['name'] . '<span class="caret"></span></a>'; $dropdown_menu = 'dropdown-menu'; self::menu_recurs($v['child'], $dropdown_menu); echo '</li>'; }else{ echo '<li> <a href="/' . $lang . $v['alias_menu'] . '">' . $v['name'] . '</a></li>'; } } echo '</ul>'; } * */ public function adminMenuAction() { $menuModel = new MenuModel(); $date = $menuModel->getAdminMenu(); $args = self::menuArray($date); $args[0] = array('id_page' => '', 'id_parent_page' => 0, 'status' => 1, 'name' => 'Вернуться на сайт', 'alias_menu' => '', 'level' => 1); self::$admin_menu_array = $args; return $this->render_admin_menu($args); }
/** * 编辑子菜单 */ function edit() { //父菜单ID $menu_id = $_SESSION['menuid']; //得到子菜单Id $menuitem_id = $_GET['id']; //得到数据 $menuitem = new MenuItemModel(); $menuitems = $menuitem->getById($menuitem_id); //得到所有父菜单,然后在模板中判断选择 $menus = new MenuModel(); $menu_list = $menus->select(); //得到该父菜单下的所有子菜单 $menu_items = new MenuItemModel(); $where = array('menuid' => $menu_id); $m_items = $menu_items->where($where)->select(); $this->assign('itemslist', $menuitems); $this->assign('menu_list', $menu_list); $this->assign('m_items', $m_items); $this->display(); }
public function actionGiftUpdate($id) { $menuList = array(); $keyword = $common = ''; $model = GiftModel::model()->findByPk($id); switch ($model->type) { //获取关联表数据 case GiftModel::TYPE_KEYWORDS: $keywords = KeywordsModel::model()->findAll('type=:type and responseId=:responseId', array(':type' => GiftModel::GIFT_TYPE, ':responseId' => $id)); foreach ($keywords as $k) { $oldKeywords[] = $k->name; $oldIsAccurate = $k->isAccurate; $isAccurate = $k->isAccurate; $keyword .= $common . $k->name; $common = ','; } $model->keywords = $keyword; $model->isAccurate = $isAccurate; break; case GiftModel::TYPE_MENU: $action = MenuactionModel::model()->with('action_menu')->find('action_menu.wechatId=:wechatId and responseId=:responseId', array(':wechatId' => $this->wechatInfo->id, ':responseId' => $id)); $oldAction = $model->action = isset($action->menuId) ? $action->menuId : 0; //取menu的下拉列表 $menuList = MenuModel::model()->getMenuDropDownList($this->wechatInfo->id, Globals::TYPE_GIFT); break; } if (isset($_POST['GiftModel'])) { $model->attributes = $_POST['GiftModel']; if ($model->validate()) { switch ($model->type) { //根据活动类型更新不同关联表 case GiftModel::TYPE_KEYWORDS: $keywordsArray = explode(',', $_POST['GiftModel']['keywords']); $keywordsAdd = array_unique(array_merge($oldKeywords, $keywordsArray)); $arrayDel = array_diff($keywordsAdd, $keywordsArray); //删除了的关键字 $arrayAdd = array_diff($keywordsAdd, $oldKeywords); //添加的关键字 $arrayAlive = array_diff($oldKeywords, $arrayAdd); //没改变的 $newIsAccurate = $_POST['GiftModel']['isAccurate']; if ($isAccurate != $newIsAccurate && $arrayAlive) { //是否精准匹配改变了 foreach ($arrayAlive as $name) { $keywordsModel = KeywordsModel::model()->find('name=:name', array(':name' => $name)); $keywordsModel->isAccurate = $newIsAccurate; $keywordsModel->save(); } } foreach ($arrayAdd as $k) { //新加关键词 $keywordsModel = new KeywordsModel(); $keywordsModel->responseId = $id; $keywordsModel->name = $k; $keywordsModel->isAccurate = $newIsAccurate; $keywordsModel->wechatId = $this->wechatInfo->id; $keywordsModel->type = GiftModel::GIFT_TYPE; $keywordsModel->save(); } foreach ($arrayDel as $k) { //删除的关键词 $keywordsModel = KeywordsModel::model()->find('responseId=:responseId and name=:name', array(':name' => $k, ':responseId' => $id)); $keywordsModel->delete(); } if ($oldIsAccurate != $isAccurate) { KeywordsModel::model()->updateAll(array('isAccurate' => $isAccurate), 'responseId=:responseId', array(':responseId' => $id)); } //更新是否精准匹配字段 break; case GiftModel::TYPE_MENU: $newAction = $_POST['GiftModel']['action']; if ($oldAction != $newAction) { //检测menu action是否被其他使用 // $actionExist = MenuactionModel::model()->find('wechatId=:wechatId and action=:action', array(':wechatId' => $this->wechatInfo->id, ':action' => $newAction)); // if ($actionExist) { // ShowMessage::error('此菜单动作已经被使用了'); // } if ($oldAction) { $actionModel = MenuactionModel::model()->find('menuId=:menuId', array(':menuId' => $oldAction)); $actionModel->responseId = 0; $actionModel->save(); //原来菜单responseId置为0 } $newActionModel = MenuactionModel::model()->find('menuId=:menuId', array(':menuId' => $newAction)); $newActionModel->responseId = $model->id; $newActionModel->save(); } break; } $model->save(); //更新code表,防止礼包时礼包码表未创建成功问题 $result = GiftModel::model()->createCodeTable($this->wechatInfo->id); if ($result == GiftModel::TABLE_CREATE_FAILED) { ShowMessage::error('数据异常,请再次编辑一下'); } else { ShowMessage::success('编辑成功', Yii::app()->createUrl('market/gift', array('type' => $model->type))); } } } Yii::app()->clientScript->scriptMap['jquery.js'] = false; $this->render('giftUpdate', array('model' => $model, 'type' => $model->type, 'wechatId' => $this->wechatInfo->id, 'responseId' => $id, 'menuList' => $menuList)); }
public function actionReplayUpdate($id) { $menuList = array(); $keyword = $common = ''; $model = OpenReplayModel::model()->findByPk($id); if ($model->wechatId != $this->wechatInfo->id) { return; } $open = array('' => '请选择') + CHtml::listData(OpenPlatformModel::model()->findAll('wechatId=:wechatId and status=:status', array(':wechatId' => $this->wechatInfo->id, ':status' => 1)), 'id', 'name'); switch ($model->type) { //获取关联表数据 case GiftModel::TYPE_KEYWORDS: $keywords = KeywordsModel::model()->findAll('type=:type and responseId=:responseId', array(':type' => OpenReplayModel::OPEN_TYPE, ':responseId' => $id)); foreach ($keywords as $k) { $oldKeywords[] = $k->name; $oldIsAccurate = $k->isAccurate; $isAccurate = $k->isAccurate; $keyword .= $common . $k->name; $common = ','; } $model->keywords = $keyword; $model->isAccurate = $isAccurate; break; case GiftModel::TYPE_MENU: //取menu的下拉列表 $menuList = MenuModel::model()->getMenuDropDownList($this->wechatInfo->id, Globals::TYPE_OPEN); $action = MenuactionModel::model()->with('action_menu')->find('action_menu.wechatId=:wechatId and responseId=:responseId', array(':wechatId' => $this->wechatInfo->id, ':responseId' => $id)); $oldAction = $model->action = isset($action->menuId) ? $action->menuId : 0; break; } if (isset($_POST['OpenReplayModel'])) { $model->attributes = $_POST['OpenReplayModel']; if ($model->validate()) { switch ($model->type) { //根据活动类型更新不同关联表 case GiftModel::TYPE_KEYWORDS: $keywordsArray = explode(',', $_POST['OpenReplayModel']['keywords']); $keywordsAdd = array_unique(array_merge($oldKeywords, $keywordsArray)); $arrayDel = array_diff($keywordsAdd, $keywordsArray); //删除了的关键字 $arrayAdd = array_diff($keywordsAdd, $oldKeywords); //添加的关键字 $arrayAlive = array_diff($oldKeywords, $arrayAdd); //没改变的 $newIsAccurate = $_POST['OpenReplayModel']['isAccurate']; if ($isAccurate != $newIsAccurate && $arrayAlive) { //是否精准匹配改变了 foreach ($arrayAlive as $name) { $keywordsModel = KeywordsModel::model()->find('name=:name', array(':name' => $name)); $keywordsModel->isAccurate = $newIsAccurate; $keywordsModel->save(); } } foreach ($arrayAdd as $k) { //新加关键词 $keywordsModel = new KeywordsModel(); $keywordsModel->responseId = $id; $keywordsModel->name = $k; $keywordsModel->isAccurate = $newIsAccurate; $keywordsModel->wechatId = $this->wechatInfo->id; $keywordsModel->type = OpenReplayModel::OPEN_TYPE; $keywordsModel->save(); } foreach ($arrayDel as $k) { //删除的关键词 $keywordsModel = KeywordsModel::model()->find('responseId=:responseId and name=:name', array(':name' => $k, ':responseId' => $id)); $keywordsModel->delete(); } if ($oldIsAccurate != $isAccurate) { KeywordsModel::model()->updateAll(array('isAccurate' => $isAccurate), 'responseId=:responseId', array(':responseId' => $id)); } //更新是否精准匹配字段 break; case GiftModel::TYPE_MENU: $newAction = $_POST['OpenReplayModel']['action']; if ($oldAction != $newAction) { // //检测menu action是否被其他使用 // $actionExist = MenuactionModel::model()->find('wechatId=:wechatId and action=:action', array(':wechatId' => $this->wechatInfo->id, ':action' => $newAction)); // if ($actionExist) { // ShowMessage::error('此菜单动作已经被使用了'); // } // $actionModel = MenuactionModel::model()->find('type=:type and action=:action', array(':type' => OpenReplayModel::OPEN_TYPE, ':action' => $oldAction)); // $actionModel->action = $newAction; // $actionModel->save(); if ($oldAction) { $actionModel = MenuactionModel::model()->find('menuId=:menuId', array(':menuId' => $oldAction)); $actionModel->responseId = 0; $actionModel->save(); //原来菜单responseId置为0 } $newActionModel = MenuactionModel::model()->find('menuId=:menuId', array(':menuId' => $newAction)); $newActionModel->responseId = $model->id; $newActionModel->save(); } break; } $model->save(); ShowMessage::success('编辑成功', Yii::app()->createUrl('open/replay', array('type' => $model->type))); } } Yii::app()->clientScript->scriptMap['jquery.js'] = false; $this->render('replayUpdate', array('model' => $model, 'type' => $model->type, 'wechatId' => $this->wechatInfo->id, 'responseId' => $id, 'open' => $open, 'menuList' => $menuList)); }
public static function createFromData($pdo, $data) { $obj = new MenuModel($pdo); $obj->load($data); return $obj; }
public function actionUpdate($id) { $model = MenuModel::model()->with('menu_action')->findByPk($id); if ($_POST) { $status = 1; $msg = '更新成功'; $model->name = $_POST['name']; $model->type = $_POST['type']; if (!$model->parentId && $_POST['parentId']) { $status = -1; $msg = '此菜单含有子菜单,不能做此修改'; } else { $model->parentId = $_POST['parentId'] ? $_POST['parentId'] : 0; $modelAction = MenuactionModel::model()->findByPk($model->menu_action->id); $modelAction->action = $_POST['type'] == Globals::TYPE_URL ? $_POST['url'] : $_POST['action']; //responseId 响应ID if ($_POST['type'] == Globals::TYPE_KEYWORDS || $_POST['type'] == Globals::TYPE_GIFT) { //如果是关键词则需要找到对应的responseId $keyword = KeywordsModel::model()->find("wechatId=:wechatId and name like concat('%',:name,'%') order by id desc", array(':wechatId' => $this->wechatInfo->id, ':name' => $_POST['action'])); if (!empty($keyword)) { $modelAction->responseId = $keyword->responseId; } else { $msg = '不存在该关键词'; } } if ($model->validate() && $modelAction->validate()) { $modelAction->save(); $model->save(); } else { $status = -1; $error = $model->getErrors(); if ($error) { foreach ($error as $e) { $msg .= $e[0]; } } } } echo json_encode(array('status' => $status, 'msg' => $msg)); } else { $result['name'] = $model->name; $result['type'] = $model->type; $result['url'] = $result['action'] = isset($model->menu_action->action) ? $model->menu_action->action : ''; $result['actionId'] = isset($model->menu_action->id) ? $model->menu_action->id : 0; echo json_encode($result); } }
if (isset($_GET["action"]) && in_array($_GET["action"], $possible_url)) { switch ($_GET["action"]) { case "signing_in": $ProfileModel = new ProfileModel($conn); $value = $ProfileModel->login_detail_check($_GET["usrid"], $_GET["pwd"], $_GET["comp"]); break; case "get_profile_data": $ProfileModel = new ProfileModel($conn); $value = $ProfileModel->get_profile_data(); break; case "get_all_companies": $CompanyModel = new CompanyModel($conn); $value = $CompanyModel->get_all_companies(); break; case "create_menu": $MenuModel = new MenuModel($conn); $value = $MenuModel->create_main_menu(); break; case "get_table_default": $TableModel = new TableModel($conn, $_GET); $value = $TableModel->get_table(); break; case "save_table_default": $EditTableModel = new EditTable($conn, $_GET, $_POST); $value = $EditTableModel->edit_table(); break; case "input_check": $inputCheck = new InputCheck($conn); $value = $inputCheck->check(); break; }
public function actionCreate() { $menuList = array(); $type = Yii::app()->request->getParam('type'); $type = $type ? $type : Globals::TYPE_KEYWORDS; if ($type == Globals::TYPE_MENU) { //取menu的下拉列表 $menuList = MenuModel::model()->getMenuDropDownList($this->wechatInfo->id, Globals::TYPE_GIFT); } $model = new WheelModel(); if (isset($_POST['WheelModel'])) { $model->type = $type; $model->attributes = $_POST['WheelModel']; $model->wechatId = $this->wechatInfo->id; if ($_FILES) { $file = array('name' => $_FILES['WheelModel']['name']['backgroundPic'], 'type' => $_FILES['WheelModel']['type']['backgroundPic'], 'tmp_name' => $_FILES['WheelModel']['tmp_name']['backgroundPic'], 'error' => $_FILES['WheelModel']['error']['backgroundPic'], 'size' => $_FILES['WheelModel']['size']['backgroundPic']); $uploadPath = Yii::app()->params['scratchPath'] . "/" . $this->wechatInfo->id . '/'; $fileUpload = new FileUpload($uploadPath, $file); $fileUpload->move(); $result = $fileUpload->getMessages(); if (isset($result['name'])) { $backgroundPic = $result['name']; } else { ShowMessage::Error(current($result)); } $file = array('name' => $_FILES['WheelModel']['name']['button'], 'type' => $_FILES['WheelModel']['type']['button'], 'tmp_name' => $_FILES['WheelModel']['tmp_name']['button'], 'error' => $_FILES['WheelModel']['error']['button'], 'size' => $_FILES['WheelModel']['size']['button']); $uploadPath = Yii::app()->params['scratchPath'] . "/" . $this->wechatInfo->id . '/'; $fileUpload = new FileUpload($uploadPath, $file); $fileUpload->move(); $result = $fileUpload->getMessages(); if (isset($result['name'])) { $button = $result['name']; } else { ShowMessage::Error(current($result)); } } //奖项处理 for ($i = 1; $i <= 4; $i++) { ${'award' . $i} = $_POST['award' . $i]; ${'isentity' . $i} = $_POST['isentity' . $i] ? $_POST['isentity' . $i] : 0; $awards[$i] = array('name' => ${'award' . $i}, 'isentity' => ${'isentity' . $i}); } $model->awards = serialize($awards); $model->backgroundPic = $backgroundPic; $model->button = $button; $model->created_at = date('Y-m-d H:i:s'); //$model->ispaward = '';//$_POST['WheelModel']['ispaward']; if ($model->validate()) { $model->save(); switch ($type) { case Globals::TYPE_KEYWORDS: $keywords = $_POST['WheelModel']['keywords']; $isAccurate = $_POST['WheelModel']['isAccurate']; $keywordsArray = explode(',', $keywords); foreach ($keywordsArray as $k) { $keywordsModel = new KeywordsModel(); $keywordsModel->responseId = $model->id; $keywordsModel->type = Globals::TYPE_SCRATCH; $keywordsModel->isAccurate = $isAccurate; $keywordsModel->name = $k; $keywordsModel->wechatId = $this->wechatInfo->id; $keywordsModel->save(); } break; case Globals::TYPE_MENU: $menuId = $_POST['WheelModel']['action']; $menuActionModel = MenuactionModel::model()->find('menuId=:menuId', array(':menuId' => $menuId)); $menuActionModel->responseId = $model->id; $menuActionModel->save(); break; } ShowMessage::success('添加成功', Yii::app()->createUrl('scratch', array('type' => $type))); } } Yii::app()->clientScript->scriptMap['jquery.js'] = false; $this->render('create', array('model' => $model, 'type' => $type ? $type : GiftModel::TYPE_KEYWORDS, 'wechatId' => $this->wechatInfo->id, 'responseId' => 0, 'menuList' => $menuList)); }
public function editAction() { if (Session::hasUser('admin')) { $indexModel = new IndexModel(); $data_page = $indexModel->getPage(Router::getId(), Router::getLanguage(), $this->material_type); $menuModel = new MenuModel(); $data = $menuModel->getMainMenu('uk'); $menuController = new MenuController(); $main_menu_array = $menuController->menuArray($data); $data_menu_item = $menuModel->getMenuDatePage($data_page[0]['id']); $redirect_status = null; $request = new Request(); $editModel = new AddEditModel($request, $this->material_type); if ($request->isPost()) { if ($editModel->isValid()) { if ($editModel->isAliasExist($data_page[0]['id'])) { if ($editModel->inMenu()) { $file_data = array('max_image_size' => Config::get('max_image_size'), 'max_image_width' => Config::get('max_image_width'), 'max_image_height' => Config::get('max_image_height')); $fileUpload = new UploadFile($request, $file_data); $redirect_status = $fileUpload->uploadImg($request, $this->material_type); if ($redirect_status) { $editModel->edit($data_page[0]['id']); } } else { $with_without_menu = 1; $editModel->edit($data_page[0]['id'], $with_without_menu); } } else { Session::setFlash('Документ с таким псевдонимом уже существует!'); } } else { Session::setFlash('Поле "Заголовок" обязательно для заполнения'); } } $this->rewrite_file_alias(); $args = array('data_page' => $data_page, 'data_menu' => $main_menu_array, 'edit_model' => $editModel, 'data_menu_item' => $data_menu_item, 'redirect' => $request->post('redirect'), 'redirect_status' => $redirect_status, 'without_menu' => $request->post('without_menu'), 'menu_disable' => Config::get('menu_disable'), 'id' => $data_page[0]['id']); $tpl = 'edit' . str_replace(' ', '', ucwords(str_replace('_', ' ', $this->material_type))); return $this->render_admin($args, $tpl); } else { throw new Exception('Access denied', 403); } }
/** * 删除菜单项 */ function del() { //序列化主键Id为:1,2,3,...以便批量删除 $del_id = $_POST['del_id']; $str = implode($del_id, ','); //实例化 $menu = new MenuModel(); //删除文章 if ($menu->delete($str)) { //同时删除其下属子菜单 $menu_items = new MenuItemModel(); $where = array('menuid' => array('in', $del_id)); $menu_items->where($where)->delete(); $this->assign('jumpUrl', __URL__ . '/index'); $this->success('菜单删除成功~~'); } else { $this->assign('jumpUrl', __URL__ . '/index'); $this->error('删除失败'); } }
*/ /** Set flag that this is a parent file */ define("_VALID_UA", 1); require_once "config.inc.php"; require_once "include/page.inc.php"; require_once "include/db.functions.php"; require_once "include/time.inc.php"; require_once "include/basic.lib.php"; require_once "include/config.inc.php"; require_once "include/MenuItem.class.php"; ################################################################################ // init session and connect to database page_start(); ################################################################################ // create model $model = new MenuModel(); // create view $view = new MenuView(); // collect data $data = array(); // time $data['TIME'] = $model->getTime(); // cave selector $data['SELECT'] = $model->getSelector(); // fill menu icons $icons = $model->getIcons(); foreach ($icons as $icon) { $data['ICON'][] = $icon->getTmplData(); } // fill menu items $items = $model->getItems();
/** * 获取左侧菜单栏目 */ public function menusInit() { $menuModel = new \MenuModel(); $this->assign('menus', $menuModel->getLists('*')); }