本文整理汇总了PHP中Controller::init方法的典型用法代码示例。如果您正苦于以下问题:PHP Controller::init方法的具体用法?PHP Controller::init怎么用?PHP Controller::init使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Controller
的用法示例。
在下文中一共展示了Controller::init方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init
/**
* Initialise the controller
*/
public function init()
{
parent::init();
if (!Member::currentUser()) {
$this->redirect('home/index');
}
}
示例2: init
public function init()
{
parent::init();
if (!Yii::app()->getUser()->getIsGuest()) {
Layout::addBlock('sidebar.left', array('id' => 'profile_sidebar', 'content' => $this->widget('ProfileWidget', array('userModel' => Yii::app()->getUser()->getModel()), true)));
}
}
示例3: init
/**
* 初始化
* @see CController::init()
*/
public function init()
{
parent::init();
//前端控制器在此获得分类,从顶级分类(0)开始分层往下取,得到所有层次的分类
// ppr(XXcache::system('_catalog')); //这里是遍历出来未按照从属排序
// ppr($this->_catalog); //这里重新按从属排序
$this->_catalog = Catalog::get(0, XXcache::system('_catalog'));
//系统配置
$this->_conf = XXcache::system('_config');
$this->_seoTitle = $this->_conf['seo_title'];
$this->_seoKeywords = $this->_conf['seo_keywords'];
$this->_seoDescription = $this->_conf['seo_description'];
if ($this->_conf['site_status'] == 'close') {
self::_closed();
}
$this->_thisUrl = higu();
if ($this->_conf['cache_page_status'] == 'open') {
$value = Yii::app()->cache->get($this->_thisUrl);
if ($value === false) {
echo 'nocache';
} else {
echo 'cache';
echo $value;
}
}
}
示例4: init
function init()
{
parent::init();
if (!(Director::isDev() || Director::is_cli() || Permission::check("ADMIN"))) {
return Security::permissionFailure($this);
}
}
示例5: init
function init() {
parent::init();
// check for valid url mapping
// lacking this information can cause really nasty bugs,
// e.g. when running Director::test() from a FunctionalTest instance
global $_FILE_TO_URL_MAPPING;
if(Director::is_cli()) {
if(isset($_FILE_TO_URL_MAPPING)) {
$fullPath = $testPath = $_SERVER['SCRIPT_FILENAME'];
while($testPath && $testPath != "/") {
$matched = false;
if(isset($_FILE_TO_URL_MAPPING[$testPath])) {
$matched = true;
break;
}
$testPath = dirname($testPath);
}
if(!$matched) {
echo 'Warning: You probably want to define '.
'an entry in $_FILE_TO_URL_MAPPING that covers "' . Director::baseFolder() . '"' . "\n";
}
}
else {
echo 'Warning: You probably want to define $_FILE_TO_URL_MAPPING in '.
'your _ss_environment.php as instructed on the "sake" page of the doc.silverstripe.com wiki' . "\n";
}
}
}
示例6: init
function init()
{
Yii::app()->bootstrap;
Yii::app()->params['useBootstrap'] = true;
parent::init();
$this->menuTitle = Yii::t('common', 'Operations');
}
示例7: init
function init()
{
parent::init();
if (!Permission::check('ADMIN')) {
Security::permissionFailure();
}
}
示例8: init
/**
* Initialise the controller
*/
public function init()
{
parent::init();
if (!Member::currentUser() || !Member::currentUser()->IsAdmin()) {
$this->redirect('cloud/index');
}
}
示例9: init
public function init()
{
parent::init();
if ($this->modelClass === NULL) {
throw new CHttpException(500, 'Model class is not declared in ' . get_called_class());
}
}
示例10: init
public function init()
{
parent::init();
$passwdErrorTimes = zmf::getCookie('checkWithCaptcha');
$time = zmf::config('adminErrorTimes');
if ($time > 0) {
if ($passwdErrorTimes >= $time) {
header('Content-Type: text/html; charset=utf-8');
echo '您暂时已被禁止访问';
Yii::app()->end();
}
}
$uid = zmf::uid();
if ($uid) {
// $randKey_cookie = zmf::getCookie('adminRandKey' . $uid);
// $randKey_cache = zmf::getFCache('adminRandKey' . $uid);
// if (!$randKey_cookie || ($randKey_cache != $randKey_cookie)) {
// Yii::app()->user->logout();
// $this->message(0, '登录已过期,请重新登录', Yii::app()->createUrl('admin/site/login'));
// }
$this->userInfo = Users::getOne($uid);
$this->uid = $uid;
} else {
$currentUrl = Yii::app()->request->url;
if (strpos($currentUrl, '/site/') === false) {
$this->message(0, '请先登录', Yii::app()->createUrl('/site/login'));
}
}
}
示例11: init
public function init()
{
parent::init();
if (!Member::currentUser()) {
return $this->httpError(403);
}
}
示例12: init
/**
* Initialise the controller
*/
public function init()
{
parent::init();
if (!Member::currentUser() || !Member::currentUser()->IsContentAuthor()) {
$this->redirect('Security/login?BackURL=cloud/index');
}
}
示例13: init
/**
*
* @return void
*/
public function init()
{
parent::init();
if (!Permission::check('ADMIN')) {
return $this->redirect('/', 403);
}
}
示例14: init
public function init()
{
parent::init();
// Prevent clickjacking, see https://developer.mozilla.org/en-US/docs/HTTP/X-Frame-Options
$this->response->addHeader('X-Frame-Options', 'SAMEORIGIN');
$this->extend('onAfterInit');
}
示例15: init
/**
* Initialises the controller and ensures that only
* ADMIN level users can access this controller
*/
public function init()
{
parent::init();
if (!Permission::check('ADMIN')) {
return $this->httpError(403);
}
}