code
stringlengths
17
296k
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
protected function fetchData() { if(!($this->sql instanceof CDbCommand)) { $db=$this->db===null ? Yii::app()->db : $this->db; $command=$db->createCommand($this->sql); } else $command=clone $this->sql; if(($sort=$this->getSort())!==false) { $order=$sort->getOrderBy(); if(!empty($order)) { if(preg_match('/\s+order\s+by\s+[\w\s,\.]+$/i',$command->text)) $command->text.=', '.$order; else $command->text.=' ORDER BY '.$order; } } if(($pagination=$this->getPagination())!==false) { $pagination->setItemCount($this->getTotalItemCount()); $limit=$pagination->getLimit(); $offset=$pagination->getOffset(); $command->text=$command->getConnection()->getCommandBuilder()->applyLimit($command->text,$limit,$offset); } foreach($this->params as $name=>$value) $command->bindValue($name,$value); return $command->queryAll(); }
Fetches the data from the persistent data storage. @return array list of data items
fetchData
php
yiisoft/yii
framework/web/CSqlDataProvider.php
https://github.com/yiisoft/yii/blob/master/framework/web/CSqlDataProvider.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 fetchData() { if(($sort=$this->getSort())!==false && ($order=$sort->getOrderBy())!='') $this->sortData($this->getSortDirections($order)); if(($pagination=$this->getPagination())!==false) { $pagination->setItemCount($this->getTotalItemCount()); return array_slice($this->rawData, $pagination->getOffset(), $pagination->getLimit()); } else return $this->rawData; }
Fetches the data from the persistent data storage. @return array list of data items
fetchData
php
yiisoft/yii
framework/web/CArrayDataProvider.php
https://github.com/yiisoft/yii/blob/master/framework/web/CArrayDataProvider.php
BSD-3-Clause
protected function fetchKeys() { if($this->keyField===false) return array_keys($this->rawData); $keys=array(); foreach($this->getData() as $i=>$data) $keys[$i]=is_object($data) ? $data->{$this->keyField} : $data[$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/CArrayDataProvider.php
https://github.com/yiisoft/yii/blob/master/framework/web/CArrayDataProvider.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
public function setPageState($name,$value,$defaultValue=null) { if($this->_pageStates===null) $this->_pageStates=$this->loadPageStates(); if($value===$defaultValue) unset($this->_pageStates[$name]); else $this->_pageStates[$name]=$value; $params=func_get_args(); $this->recordCachingAction('','setPageState',$params); }
Saves 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 $value the page state value @param mixed $defaultValue the default page state value. If this is the same as the given value, the state will be removed from persistent storage. @see getPageState @see CHtml::statefulForm
setPageState
php
yiisoft/yii
framework/web/CController.php
https://github.com/yiisoft/yii/blob/master/framework/web/CController.php
BSD-3-Clause
protected function loadPageStates() { if(!empty($_POST[self::STATE_INPUT_NAME])) { if(($data=base64_decode($_POST[self::STATE_INPUT_NAME]))!==false) { if(extension_loaded('zlib')) $data=@gzuncompress($data); if(($data=Yii::app()->getSecurityManager()->validateData($data))!==false) return unserialize($data); } } return array(); }
Loads page states from a hidden input. @return array the loaded page states
loadPageStates
php
yiisoft/yii
framework/web/CController.php
https://github.com/yiisoft/yii/blob/master/framework/web/CController.php
BSD-3-Clause
protected function savePageStates($states,&$output) { $data=Yii::app()->getSecurityManager()->hashData(serialize($states)); if(extension_loaded('zlib')) $data=gzcompress($data); $value=base64_encode($data); $output=str_replace(CHtml::pageStateField(''),CHtml::pageStateField($value),$output); }
Saves page states as a base64 string. @param array $states the states to be saved. @param string $output the output to be modified. Note, this is passed by reference.
savePageStates
php
yiisoft/yii
framework/web/CController.php
https://github.com/yiisoft/yii/blob/master/framework/web/CController.php
BSD-3-Clause
public function init() { parent::init(); $this->normalizeRequest(); }
Initializes the application component. This method overrides the parent implementation by preprocessing the user request data.
init
php
yiisoft/yii
framework/web/CHttpRequest.php
https://github.com/yiisoft/yii/blob/master/framework/web/CHttpRequest.php
BSD-3-Clause
protected function normalizeRequest() { // normalize request if(version_compare(PHP_VERSION,'7.4.0','<')) { if(function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc()) { if(isset($_GET)) $_GET=$this->stripSlashes($_GET); if(isset($_POST)) $_POST=$this->stripSlashes($_POST); if(isset($_REQUEST)) $_REQUEST=$this->stripSlashes($_REQUEST); if(isset($_COOKIE)) $_COOKIE=$this->stripSlashes($_COOKIE); } } if($this->enableCsrfValidation) Yii::app()->attachEventHandler('onBeginRequest',array($this,'validateCsrfToken')); }
Normalizes the request data. This method strips off slashes in request data if get_magic_quotes_gpc() returns true. It also performs CSRF validation if {@link enableCsrfValidation} is true.
normalizeRequest
php
yiisoft/yii
framework/web/CHttpRequest.php
https://github.com/yiisoft/yii/blob/master/framework/web/CHttpRequest.php
BSD-3-Clause
public function stripSlashes(&$data) { if(is_array($data)) { if(count($data) == 0) return $data; $keys=array_map('stripslashes',array_keys($data)); $data=array_combine($keys,array_values($data)); return array_map(array($this,'stripSlashes'),$data); } else return stripslashes($data); }
Strips slashes from input data. This method is applied when magic quotes is enabled. @param mixed $data input data to be processed @return mixed processed data
stripSlashes
php
yiisoft/yii
framework/web/CHttpRequest.php
https://github.com/yiisoft/yii/blob/master/framework/web/CHttpRequest.php
BSD-3-Clause
public function getParam($name,$defaultValue=null) { return isset($_GET[$name]) ? $_GET[$name] : (isset($_POST[$name]) ? $_POST[$name] : $defaultValue); }
Returns the named GET or POST parameter value. If the GET or POST parameter does not exist, the second parameter to this method will be returned. If both GET and POST contains such a named parameter, the GET parameter takes precedence. @param string $name the GET parameter name @param mixed $defaultValue the default parameter value if the GET parameter does not exist. @return mixed the GET parameter value @see getQuery @see getPost
getParam
php
yiisoft/yii
framework/web/CHttpRequest.php
https://github.com/yiisoft/yii/blob/master/framework/web/CHttpRequest.php
BSD-3-Clause
public function getQuery($name,$defaultValue=null) { return isset($_GET[$name]) ? $_GET[$name] : $defaultValue; }
Returns the named GET parameter value. If the GET parameter does not exist, the second parameter to this method will be returned. @param string $name the GET parameter name @param mixed $defaultValue the default parameter value if the GET parameter does not exist. @return mixed the GET parameter value @see getPost @see getParam
getQuery
php
yiisoft/yii
framework/web/CHttpRequest.php
https://github.com/yiisoft/yii/blob/master/framework/web/CHttpRequest.php
BSD-3-Clause
public function getPost($name,$defaultValue=null) { return isset($_POST[$name]) ? $_POST[$name] : $defaultValue; }
Returns the named POST parameter value. If the POST parameter does not exist, the second parameter to this method will be returned. @param string $name the POST parameter name @param mixed $defaultValue the default parameter value if the POST parameter does not exist. @return mixed the POST parameter value @see getParam @see getQuery
getPost
php
yiisoft/yii
framework/web/CHttpRequest.php
https://github.com/yiisoft/yii/blob/master/framework/web/CHttpRequest.php
BSD-3-Clause
public function getDelete($name,$defaultValue=null) { if($this->getIsDeleteViaPostRequest()) return $this->getPost($name, $defaultValue); if($this->getIsDeleteRequest()) { $restParams=$this->getRestParams(); return isset($restParams[$name]) ? $restParams[$name] : $defaultValue; } else return $defaultValue; }
Returns the named DELETE parameter value. If the DELETE parameter does not exist or if the current request is not a DELETE request, the second parameter to this method will be returned. If the DELETE request was tunneled through POST via _method parameter, the POST parameter will be returned instead (available since version 1.1.11). @param string $name the DELETE parameter name @param mixed $defaultValue the default parameter value if the DELETE parameter does not exist. @return mixed the DELETE parameter value @since 1.1.7
getDelete
php
yiisoft/yii
framework/web/CHttpRequest.php
https://github.com/yiisoft/yii/blob/master/framework/web/CHttpRequest.php
BSD-3-Clause
public function getPut($name,$defaultValue=null) { if($this->getIsPutViaPostRequest()) return $this->getPost($name, $defaultValue); if($this->getIsPutRequest()) { $restParams=$this->getRestParams(); return isset($restParams[$name]) ? $restParams[$name] : $defaultValue; } else return $defaultValue; }
Returns the named PUT parameter value. If the PUT parameter does not exist or if the current request is not a PUT request, the second parameter to this method will be returned. If the PUT request was tunneled through POST via _method parameter, the POST parameter will be returned instead (available since version 1.1.11). @param string $name the PUT parameter name @param mixed $defaultValue the default parameter value if the PUT parameter does not exist. @return mixed the PUT parameter value @since 1.1.7
getPut
php
yiisoft/yii
framework/web/CHttpRequest.php
https://github.com/yiisoft/yii/blob/master/framework/web/CHttpRequest.php
BSD-3-Clause
public function getPatch($name,$defaultValue=null) { if($this->getIsPatchViaPostRequest()) return $this->getPost($name, $defaultValue); if($this->getIsPatchRequest()) { $restParams=$this->getRestParams(); return isset($restParams[$name]) ? $restParams[$name] : $defaultValue; } else return $defaultValue; }
Returns the named PATCH parameter value. If the PATCH parameter does not exist or if the current request is not a PATCH request, the second parameter to this method will be returned. If the PATCH request was tunneled through POST via _method parameter, the POST parameter will be returned instead. @param string $name the PATCH parameter name @param mixed $defaultValue the default parameter value if the PATCH parameter does not exist. @return mixed the PATCH parameter value @since 1.1.16
getPatch
php
yiisoft/yii
framework/web/CHttpRequest.php
https://github.com/yiisoft/yii/blob/master/framework/web/CHttpRequest.php
BSD-3-Clause
public function getRestParams() { if($this->_restParams===null) { $result=array(); if (strncmp((string)$this->getContentType(), 'application/json', 16) === 0) $result = CJSON::decode($this->getRawBody(), $this->jsonAsArray); elseif(function_exists('mb_parse_str')) mb_parse_str($this->getRawBody(), $result); else parse_str($this->getRawBody(), $result); $this->_restParams=$result; } return $this->_restParams; }
Returns request parameters. Typically PUT, PATCH or DELETE. @return array the request parameters @since 1.1.7 @since 1.1.13 method became public
getRestParams
php
yiisoft/yii
framework/web/CHttpRequest.php
https://github.com/yiisoft/yii/blob/master/framework/web/CHttpRequest.php
BSD-3-Clause
public function getRawBody() { static $rawBody; if($rawBody===null) $rawBody=file_get_contents('php://input'); return $rawBody; }
Returns the raw HTTP request body. @return string the request body @since 1.1.13
getRawBody
php
yiisoft/yii
framework/web/CHttpRequest.php
https://github.com/yiisoft/yii/blob/master/framework/web/CHttpRequest.php
BSD-3-Clause
public function getUrl() { return $this->getRequestUri(); }
Returns the currently requested URL. This is the same as {@link getRequestUri}. @return string part of the request URL after the host info.
getUrl
php
yiisoft/yii
framework/web/CHttpRequest.php
https://github.com/yiisoft/yii/blob/master/framework/web/CHttpRequest.php
BSD-3-Clause
public function getHostInfo($schema='') { if($this->_hostInfo===null) { if($secure=$this->getIsSecureConnection()) $http='https'; else $http='http'; if(isset($_SERVER['HTTP_HOST'])) $this->_hostInfo=$http.'://'.$_SERVER['HTTP_HOST']; else { $this->_hostInfo=$http.'://'.$_SERVER['SERVER_NAME']; $port=$secure ? $this->getSecurePort() : $this->getPort(); if(($port!==80 && !$secure) || ($port!==443 && $secure)) $this->_hostInfo.=':'.$port; } } if($schema!=='') { $secure=$this->getIsSecureConnection(); if($secure && $schema==='https' || !$secure && $schema==='http') return $this->_hostInfo; $port=$schema==='https' ? $this->getSecurePort() : $this->getPort(); if($port!==80 && $schema==='http' || $port!==443 && $schema==='https') $port=':'.$port; else $port=''; $pos=strpos($this->_hostInfo,':'); return $schema.substr($this->_hostInfo,$pos,strcspn($this->_hostInfo,':',$pos+1)+1).$port; } else return $this->_hostInfo; }
Returns the schema and host part of the application URL. The returned URL does not have an ending slash. By default this is determined based on the user request information. You may explicitly specify it by setting the {@link setHostInfo hostInfo} property. @param string $schema schema to use (e.g. http, https). If empty, the schema used for the current request will be used. @return string schema and hostname part (with port number if needed) of the request URL (e.g. https://www.yiiframework.com) @see setHostInfo
getHostInfo
php
yiisoft/yii
framework/web/CHttpRequest.php
https://github.com/yiisoft/yii/blob/master/framework/web/CHttpRequest.php
BSD-3-Clause
public function setHostInfo($value) { $this->_hostInfo=rtrim($value,'/'); }
Sets the schema and host part of the application URL. This setter is provided in case the schema and hostname cannot be determined on certain Web servers. @param string $value the schema and host part of the application URL.
setHostInfo
php
yiisoft/yii
framework/web/CHttpRequest.php
https://github.com/yiisoft/yii/blob/master/framework/web/CHttpRequest.php
BSD-3-Clause
public function getBaseUrl($absolute=false) { if($this->_baseUrl===null) $this->_baseUrl=rtrim(dirname($this->getScriptUrl()),'\\/'); return $absolute ? $this->getHostInfo() . $this->_baseUrl : $this->_baseUrl; }
Returns the relative URL for the application. This is similar to {@link getScriptUrl scriptUrl} except that it does not have the script file name, and the ending slashes are stripped off. @param boolean $absolute whether to return an absolute URL. Defaults to false, meaning returning a relative one. @return string the relative URL for the application @see setScriptUrl
getBaseUrl
php
yiisoft/yii
framework/web/CHttpRequest.php
https://github.com/yiisoft/yii/blob/master/framework/web/CHttpRequest.php
BSD-3-Clause
public function setBaseUrl($value) { $this->_baseUrl=$value; }
Sets the relative URL for the application. By default the URL is determined based on the entry script URL. This setter is provided in case you want to change this behavior. @param string $value the relative URL for the application
setBaseUrl
php
yiisoft/yii
framework/web/CHttpRequest.php
https://github.com/yiisoft/yii/blob/master/framework/web/CHttpRequest.php
BSD-3-Clause
public function getScriptUrl() { if($this->_scriptUrl===null) { $scriptName=basename($_SERVER['SCRIPT_FILENAME']); if(basename($_SERVER['SCRIPT_NAME'])===$scriptName) $this->_scriptUrl=$_SERVER['SCRIPT_NAME']; elseif(basename($_SERVER['PHP_SELF'])===$scriptName) $this->_scriptUrl=$_SERVER['PHP_SELF']; elseif(isset($_SERVER['ORIG_SCRIPT_NAME']) && basename($_SERVER['ORIG_SCRIPT_NAME'])===$scriptName) $this->_scriptUrl=$_SERVER['ORIG_SCRIPT_NAME']; elseif(($pos=strpos($_SERVER['PHP_SELF'],'/'.$scriptName))!==false) $this->_scriptUrl=substr($_SERVER['SCRIPT_NAME'],0,$pos).'/'.$scriptName; elseif(isset($_SERVER['DOCUMENT_ROOT']) && strpos($_SERVER['SCRIPT_FILENAME'],$_SERVER['DOCUMENT_ROOT'])===0) $this->_scriptUrl=str_replace('\\','/',str_replace($_SERVER['DOCUMENT_ROOT'],'',$_SERVER['SCRIPT_FILENAME'])); else throw new CException(Yii::t('yii','CHttpRequest is unable to determine the entry script URL.')); } return $this->_scriptUrl; }
Returns the relative URL of the entry script. The implementation of this method referenced Zend_Controller_Request_Http in Zend Framework. @throws CException when it is unable to determine the entry script URL. @return string the relative URL of the entry script.
getScriptUrl
php
yiisoft/yii
framework/web/CHttpRequest.php
https://github.com/yiisoft/yii/blob/master/framework/web/CHttpRequest.php
BSD-3-Clause
public function setScriptUrl($value) { $this->_scriptUrl='/'.trim($value,'/'); }
Sets the relative URL for the application entry script. This setter is provided in case the entry script URL cannot be determined on certain Web servers. @param string $value the relative URL for the application entry script.
setScriptUrl
php
yiisoft/yii
framework/web/CHttpRequest.php
https://github.com/yiisoft/yii/blob/master/framework/web/CHttpRequest.php
BSD-3-Clause
public function getPathInfo() { if($this->_pathInfo===null) { $pathInfo=$this->getRequestUri(); if(($pos=strpos($pathInfo,'?'))!==false) $pathInfo=substr($pathInfo,0,$pos); $pathInfo=$this->decodePathInfo($pathInfo); $scriptUrl=$this->getScriptUrl(); $baseUrl=$this->getBaseUrl(); if(strpos($pathInfo,$scriptUrl)===0) $pathInfo=substr($pathInfo,strlen($scriptUrl)); elseif($baseUrl==='' || strpos($pathInfo,$baseUrl)===0) $pathInfo=substr($pathInfo,strlen($baseUrl)); elseif(strpos($_SERVER['PHP_SELF'],$scriptUrl)===0) $pathInfo=substr($_SERVER['PHP_SELF'],strlen($scriptUrl)); else throw new CException(Yii::t('yii','CHttpRequest is unable to determine the path info of the request.')); if($pathInfo==='/' || $pathInfo===false) $pathInfo=''; elseif($pathInfo!=='' && $pathInfo[0]==='/') $pathInfo=substr($pathInfo,1); if(($posEnd=strlen($pathInfo)-1)>0 && $pathInfo[$posEnd]==='/') $pathInfo=substr($pathInfo,0,$posEnd); $this->_pathInfo=$pathInfo; } return $this->_pathInfo; }
Returns the path info of the currently requested URL. This refers to the part that is after the entry script and before the question mark. The starting and ending slashes are stripped off. @return string part of the request URL that is after the entry script and before the question mark. Note, the returned pathinfo is decoded starting from 1.1.4. Prior to 1.1.4, whether it is decoded or not depends on the server configuration (in most cases it is not decoded). @throws CException if the request URI cannot be determined due to improper server configuration
getPathInfo
php
yiisoft/yii
framework/web/CHttpRequest.php
https://github.com/yiisoft/yii/blob/master/framework/web/CHttpRequest.php
BSD-3-Clause
protected function decodePathInfo($pathInfo) { $pathInfo = urldecode($pathInfo); // is it UTF-8? // https://w3.org/International/questions/qa-forms-utf-8.html if(preg_match('%^(?: [\x09\x0A\x0D\x20-\x7E] # ASCII | [\xC2-\xDF][\x80-\xBF] # non-overlong 2-byte | \xE0[\xA0-\xBF][\x80-\xBF] # excluding overlongs | [\xE1-\xEC\xEE\xEF][\x80-\xBF]{2} # straight 3-byte | \xED[\x80-\x9F][\x80-\xBF] # excluding surrogates | \xF0[\x90-\xBF][\x80-\xBF]{2} # planes 1-3 | [\xF1-\xF3][\x80-\xBF]{3} # planes 4-15 | \xF4[\x80-\x8F][\x80-\xBF]{2} # plane 16 )*$%xs', $pathInfo)) { return $pathInfo; } else { return $this->utf8Encode($pathInfo); } }
Decodes the path info. This method is an improved variant of the native urldecode() function and used in {@link getPathInfo getPathInfo()} to decode the path part of the request URI. You may override this method to change the way the path info is being decoded. @param string $pathInfo encoded path info @return string decoded path info @since 1.1.10
decodePathInfo
php
yiisoft/yii
framework/web/CHttpRequest.php
https://github.com/yiisoft/yii/blob/master/framework/web/CHttpRequest.php
BSD-3-Clause
private function utf8Encode($s) { $s.=$s; $len=strlen($s); for ($i=$len>>1,$j=0; $i<$len; ++$i,++$j) { switch (true) { case $s[$i] < "\x80": $s[$j] = $s[$i]; break; case $s[$i] < "\xC0": $s[$j] = "\xC2"; $s[++$j] = $s[$i]; break; default: $s[$j] = "\xC3"; $s[++$j] = chr(ord($s[$i]) - 64); break; } } return substr($s, 0, $j); }
Encodes an ISO-8859-1 string to UTF-8 @param string $s @return string the UTF-8 translation of `s`. @see https://github.com/yiisoft/yii/issues/4505 @see https://github.com/symfony/polyfill-php72/blob/master/Php72.php#L24
utf8Encode
php
yiisoft/yii
framework/web/CHttpRequest.php
https://github.com/yiisoft/yii/blob/master/framework/web/CHttpRequest.php
BSD-3-Clause
public function getRequestUri() { if($this->_requestUri===null) { if(isset($_SERVER['REQUEST_URI'])) { $this->_requestUri=$_SERVER['REQUEST_URI']; if(!empty($_SERVER['HTTP_HOST'])) { if(strpos($this->_requestUri,$_SERVER['HTTP_HOST'])!==false) $this->_requestUri=preg_replace('/^\w+:\/\/[^\/]+/','',$this->_requestUri); } else $this->_requestUri=preg_replace('/^(http|https):\/\/[^\/]+/i','',$this->_requestUri); } elseif(isset($_SERVER['ORIG_PATH_INFO'])) // IIS 5.0 CGI { $this->_requestUri=$_SERVER['ORIG_PATH_INFO']; if(!empty($_SERVER['QUERY_STRING'])) $this->_requestUri.='?'.$_SERVER['QUERY_STRING']; } else throw new CException(Yii::t('yii','CHttpRequest is unable to determine the request URI.')); } return $this->_requestUri; }
Returns the request URI portion for the currently requested URL. This refers to the portion that is after the {@link hostInfo host info} part. It includes the {@link queryString query string} part if any. The implementation of this method referenced Zend_Controller_Request_Http in Zend Framework. @return string the request URI portion for the currently requested URL. @throws CException if the request URI cannot be determined due to improper server configuration
getRequestUri
php
yiisoft/yii
framework/web/CHttpRequest.php
https://github.com/yiisoft/yii/blob/master/framework/web/CHttpRequest.php
BSD-3-Clause
public function getQueryString() { return isset($_SERVER['QUERY_STRING'])?$_SERVER['QUERY_STRING']:''; }
Returns part of the request URL that is after the question mark. @return string part of the request URL that is after the question mark
getQueryString
php
yiisoft/yii
framework/web/CHttpRequest.php
https://github.com/yiisoft/yii/blob/master/framework/web/CHttpRequest.php
BSD-3-Clause
public function getIsSecureConnection() { return isset($_SERVER['HTTPS']) && (strcasecmp($_SERVER['HTTPS'],'on')===0 || $_SERVER['HTTPS']==1) || isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && strcasecmp($_SERVER['HTTP_X_FORWARDED_PROTO'],'https')===0; }
Return if the request is sent via secure channel (https). @return boolean if the request is sent via secure channel (https)
getIsSecureConnection
php
yiisoft/yii
framework/web/CHttpRequest.php
https://github.com/yiisoft/yii/blob/master/framework/web/CHttpRequest.php
BSD-3-Clause
public function getRequestType() { if(isset($_POST['_method'])) return strtoupper($_POST['_method']); elseif(isset($_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE'])) return strtoupper($_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE']); return strtoupper(isset($_SERVER['REQUEST_METHOD'])?$_SERVER['REQUEST_METHOD']:'GET'); }
Returns the request type, such as GET, POST, HEAD, PUT, PATCH, DELETE. Request type can be manually set in POST requests with a parameter named _method. Useful for RESTful request from older browsers which do not support PUT, PATCH or DELETE natively (available since version 1.1.11). @return string request type, such as GET, POST, HEAD, PUT, PATCH, DELETE.
getRequestType
php
yiisoft/yii
framework/web/CHttpRequest.php
https://github.com/yiisoft/yii/blob/master/framework/web/CHttpRequest.php
BSD-3-Clause
public function getIsPostRequest() { return isset($_SERVER['REQUEST_METHOD']) && !strcasecmp($_SERVER['REQUEST_METHOD'],'POST'); }
Returns whether this is a POST request. @return boolean whether this is a POST request.
getIsPostRequest
php
yiisoft/yii
framework/web/CHttpRequest.php
https://github.com/yiisoft/yii/blob/master/framework/web/CHttpRequest.php
BSD-3-Clause
public function getIsDeleteRequest() { return (isset($_SERVER['REQUEST_METHOD']) && !strcasecmp($_SERVER['REQUEST_METHOD'],'DELETE')) || $this->getIsDeleteViaPostRequest(); }
Returns whether this is a DELETE request. @return boolean whether this is a DELETE request. @since 1.1.7
getIsDeleteRequest
php
yiisoft/yii
framework/web/CHttpRequest.php
https://github.com/yiisoft/yii/blob/master/framework/web/CHttpRequest.php
BSD-3-Clause
protected function getIsDeleteViaPostRequest() { return isset($_POST['_method']) && !strcasecmp($_POST['_method'],'DELETE'); }
Returns whether this is a DELETE request which was tunneled through POST. @return boolean whether this is a DELETE request tunneled through POST. @since 1.1.11
getIsDeleteViaPostRequest
php
yiisoft/yii
framework/web/CHttpRequest.php
https://github.com/yiisoft/yii/blob/master/framework/web/CHttpRequest.php
BSD-3-Clause
public function getIsPutRequest() { return (isset($_SERVER['REQUEST_METHOD']) && !strcasecmp($_SERVER['REQUEST_METHOD'],'PUT')) || $this->getIsPutViaPostRequest(); }
Returns whether this is a PUT request. @return boolean whether this is a PUT request. @since 1.1.7
getIsPutRequest
php
yiisoft/yii
framework/web/CHttpRequest.php
https://github.com/yiisoft/yii/blob/master/framework/web/CHttpRequest.php
BSD-3-Clause
protected function getIsPutViaPostRequest() { return isset($_POST['_method']) && !strcasecmp($_POST['_method'],'PUT'); }
Returns whether this is a PUT request which was tunneled through POST. @return boolean whether this is a PUT request tunneled through POST. @since 1.1.11
getIsPutViaPostRequest
php
yiisoft/yii
framework/web/CHttpRequest.php
https://github.com/yiisoft/yii/blob/master/framework/web/CHttpRequest.php
BSD-3-Clause
public function getIsPatchRequest() { return (isset($_SERVER['REQUEST_METHOD']) && !strcasecmp($_SERVER['REQUEST_METHOD'],'PATCH')) || $this->getIsPatchViaPostRequest(); }
Returns whether this is a PATCH request. @return boolean whether this is a PATCH request. @since 1.1.16
getIsPatchRequest
php
yiisoft/yii
framework/web/CHttpRequest.php
https://github.com/yiisoft/yii/blob/master/framework/web/CHttpRequest.php
BSD-3-Clause
protected function getIsPatchViaPostRequest() { return isset($_POST['_method']) && !strcasecmp($_POST['_method'],'PATCH'); }
Returns whether this is a PATCH request which was tunneled through POST. @return boolean whether this is a PATCH request tunneled through POST. @since 1.1.16
getIsPatchViaPostRequest
php
yiisoft/yii
framework/web/CHttpRequest.php
https://github.com/yiisoft/yii/blob/master/framework/web/CHttpRequest.php
BSD-3-Clause
public function getIsAjaxRequest() { return isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH']==='XMLHttpRequest'; }
Returns whether this is an AJAX (XMLHttpRequest) request. @return boolean whether this is an AJAX (XMLHttpRequest) request.
getIsAjaxRequest
php
yiisoft/yii
framework/web/CHttpRequest.php
https://github.com/yiisoft/yii/blob/master/framework/web/CHttpRequest.php
BSD-3-Clause
public function getIsFlashRequest() { return isset($_SERVER['HTTP_USER_AGENT']) && (stripos($_SERVER['HTTP_USER_AGENT'],'Shockwave')!==false || stripos($_SERVER['HTTP_USER_AGENT'],'Flash')!==false); }
Returns whether this is an Adobe Flash or Adobe Flex request. @return boolean whether this is an Adobe Flash or Adobe Flex request. @since 1.1.11
getIsFlashRequest
php
yiisoft/yii
framework/web/CHttpRequest.php
https://github.com/yiisoft/yii/blob/master/framework/web/CHttpRequest.php
BSD-3-Clause
public function getServerPort() { return $_SERVER['SERVER_PORT']; }
Returns the server port number. @return integer server port number
getServerPort
php
yiisoft/yii
framework/web/CHttpRequest.php
https://github.com/yiisoft/yii/blob/master/framework/web/CHttpRequest.php
BSD-3-Clause
public function getUrlReferrer() { return isset($_SERVER['HTTP_REFERER'])?$_SERVER['HTTP_REFERER']:null; }
Returns the URL referrer, null if not present @return string URL referrer, null if not present
getUrlReferrer
php
yiisoft/yii
framework/web/CHttpRequest.php
https://github.com/yiisoft/yii/blob/master/framework/web/CHttpRequest.php
BSD-3-Clause
public function getUserAgent() { return isset($_SERVER['HTTP_USER_AGENT'])?$_SERVER['HTTP_USER_AGENT']:null; }
Returns the user agent, null if not present. @return string user agent, null if not present
getUserAgent
php
yiisoft/yii
framework/web/CHttpRequest.php
https://github.com/yiisoft/yii/blob/master/framework/web/CHttpRequest.php
BSD-3-Clause
public function getUserHost() { return isset($_SERVER['REMOTE_HOST'])?$_SERVER['REMOTE_HOST']:null; }
Returns the user host name, null if it cannot be determined. @return string user host name, null if cannot be determined
getUserHost
php
yiisoft/yii
framework/web/CHttpRequest.php
https://github.com/yiisoft/yii/blob/master/framework/web/CHttpRequest.php
BSD-3-Clause
public function getScriptFile() { if($this->_scriptFile!==null) return $this->_scriptFile; else return $this->_scriptFile=realpath($_SERVER['SCRIPT_FILENAME']); }
Returns entry script file path. @return string entry script file path (processed w/ realpath())
getScriptFile
php
yiisoft/yii
framework/web/CHttpRequest.php
https://github.com/yiisoft/yii/blob/master/framework/web/CHttpRequest.php
BSD-3-Clause
public function getBrowser($userAgent=null) { return get_browser($userAgent,true); }
Returns information about the capabilities of user browser. @param string $userAgent the user agent to be analyzed. Defaults to null, meaning using the current User-Agent HTTP header information. @return array user browser capabilities. @see https://www.php.net/manual/en/function.get-browser.php
getBrowser
php
yiisoft/yii
framework/web/CHttpRequest.php
https://github.com/yiisoft/yii/blob/master/framework/web/CHttpRequest.php
BSD-3-Clause
public function getAcceptTypes() { return isset($_SERVER['HTTP_ACCEPT'])?$_SERVER['HTTP_ACCEPT']:null; }
Returns user browser accept types, null if not present. @return string user browser accept types, null if not present
getAcceptTypes
php
yiisoft/yii
framework/web/CHttpRequest.php
https://github.com/yiisoft/yii/blob/master/framework/web/CHttpRequest.php
BSD-3-Clause
public function getContentType() { if (isset($_SERVER["CONTENT_TYPE"])) { return $_SERVER["CONTENT_TYPE"]; } elseif (isset($_SERVER["HTTP_CONTENT_TYPE"])) { //fix bug https://bugs.php.net/bug.php?id=66606 return $_SERVER["HTTP_CONTENT_TYPE"]; } return null; }
Returns request content-type The Content-Type header field indicates the MIME type of the data contained in {@link getRawBody()} or, in the case of the HEAD method, the media type that would have been sent had the request been a GET. @return string request content-type. Null is returned if this information is not available. @link https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.17 HTTP 1.1 header field definitions @since 1.1.17
getContentType
php
yiisoft/yii
framework/web/CHttpRequest.php
https://github.com/yiisoft/yii/blob/master/framework/web/CHttpRequest.php
BSD-3-Clause
public function getPort() { if($this->_port===null) $this->_port=!$this->getIsSecureConnection() && isset($_SERVER['SERVER_PORT']) ? (int)$_SERVER['SERVER_PORT'] : 80; return $this->_port; }
Returns the port to use for insecure requests. Defaults to 80, or the port specified by the server if the current request is insecure. You may explicitly specify it by setting the {@link setPort port} property. @return integer port number for insecure requests. @see setPort @since 1.1.3
getPort
php
yiisoft/yii
framework/web/CHttpRequest.php
https://github.com/yiisoft/yii/blob/master/framework/web/CHttpRequest.php
BSD-3-Clause
public function setPort($value) { $this->_port=(int)$value; $this->_hostInfo=null; }
Sets the port to use for insecure requests. This setter is provided in case a custom port is necessary for certain server configurations. @param integer $value port number. @since 1.1.3
setPort
php
yiisoft/yii
framework/web/CHttpRequest.php
https://github.com/yiisoft/yii/blob/master/framework/web/CHttpRequest.php
BSD-3-Clause
public function getSecurePort() { if($this->_securePort===null) $this->_securePort=$this->getIsSecureConnection() && isset($_SERVER['SERVER_PORT']) ? (int)$_SERVER['SERVER_PORT'] : 443; return $this->_securePort; }
Returns the port to use for secure requests. Defaults to 443, or the port specified by the server if the current request is secure. You may explicitly specify it by setting the {@link setSecurePort securePort} property. @return integer port number for secure requests. @see setSecurePort @since 1.1.3
getSecurePort
php
yiisoft/yii
framework/web/CHttpRequest.php
https://github.com/yiisoft/yii/blob/master/framework/web/CHttpRequest.php
BSD-3-Clause
public function setSecurePort($value) { $this->_securePort=(int)$value; $this->_hostInfo=null; }
Sets the port to use for secure requests. This setter is provided in case a custom port is necessary for certain server configurations. @param integer $value port number. @since 1.1.3
setSecurePort
php
yiisoft/yii
framework/web/CHttpRequest.php
https://github.com/yiisoft/yii/blob/master/framework/web/CHttpRequest.php
BSD-3-Clause
public function getCookies() { if($this->_cookies!==null) return $this->_cookies; else return $this->_cookies=new CCookieCollection($this); }
Returns the cookie collection. The result can be used like an associative array. Adding {@link CHttpCookie} objects to the collection will send the cookies to the client; and removing the objects from the collection will delete those cookies on the client. @return CCookieCollection the cookie collection.
getCookies
php
yiisoft/yii
framework/web/CHttpRequest.php
https://github.com/yiisoft/yii/blob/master/framework/web/CHttpRequest.php
BSD-3-Clause
public static function parseAcceptHeader($header) { $matches=array(); $accepts=array(); // get individual entries with their type, subtype, basetype and params if($header!==null) preg_match_all('/(?:\G\s?,\s?|^)(\w+|\*)\/(\w+|\*)(?:\+(\w+))?|(?<!^)\G(?:\s?;\s?(\w+)=([\w\.]+))/',$header,$matches); // the regexp should (in theory) always return an array of 6 arrays if(count($matches)===6) { $i=0; $itemLen=count($matches[1]); while($i<$itemLen) { // fill out a content type $accept=array( 'type'=>$matches[1][$i], 'subType'=>$matches[2][$i], 'baseType'=>null, 'params'=>array(), ); // fill in the base type if it exists if($matches[3][$i]!==null && $matches[3][$i]!=='') $accept['baseType']=$matches[3][$i]; // continue looping while there is no new content type, to fill in all accompanying params for($i++;$i<$itemLen;$i++) { // if the next content type is null, then the item is a param for the current content type if($matches[1][$i]===null || $matches[1][$i]==='') { // if this is the quality param, convert it to a double if($matches[4][$i]==='q') { // sanity check on q value $q=(double)$matches[5][$i]; if($q>1) $q=(double)1; elseif($q<0) $q=(double)0; $accept['params'][$matches[4][$i]]=$q; } else $accept['params'][$matches[4][$i]]=$matches[5][$i]; } else break; } // q defaults to 1 if not explicitly given if(!isset($accept['params']['q'])) $accept['params']['q']=(double)1; $accepts[] = $accept; } } return $accepts; }
Parses an HTTP Accept header, returning an array map with all parts of each entry. Each array entry consists of a map with the type, subType, baseType and params, an array map of key-value parameters, obligatorily including a `q` value (i.e. preference ranking) as a double. For example, an Accept header value of <code>'application/xhtml+xml;q=0.9;level=1'</code> would give an array entry of <pre> array( 'type' => 'application', 'subType' => 'xhtml', 'baseType' => 'xml', 'params' => array( 'q' => 0.9, 'level' => '1', ), ) </pre> <b>Please note:</b> To avoid great complexity, there are no steps taken to ensure that quoted strings are treated properly. If the header text includes quoted strings containing space or the , or ; characters then the results may not be correct! See also {@link https://tools.ietf.org/html/rfc2616#section-14.1} for details on Accept header. @param string $header the accept header value to parse @return array the user accepted MIME types.
parseAcceptHeader
php
yiisoft/yii
framework/web/CHttpRequest.php
https://github.com/yiisoft/yii/blob/master/framework/web/CHttpRequest.php
BSD-3-Clause
public static function compareAcceptTypes($a,$b) { // check for equal quality first if($a['params']['q']===$b['params']['q']) if(!($a['type']==='*' xor $b['type']==='*')) if (!($a['subType']==='*' xor $b['subType']==='*')) // finally, higher number of parameters counts as greater precedence if(count($a['params'])===count($b['params'])) return 0; else return count($a['params'])<count($b['params']) ? 1 : -1; // more specific takes precedence - whichever one doesn't have a * subType else return $a['subType']==='*' ? 1 : -1; // more specific takes precedence - whichever one doesn't have a * type else return $a['type']==='*' ? 1 : -1; else return ($a['params']['q']<$b['params']['q']) ? 1 : -1; }
Compare function for determining the preference of accepted MIME type array maps See {@link parseAcceptHeader()} for the format of $a and $b @param array $a user accepted MIME type as an array map @param array $b user accepted MIME type as an array map @return integer -1, 0 or 1 if $a has respectively greater preference, equal preference or less preference than $b (higher preference comes first).
compareAcceptTypes
php
yiisoft/yii
framework/web/CHttpRequest.php
https://github.com/yiisoft/yii/blob/master/framework/web/CHttpRequest.php
BSD-3-Clause
public function getPreferredAcceptTypes() { if($this->_preferredAcceptTypes===null) { $accepts=self::parseAcceptHeader($this->getAcceptTypes()); usort($accepts,array(get_class($this),'compareAcceptTypes')); $this->_preferredAcceptTypes=$accepts; } return $this->_preferredAcceptTypes; }
Returns an array of user accepted MIME types in order of preference. Each array entry consists of a map with the type, subType, baseType and params, an array map of key-value parameters. See {@link parseAcceptHeader()} for a description of the array map. @return array the user accepted MIME types, as array maps, in the order of preference.
getPreferredAcceptTypes
php
yiisoft/yii
framework/web/CHttpRequest.php
https://github.com/yiisoft/yii/blob/master/framework/web/CHttpRequest.php
BSD-3-Clause
public function getPreferredAcceptType() { $preferredAcceptTypes=$this->getPreferredAcceptTypes(); return empty($preferredAcceptTypes) ? false : $preferredAcceptTypes[0]; }
Returns the user preferred accept MIME type. The MIME type is returned as an array map (see {@link parseAcceptHeader()}). @return array the user preferred accept MIME type or false if the user does not have any.
getPreferredAcceptType
php
yiisoft/yii
framework/web/CHttpRequest.php
https://github.com/yiisoft/yii/blob/master/framework/web/CHttpRequest.php
BSD-3-Clause
private function stringCompare($a, $b) { if ($a[0] == $b[0]) { return 0; } return ($a[0] < $b[0]) ? 1 : -1; }
String compare function used by usort. Included to circumvent the use of closures (not supported by PHP 5.2) and create_function (deprecated since PHP 7.2.0) @param array $a @param array $b @return int -1 (a>b), 0 (a==b), 1 (a<b)
stringCompare
php
yiisoft/yii
framework/web/CHttpRequest.php
https://github.com/yiisoft/yii/blob/master/framework/web/CHttpRequest.php
BSD-3-Clause
public function setBasePath($value) { if(($basePath=realpath($value))!==false && is_dir($basePath) && is_writable($basePath)) $this->_basePath=$basePath; else throw new CException(Yii::t('yii','CAssetManager.basePath "{path}" is invalid. Please make sure the directory exists and is writable by the Web server process.', array('{path}'=>$value))); }
Sets the root directory storing published asset files. @param string $value the root directory storing published asset files @throws CException if the base path is invalid
setBasePath
php
yiisoft/yii
framework/web/CAssetManager.php
https://github.com/yiisoft/yii/blob/master/framework/web/CAssetManager.php
BSD-3-Clause
public function getPublishedPath($path,$hashByName=false) { if(is_string($path) && ($path=realpath($path))!==false) { $base=$this->getBasePath().DIRECTORY_SEPARATOR.$this->generatePath($path,$hashByName); return is_file($path) ? $base.DIRECTORY_SEPARATOR.basename($path) : $base ; } else return false; }
Returns the published path of a file path. This method does not perform any publishing. It merely tells you if the file or directory is published, where it will go. @param string $path directory or file path being published @param boolean $hashByName whether the published directory should be named as the hashed basename. If false, the name will be the hash taken from dirname of the path being published and path mtime. Defaults to false. Set true if the path being published is shared among different extensions. @return string the published file path. False if the file or directory does not exist
getPublishedPath
php
yiisoft/yii
framework/web/CAssetManager.php
https://github.com/yiisoft/yii/blob/master/framework/web/CAssetManager.php
BSD-3-Clause
public function getPublishedUrl($path,$hashByName=false) { if(isset($this->_published[$path])) return $this->_published[$path]; if(is_string($path) && ($path=realpath($path))!==false) { $base=$this->getBaseUrl().'/'.$this->generatePath($path,$hashByName); return is_file($path) ? $base.'/'.basename($path) : $base; } else return false; }
Returns the URL of a published file path. This method does not perform any publishing. It merely tells you if the file path is published, what the URL will be to access it. @param string $path directory or file path being published @param boolean $hashByName whether the published directory should be named as the hashed basename. If false, the name will be the hash taken from dirname of the path being published and path mtime. Defaults to false. Set true if the path being published is shared among different extensions. @return string the published URL for the file or directory. False if the file or directory does not exist.
getPublishedUrl
php
yiisoft/yii
framework/web/CAssetManager.php
https://github.com/yiisoft/yii/blob/master/framework/web/CAssetManager.php
BSD-3-Clause
protected function hash($path) { return sprintf('%x',crc32($path.Yii::getVersion())); }
Generate a CRC32 hash for the directory path. Collisions are higher than MD5 but generates a much smaller hash string. @param string $path string to be hashed. @return string hashed string.
hash
php
yiisoft/yii
framework/web/CAssetManager.php
https://github.com/yiisoft/yii/blob/master/framework/web/CAssetManager.php
BSD-3-Clause