本文整理汇总了PHP中Action::model方法的典型用法代码示例。如果您正苦于以下问题:PHP Action::model方法的具体用法?PHP Action::model怎么用?PHP Action::model使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Action
的用法示例。
在下文中一共展示了Action::model方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
public function run()
{
preg_match("/(^.*?)\\?|(^.*)/", $_SERVER['REQUEST_URI'], $matchs);
$currentRoute = empty($matchs[1]) ? $matchs[2] : $matchs[1];
//$closeUser = Yii::app()->params['close_user'];
if ($this->allMenu) {
$actions = Action::model()->getAllMenu();
} else {
$actions = Privilege::getMenu($this->userid);
}
//var_dump($this->userid,$actions);exit;
$first = $second = array();
foreach ($actions as $v) {
if ($v['is_menu'] == 1) {
$first[$v['aid']] = $v;
} else {
if ($v['is_menu'] == 2) {
if (!isset($second[$v['first_menu']])) {
$second[$v['first_menu']] = array();
}
$second[$v['first_menu']][] = $v;
}
}
}
if (empty($this->horiz)) {
$this->render('main.views.widget.left_menu_metro', array('first' => $first, 'second' => $second));
} else {
$this->render('main.views.widget.horiz_menu_metro', array('first' => $first, 'second' => $second));
}
}
示例2: beforeAction
protected function beforeAction($action)
{
header("Cache-Control: no-cache, must-revalidate");
date_default_timezone_set('PRC');
// 登陆
preg_match("/(^.*?)\\?|(^.*)/", $_SERVER['REQUEST_URI'], $matchs);
$requestUrl = empty($matchs[1]) ? $matchs[2] : $matchs[1];
// 页面title
$actionInfo = Action::model()->find("route=:route", array(':route' => $requestUrl));
if (!empty($actionInfo)) {
$this->actionName = $actionInfo['aname'];
}
$closeUser = Yii::app()->params['close_user'];
// 登陆限制
if ($closeUser || ($_SERVER['REQUEST_URI'] == '/main/user/logout' || preg_match('|^/main/user/login|', $_SERVER['REQUEST_URI']) || preg_match('|^/main/user/register|', $_SERVER['REQUEST_URI']) || $requestUrl == '/site/error')) {
return true;
}
// get user info
$userInfo = Login::getLoginInfo();
$url = urlencode($_SERVER['REQUEST_URI']);
if (empty($userInfo)) {
$this->redirect('/main/user/login?url=' . $url);
}
$this->userid = $userInfo['uid'];
$this->userInfo = $userInfo;
// 权限限制
if ($userInfo['uname'] == 'superman' && !Privilege::hasPrivilege($userInfo['uid'], $requestUrl) && $requestUrl != '/site/index' && $requestUrl != '/main/user/lock') {
return false;
}
return true;
}
示例3: run
public function run()
{
preg_match("/(^.*?)\\?|(^.*)/", $_SERVER['REQUEST_URI'], $matchs);
$curRoute = empty($matchs[1]) ? $matchs[2] : $matchs[1];
$level = 1;
$curAction = Action::model()->find("route=:route", array(":route" => $curRoute));
$firstAction = array();
if ($curAction['is_menu'] == 2) {
$level = 2;
$firstAction = Action::model()->findByPk($curAction['first_menu']);
}
$this->render('main.views.widget.page_title_metro', array('level' => $level, 'first' => $firstAction, 'curaction' => $curAction));
}
示例4: actionEdit
public function actionEdit()
{
//echo "<pre>";var_dump($_REQUEST);exit;
$action = new Action();
$actionInfo = array();
$label = '';
foreach ($_REQUEST as $k => $v) {
$_REQUEST[$k] = trim($v);
}
$menutype = isset($_REQUEST['menu_type']) ? intval($_REQUEST['menu_type']) : '0';
$whichFirstMenu = isset($_REQUEST['firstmenu']) ? intval($_REQUEST['firstmenu']) : '-1';
$menusort = isset($_REQUEST['menusort']) ? intval($_REQUEST['menusort']) : 0;
$firstmenus = Action::model()->findAll('is_menu=1');
if (isset($_REQUEST['id']) && $_REQUEST['id'] != '') {
// 修改
$actionInfo = $action->find('aid=:id', array(':id' => $_REQUEST['id']));
if (!empty($_REQUEST['modify'])) {
$action->updateByPk($_REQUEST['id'], array('aname' => $_REQUEST['name'], 'route' => $_REQUEST['route'], 'is_menu' => $menutype, 'menusort' => $menusort, 'first_menu' => $whichFirstMenu));
$this->redirect('/main/action/list');
}
} elseif (!empty($_REQUEST['name'])) {
// 新增
$actionInfo = $action->find('aname=:name or route=:route', array(':name' => $_REQUEST['name'], ':route' => $_REQUEST['route']));
if (!empty($actionInfo)) {
$this->render('edit', array('firstmenus' => $firstmenus, 'entity' => $actionInfo, 'label' => 'has_action'));
exit;
}
if (!empty($_REQUEST['modify'])) {
$action->aname = $_REQUEST['name'];
$action->route = $_REQUEST['route'];
$action->is_menu = $menutype;
$action->first_menu = $whichFirstMenu;
$action->menusort = $menusort;
$action->save();
$this->redirect('/main/action/list');
}
//echo "<pre>";var_dump($_REQUEST,$actionInfo);exit;
}
$this->render('edit', array('firstmenus' => $firstmenus, 'entity' => $actionInfo, 'label' => $label));
}