code
stringlengths
17
247k
docstring
stringlengths
30
30.3k
func_name
stringlengths
1
89
language
stringclasses
1 value
repo
stringlengths
7
63
path
stringlengths
7
153
url
stringlengths
51
209
license
stringclasses
4 values
public function authenticate($attribute,$params) { $this->_identity=new UserIdentity($this->username,$this->password); if(!$this->_identity->authenticate()) $this->addError('password','Incorrect username or password.'); }
Authenticates the password. This is the 'authenticate' validator as declared in rules(). @param string $attribute the name of the attribute to be validated. @param array $params additional parameters passed with rule when being executed.
authenticate
php
yiisoft/yii
demos/blog/protected/models/LoginForm.php
https://github.com/yiisoft/yii/blob/master/demos/blog/protected/models/LoginForm.php
BSD-3-Clause
public function login() { if($this->_identity===null) { $this->_identity=new UserIdentity($this->username,$this->password); $this->_identity->authenticate(); } if($this->_identity->errorCode===UserIdentity::ERROR_NONE) { $duration=$this->rememberMe ? 3600*24*30 : 0; // 30 days Yii::app()->user->login($this->_identity,$duration); return true; } else return false; }
Logs in the user using the given username and password in the model. @return boolean whether login is successful
login
php
yiisoft/yii
demos/blog/protected/models/LoginForm.php
https://github.com/yiisoft/yii/blob/master/demos/blog/protected/models/LoginForm.php
BSD-3-Clause
public function normalizeTags($attribute,$params) { $this->tags=Tag::array2string(array_unique(Tag::string2array($this->tags))); }
Normalizes the user-entered tags.
normalizeTags
php
yiisoft/yii
demos/blog/protected/models/Post.php
https://github.com/yiisoft/yii/blob/master/demos/blog/protected/models/Post.php
BSD-3-Clause
public function addComment($comment) { if(Yii::app()->params['commentNeedApproval']) $comment->status=Comment::STATUS_PENDING; else $comment->status=Comment::STATUS_APPROVED; $comment->post_id=$this->id; return $comment->save(); }
Adds a new comment to this post. This method will set status and post_id of the comment accordingly. @param Comment the comment to be added @return boolean whether the comment is saved successfully
addComment
php
yiisoft/yii
demos/blog/protected/models/Post.php
https://github.com/yiisoft/yii/blob/master/demos/blog/protected/models/Post.php
BSD-3-Clause
protected function afterFind() { parent::afterFind(); $this->_oldTags=$this->tags; }
This is invoked when a record is populated with data from a find() call.
afterFind
php
yiisoft/yii
demos/blog/protected/models/Post.php
https://github.com/yiisoft/yii/blob/master/demos/blog/protected/models/Post.php
BSD-3-Clause
protected function afterSave() { parent::afterSave(); Tag::model()->updateFrequency($this->_oldTags, $this->tags); }
This is invoked after the record is saved.
afterSave
php
yiisoft/yii
demos/blog/protected/models/Post.php
https://github.com/yiisoft/yii/blob/master/demos/blog/protected/models/Post.php
BSD-3-Clause
protected function afterDelete() { parent::afterDelete(); Comment::model()->deleteAll('post_id='.$this->id); Tag::model()->updateFrequency($this->tags, ''); }
This is invoked after the record is deleted.
afterDelete
php
yiisoft/yii
demos/blog/protected/models/Post.php
https://github.com/yiisoft/yii/blob/master/demos/blog/protected/models/Post.php
BSD-3-Clause
public function search() { $criteria=new CDbCriteria; $criteria->compare('title',$this->title,true); $criteria->compare('status',$this->status); return new CActiveDataProvider('Post', array( 'criteria'=>$criteria, 'sort'=>array( 'defaultOrder'=>'status, update_time DESC', ), )); }
Retrieves the list of posts based on the current search/filter conditions. @return CActiveDataProvider the data provider that can return the needed posts.
search
php
yiisoft/yii
demos/blog/protected/models/Post.php
https://github.com/yiisoft/yii/blob/master/demos/blog/protected/models/Post.php
BSD-3-Clause
public function validatePassword($password) { return CPasswordHelper::verifyPassword($password,$this->password); }
Checks if the given password is correct. @param string the password to be validated @return boolean whether the password is valid
validatePassword
php
yiisoft/yii
demos/blog/protected/models/User.php
https://github.com/yiisoft/yii/blob/master/demos/blog/protected/models/User.php
BSD-3-Clause
public function actionIndex() { echo 'Hello World'; }
Index action is the default action in a controller.
actionIndex
php
yiisoft/yii
demos/helloworld/protected/controllers/SiteController.php
https://github.com/yiisoft/yii/blob/master/demos/helloworld/protected/controllers/SiteController.php
BSD-3-Clause
public function actions() { return array( 'phonebook'=>array( 'class'=>'CWebServiceAction', 'classMap'=>array( 'Contact', ), ), ); }
Declares the 'phonebook' Web service action.
actions
php
yiisoft/yii
demos/phonebook/protected/controllers/SiteController.php
https://github.com/yiisoft/yii/blob/master/demos/phonebook/protected/controllers/SiteController.php
BSD-3-Clause
public function actionIndex() { $this->render('index'); }
This is the default action that displays the phonebook Flex client.
actionIndex
php
yiisoft/yii
demos/phonebook/protected/controllers/SiteController.php
https://github.com/yiisoft/yii/blob/master/demos/phonebook/protected/controllers/SiteController.php
BSD-3-Clause
public function actionTest() { $wsdlUrl=Yii::app()->request->hostInfo.$this->createUrl('phonebook'); $client=new SoapClient($wsdlUrl); echo "<pre>"; echo "login...\n"; $client->login('demo','demo'); echo "fetching all contacts\n"; print_r($client->getContacts()); echo "\ninserting a new contact..."; $contact=new Contact; $contact->name='Tester Name'; $contact->phone='123-123-1234'; $client->saveContact($contact); echo "done\n\n"; echo "fetching all contacts\n"; print_r($client->getContacts()); echo "</pre>"; }
This action serves as a SOAP client to test the phonebook Web service.
actionTest
php
yiisoft/yii
demos/phonebook/protected/controllers/SiteController.php
https://github.com/yiisoft/yii/blob/master/demos/phonebook/protected/controllers/SiteController.php
BSD-3-Clause
public function beforeWebMethod($service) { $safeMethods=array( 'login', 'getContacts', ); $pattern='/^('.implode('|',$safeMethods).')$/i'; if(!Yii::app()->user->isGuest || preg_match($pattern,$service->methodName)) return true; else throw new CException('Login required.'); }
This method is required by IWebServiceProvider. It makes sure the user is logged in before making changes to data. @param CWebService the currently requested Web service. @return boolean whether the remote method should be executed.
beforeWebMethod
php
yiisoft/yii
demos/phonebook/protected/controllers/SiteController.php
https://github.com/yiisoft/yii/blob/master/demos/phonebook/protected/controllers/SiteController.php
BSD-3-Clause
public function afterWebMethod($service) { }
This method is required by IWebServiceProvider. @param CWebService the currently requested Web service.
afterWebMethod
php
yiisoft/yii
demos/phonebook/protected/controllers/SiteController.php
https://github.com/yiisoft/yii/blob/master/demos/phonebook/protected/controllers/SiteController.php
BSD-3-Clause
public function deleteContact($id) { return Contact::model()->deleteByPk($id); }
Deletes the specified contact record. @param integer ID of the contact to be deleted @return integer number of records deleted @soap
deleteContact
php
yiisoft/yii
demos/phonebook/protected/controllers/SiteController.php
https://github.com/yiisoft/yii/blob/master/demos/phonebook/protected/controllers/SiteController.php
BSD-3-Clause
public function authenticate() { if($this->username==='demo' && $this->password==='demo') $this->errorCode=self::ERROR_NONE; else $this->errorCode=self::ERROR_PASSWORD_INVALID; return !$this->errorCode; }
Validates the username and password. This method should check the validity of the provided username and password in some way. In case of any authentication failure, set errorCode and errorMessage with appropriate values and return false. @param string username @param string password @return boolean whether the username and password are valid
authenticate
php
yiisoft/yii
demos/phonebook/protected/components/UserIdentity.php
https://github.com/yiisoft/yii/blob/master/demos/phonebook/protected/components/UserIdentity.php
BSD-3-Clause
public function actionPlay() { static $levels=array( '10'=>'Easy game; you are allowed 10 misses.', '5'=>'Medium game; you are allowed 5 misses.', '3'=>'Hard game; you are allowed 3 misses.', ); // if a difficulty level is correctly chosen if(isset($_POST['level']) && isset($levels[$_POST['level']])) { $this->word=$this->generateWord(); $this->guessWord=str_repeat('_',strlen($this->word)); $this->level=$_POST['level']; $this->misses=0; $this->setPageState('guessed',null); // show the guess page $this->render('guess'); } else { $params=array( 'levels'=>$levels, // if this is a POST request, it means the level is not chosen 'error'=>Yii::app()->request->isPostRequest, ); // show the difficulty level page $this->render('play',$params); } }
The 'play' action. In this action, users are asked to choose a difficulty level of the game.
actionPlay
php
yiisoft/yii
demos/hangman/protected/controllers/GameController.php
https://github.com/yiisoft/yii/blob/master/demos/hangman/protected/controllers/GameController.php
BSD-3-Clause
public function actionGuess() { // check to see if the letter is guessed correctly if(isset($_GET['g'][0]) && ($result=$this->guess($_GET['g'][0]))!==null) $this->render($result ? 'win' : 'lose'); else // the letter is guessed correctly, but not win yet { $guessed=$this->getPageState('guessed',array()); $guessed[$_GET['g'][0]]=true; $this->setPageState('guessed',$guessed,array()); $this->render('guess'); } }
The 'guess' action. This action is invoked each time when the user makes a guess.
actionGuess
php
yiisoft/yii
demos/hangman/protected/controllers/GameController.php
https://github.com/yiisoft/yii/blob/master/demos/hangman/protected/controllers/GameController.php
BSD-3-Clause
public function actionGiveup() { $this->render('lose'); }
The 'guess' action. This action is invoked when the user gives up the game.
actionGiveup
php
yiisoft/yii
demos/hangman/protected/controllers/GameController.php
https://github.com/yiisoft/yii/blob/master/demos/hangman/protected/controllers/GameController.php
BSD-3-Clause
public function isGuessed($letter) { $guessed=$this->getPageState('guessed',array()); return isset($guessed[$letter]); }
Checks to see if a letter is already guessed. @param string the letter @return boolean whether the letter is already guessed.
isGuessed
php
yiisoft/yii
demos/hangman/protected/controllers/GameController.php
https://github.com/yiisoft/yii/blob/master/demos/hangman/protected/controllers/GameController.php
BSD-3-Clause
protected function generateWord() { $wordFile=dirname(__FILE__).'/words.txt'; $words=preg_split("/[\s,]+/",file_get_contents($wordFile)); do { $i=rand(0,count($words)-1); $word=$words[$i]; } while(strlen($word)<5 || !ctype_alpha($word)); return strtoupper($word); }
Generates a word to be guessed. @return string the word to be guessed
generateWord
php
yiisoft/yii
demos/hangman/protected/controllers/GameController.php
https://github.com/yiisoft/yii/blob/master/demos/hangman/protected/controllers/GameController.php
BSD-3-Clause
protected function guess($letter) { $word=$this->word; $guessWord=$this->guessWord; $pos=0; $success=false; while(($pos=strpos($word,$letter,$pos))!==false) { $guessWord[$pos]=$letter; $success=true; $pos++; } if($success) { $this->guessWord=$guessWord; if($guessWord===$word) return true; } else { $this->misses++; if($this->misses>=$this->level) return false; } }
Checks to see if a letter is guessed correctly. @param string the letter @return mixed true if the word is guessed correctly, false if the user has used up all guesses and the word is guessed incorrectly, and null if the letter is guessed correctly but the whole word is guessed correctly yet.
guess
php
yiisoft/yii
demos/hangman/protected/controllers/GameController.php
https://github.com/yiisoft/yii/blob/master/demos/hangman/protected/controllers/GameController.php
BSD-3-Clause
public function getLevel() { return $this->getPageState('level'); }
@return integer the difficulty level. This value is persistent during the whole game session.
getLevel
php
yiisoft/yii
demos/hangman/protected/controllers/GameController.php
https://github.com/yiisoft/yii/blob/master/demos/hangman/protected/controllers/GameController.php
BSD-3-Clause
public function setLevel($value) { $this->setPageState('level',$value); }
@param integer the difficulty level. This value is persistent during the whole game session.
setLevel
php
yiisoft/yii
demos/hangman/protected/controllers/GameController.php
https://github.com/yiisoft/yii/blob/master/demos/hangman/protected/controllers/GameController.php
BSD-3-Clause
public function getWord() { return $this->getPageState('word'); }
@return string the word to be guessed. This value is persistent during the whole game session.
getWord
php
yiisoft/yii
demos/hangman/protected/controllers/GameController.php
https://github.com/yiisoft/yii/blob/master/demos/hangman/protected/controllers/GameController.php
BSD-3-Clause
public function setWord($value) { $this->setPageState('word',$value); }
@param string the word to be guessed. This value is persistent during the whole game session.
setWord
php
yiisoft/yii
demos/hangman/protected/controllers/GameController.php
https://github.com/yiisoft/yii/blob/master/demos/hangman/protected/controllers/GameController.php
BSD-3-Clause
public function getGuessWord() { return $this->getPageState('guessWord'); }
@return string the word being guessed. This value is persistent during the whole game session.
getGuessWord
php
yiisoft/yii
demos/hangman/protected/controllers/GameController.php
https://github.com/yiisoft/yii/blob/master/demos/hangman/protected/controllers/GameController.php
BSD-3-Clause
public function setGuessWord($value) { $this->setPageState('guessWord',$value); }
@param string the word being guessed. This value is persistent during the whole game session.
setGuessWord
php
yiisoft/yii
demos/hangman/protected/controllers/GameController.php
https://github.com/yiisoft/yii/blob/master/demos/hangman/protected/controllers/GameController.php
BSD-3-Clause
public function getMisses() { return $this->getPageState('misses'); }
@return integer the number of misses. This value is persistent during the whole game session.
getMisses
php
yiisoft/yii
demos/hangman/protected/controllers/GameController.php
https://github.com/yiisoft/yii/blob/master/demos/hangman/protected/controllers/GameController.php
BSD-3-Clause
public function setMisses($value) { $this->setPageState('misses',$value); }
@param integer the number of misses. This value is persistent during the whole game session.
setMisses
php
yiisoft/yii
demos/hangman/protected/controllers/GameController.php
https://github.com/yiisoft/yii/blob/master/demos/hangman/protected/controllers/GameController.php
BSD-3-Clause
public function actionReport($sourcePath, $translationPath, $title = 'Translation report') { $sourcePath=trim($sourcePath, '/\\'); $translationPath=trim($translationPath, '/\\'); $results = array(); $dir = new DirectoryIterator($sourcePath); foreach ($dir as $fileinfo) { if (!$fileinfo->isDot() && !$fileinfo->isDir()) { $translatedFilePath = $translationPath.'/'.$fileinfo->getFilename(); $sourceFilePath = $sourcePath.'/'.$fileinfo->getFilename(); $errors = $this->checkFiles($translatedFilePath); $diff = empty($errors) ? $this->getDiff($translatedFilePath, $sourceFilePath) : ''; if(!empty($diff)) { $errors[] = 'Translation outdated.'; } $result = array( 'errors' => $errors, 'diff' => $diff, ); $results[$fileinfo->getFilename()] = $result; } } // checking if there are obsolete translation files $dir = new DirectoryIterator($translationPath); foreach ($dir as $fileinfo) { if (!$fileinfo->isDot() && !$fileinfo->isDir()) { $translatedFilePath = $translationPath.'/'.$fileinfo->getFilename(); $errors = $this->checkFiles(null, $translatedFilePath); if(!empty($errors)) { $results[$fileinfo->getFilename()]['errors'] = $errors; } } } $this->renderFile(dirname(__FILE__).'/translations/report_html.php', array( 'results' => $results, 'sourcePath' => $sourcePath, 'translationPath' => $translationPath, 'title' => $title, )); }
Generates summary report for given translation and original directories @param string $sourcePath the directory where the original documentation files are @param string $translationPath the directory where the translated documentation files are @param string $title custom title to use for report
actionReport
php
yiisoft/yii
build/commands/TranslationsCommand.php
https://github.com/yiisoft/yii/blob/master/build/commands/TranslationsCommand.php
BSD-3-Clause
protected function highlightDiff($diff) { $lines = explode("\n", $diff); foreach ($lines as $key => $val) { if (mb_substr($val,0,1,'utf-8') === '@') { $lines[$key] = '<span class="info">'.CHtml::encode($val).'</span>'; } else if (mb_substr($val,0,1,'utf-8') === '+') { $lines[$key] = '<ins>'.CHtml::encode($val).'</ins>'; } else if (mb_substr($val,0,1,'utf-8') === '-') { $lines[$key] = '<del>'.CHtml::encode($val).'</del>'; } else { $lines[$key] = CHtml::encode($val); } } return implode("\n", $lines); }
Adds all necessary HTML tags and classes to diff output @param string $diff DIFF @return string highlighted DIFF
highlightDiff
php
yiisoft/yii
build/commands/TranslationsCommand.php
https://github.com/yiisoft/yii/blob/master/build/commands/TranslationsCommand.php
BSD-3-Clause
public function is_utf8($str) { $c=0; $b=0; $bits=0; $len=strlen($str); for($i=0; $i<$len; $i++){ $c=ord($str[$i]); if($c > 128){ if(($c >= 254)) return false; elseif($c >= 252) $bits=6; elseif($c >= 248) $bits=5; elseif($c >= 240) $bits=4; elseif($c >= 224) $bits=3; elseif($c >= 192) $bits=2; else return false; if(($i+$bits) > $len) return false; while($bits > 1){ $i++; $b=ord($str[$i]); if($b < 128 || $b > 191) return false; $bits--; } } } return true; }
php.net/manual/de/function.mb-detect-encoding.php#85294 */
is_utf8
php
yiisoft/yii
build/commands/Utf8Command.php
https://github.com/yiisoft/yii/blob/master/build/commands/Utf8Command.php
BSD-3-Clause
public function actionIndex() { // renders the view file 'protected/views/site/index.php' // using the default layout 'protected/views/layouts/main.php' $this->render('index'); }
This is the default 'index' action that is invoked when an action is not explicitly requested by users.
actionIndex
php
yiisoft/yii
build/commands/lite/protected/controllers/SiteController.php
https://github.com/yiisoft/yii/blob/master/build/commands/lite/protected/controllers/SiteController.php
BSD-3-Clause
public function actionLogin() { $user=new LoginForm; if(Yii::app()->request->isPostRequest) { // collect user input data if(isset($_POST['LoginForm'])) $user->setAttributes($_POST['LoginForm']); // validate user input and redirect to previous page if valid if($user->validate()) $this->redirect(Yii::app()->user->returnUrl); } // display the login form $this->render('login',array('user'=>$user)); }
Displays a login form to login a user.
actionLogin
php
yiisoft/yii
build/commands/lite/protected/controllers/SiteController.php
https://github.com/yiisoft/yii/blob/master/build/commands/lite/protected/controllers/SiteController.php
BSD-3-Clause
public function filters() { return array( 'accessControl', // perform access control for CRUD operations ); }
Specifies the action filters. This method overrides the parent implementation. @return array action filters
filters
php
yiisoft/yii
build/commands/lite/protected/controllers/PostController.php
https://github.com/yiisoft/yii/blob/master/build/commands/lite/protected/controllers/PostController.php
BSD-3-Clause
public function accessRules() { return array( array('deny', // deny access to CUD for guest users 'actions'=>array('delete'), 'users'=>array('?'), ), ); }
Specifies the access control rules. This method overrides the parent implementation. It is only effective when 'accessControl' filter is enabled. @return array access control rules
accessRules
php
yiisoft/yii
build/commands/lite/protected/controllers/PostController.php
https://github.com/yiisoft/yii/blob/master/build/commands/lite/protected/controllers/PostController.php
BSD-3-Clause
public function actionCreate() { $post=new Post; if(Yii::app()->request->isPostRequest) { if(isset($_POST['Post'])) $post->setAttributes($_POST['Post']); if($post->save()) $this->redirect(array('show','id'=>$post->id)); } $this->render('create',array('post'=>$post)); }
Creates a new post. If creation is successful, the browser will be redirected to the 'show' page.
actionCreate
php
yiisoft/yii
build/commands/lite/protected/controllers/PostController.php
https://github.com/yiisoft/yii/blob/master/build/commands/lite/protected/controllers/PostController.php
BSD-3-Clause
public function actionUpdate() { $post=$this->loadPost(); if(Yii::app()->request->isPostRequest) { if(isset($_POST['Post'])) $post->setAttributes($_POST['Post']); if($post->save()) $this->redirect(array('show','id'=>$post->id)); } $this->render('update',array('post'=>$post)); }
Updates a particular post. If update is successful, the browser will be redirected to the 'show' page.
actionUpdate
php
yiisoft/yii
build/commands/lite/protected/controllers/PostController.php
https://github.com/yiisoft/yii/blob/master/build/commands/lite/protected/controllers/PostController.php
BSD-3-Clause
public function actionDelete() { if(Yii::app()->request->isPostRequest) { // we only allow deletion via POST request $this->loadPost()->delete(); $this->redirect(array('list')); } else throw new CHttpException(500,'Invalid request. Please do not repeat this request again.'); }
Deletes a particular post. If deletion is successful, the browser will be redirected to the 'list' page.
actionDelete
php
yiisoft/yii
build/commands/lite/protected/controllers/PostController.php
https://github.com/yiisoft/yii/blob/master/build/commands/lite/protected/controllers/PostController.php
BSD-3-Clause
protected function loadPost() { if(isset($_GET['id'])) $post=Post::model()->findbyPk($_GET['id']); if(isset($post)) return $post; else throw new CHttpException(500,'The requested post does not exist.'); }
Loads the data model based on the primary key given in the GET variable. If the data model is not found, an HTTP exception will be raised.
loadPost
php
yiisoft/yii
build/commands/lite/protected/controllers/PostController.php
https://github.com/yiisoft/yii/blob/master/build/commands/lite/protected/controllers/PostController.php
BSD-3-Clause
protected function getListCriteria($pages) { $criteria=new CDbCriteria; $columns=Post::model()->tableSchema->columns; if(isset($_GET['sort']) && isset($columns[$_GET['sort']])) { $criteria->order=$columns[$_GET['sort']]->rawName; if(isset($_GET['desc'])) $criteria->order.=' DESC'; } $criteria->limit=$pages->pageSize; $criteria->offset=$pages->currentPage*$pages->pageSize; return $criteria; }
@param CPagination the pagination information @return CDbCriteria the query criteria for Post list. It includes the ORDER BY and LIMIT/OFFSET information.
getListCriteria
php
yiisoft/yii
build/commands/lite/protected/controllers/PostController.php
https://github.com/yiisoft/yii/blob/master/build/commands/lite/protected/controllers/PostController.php
BSD-3-Clause
protected function generateColumnHeader($column) { $params=$_GET; if(isset($params['sort']) && $params['sort']===$column) { if(isset($params['desc'])) unset($params['desc']); else $params['desc']=1; } else { $params['sort']=$column; unset($params['desc']); } $url=$this->createUrl('list',$params); return CHtml::link(Post::model()->getAttributeLabel($column),$url); }
Generates the header cell for the specified column. This method will generate a hyperlink for the column. Clicking on the link will cause the data to be sorted according to the column. @param string the column name @return string the generated header cell content
generateColumnHeader
php
yiisoft/yii
build/commands/lite/protected/controllers/PostController.php
https://github.com/yiisoft/yii/blob/master/build/commands/lite/protected/controllers/PostController.php
BSD-3-Clause
public function authenticate($attribute,$params) { if(!$this->hasErrors()) // we only want to authenticate when no input errors { $identity=new UserIdentity($this->username,$this->password); if($identity->authenticate()) { $duration=$this->rememberMe ? 3600*24*30 : 0; // 30 days Yii::app()->user->login($identity,$duration); } else $this->addError('password','Incorrect password.'); } }
Authenticates the password. This is the 'authenticate' validator as declared in rules().
authenticate
php
yiisoft/yii
build/commands/lite/protected/models/LoginForm.php
https://github.com/yiisoft/yii/blob/master/build/commands/lite/protected/models/LoginForm.php
BSD-3-Clause
public function main() { $this->addProperty('yii.version',$this->getYiiVersion()); $this->addProperty('yii.revision',$this->getYiiRevision()); $this->addProperty('yii.winbuild', substr(PHP_OS, 0, 3) == 'WIN' ? 'true' : 'false'); $this->addProperty('yii.release',$this->getYiiRelease()); $this->addProperty('yii.date',date('M j, Y')); }
Execute lint check against PhingFile or a FileSet
main
php
yiisoft/yii
build/tasks/YiiInitTask.php
https://github.com/yiisoft/yii/blob/master/build/tasks/YiiInitTask.php
BSD-3-Clause
public static function createApplication($class,$config=null) { return new $class($config); }
Creates an application of the specified class. @param string $class the application class name @param mixed $config application configuration. This parameter will be passed as the parameter to the constructor of the application class. @return mixed the application instance
createApplication
php
yiisoft/yii
framework/YiiBase.php
https://github.com/yiisoft/yii/blob/master/framework/YiiBase.php
BSD-3-Clause
public static function app() { return self::$_app; }
Returns the application singleton or null if the singleton has not been created yet. @return CApplication the application singleton, null if the singleton has not been created yet.
app
php
yiisoft/yii
framework/YiiBase.php
https://github.com/yiisoft/yii/blob/master/framework/YiiBase.php
BSD-3-Clause
public static function setApplication($app) { if(self::$_app===null || $app===null) self::$_app=$app; else throw new CException(Yii::t('yii','Yii application can only be created once.')); }
Stores the application instance in the class static member. This method helps implement a singleton pattern for CApplication. Repeated invocation of this method or the CApplication constructor will cause the throw of an exception. To retrieve the application instance, use {@link app()}. @param CApplication $app the application instance. If this is null, the existing application singleton will be removed. @throws CException if multiple application instances are registered.
setApplication
php
yiisoft/yii
framework/YiiBase.php
https://github.com/yiisoft/yii/blob/master/framework/YiiBase.php
BSD-3-Clause
public static function import($alias,$forceInclude=false) { if(isset(self::$_imports[$alias])) // previously imported return self::$_imports[$alias]; if(class_exists($alias,false) || interface_exists($alias,false)) return self::$_imports[$alias]=$alias; if(($pos=strrpos($alias,'\\'))!==false) // a class name in PHP 5.3 namespace format { $namespace=str_replace('\\','.',ltrim(substr($alias,0,$pos),'\\')); if(($path=self::getPathOfAlias($namespace))!==false) { $classFile=$path.DIRECTORY_SEPARATOR.substr($alias,$pos+1).'.php'; if($forceInclude) { if(is_file($classFile)) require($classFile); else throw new CException(Yii::t('yii','Alias "{alias}" is invalid. Make sure it points to an existing PHP file and the file is readable.',array('{alias}'=>$alias))); self::$_imports[$alias]=$alias; } else self::$classMap[$alias]=$classFile; return $alias; } else { // try to autoload the class with an autoloader if (class_exists($alias,true)) return self::$_imports[$alias]=$alias; else throw new CException(Yii::t('yii','Alias "{alias}" is invalid. Make sure it points to an existing directory or file.', array('{alias}'=>$namespace))); } } if(($pos=strrpos($alias,'.'))===false) // a simple class name { // try to autoload the class with an autoloader if $forceInclude is true if($forceInclude && (Yii::autoload($alias,true) || class_exists($alias,true))) self::$_imports[$alias]=$alias; return $alias; } $className=(string)substr($alias,$pos+1); $isClass=$className!=='*'; if($isClass && (class_exists($className,false) || interface_exists($className,false))) return self::$_imports[$alias]=$className; if(($path=self::getPathOfAlias($alias))!==false) { if($isClass) { if($forceInclude) { if(is_file($path.'.php')) require($path.'.php'); else throw new CException(Yii::t('yii','Alias "{alias}" is invalid. Make sure it points to an existing PHP file and the file is readable.',array('{alias}'=>$alias))); self::$_imports[$alias]=$className; } else self::$classMap[$className]=$path.'.php'; return $className; } else // a directory { if(self::$_includePaths===null) { self::$_includePaths=array_unique(explode(PATH_SEPARATOR,get_include_path())); if(($pos=array_search('.',self::$_includePaths,true))!==false) unset(self::$_includePaths[$pos]); } array_unshift(self::$_includePaths,$path); if(self::$enableIncludePath && set_include_path('.'.PATH_SEPARATOR.implode(PATH_SEPARATOR,self::$_includePaths))===false) self::$enableIncludePath=false; return self::$_imports[$alias]=$path; } } else throw new CException(Yii::t('yii','Alias "{alias}" is invalid. Make sure it points to an existing directory or file.', array('{alias}'=>$alias))); }
Imports a class or a directory. Importing a class is like including the corresponding class file. The main difference is that importing a class is much lighter because it only includes the class file when the class is referenced the first time. Importing a directory is equivalent to adding a directory into the PHP include path. If multiple directories are imported, the directories imported later will take precedence in class file searching (i.e., they are added to the front of the PHP include path). Path aliases are used to import a class or directory. For example, <ul> <li><code>application.components.GoogleMap</code>: import the <code>GoogleMap</code> class.</li> <li><code>application.components.*</code>: import the <code>components</code> directory.</li> </ul> The same path alias can be imported multiple times, but only the first time is effective. Importing a directory does not import any of its subdirectories. Starting from version 1.1.5, this method can also be used to import a class in namespace format (available for PHP 5.3 or above only). It is similar to importing a class in path alias format, except that the dot separator is replaced by the backslash separator. For example, importing <code>application\components\GoogleMap</code> is similar to importing <code>application.components.GoogleMap</code>. The difference is that the former class is using qualified name, while the latter unqualified. Note, importing a class in namespace format requires that the namespace corresponds to a valid path alias once backslash characters are replaced with dot characters. For example, the namespace <code>application\components</code> must correspond to a valid path alias <code>application.components</code>. @param string $alias path alias to be imported @param boolean $forceInclude whether to include the class file immediately. If false, the class file will be included only when the class is being used. This parameter is used only when the path alias refers to a class. @return string the class name or the directory that this alias refers to @throws CException if the alias is invalid
import
php
yiisoft/yii
framework/YiiBase.php
https://github.com/yiisoft/yii/blob/master/framework/YiiBase.php
BSD-3-Clause
public static function setPathOfAlias($alias,$path) { if(empty($path)) unset(self::$_aliases[$alias]); else self::$_aliases[$alias]=rtrim($path,'\\/'); }
Create a path alias. Note, this method neither checks the existence of the path nor normalizes the path. @param string $alias alias to the path @param string $path the path corresponding to the alias. If this is null, the corresponding path alias will be removed.
setPathOfAlias
php
yiisoft/yii
framework/YiiBase.php
https://github.com/yiisoft/yii/blob/master/framework/YiiBase.php
BSD-3-Clause
public static function trace($msg,$category='application') { if(YII_DEBUG) self::log($msg,CLogger::LEVEL_TRACE,$category); }
Writes a trace message. This method will only log a message when the application is in debug mode. @param string $msg message to be logged @param string $category category of the message @see log
trace
php
yiisoft/yii
framework/YiiBase.php
https://github.com/yiisoft/yii/blob/master/framework/YiiBase.php
BSD-3-Clause
public static function endProfile($token,$category='application') { self::log('end:'.$token,CLogger::LEVEL_PROFILE,$category); }
Marks the end of a code block for profiling. This has to be matched with a previous call to {@link beginProfile()} with the same token. @param string $token token for the code block @param string $category the category of this log message @see beginProfile
endProfile
php
yiisoft/yii
framework/YiiBase.php
https://github.com/yiisoft/yii/blob/master/framework/YiiBase.php
BSD-3-Clause
public static function powered() { return Yii::t('yii','Powered by {yii}.', array('{yii}'=>'<a href="https://www.yiiframework.com/" rel="external">Yii Framework</a>')); }
Returns a string that can be displayed on your Web page showing Powered-by-Yii information @return string a string that can be displayed on your Web page showing Powered-by-Yii information
powered
php
yiisoft/yii
framework/YiiBase.php
https://github.com/yiisoft/yii/blob/master/framework/YiiBase.php
BSD-3-Clause
public function getViewFile($controller,$viewName) { $moduleViewPath=$this->getViewPath(); if(($module=$controller->getModule())!==null) $moduleViewPath.='/'.$module->getId(); return $controller->resolveViewFile($viewName,$this->getViewPath().'/'.$controller->getUniqueId(),$this->getViewPath(),$moduleViewPath); }
Finds the view file for the specified controller's view. @param CController $controller the controller @param string $viewName the view name @return string the view file path. False if the file does not exist.
getViewFile
php
yiisoft/yii
framework/web/CTheme.php
https://github.com/yiisoft/yii/blob/master/framework/web/CTheme.php
BSD-3-Clause
public function getLayoutFile($controller,$layoutName) { $moduleViewPath=$basePath=$this->getViewPath(); $module=$controller->getModule(); if(empty($layoutName)) { while($module!==null) { if($module->layout===false) return false; if(!empty($module->layout)) break; $module=$module->getParentModule(); } if($module===null) $layoutName=Yii::app()->layout; else { $layoutName=$module->layout; $moduleViewPath.='/'.$module->getId(); } } elseif($module!==null) $moduleViewPath.='/'.$module->getId(); return $controller->resolveViewFile($layoutName,$moduleViewPath.'/layouts',$basePath,$moduleViewPath); }
Finds the layout file for the specified controller's layout. @param CController $controller the controller @param string $layoutName the layout name @return string the layout file path. False if the file does not exist.
getLayoutFile
php
yiisoft/yii
framework/web/CTheme.php
https://github.com/yiisoft/yii/blob/master/framework/web/CTheme.php
BSD-3-Clause
public function setCriteria($value) { $this->_criteria=$value instanceof CDbCriteria ? $value : new CDbCriteria($value); }
Sets the query criteria. @param CDbCriteria|array $value the query criteria. This can be either a CDbCriteria object or an array representing the query criteria.
setCriteria
php
yiisoft/yii
framework/web/CActiveDataProvider.php
https://github.com/yiisoft/yii/blob/master/framework/web/CActiveDataProvider.php
BSD-3-Clause
public function getCountCriteria() { if($this->_countCriteria===null) return $this->getCriteria(); return $this->_countCriteria; }
Returns the count query criteria. @return CDbCriteria the count query criteria. @since 1.1.14
getCountCriteria
php
yiisoft/yii
framework/web/CActiveDataProvider.php
https://github.com/yiisoft/yii/blob/master/framework/web/CActiveDataProvider.php
BSD-3-Clause
public function setCountCriteria($value) { $this->_countCriteria=$value instanceof CDbCriteria ? $value : new CDbCriteria($value); }
Sets the count query criteria. @param CDbCriteria|array $value the count query criteria. This can be either a CDbCriteria object or an array representing the query criteria. @since 1.1.14
setCountCriteria
php
yiisoft/yii
framework/web/CActiveDataProvider.php
https://github.com/yiisoft/yii/blob/master/framework/web/CActiveDataProvider.php
BSD-3-Clause
protected function getModel($className) { return CActiveRecord::model($className); }
Given active record class name returns new model instance. @param string $className active record class name. @return CActiveRecord active record model instance. @since 1.1.14
getModel
php
yiisoft/yii
framework/web/CActiveDataProvider.php
https://github.com/yiisoft/yii/blob/master/framework/web/CActiveDataProvider.php
BSD-3-Clause
protected function fetchData() { $criteria=clone $this->getCriteria(); if(($pagination=$this->getPagination())!==false) { $pagination->setItemCount($this->getTotalItemCount()); $pagination->applyLimit($criteria); } $baseCriteria=$this->model->getDbCriteria(false); if(($sort=$this->getSort())!==false) { // set model criteria so that CSort can use its table alias setting if($baseCriteria!==null) { $c=clone $baseCriteria; $c->mergeWith($criteria); $this->model->setDbCriteria($c); } else $this->model->setDbCriteria($criteria); $sort->applyOrder($criteria); } $this->model->setDbCriteria($baseCriteria!==null ? clone $baseCriteria : null); $data=$this->model->findAll($criteria); $this->model->setDbCriteria($baseCriteria); // restore original criteria return $data; }
Fetches the data from the persistent data storage. @return array list of data items
fetchData
php
yiisoft/yii
framework/web/CActiveDataProvider.php
https://github.com/yiisoft/yii/blob/master/framework/web/CActiveDataProvider.php
BSD-3-Clause
protected function calculateTotalItemCount() { $baseCriteria=$this->model->getDbCriteria(false); if($baseCriteria!==null) $baseCriteria=clone $baseCriteria; $count=$this->model->count($this->getCountCriteria()); $this->model->setDbCriteria($baseCriteria); return $count; }
Calculates the total number of data items. @return integer the total number of data items.
calculateTotalItemCount
php
yiisoft/yii
framework/web/CActiveDataProvider.php
https://github.com/yiisoft/yii/blob/master/framework/web/CActiveDataProvider.php
BSD-3-Clause
protected function fetchKeys() { $keys=array(); if($data=$this->getData()) { if(is_object(reset($data))) foreach($data as $i=>$item) $keys[$i]=$item->{$this->keyField}; else foreach($data as $i=>$item) $keys[$i]=$item[$this->keyField]; } return $keys; }
Fetches the data item keys from the persistent data storage. @return array list of data item keys.
fetchKeys
php
yiisoft/yii
framework/web/CSqlDataProvider.php
https://github.com/yiisoft/yii/blob/master/framework/web/CSqlDataProvider.php
BSD-3-Clause
protected function calculateTotalItemCount() { return 0; }
Calculates the total number of data items. This method is invoked when {@link getTotalItemCount()} is invoked and {@link totalItemCount} is not set previously. The default implementation simply returns 0. You may override this method to return accurate total number of data items. @return integer the total number of data items.
calculateTotalItemCount
php
yiisoft/yii
framework/web/CSqlDataProvider.php
https://github.com/yiisoft/yii/blob/master/framework/web/CSqlDataProvider.php
BSD-3-Clause
protected function calculateTotalItemCount() { return count($this->rawData); }
Calculates the total number of data items. This method simply returns the number of elements in {@link rawData}. @return integer the total number of data items.
calculateTotalItemCount
php
yiisoft/yii
framework/web/CArrayDataProvider.php
https://github.com/yiisoft/yii/blob/master/framework/web/CArrayDataProvider.php
BSD-3-Clause
protected function getSortingFieldValue($data, $fields) { if(is_object($data)) { foreach($fields as $field) $data=isset($data->$field) ? $data->$field : null; } else { foreach($fields as $field) $data=isset($data[$field]) ? $data[$field] : null; } return $this->caseSensitiveSort ? $data : mb_strtolower($data,Yii::app()->charset); }
Get field for sorting, using dot like delimiter in query. @param mixed $data array or object @param array $fields sorting fields in $data @return mixed $data sorting field value
getSortingFieldValue
php
yiisoft/yii
framework/web/CArrayDataProvider.php
https://github.com/yiisoft/yii/blob/master/framework/web/CArrayDataProvider.php
BSD-3-Clause
public function init() { }
Initializes the controller. This method is called by the application before the controller starts to execute. You may override this method to perform the needed initialization for the controller.
init
php
yiisoft/yii
framework/web/CController.php
https://github.com/yiisoft/yii/blob/master/framework/web/CController.php
BSD-3-Clause
public function filters() { return array(); }
Returns the filter configurations. By overriding this method, child classes can specify filters to be applied to actions. This method returns an array of filter specifications. Each array element specify a single filter. For a method-based filter (called inline filter), it is specified as 'FilterName[ +|- Action1, Action2, ...]', where the '+' ('-') operators describe which actions should be (should not be) applied with the filter. For a class-based filter, it is specified as an array like the following: <pre> array( 'FilterClass[ +|- Action1, Action2, ...]', 'name1'=>'value1', 'name2'=>'value2', ... ) </pre> where the name-value pairs will be used to initialize the properties of the filter. Note, in order to inherit filters defined in the parent class, a child class needs to merge the parent filters with child filters using functions like array_merge(). @return array a list of filter configurations. @see CFilter
filters
php
yiisoft/yii
framework/web/CController.php
https://github.com/yiisoft/yii/blob/master/framework/web/CController.php
BSD-3-Clause
public function behaviors() { return array(); }
Returns a list of behaviors that this controller should behave as. The return value should be an array of behavior configurations indexed by behavior names. Each behavior configuration can be either a string specifying the behavior class or an array of the following structure: <pre> 'behaviorName'=>array( 'class'=>'path.to.BehaviorClass', 'property1'=>'value1', 'property2'=>'value2', ) </pre> Note, the behavior classes must implement {@link IBehavior} or extend from {@link CBehavior}. Behaviors declared in this method will be attached to the controller when it is instantiated. For more details about behaviors, see {@link CComponent}. @return array the behavior configurations (behavior name=>behavior configuration)
behaviors
php
yiisoft/yii
framework/web/CController.php
https://github.com/yiisoft/yii/blob/master/framework/web/CController.php
BSD-3-Clause
public function accessRules() { return array(); }
Returns the access rules for this controller. Override this method if you use the {@link filterAccessControl accessControl} filter. @return array list of access rules. See {@link CAccessControlFilter} for details about rule specification.
accessRules
php
yiisoft/yii
framework/web/CController.php
https://github.com/yiisoft/yii/blob/master/framework/web/CController.php
BSD-3-Clause
public function run($actionID) { if(($action=$this->createAction($actionID))!==null) { if(($parent=$this->getModule())===null) $parent=Yii::app(); if($parent->beforeControllerAction($this,$action)) { $this->runActionWithFilters($action,$this->filters()); $parent->afterControllerAction($this,$action); } } else $this->missingAction($actionID); }
Runs the named action. Filters specified via {@link filters()} will be applied. @param string $actionID action ID @throws CHttpException if the action does not exist or the action name is not proper. @see filters @see createAction @see runAction
run
php
yiisoft/yii
framework/web/CController.php
https://github.com/yiisoft/yii/blob/master/framework/web/CController.php
BSD-3-Clause
public function runActionWithFilters($action,$filters) { if(empty($filters)) $this->runAction($action); else { $priorAction=$this->_action; $this->_action=$action; CFilterChain::create($this,$action,$filters)->run(); $this->_action=$priorAction; } }
Runs an action with the specified filters. A filter chain will be created based on the specified filters and the action will be executed then. @param CAction $action the action to be executed. @param array $filters list of filters to be applied to the action. @see filters @see createAction @see runAction
runActionWithFilters
php
yiisoft/yii
framework/web/CController.php
https://github.com/yiisoft/yii/blob/master/framework/web/CController.php
BSD-3-Clause
public function runAction($action) { $priorAction=$this->_action; $this->_action=$action; if($this->beforeAction($action)) { if($action->runWithParams($this->getActionParams())===false) $this->invalidActionParams($action); else $this->afterAction($action); } $this->_action=$priorAction; }
Runs the action after passing through all filters. This method is invoked by {@link runActionWithFilters} after all possible filters have been executed and the action starts to run. @param CAction $action action to run
runAction
php
yiisoft/yii
framework/web/CController.php
https://github.com/yiisoft/yii/blob/master/framework/web/CController.php
BSD-3-Clause
public function getActionParams() { return $_GET; }
Returns the request parameters that will be used for action parameter binding. By default, this method will return $_GET. You may override this method if you want to use other request parameters (e.g. $_GET+$_POST). @return array the request parameters to be used for action parameter binding @since 1.1.7
getActionParams
php
yiisoft/yii
framework/web/CController.php
https://github.com/yiisoft/yii/blob/master/framework/web/CController.php
BSD-3-Clause
public function invalidActionParams($action) { throw new CHttpException(400,Yii::t('yii','Your request is invalid.')); }
This method is invoked when the request parameters do not satisfy the requirement of the specified action. The default implementation will throw a 400 HTTP exception. @param CAction $action the action being executed @since 1.1.7 @throws CHttpException
invalidActionParams
php
yiisoft/yii
framework/web/CController.php
https://github.com/yiisoft/yii/blob/master/framework/web/CController.php
BSD-3-Clause
public function processOutput($output) { Yii::app()->getClientScript()->render($output); // if using page caching, we should delay dynamic output replacement if($this->_dynamicOutput!==null && $this->isCachingStackEmpty()) { $output=$this->processDynamicOutput($output); $this->_dynamicOutput=null; } if($this->_pageStates===null) $this->_pageStates=$this->loadPageStates(); if(!empty($this->_pageStates)) $this->savePageStates($this->_pageStates,$output); return $output; }
Postprocesses the output generated by {@link render()}. This method is invoked at the end of {@link render()} and {@link renderText()}. If there are registered client scripts, this method will insert them into the output at appropriate places. If there are dynamic contents, they will also be inserted. This method may also save the persistent page states in hidden fields of stateful forms in the page. @param string $output the output generated by the current action @return string the output that has been processed.
processOutput
php
yiisoft/yii
framework/web/CController.php
https://github.com/yiisoft/yii/blob/master/framework/web/CController.php
BSD-3-Clause
public function processDynamicOutput($output) { if($this->_dynamicOutput) { $output=preg_replace_callback('/<###dynamic-(\d+)###>/',array($this,'replaceDynamicOutput'),$output); } return $output; }
Postprocesses the dynamic output. This method is internally used. Do not call this method directly. @param string $output output to be processed @return string the processed output
processDynamicOutput
php
yiisoft/yii
framework/web/CController.php
https://github.com/yiisoft/yii/blob/master/framework/web/CController.php
BSD-3-Clause
protected function replaceDynamicOutput($matches) { $content=$matches[0]; if(isset($this->_dynamicOutput[$matches[1]])) { $content=$this->_dynamicOutput[$matches[1]]; $this->_dynamicOutput[$matches[1]]=null; } return $content; }
Replaces the dynamic content placeholders with actual content. This is a callback function used internally. @param array $matches matches @return string the replacement @see processOutput
replaceDynamicOutput
php
yiisoft/yii
framework/web/CController.php
https://github.com/yiisoft/yii/blob/master/framework/web/CController.php
BSD-3-Clause
public function createAction($actionID) { if($actionID==='') $actionID=$this->defaultAction; if(method_exists($this,'action'.$actionID) && strcasecmp($actionID,'s')) // we have actions method return new CInlineAction($this,$actionID); else { $action=$this->createActionFromMap($this->actions(),$actionID,$actionID); if($action!==null && !method_exists($action,'run')) throw new CException(Yii::t('yii', 'Action class {class} must implement the "run" method.', array('{class}'=>get_class($action)))); return $action; } }
Creates the action instance based on the action name. The action can be either an inline action or an object. The latter is created by looking up the action map specified in {@link actions}. @param string $actionID ID of the action. If empty, the {@link defaultAction default action} will be used. @return CAction the action instance, null if the action does not exist. @see actions @throws CException
createAction
php
yiisoft/yii
framework/web/CController.php
https://github.com/yiisoft/yii/blob/master/framework/web/CController.php
BSD-3-Clause
public function missingAction($actionID) { throw new CHttpException(404,Yii::t('yii','The system is unable to find the requested action "{action}".', array('{action}'=>$actionID==''?$this->defaultAction:$actionID))); }
Handles the request whose action is not recognized. This method is invoked when the controller cannot find the requested action. The default implementation simply throws an exception. @param string $actionID the missing action name @throws CHttpException whenever this method is invoked
missingAction
php
yiisoft/yii
framework/web/CController.php
https://github.com/yiisoft/yii/blob/master/framework/web/CController.php
BSD-3-Clause
public function getModule() { return $this->_module; }
@return CWebModule the module that this controller belongs to. It returns null if the controller does not belong to any module
getModule
php
yiisoft/yii
framework/web/CController.php
https://github.com/yiisoft/yii/blob/master/framework/web/CController.php
BSD-3-Clause
public function getViewPath() { if(($module=$this->getModule())===null) $module=Yii::app(); return $module->getViewPath().DIRECTORY_SEPARATOR.$this->getId(); }
Returns the directory containing view files for this controller. The default implementation returns 'protected/views/ControllerID'. Child classes may override this method to use customized view path. If the controller belongs to a module, the default view path is the {@link CWebModule::getViewPath module view path} appended with the controller ID. @return string the directory containing the view files for this controller. Defaults to 'protected/views/ControllerID'.
getViewPath
php
yiisoft/yii
framework/web/CController.php
https://github.com/yiisoft/yii/blob/master/framework/web/CController.php
BSD-3-Clause
public function resolveViewFile($viewName,$viewPath,$basePath,$moduleViewPath=null) { if(empty($viewName)) return false; if($moduleViewPath===null) $moduleViewPath=$basePath; if(($renderer=Yii::app()->getViewRenderer())!==null) $extension=$renderer->fileExtension; else $extension='.php'; if($viewName[0]==='/') { if(strncmp($viewName,'//',2)===0) $viewFile=$basePath.$viewName; else $viewFile=$moduleViewPath.$viewName; } elseif(strpos($viewName,'.')) $viewFile=Yii::getPathOfAlias($viewName); else $viewFile=$viewPath.DIRECTORY_SEPARATOR.$viewName; if(is_file($viewFile.$extension)) return Yii::app()->findLocalizedFile($viewFile.$extension); elseif($extension!=='.php' && is_file($viewFile.'.php')) return Yii::app()->findLocalizedFile($viewFile.'.php'); else return false; }
Finds a view file based on its name. The view name can be in one of the following formats: <ul> <li>absolute view within a module: the view name starts with a single slash '/'. In this case, the view will be searched for under the currently active module's view path. If there is no active module, the view will be searched for under the application's view path.</li> <li>absolute view within the application: the view name starts with double slashes '//'. In this case, the view will be searched for under the application's view path. This syntax has been available since version 1.1.3.</li> <li>aliased view: the view name contains dots and refers to a path alias. The view file is determined by calling {@link YiiBase::getPathOfAlias()}. Note that aliased views cannot be themed because they can refer to a view file located at arbitrary places.</li> <li>relative view: otherwise. Relative views will be searched for under the currently active controller's view path.</li> </ul> For absolute view and relative view, the corresponding view file is a PHP file whose name is the same as the view name. The file is located under a specified directory. This method will call {@link CApplication::findLocalizedFile} to search for a localized file, if any. @param string $viewName the view name @param string $viewPath the directory that is used to search for a relative view name @param string $basePath the directory that is used to search for an absolute view name under the application @param string $moduleViewPath the directory that is used to search for an absolute view name under the current module. If this is not set, the application base view path will be used. @return mixed the view file path. False if the view file does not exist.
resolveViewFile
php
yiisoft/yii
framework/web/CController.php
https://github.com/yiisoft/yii/blob/master/framework/web/CController.php
BSD-3-Clause
public function getClips() { if($this->_clips!==null) return $this->_clips; else return $this->_clips=new CMap; }
Returns the list of clips. A clip is a named piece of rendering result that can be inserted at different places. @return CMap the list of clips @see CClipWidget
getClips
php
yiisoft/yii
framework/web/CController.php
https://github.com/yiisoft/yii/blob/master/framework/web/CController.php
BSD-3-Clause
public function forward($route,$exit=true) { if(strpos($route,'/')===false) $this->run($route); else { if($route[0]!=='/' && ($module=$this->getModule())!==null) $route=$module->getId().'/'.$route; Yii::app()->runController($route); } if($exit) Yii::app()->end(); }
Processes the request using another controller action. This is like {@link redirect}, but the user browser's URL remains unchanged. In most cases, you should call {@link redirect} instead of this method. @param string $route the route of the new controller action. This can be an action ID, or a complete route with module ID (optional in the current module), controller ID and action ID. If the former, the action is assumed to be located within the current controller. @param boolean $exit whether to end the application after this call. Defaults to true. @since 1.1.0
forward
php
yiisoft/yii
framework/web/CController.php
https://github.com/yiisoft/yii/blob/master/framework/web/CController.php
BSD-3-Clause
public function render($view,$data=null,$return=false) { if($this->beforeRender($view)) { $output=$this->renderPartial($view,$data,true); if(($layoutFile=$this->getLayoutFile($this->layout))!==false) $output=$this->renderFile($layoutFile,array('content'=>$output),true); $this->afterRender($view,$output); $output=$this->processOutput($output); if($return) return $output; else echo $output; } }
Renders a view with a layout. This method first calls {@link renderPartial} to render the view (called content view). It then renders the layout view which may embed the content view at appropriate place. In the layout view, the content view rendering result can be accessed via variable <code>$content</code>. At the end, it calls {@link processOutput} to insert scripts and dynamic contents if they are available. By default, the layout view script is "protected/views/layouts/main.php". This may be customized by changing {@link layout}. @param string $view name of the view to be rendered. See {@link getViewFile} for details about how the view script is resolved. @param array $data data to be extracted into PHP variables and made available to the view script @param boolean $return whether the rendering result should be returned instead of being displayed to end users. @return string the rendering result. Null if the rendering result is not required. @see renderPartial @see getLayoutFile
render
php
yiisoft/yii
framework/web/CController.php
https://github.com/yiisoft/yii/blob/master/framework/web/CController.php
BSD-3-Clause
protected function beforeRender($view) { return true; }
This method is invoked at the beginning of {@link render()}. You may override this method to do some preprocessing when rendering a view. @param string $view the view to be rendered @return boolean whether the view should be rendered. @since 1.1.5
beforeRender
php
yiisoft/yii
framework/web/CController.php
https://github.com/yiisoft/yii/blob/master/framework/web/CController.php
BSD-3-Clause
protected function afterRender($view, &$output) { }
This method is invoked after the specified view is rendered by calling {@link render()}. Note that this method is invoked BEFORE {@link processOutput()}. You may override this method to do some postprocessing for the view rendering. @param string $view the view that has been rendered @param string $output the rendering result of the view. Note that this parameter is passed as a reference. That means you can modify it within this method. @since 1.1.5
afterRender
php
yiisoft/yii
framework/web/CController.php
https://github.com/yiisoft/yii/blob/master/framework/web/CController.php
BSD-3-Clause
public function renderText($text,$return=false) { if(($layoutFile=$this->getLayoutFile($this->layout))!==false) $text=$this->renderFile($layoutFile,array('content'=>$text),true); $text=$this->processOutput($text); if($return) return $text; else echo $text; }
Renders a static text string. The string will be inserted in the current controller layout and returned back. @param string $text the static text string @param boolean $return whether the rendering result should be returned instead of being displayed to end users. @return string the rendering result. Null if the rendering result is not required. @see getLayoutFile
renderText
php
yiisoft/yii
framework/web/CController.php
https://github.com/yiisoft/yii/blob/master/framework/web/CController.php
BSD-3-Clause
public function renderDynamic($callback) { $n=($this->_dynamicOutput === null ? 0 : count($this->_dynamicOutput)); echo "<###dynamic-$n###>"; $params=func_get_args(); array_shift($params); $this->renderDynamicInternal($callback,$params); }
Renders dynamic content returned by the specified callback. This method is used together with {@link COutputCache}. Dynamic contents will always show as their latest state even if the content surrounding them is being cached. This is especially useful when caching pages that are mostly static but contain some small dynamic regions, such as username or current time. We can use this method to render these dynamic regions to ensure they are always up-to-date. The first parameter to this method should be a valid PHP callback, while the rest parameters will be passed to the callback. Note, the callback and its parameter values will be serialized and saved in cache. Make sure they are serializable. @param callable $callback a PHP callback which returns the needed dynamic content. When the callback is specified as a string, it will be first assumed to be a method of the current controller class. If the method does not exist, it is assumed to be a global PHP function. Note, the callback should return the dynamic content instead of echoing it.
renderDynamic
php
yiisoft/yii
framework/web/CController.php
https://github.com/yiisoft/yii/blob/master/framework/web/CController.php
BSD-3-Clause
public function renderDynamicInternal($callback,$params) { $this->recordCachingAction('','renderDynamicInternal',array($callback,$params)); if(is_string($callback) && method_exists($this,$callback)) $callback=array($this,$callback); $this->_dynamicOutput[]=call_user_func_array($callback,$params); }
This method is internally used. @param callable $callback a PHP callback which returns the needed dynamic content. @param array $params parameters passed to the PHP callback @see renderDynamic
renderDynamicInternal
php
yiisoft/yii
framework/web/CController.php
https://github.com/yiisoft/yii/blob/master/framework/web/CController.php
BSD-3-Clause
public function refresh($terminate=true,$anchor='') { $this->redirect(Yii::app()->getRequest()->getUrl().$anchor,$terminate); }
Refreshes the current page. The effect of this method call is the same as user pressing the refresh button on the browser (without post data). @param boolean $terminate whether to terminate the current application after calling this method @param string $anchor the anchor that should be appended to the redirection URL. Defaults to empty. Make sure the anchor starts with '#' if you want to specify it.
refresh
php
yiisoft/yii
framework/web/CController.php
https://github.com/yiisoft/yii/blob/master/framework/web/CController.php
BSD-3-Clause
public function recordCachingAction($context,$method,$params) { if($this->_cachingStack) // record only when there is an active output cache { foreach($this->_cachingStack as $cache) $cache->recordAction($context,$method,$params); } }
Records a method call when an output cache is in effect. When the content is served from the output cache, the recorded method will be re-invoked. @param string $context a property name of the controller. It refers to an object whose method is being called. If empty it means the controller itself. @param string $method the method name @param array $params parameters passed to the method @see COutputCache
recordCachingAction
php
yiisoft/yii
framework/web/CController.php
https://github.com/yiisoft/yii/blob/master/framework/web/CController.php
BSD-3-Clause
public function isCachingStackEmpty() { return $this->_cachingStack===null || !$this->_cachingStack->getCount(); }
Returns whether the caching stack is empty. @return boolean whether the caching stack is empty. If not empty, it means currently there are some output cache in effect. Note, the return result of this method may change when it is called in different output regions, depending on the partition of output caches.
isCachingStackEmpty
php
yiisoft/yii
framework/web/CController.php
https://github.com/yiisoft/yii/blob/master/framework/web/CController.php
BSD-3-Clause
protected function beforeAction($action) { return true; }
This method is invoked right before an action is to be executed (after all possible filters.) You may override this method to do last-minute preparation for the action. @param CAction $action the action to be executed. @return boolean whether the action should be executed.
beforeAction
php
yiisoft/yii
framework/web/CController.php
https://github.com/yiisoft/yii/blob/master/framework/web/CController.php
BSD-3-Clause
protected function afterAction($action) { }
This method is invoked right after an action is executed. You may override this method to do some postprocessing for the action. @param CAction $action the action just executed.
afterAction
php
yiisoft/yii
framework/web/CController.php
https://github.com/yiisoft/yii/blob/master/framework/web/CController.php
BSD-3-Clause
public function filterPostOnly($filterChain) { if(Yii::app()->getRequest()->getIsPostRequest()) $filterChain->run(); else throw new CHttpException(400,Yii::t('yii','Your request is invalid.')); }
The filter method for 'postOnly' filter. This filter throws an exception (CHttpException with code 400) if the applied action is receiving a non-POST request. @param CFilterChain $filterChain the filter chain that the filter is on. @throws CHttpException if the current request is not a POST request
filterPostOnly
php
yiisoft/yii
framework/web/CController.php
https://github.com/yiisoft/yii/blob/master/framework/web/CController.php
BSD-3-Clause
public function filterAjaxOnly($filterChain) { if(Yii::app()->getRequest()->getIsAjaxRequest()) $filterChain->run(); else throw new CHttpException(400,Yii::t('yii','Your request is invalid.')); }
The filter method for 'ajaxOnly' filter. This filter throws an exception (CHttpException with code 400) if the applied action is receiving a non-AJAX request. @param CFilterChain $filterChain the filter chain that the filter is on. @throws CHttpException if the current request is not an AJAX request.
filterAjaxOnly
php
yiisoft/yii
framework/web/CController.php
https://github.com/yiisoft/yii/blob/master/framework/web/CController.php
BSD-3-Clause
public function filterAccessControl($filterChain) { $filter=new CAccessControlFilter; $filter->setRules($this->accessRules()); $filter->filter($filterChain); }
The filter method for 'accessControl' filter. This filter is a wrapper of {@link CAccessControlFilter}. To use this filter, you must override {@link accessRules} method. @param CFilterChain $filterChain the filter chain that the filter is on.
filterAccessControl
php
yiisoft/yii
framework/web/CController.php
https://github.com/yiisoft/yii/blob/master/framework/web/CController.php
BSD-3-Clause
public function getPageState($name,$defaultValue=null) { if($this->_pageStates===null) $this->_pageStates=$this->loadPageStates(); return isset($this->_pageStates[$name])?$this->_pageStates[$name]:$defaultValue; }
Returns a persistent page state value. A page state is a variable that is persistent across POST requests of the same page. In order to use persistent page states, the form(s) must be stateful which are generated using {@link CHtml::statefulForm}. @param string $name the state name @param mixed $defaultValue the value to be returned if the named state is not found @return mixed the page state value @see setPageState @see CHtml::statefulForm
getPageState
php
yiisoft/yii
framework/web/CController.php
https://github.com/yiisoft/yii/blob/master/framework/web/CController.php
BSD-3-Clause