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 evaluateVisible() { return true; }
Evaluates the visibility of this element. Child classes should override this method to implement the actual algorithm for determining the visibility. @return boolean whether this element is visible. Defaults to true.
evaluateVisible
php
yiisoft/yii
framework/web/form/CFormElement.php
https://github.com/yiisoft/yii/blob/master/framework/web/form/CFormElement.php
BSD-3-Clause
public function getOn() { return $this->_on; }
Returns a value indicating under which scenarios this button is visible. If the value is empty, it means the button is visible under all scenarios. Otherwise, only when the model is in the scenario whose name can be found in this value, will the button be visible. See {@link CModel::scenario} for more information about model scenarios. @return string scenario names separated by commas. Defaults to null.
getOn
php
yiisoft/yii
framework/web/form/CFormButtonElement.php
https://github.com/yiisoft/yii/blob/master/framework/web/form/CFormButtonElement.php
BSD-3-Clause
protected function evaluateVisible() { return empty($this->_on) || in_array($this->getParent()->getModel()->getScenario(),$this->_on); }
Evaluates the visibility of this element. This method will check the {@link on} property to see if the model is in a scenario that should have this string displayed. @return boolean whether this element is visible.
evaluateVisible
php
yiisoft/yii
framework/web/form/CFormButtonElement.php
https://github.com/yiisoft/yii/blob/master/framework/web/form/CFormButtonElement.php
BSD-3-Clause
public function filter($filterChain) { $method='filter'.$this->name; $filterChain->controller->$method($filterChain); }
Performs the filtering. This method calls the filter method defined in the controller class. @param CFilterChain $filterChain the filter chain that the filter is on.
filter
php
yiisoft/yii
framework/web/filters/CInlineFilter.php
https://github.com/yiisoft/yii/blob/master/framework/web/filters/CInlineFilter.php
BSD-3-Clause
public function preFilter($filterChain) { // Only cache GET and HEAD requests if(!in_array(Yii::app()->getRequest()->getRequestType(), array('GET', 'HEAD'))) return true; $lastModified=$this->getLastModifiedValue(); $etag=$this->getEtagValue(); if($etag===false&&$lastModified===false) return true; if($etag) header('ETag: '.$etag); $this->sendCacheControlHeader(); $cacheValid = false; if(isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])&&isset($_SERVER['HTTP_IF_NONE_MATCH'])) { if($this->checkLastModified($lastModified)&&$this->checkEtag($etag)) { $cacheValid=true; } } elseif(isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])) { if($this->checkLastModified($lastModified)) { $cacheValid=true; } } elseif(isset($_SERVER['HTTP_IF_NONE_MATCH'])) { if($this->checkEtag($etag)) { $cacheValid=true; } } if($lastModified) header('Last-Modified: '.gmdate('D, d M Y H:i:s', $lastModified).' GMT'); if ($cacheValid) { $this->send304Header(); return false; } return true; }
Performs the pre-action filtering. @param CFilterChain $filterChain the filter chain that the filter is on. @return boolean whether the filtering process should continue and the action should be executed.
preFilter
php
yiisoft/yii
framework/web/filters/CHttpCacheFilter.php
https://github.com/yiisoft/yii/blob/master/framework/web/filters/CHttpCacheFilter.php
BSD-3-Clause
protected function checkEtag($etag) { return isset($_SERVER['HTTP_IF_NONE_MATCH'])&&$_SERVER['HTTP_IF_NONE_MATCH']==$etag; }
Check if the etag supplied by the client matches our generated one @param string $etag the supplied etag @return boolean true if the supplied etag matches $etag
checkEtag
php
yiisoft/yii
framework/web/filters/CHttpCacheFilter.php
https://github.com/yiisoft/yii/blob/master/framework/web/filters/CHttpCacheFilter.php
BSD-3-Clause
protected function checkLastModified($lastModified) { return isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])&&@strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE'])>=$lastModified; }
Checks if the last modified date supplied by the client is still up to date @param integer $lastModified the last modified date @return boolean true if the last modified date sent by the client is newer or equal to $lastModified
checkLastModified
php
yiisoft/yii
framework/web/filters/CHttpCacheFilter.php
https://github.com/yiisoft/yii/blob/master/framework/web/filters/CHttpCacheFilter.php
BSD-3-Clause
protected function send304Header() { $httpVersion=Yii::app()->request->getHttpVersion(); header("HTTP/$httpVersion 304 Not Modified"); }
Sends the 304 HTTP status code to the client
send304Header
php
yiisoft/yii
framework/web/filters/CHttpCacheFilter.php
https://github.com/yiisoft/yii/blob/master/framework/web/filters/CHttpCacheFilter.php
BSD-3-Clause
protected function sendCacheControlHeader() { if(Yii::app()->session->isStarted) { Yii::app()->session->setCacheLimiter('public'); header('Pragma:',true); } header('Cache-Control: '.$this->cacheControl,true); }
Sends the cache control header to the client @see cacheControl @since 1.1.12
sendCacheControlHeader
php
yiisoft/yii
framework/web/filters/CHttpCacheFilter.php
https://github.com/yiisoft/yii/blob/master/framework/web/filters/CHttpCacheFilter.php
BSD-3-Clause
protected function generateEtag($seed) { return '"'.base64_encode(sha1(serialize($seed),true)).'"'; }
Generates a quoted string out of the seed @param mixed $seed Seed for the ETag @return string Quoted string serving as ETag
generateEtag
php
yiisoft/yii
framework/web/filters/CHttpCacheFilter.php
https://github.com/yiisoft/yii/blob/master/framework/web/filters/CHttpCacheFilter.php
BSD-3-Clause
public function init() { }
Initializes the filter. This method is invoked after the filter properties are initialized and before {@link preFilter} is called. You may override this method to include some initialization logic. @since 1.1.4
init
php
yiisoft/yii
framework/web/filters/CFilter.php
https://github.com/yiisoft/yii/blob/master/framework/web/filters/CFilter.php
BSD-3-Clause
protected function preFilter($filterChain) { return true; }
Performs the pre-action filtering. @param CFilterChain $filterChain the filter chain that the filter is on. @return boolean whether the filtering process should continue and the action should be executed.
preFilter
php
yiisoft/yii
framework/web/filters/CFilter.php
https://github.com/yiisoft/yii/blob/master/framework/web/filters/CFilter.php
BSD-3-Clause
protected function postFilter($filterChain) { }
Performs the post-action filtering. @param CFilterChain $filterChain the filter chain that the filter is on.
postFilter
php
yiisoft/yii
framework/web/filters/CFilter.php
https://github.com/yiisoft/yii/blob/master/framework/web/filters/CFilter.php
BSD-3-Clause
public function insertAt($index,$item) { if($item instanceof IFilter) parent::insertAt($index,$item); else throw new CException(Yii::t('yii','CFilterChain can only take objects implementing the IFilter interface.')); }
Inserts an item at the specified position. This method overrides the parent implementation by adding additional check for the item to be added. In particular, only objects implementing {@link IFilter} can be added to the list. @param integer $index the specified position. @param mixed $item new item @throws CException If the index specified exceeds the bound or the list is read-only, or the item is not an {@link IFilter} instance.
insertAt
php
yiisoft/yii
framework/web/filters/CFilterChain.php
https://github.com/yiisoft/yii/blob/master/framework/web/filters/CFilterChain.php
BSD-3-Clause
public function run() { if($this->offsetExists($this->filterIndex)) { $filter=$this->itemAt($this->filterIndex++); Yii::trace('Running filter '.($filter instanceof CInlineFilter ? get_class($this->controller).'.filter'.$filter->name.'()':get_class($filter).'.filter()'),'system.web.filters.CFilterChain'); $filter->filter($this); }
Executes the filter indexed at {@link filterIndex}. After this method is called, {@link filterIndex} will be automatically incremented by one. This method is usually invoked in filters so that the filtering process can continue and the action can be executed.
run
php
yiisoft/yii
framework/web/filters/CFilterChain.php
https://github.com/yiisoft/yii/blob/master/framework/web/filters/CFilterChain.php
BSD-3-Clause
public function init() { list($name,$id)=$this->resolveNameID(); if(isset($this->htmlOptions['id'])) $id=$this->htmlOptions['id']; else $this->htmlOptions['id']=$id; if(isset($this->htmlOptions['name'])) $name=$this->htmlOptions['name']; $this->registerClientScript(); if($this->hasModel()) { $field=$this->textArea ? 'activeTextArea' : 'activeTextField'; echo CHtml::$field($this->model,$this->attribute,$this->htmlOptions); } else { $field=$this->textArea ? 'textArea' : 'textField'; echo CHtml::$field($name,$this->value,$this->htmlOptions); } }
Initializes the widget. This method registers all needed client scripts and renders the autocomplete input.
init
php
yiisoft/yii
framework/web/widgets/CAutoComplete.php
https://github.com/yiisoft/yii/blob/master/framework/web/widgets/CAutoComplete.php
BSD-3-Clause
public function registerClientScript() { $id=$this->htmlOptions['id']; $acOptions=$this->getClientOptions(); $options=$acOptions===array()?'{}' : CJavaScript::encode($acOptions); $cs=Yii::app()->getClientScript(); $cs->registerCoreScript('autocomplete'); if($this->data!==null) $data=CJavaScript::encode($this->data); else { $url=CHtml::normalizeUrl($this->url); $data='"'.$url.'"'; } $cs->registerScript('Yii.CAutoComplete#'.$id,"jQuery(\"#{$id}\").legacyautocomplete($data,{$options}){$this->methodChain};"); if($this->cssFile!==false) self::registerCssFile($this->cssFile); }
Registers the needed CSS and JavaScript.
registerClientScript
php
yiisoft/yii
framework/web/widgets/CAutoComplete.php
https://github.com/yiisoft/yii/blob/master/framework/web/widgets/CAutoComplete.php
BSD-3-Clause
public static function registerCssFile($url=null) { $cs=Yii::app()->getClientScript(); if($url===null) $url=$cs->getCoreScriptUrl().'/autocomplete/jquery.autocomplete.css'; $cs->registerCssFile($url); }
Registers the needed CSS file. @param string $url the CSS URL. If null, a default CSS URL will be used.
registerCssFile
php
yiisoft/yii
framework/web/widgets/CAutoComplete.php
https://github.com/yiisoft/yii/blob/master/framework/web/widgets/CAutoComplete.php
BSD-3-Clause
public function registerClientScript() { $cs=Yii::app()->getClientScript(); $cs->registerCoreScript('yiitab'); $id=$this->getId(); $cs->registerScript('Yii.CTabView#'.$id,"jQuery(\"#{$id}\").yiitab();"); if($this->cssFile!==false) self::registerCssFile($this->cssFile); }
Registers the needed CSS and JavaScript.
registerClientScript
php
yiisoft/yii
framework/web/widgets/CTabView.php
https://github.com/yiisoft/yii/blob/master/framework/web/widgets/CTabView.php
BSD-3-Clause
public static function registerCssFile($url=null) { $cs=Yii::app()->getClientScript(); if($url===null) $url=$cs->getCoreScriptUrl().'/yiitab/jquery.yiitab.css'; $cs->registerCssFile($url,'screen'); }
Registers the needed CSS file. @param string $url the CSS URL. If null, a default CSS URL will be used.
registerCssFile
php
yiisoft/yii
framework/web/widgets/CTabView.php
https://github.com/yiisoft/yii/blob/master/framework/web/widgets/CTabView.php
BSD-3-Clause
public function run() { if($this->mask=='') throw new CException(Yii::t('yii','Property CMaskedTextField.mask cannot be empty.')); list($name,$id)=$this->resolveNameID(); if(isset($this->htmlOptions['id'])) $id=$this->htmlOptions['id']; else $this->htmlOptions['id']=$id; if(isset($this->htmlOptions['name'])) $name=$this->htmlOptions['name']; $this->registerClientScript(); if($this->hasModel()) echo CHtml::activeTextField($this->model,$this->attribute,$this->htmlOptions); else echo CHtml::textField($name,$this->value,$this->htmlOptions); }
Executes the widget. This method registers all needed client scripts and renders the text field.
run
php
yiisoft/yii
framework/web/widgets/CMaskedTextField.php
https://github.com/yiisoft/yii/blob/master/framework/web/widgets/CMaskedTextField.php
BSD-3-Clause
public function registerClientScript() { $id=$this->htmlOptions['id']; $miOptions=$this->getClientOptions(); $options=$miOptions!==array() ? ','.CJavaScript::encode($miOptions) : ''; $js=''; if(is_array($this->charMap)) $js.='jQuery.mask.definitions='.CJavaScript::encode($this->charMap).";\n"; $js.="jQuery(\"#{$id}\").mask(\"{$this->mask}\"{$options});"; $cs=Yii::app()->getClientScript(); $cs->registerCoreScript('maskedinput'); $cs->registerScript('Yii.CMaskedTextField#'.$id,$js); }
Registers the needed CSS and JavaScript.
registerClientScript
php
yiisoft/yii
framework/web/widgets/CMaskedTextField.php
https://github.com/yiisoft/yii/blob/master/framework/web/widgets/CMaskedTextField.php
BSD-3-Clause
public function filter($filterChain) { if(!$this->getIsContentCached()) $filterChain->run(); $this->run(); }
Performs filtering before the action is executed. This method is meant to be overridden by child classes if begin-filtering is needed. @param CFilterChain $filterChain list of filters being applied to an action
filter
php
yiisoft/yii
framework/web/widgets/COutputCache.php
https://github.com/yiisoft/yii/blob/master/framework/web/widgets/COutputCache.php
BSD-3-Clause
protected function getBaseCacheKey() { return self::CACHE_KEY_PREFIX.$this->getId().'.'; }
Caclulates the base cache key. The calculated key will be further variated in {@link getCacheKey}. Derived classes may override this method if more variations are needed. @return string basic cache key without variations
getBaseCacheKey
php
yiisoft/yii
framework/web/widgets/COutputCache.php
https://github.com/yiisoft/yii/blob/master/framework/web/widgets/COutputCache.php
BSD-3-Clause
protected function getCacheKey() { if($this->_key!==null) return $this->_key; else { $key=$this->getBaseCacheKey().'.'; if($this->varyByRoute) { $controller=$this->getController(); $key.=$controller->getUniqueId().'/'; if(($action=$controller->getAction())!==null) $key.=$action->getId(); } $key.='.'; if($this->varyBySession) $key.=Yii::app()->getSession()->getSessionID(); $key.='.'; if(is_array($this->varyByParam) && isset($this->varyByParam[0])) { $params=array(); foreach($this->varyByParam as $name) { if(isset($_GET[$name])) $params[$name]=$_GET[$name]; else $params[$name]=''; } $key.=serialize($params); } $key.='.'; if($this->varyByExpression!==null) $key.=$this->evaluateExpression($this->varyByExpression); $key.='.'; if($this->varyByLanguage) $key.=Yii::app()->language; $key.='.'; return $this->_key=$key; } }
Calculates the cache key. The key is calculated based on {@link getBaseCacheKey} and other factors, including {@link varyByRoute}, {@link varyByParam}, {@link varyBySession} and {@link varyByLanguage}. @return string cache key
getCacheKey
php
yiisoft/yii
framework/web/widgets/COutputCache.php
https://github.com/yiisoft/yii/blob/master/framework/web/widgets/COutputCache.php
BSD-3-Clause
public function recordAction($context,$method,$params) { $this->_actions[]=array($context,$method,$params); }
Records a method call when this 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. The property should refer to an object whose method is being recorded. If empty it means the controller itself. @param string $method the method name @param array $params parameters passed to the method
recordAction
php
yiisoft/yii
framework/web/widgets/COutputCache.php
https://github.com/yiisoft/yii/blob/master/framework/web/widgets/COutputCache.php
BSD-3-Clause
public function processOutput($output) { $output=$this->purify($output); parent::processOutput($output); }
Processes the captured output. This method purifies the output using {@link http://htmlpurifier.org HTML Purifier}. @param string $output the captured output to be processed
processOutput
php
yiisoft/yii
framework/web/widgets/CHtmlPurifier.php
https://github.com/yiisoft/yii/blob/master/framework/web/widgets/CHtmlPurifier.php
BSD-3-Clause
public function purify($content) { if(is_array($content)) $content=array_map(array($this,'purify'),$content); else $content=$this->getPurifier()->purify($content); return $content; }
Purifies the HTML content by removing malicious code. @param mixed $content the content to be purified. @return mixed the purified content
purify
php
yiisoft/yii
framework/web/widgets/CHtmlPurifier.php
https://github.com/yiisoft/yii/blob/master/framework/web/widgets/CHtmlPurifier.php
BSD-3-Clause
public function setOptions($options) { $this->_options=$options; $this->createNewHtmlPurifierInstance(); return $this; }
Set the options for HTML Purifier and create a new HTML Purifier instance based on these options. @param mixed $options the options for HTML Purifier @return static the object instance itself
setOptions
php
yiisoft/yii
framework/web/widgets/CHtmlPurifier.php
https://github.com/yiisoft/yii/blob/master/framework/web/widgets/CHtmlPurifier.php
BSD-3-Clause
public function getOptions() { return $this->_options; }
Get the options for the HTML Purifier instance. @return mixed the HTML Purifier instance options
getOptions
php
yiisoft/yii
framework/web/widgets/CHtmlPurifier.php
https://github.com/yiisoft/yii/blob/master/framework/web/widgets/CHtmlPurifier.php
BSD-3-Clause
protected function getPurifier() { if($this->_purifier!==null) return $this->_purifier; return $this->createNewHtmlPurifierInstance(); }
Get the HTML Purifier instance or create a new one if it doesn't exist. @return HTMLPurifier
getPurifier
php
yiisoft/yii
framework/web/widgets/CHtmlPurifier.php
https://github.com/yiisoft/yii/blob/master/framework/web/widgets/CHtmlPurifier.php
BSD-3-Clause
protected function createNewHtmlPurifierInstance() { $this->_purifier=new HTMLPurifier($this->getOptions()); $this->_purifier->config->set('Cache.SerializerPath',Yii::app()->getRuntimePath()); return $this->_purifier; }
Create a new HTML Purifier instance. @return HTMLPurifier
createNewHtmlPurifierInstance
php
yiisoft/yii
framework/web/widgets/CHtmlPurifier.php
https://github.com/yiisoft/yii/blob/master/framework/web/widgets/CHtmlPurifier.php
BSD-3-Clause
public function init() { if(isset($this->htmlOptions['id'])) $id=$this->htmlOptions['id']; else $id=$this->htmlOptions['id']=$this->getId(); if($this->url!==null) $this->url=CHtml::normalizeUrl($this->url); $cs=Yii::app()->getClientScript(); $cs->registerCoreScript('treeview'); $options=$this->getClientOptions(); $options=$options===array()?'{}' : CJavaScript::encode($options); $cs->registerScript('Yii.CTreeView#'.$id,"jQuery(\"#{$id}\").treeview($options);"); if($this->cssFile===null) $cs->registerCssFile($cs->getCoreScriptUrl().'/treeview/jquery.treeview.css'); elseif($this->cssFile!==false) $cs->registerCssFile($this->cssFile); echo CHtml::tag('ul',$this->htmlOptions,false,false)."\n"; echo self::saveDataAsHtml($this->data); }
Initializes the widget. This method registers all needed client scripts and renders the tree view content.
init
php
yiisoft/yii
framework/web/widgets/CTreeView.php
https://github.com/yiisoft/yii/blob/master/framework/web/widgets/CTreeView.php
BSD-3-Clause
public static function saveDataAsJson($data) { if(empty($data)) return '[]'; else return CJavaScript::jsonEncode($data); }
Saves tree view data in JSON format. This method is typically used in dynamic tree view loading when the server code needs to send to the client the dynamic tree view data. @param array $data the data for the tree view (see {@link data} for possible data structure). @return string the JSON representation of the data
saveDataAsJson
php
yiisoft/yii
framework/web/widgets/CTreeView.php
https://github.com/yiisoft/yii/blob/master/framework/web/widgets/CTreeView.php
BSD-3-Clause
public function processOutput($output) { $output=$this->transform($output); if($this->purifyOutput) { $purifier=new CHtmlPurifier; $output=$purifier->purify($output); } parent::processOutput($output); }
Processes the captured output. This method converts the content in markdown syntax to HTML code. If {@link purifyOutput} is true, the HTML code will also be purified. @param string $output the captured output to be processed @see convert
processOutput
php
yiisoft/yii
framework/web/widgets/CMarkdown.php
https://github.com/yiisoft/yii/blob/master/framework/web/widgets/CMarkdown.php
BSD-3-Clause
public function transform($output) { $this->registerClientScript(); return $this->getMarkdownParser()->transform($output); }
Converts the content in markdown syntax to HTML code. This method uses {@link CMarkdownParser} to do the conversion. @param string $output the content to be converted @return string the converted content
transform
php
yiisoft/yii
framework/web/widgets/CMarkdown.php
https://github.com/yiisoft/yii/blob/master/framework/web/widgets/CMarkdown.php
BSD-3-Clause
public function registerClientScript() { if($this->cssFile!==false) self::registerCssFile($this->cssFile); }
Registers the needed CSS and JavaScript.
registerClientScript
php
yiisoft/yii
framework/web/widgets/CMarkdown.php
https://github.com/yiisoft/yii/blob/master/framework/web/widgets/CMarkdown.php
BSD-3-Clause
public static function registerCssFile($url=null) { CTextHighlighter::registerCssFile($url); }
Registers the needed CSS file. @param string $url the CSS URL. If null, a default CSS URL will be used.
registerCssFile
php
yiisoft/yii
framework/web/widgets/CMarkdown.php
https://github.com/yiisoft/yii/blob/master/framework/web/widgets/CMarkdown.php
BSD-3-Clause
public function getMarkdownParser() { if($this->_parser===null) $this->_parser=$this->createMarkdownParser(); return $this->_parser; }
Returns the markdown parser instance. This method calls {@link createMarkdownParser} to create the parser instance. Call this method multipe times will only return the same instance. @return CMarkdownParser the parser instance
getMarkdownParser
php
yiisoft/yii
framework/web/widgets/CMarkdown.php
https://github.com/yiisoft/yii/blob/master/framework/web/widgets/CMarkdown.php
BSD-3-Clause
protected function createMarkdownParser() { return new CMarkdownParser; }
Creates a markdown parser. By default, this method creates a {@link CMarkdownParser} instance. @return CMarkdownParser the markdown parser.
createMarkdownParser
php
yiisoft/yii
framework/web/widgets/CMarkdown.php
https://github.com/yiisoft/yii/blob/master/framework/web/widgets/CMarkdown.php
BSD-3-Clause
public function run() { list($name,$id)=$this->resolveNameID(); if(isset($this->htmlOptions['id'])) $id=$this->htmlOptions['id']; else $this->htmlOptions['id']=$id; if(isset($this->htmlOptions['name'])) $name=$this->htmlOptions['name']; $this->registerClientScript($id); echo CHtml::openTag('span',$this->htmlOptions)."\n"; $this->renderStars($id,$name); echo "</span>"; }
Executes the widget. This method registers all needed client scripts and renders the text field.
run
php
yiisoft/yii
framework/web/widgets/CStarRating.php
https://github.com/yiisoft/yii/blob/master/framework/web/widgets/CStarRating.php
BSD-3-Clause
public function registerClientScript($id) { $jsOptions=$this->getClientOptions(); $jsOptions=empty($jsOptions) ? '' : CJavaScript::encode($jsOptions); $js="jQuery('#{$id} > input').rating({$jsOptions});"; $cs=Yii::app()->getClientScript(); $cs->registerCoreScript('rating'); $cs->registerScript('Yii.CStarRating#'.$id,$js); if($this->cssFile!==false) self::registerCssFile($this->cssFile); }
Registers the necessary javascript and css scripts. @param string $id the ID of the container
registerClientScript
php
yiisoft/yii
framework/web/widgets/CStarRating.php
https://github.com/yiisoft/yii/blob/master/framework/web/widgets/CStarRating.php
BSD-3-Clause
public static function registerCssFile($url=null) { $cs=Yii::app()->getClientScript(); if($url===null) $url=$cs->getCoreScriptUrl().'/rating/jquery.rating.css'; $cs->registerCssFile($url); }
Registers the needed CSS file. @param string $url the CSS URL. If null, a default CSS URL will be used.
registerCssFile
php
yiisoft/yii
framework/web/widgets/CStarRating.php
https://github.com/yiisoft/yii/blob/master/framework/web/widgets/CStarRating.php
BSD-3-Clause
public function init() { ob_start(); ob_implicit_flush(false); }
Initializes the widget. This method starts the output buffering.
init
php
yiisoft/yii
framework/web/widgets/COutputProcessor.php
https://github.com/yiisoft/yii/blob/master/framework/web/widgets/COutputProcessor.php
BSD-3-Clause
public function run() { $output=ob_get_clean(); $this->processOutput($output); }
Executes the widget. This method stops output buffering and processes the captured output.
run
php
yiisoft/yii
framework/web/widgets/COutputProcessor.php
https://github.com/yiisoft/yii/blob/master/framework/web/widgets/COutputProcessor.php
BSD-3-Clause
public function processOutput($output) { if($this->hasEventHandler('onProcessOutput')) { $event=new COutputEvent($this,$output); $this->onProcessOutput($event); if(!$event->handled) echo $output; } else echo $output; }
Processes the captured output. The default implementation raises an {@link onProcessOutput} event. If the event is not handled by any event handler, the output will be echoed. @param string $output the captured output to be processed
processOutput
php
yiisoft/yii
framework/web/widgets/COutputProcessor.php
https://github.com/yiisoft/yii/blob/master/framework/web/widgets/COutputProcessor.php
BSD-3-Clause
public function onProcessOutput($event) { $this->raiseEvent('onProcessOutput',$event); }
Raised when the output has been captured. @param COutputEvent $event event parameter
onProcessOutput
php
yiisoft/yii
framework/web/widgets/COutputProcessor.php
https://github.com/yiisoft/yii/blob/master/framework/web/widgets/COutputProcessor.php
BSD-3-Clause
public function processOutput($output) { $output=$this->decorate($output); parent::processOutput($output); }
Processes the captured output. This method decorates the output with the specified {@link view}. @param string $output the captured output to be processed
processOutput
php
yiisoft/yii
framework/web/widgets/CContentDecorator.php
https://github.com/yiisoft/yii/blob/master/framework/web/widgets/CContentDecorator.php
BSD-3-Clause
protected function decorate($content) { $owner=$this->getOwner(); if($this->view===null) $viewFile=Yii::app()->getController()->getLayoutFile(null); else $viewFile=$owner->getViewFile($this->view); if($viewFile!==false) { $data=$this->data; $data['content']=$content; return $owner->renderFile($viewFile,$data,true); } else return $content; }
Decorates the content by rendering a view and embedding the content in it. The content being embedded can be accessed in the view using variable <code>$content</code> The decorated content will be displayed directly. @param string $content the content to be decorated @return string the decorated content
decorate
php
yiisoft/yii
framework/web/widgets/CContentDecorator.php
https://github.com/yiisoft/yii/blob/master/framework/web/widgets/CContentDecorator.php
BSD-3-Clause
public function run() { $clip=ob_get_clean(); if($this->renderClip) echo $clip; $this->getController()->getClips()->add($this->getId(),$clip); }
Ends recording a clip. This method stops output buffering and saves the rendering result as a named clip in the controller.
run
php
yiisoft/yii
framework/web/widgets/CClipWidget.php
https://github.com/yiisoft/yii/blob/master/framework/web/widgets/CClipWidget.php
BSD-3-Clause
public function filter($filterChain) { $this->init(); if(!$this->stopAction) { $filterChain->run(); $this->run(); } }
Performs the filtering. The default implementation simply calls {@link init()}, {@link CFilterChain::run()} and {@link run()} in order Derived classes may want to override this method to change this behavior. @param CFilterChain $filterChain the filter chain that the filter is on.
filter
php
yiisoft/yii
framework/web/widgets/CFilterWidget.php
https://github.com/yiisoft/yii/blob/master/framework/web/widgets/CFilterWidget.php
BSD-3-Clause
public function registerClientScript() { $cs=Yii::app()->getClientScript(); $cs->registerScriptFile($this->baseUrl.'/AC_OETags.js'); if($this->enableHistory) { $cs->registerCssFile($this->baseUrl.'/history/history.css'); $cs->registerScriptFile($this->baseUrl.'/history/history.js'); } }
Registers the needed CSS and JavaScript.
registerClientScript
php
yiisoft/yii
framework/web/widgets/CFlexWidget.php
https://github.com/yiisoft/yii/blob/master/framework/web/widgets/CFlexWidget.php
BSD-3-Clause
public function getFlashVarsAsString() { $params=array(); foreach($this->flashVars as $k=>$v) $params[]=urlencode($k).'='.urlencode($v); return CJavaScript::quote(implode('&',$params)); }
Generates the properly quoted flash parameter string. @return string the flash parameter string.
getFlashVarsAsString
php
yiisoft/yii
framework/web/widgets/CFlexWidget.php
https://github.com/yiisoft/yii/blob/master/framework/web/widgets/CFlexWidget.php
BSD-3-Clause
public static function actions() { return array(); }
Returns a list of actions that are used by this widget. The structure of this method's return value is similar to that returned by {@link CController::actions}. When a widget uses several actions, you can declare these actions using this method. The widget will then become an action provider, and the actions can be easily imported into a controller. Note, when creating URLs referring to the actions listed in this method, make sure the action IDs are prefixed with {@link actionPrefix}. @return array @see actionPrefix @see CController::actions
actions
php
yiisoft/yii
framework/web/widgets/CWidget.php
https://github.com/yiisoft/yii/blob/master/framework/web/widgets/CWidget.php
BSD-3-Clause
public function getOwner() { return $this->_owner; }
Returns the owner/creator of this widget. @return CBaseController owner/creator of this widget. It could be either a widget or a controller.
getOwner
php
yiisoft/yii
framework/web/widgets/CWidget.php
https://github.com/yiisoft/yii/blob/master/framework/web/widgets/CWidget.php
BSD-3-Clause
public function getId($autoGenerate=true) { if($this->_id!==null) return $this->_id; elseif($autoGenerate) return $this->_id='yw'.self::$_counter++; }
Returns the ID of the widget or generates a new one if requested. @param boolean $autoGenerate whether to generate an ID if it is not set previously @return string id of the widget.
getId
php
yiisoft/yii
framework/web/widgets/CWidget.php
https://github.com/yiisoft/yii/blob/master/framework/web/widgets/CWidget.php
BSD-3-Clause
public function getController() { if($this->_owner instanceof CController) return $this->_owner; else return Yii::app()->getController(); }
Returns the controller that this widget belongs to. @return CController the controller that this widget belongs to.
getController
php
yiisoft/yii
framework/web/widgets/CWidget.php
https://github.com/yiisoft/yii/blob/master/framework/web/widgets/CWidget.php
BSD-3-Clause
public function run() { }
Executes the widget. This method is called by {@link CBaseController::endWidget}.
run
php
yiisoft/yii
framework/web/widgets/CWidget.php
https://github.com/yiisoft/yii/blob/master/framework/web/widgets/CWidget.php
BSD-3-Clause
public function getViewPath($checkTheme=false) { $className=get_class($this); $scope=$checkTheme?'theme':'local'; if(isset(self::$_viewPaths[$className][$scope])) return self::$_viewPaths[$className][$scope]; else { if($checkTheme && ($theme=Yii::app()->getTheme())!==null) { $path=$theme->getViewPath().DIRECTORY_SEPARATOR; if(strpos($className,'\\')!==false) // namespaced class $path.=str_replace('\\','_',ltrim($className,'\\')); else $path.=$className; if(is_dir($path)) return self::$_viewPaths[$className]['theme']=$path; } $class=new ReflectionClass($className); return self::$_viewPaths[$className]['local']=dirname($class->getFileName()).DIRECTORY_SEPARATOR.'views'; } }
Returns the directory containing the view files for this widget. The default implementation returns the 'views' subdirectory of the directory containing the widget class file. If $checkTheme is set true, the directory "ThemeID/views/ClassName" will be returned when it exists. @param boolean $checkTheme whether to check if the theme contains a view path for the widget. @return string the directory containing the view files for this widget.
getViewPath
php
yiisoft/yii
framework/web/widgets/CWidget.php
https://github.com/yiisoft/yii/blob/master/framework/web/widgets/CWidget.php
BSD-3-Clause
public function processOutput($output) { $output=$this->highlight($output); parent::processOutput($output); }
Processes the captured output. This method highlights the output according to the syntax of the specified {@link language}. @param string $output the captured output to be processed
processOutput
php
yiisoft/yii
framework/web/widgets/CTextHighlighter.php
https://github.com/yiisoft/yii/blob/master/framework/web/widgets/CTextHighlighter.php
BSD-3-Clause
public function highlight($content) { $this->registerClientScript(); $options['use_language']=true; $options['tabsize']=$this->tabSize; if($this->showLineNumbers) $options['numbers']=($this->lineNumberStyle==='list')?HL_NUMBERS_LI:HL_NUMBERS_TABLE; $highlighter=empty($this->language)?false:Text_Highlighter::factory($this->language); if($highlighter===false) $o='<pre>'.CHtml::encode($content).'</pre>'; else { $highlighter->setRenderer(new Text_Highlighter_Renderer_Html($options)); $o=preg_replace('/<span\s+[^>]*>(\s*)<\/span>/','\1',$highlighter->highlight($content)); } return CHtml::tag('div',$this->containerOptions,$o); }
Highlights the content by the syntax of the specified language. @param string $content the content to be highlighted. @return string the highlighted content
highlight
php
yiisoft/yii
framework/web/widgets/CTextHighlighter.php
https://github.com/yiisoft/yii/blob/master/framework/web/widgets/CTextHighlighter.php
BSD-3-Clause
public function registerClientScript() { if($this->cssFile!==false) self::registerCssFile($this->cssFile); }
Registers the needed CSS and JavaScript.
registerClientScript
php
yiisoft/yii
framework/web/widgets/CTextHighlighter.php
https://github.com/yiisoft/yii/blob/master/framework/web/widgets/CTextHighlighter.php
BSD-3-Clause
public static function registerCssFile($url=null) { if($url===null) $url=CHtml::asset(Yii::getPathOfAlias('system.vendors.TextHighlighter.highlight').'.css'); Yii::app()->getClientScript()->registerCssFile($url); }
Registers the needed CSS file. @param string $url the CSS URL. If null, a default CSS URL will be used.
registerCssFile
php
yiisoft/yii
framework/web/widgets/CTextHighlighter.php
https://github.com/yiisoft/yii/blob/master/framework/web/widgets/CTextHighlighter.php
BSD-3-Clause
public function generateValidationHash($code) { for($h=0,$i=strlen($code)-1;$i>=0;--$i) $h+=ord($code[$i]); return $h; }
Generates a hash code that can be used for client side validation. @param string $code the CAPTCHA code @return string a hash code generated from the CAPTCHA code @since 1.1.7
generateValidationHash
php
yiisoft/yii
framework/web/widgets/captcha/CCaptchaAction.php
https://github.com/yiisoft/yii/blob/master/framework/web/widgets/captcha/CCaptchaAction.php
BSD-3-Clause
public function validate($input,$caseSensitive) { $code = $this->getVerifyCode(); $valid = $caseSensitive ? ($input === $code) : strcasecmp($input,$code)===0; $session = Yii::app()->session; $session->open(); $name = $this->getSessionKey() . 'count'; $session[$name] = $session[$name] + 1; if($session[$name] > $this->testLimit && $this->testLimit > 0) $this->getVerifyCode(true); return $valid; }
Validates the input to see if it matches the generated code. @param string $input user input @param boolean $caseSensitive whether the comparison should be case-sensitive @return boolean whether the input is valid
validate
php
yiisoft/yii
framework/web/widgets/captcha/CCaptchaAction.php
https://github.com/yiisoft/yii/blob/master/framework/web/widgets/captcha/CCaptchaAction.php
BSD-3-Clause
protected function generateVerifyCode() { if($this->minLength > $this->maxLength) $this->maxLength = $this->minLength; if($this->minLength < 3) $this->minLength = 3; if($this->maxLength > 20) $this->maxLength = 20; $length = mt_rand($this->minLength,$this->maxLength); $letters = 'bcdfghjklmnpqrstvwxyz'; $vowels = 'aeiou'; $code = ''; for($i = 0; $i < $length; ++$i) { if($i % 2 && mt_rand(0,10) > 2 || !($i % 2) && mt_rand(0,10) > 9) $code.=$vowels[mt_rand(0,4)]; else $code.=$letters[mt_rand(0,20)]; } return $code; }
Generates a new verification code. @return string the generated verification code
generateVerifyCode
php
yiisoft/yii
framework/web/widgets/captcha/CCaptchaAction.php
https://github.com/yiisoft/yii/blob/master/framework/web/widgets/captcha/CCaptchaAction.php
BSD-3-Clause
protected function getSessionKey() { return self::SESSION_VAR_PREFIX . Yii::app()->getId() . '.' . $this->getController()->getUniqueId() . '.' . $this->getId(); }
Returns the session variable name used to store verification code. @return string the session variable name
getSessionKey
php
yiisoft/yii
framework/web/widgets/captcha/CCaptchaAction.php
https://github.com/yiisoft/yii/blob/master/framework/web/widgets/captcha/CCaptchaAction.php
BSD-3-Clause
protected function renderImageGD($code) { $image = imagecreatetruecolor($this->width,$this->height); $backColor = imagecolorallocate($image, (int)($this->backColor % 0x1000000 / 0x10000), (int)($this->backColor % 0x10000 / 0x100), $this->backColor % 0x100); imagefilledrectangle($image,0,0,$this->width,$this->height,$backColor); imagecolordeallocate($image,$backColor); if($this->transparent) imagecolortransparent($image,$backColor); $foreColor = imagecolorallocate($image, (int)($this->foreColor % 0x1000000 / 0x10000), (int)($this->foreColor % 0x10000 / 0x100), $this->foreColor % 0x100); if($this->fontFile === null) $this->fontFile = dirname(__FILE__).DIRECTORY_SEPARATOR.'SpicyRice.ttf'; $length = strlen($code); $box = imagettfbbox(30,0,$this->fontFile,$code); $w = $box[4] - $box[0] + $this->offset * ($length - 1); $h = $box[1] - $box[5]; $scale = min(($this->width - $this->padding * 2) / $w,($this->height - $this->padding * 2) / $h); $x = 10; $y = round($this->height * 27 / 40); for($i = 0; $i < $length; ++$i) { $fontSize = (int)(rand(26,32) * $scale * 0.8); $angle = rand(-10,10); $letter = $code[$i]; $box = imagettftext($image,$fontSize,$angle,$x,$y,$foreColor,$this->fontFile,$letter); $x = $box[2] + $this->offset; } imagecolordeallocate($image,$foreColor); header('Pragma: public'); header('Expires: 0'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Content-Transfer-Encoding: binary'); header("Content-Type: image/png"); imagepng($image); imagedestroy($image); }
Renders the CAPTCHA image based on the code using GD library. @param string $code the verification code @since 1.1.13
renderImageGD
php
yiisoft/yii
framework/web/widgets/captcha/CCaptchaAction.php
https://github.com/yiisoft/yii/blob/master/framework/web/widgets/captcha/CCaptchaAction.php
BSD-3-Clause
protected function renderImageImagick($code) { $backColor=$this->transparent ? new ImagickPixel('transparent') : new ImagickPixel(sprintf('#%06x',$this->backColor)); $foreColor=new ImagickPixel(sprintf('#%06x',$this->foreColor)); $image=new Imagick(); $image->newImage($this->width,$this->height,$backColor); if($this->fontFile===null) $this->fontFile=dirname(__FILE__).DIRECTORY_SEPARATOR.'SpicyRice.ttf'; $draw=new ImagickDraw(); $draw->setFont($this->fontFile); $draw->setFontSize(30); $fontMetrics=$image->queryFontMetrics($draw,$code); $length=strlen($code); $w=(int)($fontMetrics['textWidth'])-8+$this->offset*($length-1); $h=(int)($fontMetrics['textHeight'])-8; $scale=min(($this->width-$this->padding*2)/$w,($this->height-$this->padding*2)/$h); $x=10; $y=round($this->height*27/40); for($i=0; $i<$length; ++$i) { $draw=new ImagickDraw(); $draw->setFont($this->fontFile); $draw->setFontSize((int)(rand(26,32)*$scale*0.8)); $draw->setFillColor($foreColor); $image->annotateImage($draw,$x,$y,rand(-10,10),$code[$i]); $fontMetrics=$image->queryFontMetrics($draw,$code[$i]); $x+=(int)($fontMetrics['textWidth'])+$this->offset; } header('Pragma: public'); header('Expires: 0'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Content-Transfer-Encoding: binary'); header("Content-Type: image/png"); $image->setImageFormat('png'); echo $image->getImageBlob(); }
Renders the CAPTCHA image based on the code using ImageMagick library. @param string $code the verification code @since 1.1.13
renderImageImagick
php
yiisoft/yii
framework/web/widgets/captcha/CCaptchaAction.php
https://github.com/yiisoft/yii/blob/master/framework/web/widgets/captcha/CCaptchaAction.php
BSD-3-Clause
public function registerClientScript() { $cs=Yii::app()->clientScript; $id=$this->imageOptions['id']; $url=$this->getController()->createUrl($this->captchaAction,array(CCaptchaAction::REFRESH_GET_VAR=>true)); $js=""; if($this->showRefreshButton) { // reserve a place in the registered script so that any enclosing button js code appears after the captcha js $cs->registerScript('Yii.CCaptcha#'.$id,'// dummy'); $label=$this->buttonLabel===null?Yii::t('yii','Get a new code'):$this->buttonLabel; $options=$this->buttonOptions; if(isset($options['id'])) $buttonID=$options['id']; else $buttonID=$options['id']=$id.'_button'; if($this->buttonType==='button') $html=CHtml::button($label, $options); else $html=CHtml::link($label, $url, $options); $js="jQuery('#$id').after(".CJSON::encode($html).");"; $selector="#$buttonID"; } if($this->clickableImage) $selector=isset($selector) ? "$selector, #$id" : "#$id"; if(!isset($selector)) return; $js.=" jQuery(document).on('click', '$selector', function(){ jQuery.ajax({ url: ".CJSON::encode($url).", dataType: 'json', cache: false, success: function(data) { jQuery('#$id').attr('src', data['url']); jQuery('body').data('{$this->captchaAction}.hash', [data['hash1'], data['hash2']]); } }); return false; }); "; $cs->registerScript('Yii.CCaptcha#'.$id,$js); }
Registers the needed client scripts.
registerClientScript
php
yiisoft/yii
framework/web/widgets/captcha/CCaptcha.php
https://github.com/yiisoft/yii/blob/master/framework/web/widgets/captcha/CCaptcha.php
BSD-3-Clause
public static function checkRequirements($extension=null) { if(extension_loaded('imagick')) { $imagickFormats=Imagick::queryFormats('PNG'); } if(extension_loaded('gd')) { $gdInfo=gd_info(); } if($extension===null) { if(isset($imagickFormats) && in_array('PNG',$imagickFormats)) return true; if(isset($gdInfo) && $gdInfo['FreeType Support']) return true; } elseif($extension=='imagick' && isset($imagickFormats) && in_array('PNG',$imagickFormats)) return true; elseif($extension=='gd' && isset($gdInfo) && $gdInfo['FreeType Support']) return true; return false; }
Checks if specified graphic extension support is loaded. @param string $extension name to be checked. Possible values are 'gd', 'imagick' and null. Default value is null meaning that both extensions will be checked. This parameter is available since 1.1.13. @return boolean true if ImageMagick extension with PNG support or GD with FreeType support is loaded, otherwise false @since 1.1.5
checkRequirements
php
yiisoft/yii
framework/web/widgets/captcha/CCaptcha.php
https://github.com/yiisoft/yii/blob/master/framework/web/widgets/captcha/CCaptcha.php
BSD-3-Clause
public function init() { if($this->nextPageLabel===null) $this->nextPageLabel=Yii::t('yii','Next &gt;'); if($this->prevPageLabel===null) $this->prevPageLabel=Yii::t('yii','&lt; Previous'); if($this->firstPageLabel===null) $this->firstPageLabel=Yii::t('yii','&lt;&lt; First'); if($this->lastPageLabel===null) $this->lastPageLabel=Yii::t('yii','Last &gt;&gt;'); if($this->header===null) $this->header=Yii::t('yii','Go to page: '); if(!isset($this->htmlOptions['id'])) $this->htmlOptions['id']=$this->getId(); if(!isset($this->htmlOptions['class'])) $this->htmlOptions['class']='yiiPager'; }
Initializes the pager by setting some default property values.
init
php
yiisoft/yii
framework/web/widgets/pagers/CLinkPager.php
https://github.com/yiisoft/yii/blob/master/framework/web/widgets/pagers/CLinkPager.php
BSD-3-Clause
public function run() { $this->registerClientScript(); $buttons=$this->createPageButtons(); if(empty($buttons)) return; echo $this->header; echo CHtml::tag('ul',$this->htmlOptions,implode("\n",$buttons)); echo $this->footer; }
Executes the widget. This overrides the parent implementation by displaying the generated page buttons.
run
php
yiisoft/yii
framework/web/widgets/pagers/CLinkPager.php
https://github.com/yiisoft/yii/blob/master/framework/web/widgets/pagers/CLinkPager.php
BSD-3-Clause
public function registerClientScript() { if($this->cssFile!==false) self::registerCssFile($this->cssFile); }
Registers the needed client scripts (mainly CSS file).
registerClientScript
php
yiisoft/yii
framework/web/widgets/pagers/CLinkPager.php
https://github.com/yiisoft/yii/blob/master/framework/web/widgets/pagers/CLinkPager.php
BSD-3-Clause
public static function registerCssFile($url=null) { if($url===null) $url=CHtml::asset(Yii::getPathOfAlias('system.web.widgets.pagers.pager').'.css'); Yii::app()->getClientScript()->registerCssFile($url); }
Registers the needed CSS file. @param string $url the CSS URL. If null, a default CSS URL will be used.
registerCssFile
php
yiisoft/yii
framework/web/widgets/pagers/CLinkPager.php
https://github.com/yiisoft/yii/blob/master/framework/web/widgets/pagers/CLinkPager.php
BSD-3-Clause
public function getPages() { if($this->_pages===null) $this->_pages=$this->createPages(); return $this->_pages; }
Returns the pagination information used by this pager. @return CPagination the pagination information
getPages
php
yiisoft/yii
framework/web/widgets/pagers/CBasePager.php
https://github.com/yiisoft/yii/blob/master/framework/web/widgets/pagers/CBasePager.php
BSD-3-Clause
public function setPages($pages) { $this->_pages=$pages; }
Sets the pagination information used by this pager. @param CPagination $pages the pagination information
setPages
php
yiisoft/yii
framework/web/widgets/pagers/CBasePager.php
https://github.com/yiisoft/yii/blob/master/framework/web/widgets/pagers/CBasePager.php
BSD-3-Clause
protected function createPages() { return new CPagination; }
Creates the default pagination. This is called by {@link getPages} when the pagination is not set before. @return CPagination the default pagination instance.
createPages
php
yiisoft/yii
framework/web/widgets/pagers/CBasePager.php
https://github.com/yiisoft/yii/blob/master/framework/web/widgets/pagers/CBasePager.php
BSD-3-Clause
protected function createPageUrl($page) { return $this->getPages()->createPageUrl($this->getController(),$page); }
Creates the URL suitable for pagination. @param integer $page the page that the URL should point to. @return string the created URL @see CPagination::createPageUrl
createPageUrl
php
yiisoft/yii
framework/web/widgets/pagers/CBasePager.php
https://github.com/yiisoft/yii/blob/master/framework/web/widgets/pagers/CBasePager.php
BSD-3-Clause
public function init() { if($this->header===null) $this->header=Yii::t('yii','Go to page: '); if(!isset($this->htmlOptions['id'])) $this->htmlOptions['id']=$this->getId(); if($this->promptText!==null) $this->htmlOptions['prompt']=$this->promptText; if(!isset($this->htmlOptions['onchange'])) $this->htmlOptions['onchange']="if(this.value!='') {window.location=this.value;};"; }
Initializes the pager by setting some default property values.
init
php
yiisoft/yii
framework/web/widgets/pagers/CListPager.php
https://github.com/yiisoft/yii/blob/master/framework/web/widgets/pagers/CListPager.php
BSD-3-Clause
public function run() { if(($pageCount=$this->getPageCount())<=1) return; $pages=array(); for($i=0;$i<$pageCount;++$i) $pages[$this->createPageUrl($i)]=$this->generatePageText($i); $selection=$this->createPageUrl($this->getCurrentPage()); echo $this->header; echo CHtml::dropDownList($this->getId(),$selection,$pages,$this->htmlOptions); echo $this->footer; }
Executes the widget. This overrides the parent implementation by displaying the generated page buttons.
run
php
yiisoft/yii
framework/web/widgets/pagers/CListPager.php
https://github.com/yiisoft/yii/blob/master/framework/web/widgets/pagers/CListPager.php
BSD-3-Clause
protected function generatePageText($page) { if($this->pageTextFormat!==null) return sprintf($this->pageTextFormat,$page+1); else return $page+1; }
Generates the list option for the specified page number. You may override this method to customize the option display. @param integer $page zero-based page number @return string the list option for the page number
generatePageText
php
yiisoft/yii
framework/web/widgets/pagers/CListPager.php
https://github.com/yiisoft/yii/blob/master/framework/web/widgets/pagers/CListPager.php
BSD-3-Clause
public function getService() { return $this->_service; }
Returns the Web service instance currently being used. @return CWebService the Web service instance
getService
php
yiisoft/yii
framework/web/services/CWebServiceAction.php
https://github.com/yiisoft/yii/blob/master/framework/web/services/CWebServiceAction.php
BSD-3-Clause
protected function createWebService($provider,$wsdlUrl,$serviceUrl) { return new CWebService($provider,$wsdlUrl,$serviceUrl); }
Creates a {@link CWebService} instance. You may override this method to customize the created instance. @param mixed $provider the web service provider class name or object @param string $wsdlUrl the URL for WSDL. @param string $serviceUrl the URL for the Web service. @return CWebService the Web service instance
createWebService
php
yiisoft/yii
framework/web/services/CWebServiceAction.php
https://github.com/yiisoft/yii/blob/master/framework/web/services/CWebServiceAction.php
BSD-3-Clause
protected function injectDom(DOMDocument $dom, DOMElement $target, DOMNode $source) { if ($source->nodeType!=XML_ELEMENT_NODE) return; $import=$dom->createElement($source->nodeName); foreach($source->attributes as $attr) $import->setAttribute($attr->name,$attr->value); foreach($source->childNodes as $child) $this->injectDom($dom,$import,$child); $target->appendChild($import); }
Import custom XML source node into WSDL document under specified target node @param DOMDocument $dom XML WSDL document being generated @param DOMElement $target XML node, to which will be appended $source node @param DOMNode $source Source XML node to be imported
injectDom
php
yiisoft/yii
framework/web/services/CWsdlGenerator.php
https://github.com/yiisoft/yii/blob/master/framework/web/services/CWsdlGenerator.php
BSD-3-Clause
public function generateWsdl() { $providerClass=is_object($this->provider) ? get_class($this->provider) : Yii::import($this->provider,true); if($this->wsdlCacheDuration>0 && $this->cacheID!==false && ($cache=Yii::app()->getComponent($this->cacheID))!==null) { $key='Yii.CWebService.'.$providerClass.$this->serviceUrl.$this->encoding; if(($wsdl=$cache->get($key))!==false) return $wsdl; } $generator=Yii::createComponent($this->generatorConfig); $wsdl=$generator->generateWsdl($providerClass,$this->serviceUrl,$this->encoding); if(isset($key)) $cache->set($key,$wsdl,$this->wsdlCacheDuration); return $wsdl; }
Generates the WSDL as defined by the provider. The cached version may be used if the WSDL is found valid in cache. @return string the generated WSDL @see wsdlCacheDuration
generateWsdl
php
yiisoft/yii
framework/web/services/CWebService.php
https://github.com/yiisoft/yii/blob/master/framework/web/services/CWebService.php
BSD-3-Clause
public function run() { header('Content-Type: text/xml;charset='.$this->encoding); if(YII_DEBUG) ini_set("soap.wsdl_cache_enabled",0); $server=new SoapServer($this->wsdlUrl,$this->getOptions()); Yii::app()->attachEventHandler('onError',array($this,'handleError')); try { if($this->persistence!==null) $server->setPersistence($this->persistence); if(is_string($this->provider)) $provider=Yii::createComponent($this->provider); else $provider=$this->provider; if(method_exists($server,'setObject')) { if (is_array($this->generatorConfig) && isset($this->generatorConfig['bindingStyle']) && $this->generatorConfig['bindingStyle']==='document') { $server->setObject(new CDocumentSoapObjectWrapper($provider)); } else { $server->setObject($provider); } } else { if (is_array($this->generatorConfig) && isset($this->generatorConfig['bindingStyle']) && $this->generatorConfig['bindingStyle']==='document') { $server->setClass('CDocumentSoapObjectWrapper',$provider); } else { $server->setClass('CSoapObjectWrapper',$provider); } } if($provider instanceof IWebServiceProvider) { if($provider->beforeWebMethod($this)) { $server->handle(); $provider->afterWebMethod($this); } } else $server->handle(); } catch(Exception $e) { if($e->getCode()!==self::SOAP_ERROR) // non-PHP error { // only log for non-PHP-error case because application's error handler already logs it // php <5.2 doesn't support string conversion auto-magically Yii::log($e->__toString(),CLogger::LEVEL_ERROR,'application'); } $message=$e->getMessage(); if(YII_DEBUG) $message.=' ('.$e->getFile().':'.$e->getLine().")\n".$e->getTraceAsString(); // We need to end application explicitly because of // https://bugs.php.net/bug.php?id=49513 Yii::app()->onEndRequest(new CEvent($this)); $server->fault(get_class($e),$message); exit(1); } }
Handles the web service request.
run
php
yiisoft/yii
framework/web/services/CWebService.php
https://github.com/yiisoft/yii/blob/master/framework/web/services/CWebService.php
BSD-3-Clause
public function __call($name,$arguments) { return call_user_func_array(array($this->object,$name),$arguments); }
PHP __call magic method. This method calls the service provider to execute the actual logic. @param string $name method name @param array $arguments method arguments @return mixed method return value
__call
php
yiisoft/yii
framework/web/services/CWebService.php
https://github.com/yiisoft/yii/blob/master/framework/web/services/CWebService.php
BSD-3-Clause
public function __call($name,$arguments) { if (is_array($arguments) && isset($arguments[0])) { $result = call_user_func_array(array($this->object, $name), (array)$arguments[0]); } else { $result = call_user_func_array(array($this->object, $name), $arguments); } return $result === null ? $result : array($name . 'Result' => $result); }
PHP __call magic method. This method calls the service provider to execute the actual logic. @param string $name method name @param array $arguments method arguments @return mixed method return value
__call
php
yiisoft/yii
framework/web/services/CWebService.php
https://github.com/yiisoft/yii/blob/master/framework/web/services/CWebService.php
BSD-3-Clause
public function createRole($name,$description='',$bizRule=null,$data=null) { return $this->createAuthItem($name,CAuthItem::TYPE_ROLE,$description,$bizRule,$data); }
Creates a role. This is a shortcut method to {@link IAuthManager::createAuthItem}. @param string $name the item name @param string $description the item description. @param string $bizRule the business rule associated with this item @param mixed $data additional data to be passed when evaluating the business rule @return CAuthItem the authorization item
createRole
php
yiisoft/yii
framework/web/auth/CAuthManager.php
https://github.com/yiisoft/yii/blob/master/framework/web/auth/CAuthManager.php
BSD-3-Clause
public function createTask($name,$description='',$bizRule=null,$data=null) { return $this->createAuthItem($name,CAuthItem::TYPE_TASK,$description,$bizRule,$data); }
Creates a task. This is a shortcut method to {@link IAuthManager::createAuthItem}. @param string $name the item name @param string $description the item description. @param string $bizRule the business rule associated with this item @param mixed $data additional data to be passed when evaluating the business rule @return CAuthItem the authorization item
createTask
php
yiisoft/yii
framework/web/auth/CAuthManager.php
https://github.com/yiisoft/yii/blob/master/framework/web/auth/CAuthManager.php
BSD-3-Clause
public function createOperation($name,$description='',$bizRule=null,$data=null) { return $this->createAuthItem($name,CAuthItem::TYPE_OPERATION,$description,$bizRule,$data); }
Creates an operation. This is a shortcut method to {@link IAuthManager::createAuthItem}. @param string $name the item name @param string $description the item description. @param string $bizRule the business rule associated with this item @param mixed $data additional data to be passed when evaluating the business rule @return CAuthItem the authorization item
createOperation
php
yiisoft/yii
framework/web/auth/CAuthManager.php
https://github.com/yiisoft/yii/blob/master/framework/web/auth/CAuthManager.php
BSD-3-Clause
public function getRoles($userId=null) { return $this->getAuthItems(CAuthItem::TYPE_ROLE,$userId); }
Returns roles. This is a shortcut method to {@link IAuthManager::getAuthItems}. @param mixed $userId the user ID. If not null, only the roles directly assigned to the user will be returned. Otherwise, all roles will be returned. @return array roles (name=>CAuthItem)
getRoles
php
yiisoft/yii
framework/web/auth/CAuthManager.php
https://github.com/yiisoft/yii/blob/master/framework/web/auth/CAuthManager.php
BSD-3-Clause
public function getTasks($userId=null) { return $this->getAuthItems(CAuthItem::TYPE_TASK,$userId); }
Returns tasks. This is a shortcut method to {@link IAuthManager::getAuthItems}. @param mixed $userId the user ID. If not null, only the tasks directly assigned to the user will be returned. Otherwise, all tasks will be returned. @return array tasks (name=>CAuthItem)
getTasks
php
yiisoft/yii
framework/web/auth/CAuthManager.php
https://github.com/yiisoft/yii/blob/master/framework/web/auth/CAuthManager.php
BSD-3-Clause
public function getOperations($userId=null) { return $this->getAuthItems(CAuthItem::TYPE_OPERATION,$userId); }
Returns operations. This is a shortcut method to {@link IAuthManager::getAuthItems}. @param mixed $userId the user ID. If not null, only the operations directly assigned to the user will be returned. Otherwise, all operations will be returned. @return array operations (name=>CAuthItem)
getOperations
php
yiisoft/yii
framework/web/auth/CAuthManager.php
https://github.com/yiisoft/yii/blob/master/framework/web/auth/CAuthManager.php
BSD-3-Clause
public function executeBizRule($bizRule,$params,$data) { if($bizRule==='' || $bizRule===null) return true; if ($this->showErrors) return eval($bizRule)!=0; else { try { return @eval($bizRule)!=0; } catch (ParseError $e) { return false; } } }
Executes the specified business rule. @param string $bizRule the business rule to be executed. @param array $params parameters passed to {@link IAuthManager::checkAccess}. @param mixed $data additional data associated with the authorization item or assignment. @return boolean whether the business rule returns true. If the business rule is empty, it will still return true.
executeBizRule
php
yiisoft/yii
framework/web/auth/CAuthManager.php
https://github.com/yiisoft/yii/blob/master/framework/web/auth/CAuthManager.php
BSD-3-Clause
protected function preFilter($filterChain) { $app=Yii::app(); $request=$app->getRequest(); $user=$app->getUser(); $verb=$request->getRequestType(); $ip=$request->getUserHostAddress(); foreach($this->getRules() as $rule) { if(($allow=$rule->isUserAllowed($user,$filterChain->controller,$filterChain->action,$ip,$verb))>0) // allowed break; elseif($allow<0) // denied { if(isset($rule->deniedCallback)) call_user_func($rule->deniedCallback, $rule); else $this->accessDenied($user,$this->resolveErrorMessage($rule)); return false; } } return true; }
Performs the pre-action filtering. @param CFilterChain $filterChain the filter chain that the filter is on. @return boolean whether the filtering process should continue and the action should be executed.
preFilter
php
yiisoft/yii
framework/web/auth/CAccessControlFilter.php
https://github.com/yiisoft/yii/blob/master/framework/web/auth/CAccessControlFilter.php
BSD-3-Clause
protected function resolveErrorMessage($rule) { if($rule->message!==null) return $rule->message; elseif($this->message!==null) return $this->message; else return Yii::t('yii','You are not authorized to perform this action.'); }
Resolves the error message to be displayed. This method will check {@link message} and {@link CAccessRule::message} to see what error message should be displayed. @param CAccessRule $rule the access rule @return string the error message @since 1.1.1
resolveErrorMessage
php
yiisoft/yii
framework/web/auth/CAccessControlFilter.php
https://github.com/yiisoft/yii/blob/master/framework/web/auth/CAccessControlFilter.php
BSD-3-Clause
protected function accessDenied($user,$message) { if($user->getIsGuest()) $user->loginRequired(); else throw new CHttpException(403,$message); }
Denies the access of the user. This method is invoked when access check fails. @param IWebUser $user the current user @param string $message the error message to be displayed @throws CHttpException
accessDenied
php
yiisoft/yii
framework/web/auth/CAccessControlFilter.php
https://github.com/yiisoft/yii/blob/master/framework/web/auth/CAccessControlFilter.php
BSD-3-Clause
public function isUserAllowed($user,$controller,$action,$ip,$verb) { if($this->isActionMatched($action) && $this->isUserMatched($user) && $this->isRoleMatched($user) && $this->isIpMatched($ip) && $this->isVerbMatched($verb) && $this->isControllerMatched($controller) && $this->isExpressionMatched($user)) return $this->allow ? 1 : -1; else return 0; }
Checks whether the Web user is allowed to perform the specified action. @param CWebUser $user the user object @param CController $controller the controller currently being executed @param CAction $action the action to be performed @param string $ip the request IP address @param string $verb the request verb (GET, POST, etc.) @return integer 1 if the user is allowed, -1 if the user is denied, 0 if the rule does not apply to the user
isUserAllowed
php
yiisoft/yii
framework/web/auth/CAccessControlFilter.php
https://github.com/yiisoft/yii/blob/master/framework/web/auth/CAccessControlFilter.php
BSD-3-Clause