code
stringlengths
17
247k
docstring
stringlengths
30
30.3k
func_name
stringlengths
1
89
language
stringclasses
1 value
repo
stringlengths
7
63
path
stringlengths
7
153
url
stringlengths
51
209
license
stringclasses
4 values
public static function getIdByName($name) { return str_replace(array('[]','][','[',']',' '),array('','_','_','','_'),$name); }
Generates a valid HTML ID based on name. @param string $name name from which to generate HTML ID @return string the ID generated based on name.
getIdByName
php
yiisoft/yii
framework/web/helpers/CHtml.php
https://github.com/yiisoft/yii/blob/master/framework/web/helpers/CHtml.php
BSD-3-Clause
public static function activeId($model,$attribute) { return self::getIdByName(self::activeName($model,$attribute)); }
Generates input field ID for a model attribute. @param CModel|string $model the data model @param string $attribute the attribute @return string the generated input field ID
activeId
php
yiisoft/yii
framework/web/helpers/CHtml.php
https://github.com/yiisoft/yii/blob/master/framework/web/helpers/CHtml.php
BSD-3-Clause
public static function modelName($model) { if(is_callable(self::$_modelNameConverter)) return call_user_func(self::$_modelNameConverter,$model); $className=is_object($model) ? get_class($model) : (string)$model; return trim(str_replace('\\','_',$className),'_'); }
Generates HTML name for given model. @see CHtml::setModelNameConverter() @param CModel|string $model the data model or the model class name @return string the generated HTML name value @since 1.1.14
modelName
php
yiisoft/yii
framework/web/helpers/CHtml.php
https://github.com/yiisoft/yii/blob/master/framework/web/helpers/CHtml.php
BSD-3-Clause
public static function setModelNameConverter($converter) { if(is_callable($converter)) self::$_modelNameConverter=$converter; elseif($converter===null) self::$_modelNameConverter=null; else throw new CException(Yii::t('yii','The $converter argument must be a valid callback or null.')); }
Set generator used in the {@link CHtml::modelName()} method. You can use the `null` value to restore default generator. @param callable|null $converter the new generator, the model or class name will be passed to this callback and result must be a valid value for HTML name attribute. @throws CException if $converter isn't a valid callback @since 1.1.14
setModelNameConverter
php
yiisoft/yii
framework/web/helpers/CHtml.php
https://github.com/yiisoft/yii/blob/master/framework/web/helpers/CHtml.php
BSD-3-Clause
public static function activeName($model,$attribute) { $a=$attribute; // because the attribute name may be changed by resolveName return self::resolveName($model,$a); }
Generates input field name for a model attribute. Unlike {@link resolveName}, this method does NOT modify the attribute name. @param CModel|string $model the data model @param string $attribute the attribute @return string the generated input field name
activeName
php
yiisoft/yii
framework/web/helpers/CHtml.php
https://github.com/yiisoft/yii/blob/master/framework/web/helpers/CHtml.php
BSD-3-Clause
protected static function activeInputField($type,$model,$attribute,$htmlOptions) { $htmlOptions['type']=$type; if($type==='text'||$type==='password'||$type==='color'||$type==='date'||$type==='datetime'|| $type==='datetime-local'||$type==='email'||$type==='month'||$type==='number'||$type==='range'|| $type==='search'||$type==='tel'||$type==='time'||$type==='url'||$type==='week') { if(!isset($htmlOptions['maxlength'])) { foreach($model->getValidators($attribute) as $validator) { if($validator instanceof CStringValidator && $validator->max!==null) { $htmlOptions['maxlength']=$validator->max; break; } } } elseif($htmlOptions['maxlength']===false) unset($htmlOptions['maxlength']); } if($type==='file') unset($htmlOptions['value']); elseif(!isset($htmlOptions['value'])) $htmlOptions['value']=self::resolveValue($model,$attribute); if($model->hasErrors($attribute)) self::addErrorCss($htmlOptions); return self::tag('input',$htmlOptions); }
Generates an input HTML tag for a model attribute. This method generates an input HTML tag based on the given data model and attribute. If the attribute has input error, the input field's CSS class will be appended with {@link errorCss}. This enables highlighting the incorrect input. @param string $type the input type (e.g. 'text', 'radio') @param CModel $model the data model @param string $attribute the attribute @param array $htmlOptions additional HTML attributes for the HTML tag @return string the generated input tag
activeInputField
php
yiisoft/yii
framework/web/helpers/CHtml.php
https://github.com/yiisoft/yii/blob/master/framework/web/helpers/CHtml.php
BSD-3-Clause
protected static function clientChange($event,&$htmlOptions) { if(!isset($htmlOptions['submit']) && !isset($htmlOptions['confirm']) && !isset($htmlOptions['ajax'])) return; if(isset($htmlOptions['live'])) { $live=$htmlOptions['live']; unset($htmlOptions['live']); } else $live = self::$liveEvents; if(isset($htmlOptions['return']) && $htmlOptions['return']) $return='return true'; else $return='return false'; if(isset($htmlOptions['on'.$event])) { $handler=trim($htmlOptions['on'.$event],';').';'; unset($htmlOptions['on'.$event]); } else $handler=''; if(isset($htmlOptions['id'])) $id=$htmlOptions['id']; else $id=$htmlOptions['id']=isset($htmlOptions['name'])?$htmlOptions['name']:self::ID_PREFIX.self::$count++; $cs=Yii::app()->getClientScript(); $cs->registerCoreScript('jquery'); if(isset($htmlOptions['submit'])) { $cs->registerCoreScript('yii'); $request=Yii::app()->getRequest(); if($request->enableCsrfValidation && isset($htmlOptions['csrf']) && $htmlOptions['csrf']) $htmlOptions['params'][$request->csrfTokenName]=$request->getCsrfToken(); if(isset($htmlOptions['params'])) $params=CJavaScript::encode($htmlOptions['params']); else $params='{}'; if($htmlOptions['submit']!=='') $url=CJavaScript::quote(self::normalizeUrl($htmlOptions['submit'])); else $url=''; $handler.="jQuery.yii.submitForm(this,'$url',$params);{$return};"; } if(isset($htmlOptions['ajax'])) $handler.=self::ajax($htmlOptions['ajax'])."{$return};"; if(isset($htmlOptions['confirm'])) { $confirm='confirm(\''.CJavaScript::quote($htmlOptions['confirm']).'\')'; if($handler!=='') $handler="if($confirm) {".$handler."} else return false;"; else $handler="return $confirm;"; } if($live) $cs->registerScript('Yii.CHtml.#' . $id,"jQuery('body').on('$event','#$id',function(){{$handler}});"); else $cs->registerScript('Yii.CHtml.#' . $id,"jQuery('#$id').on('$event', function(){{$handler}});"); unset($htmlOptions['params'],$htmlOptions['submit'],$htmlOptions['ajax'],$htmlOptions['confirm'],$htmlOptions['return'],$htmlOptions['csrf']); }
Generates the JavaScript with the specified client changes. @param string $event event name (without 'on') @param array $htmlOptions HTML attributes which may contain the following special attributes specifying the client change behaviors: <ul> <li>submit: string, specifies the URL to submit to. If the current element has a parent form, that form will be submitted, and if 'submit' is non-empty its value will replace the form's URL. If there is no parent form the data listed in 'params' will be submitted instead (via POST method), to the URL in 'submit' or the currently requested URL if 'submit' is empty. Please note that if the 'csrf' setting is true, the CSRF token will be included in the params too.</li> <li>params: array, name-value pairs that should be submitted together with the form. This is only used when 'submit' option is specified.</li> <li>csrf: boolean, whether a CSRF token should be automatically included in 'params' when {@link CHttpRequest::enableCsrfValidation} is true. Defaults to false. You may want to set this to be true if there is no enclosing form around this element. This option is meaningful only when 'submit' option is set.</li> <li>return: boolean, the return value of the javascript. Defaults to false, meaning that the execution of javascript would not cause the default behavior of the event.</li> <li>confirm: string, specifies the message that should show in a pop-up confirmation dialog.</li> <li>ajax: array, specifies the AJAX options (see {@link ajax}).</li> <li>live: boolean, whether the event handler should be delegated or directly bound. If not set, {@link liveEvents} will be used. This option has been available since version 1.1.11.</li> </ul> This parameter has been available since version 1.1.1.
clientChange
php
yiisoft/yii
framework/web/helpers/CHtml.php
https://github.com/yiisoft/yii/blob/master/framework/web/helpers/CHtml.php
BSD-3-Clause
public static function resolveNameID($model,&$attribute,&$htmlOptions) { if(!isset($htmlOptions['name'])) $htmlOptions['name']=self::resolveName($model,$attribute); if(!isset($htmlOptions['id'])) $htmlOptions['id']=self::getIdByName($htmlOptions['name']); elseif($htmlOptions['id']===false) unset($htmlOptions['id']); }
Generates input name and ID for a model attribute. This method will update the HTML options by setting appropriate 'name' and 'id' attributes. This method may also modify the attribute name if the name contains square brackets (mainly used in tabular input). @param CModel|string $model the data model @param string $attribute the attribute @param array $htmlOptions the HTML options
resolveNameID
php
yiisoft/yii
framework/web/helpers/CHtml.php
https://github.com/yiisoft/yii/blob/master/framework/web/helpers/CHtml.php
BSD-3-Clause
public static function resolveValue($model,$attribute) { if(($pos=strpos($attribute,'['))!==false) { if($pos===0) // [a]name[b][c], should ignore [a] { if(preg_match('/\](\w+(\[.+)?)/',$attribute,$matches)) $attribute=$matches[1]; // we get: name[b][c] if(($pos=strpos($attribute,'['))===false) return $model->$attribute; } $name=substr($attribute,0,$pos); $value=$model->$name; foreach(explode('][',rtrim(substr($attribute,$pos+1),']')) as $id) { if((is_array($value) || $value instanceof ArrayAccess) && isset($value[$id])) $value=$value[$id]; else return null; } return $value; } else return $model->$attribute; }
Evaluates the attribute value of the model. This method can recognize the attribute name written in array format. For example, if the attribute name is 'name[a][b]', the value "$model->name['a']['b']" will be returned. @param CModel $model the data model @param string $attribute the attribute name @return mixed the attribute value @since 1.1.3
resolveValue
php
yiisoft/yii
framework/web/helpers/CHtml.php
https://github.com/yiisoft/yii/blob/master/framework/web/helpers/CHtml.php
BSD-3-Clause
public static function quote($js,$forUrl=false) { $js = (string)$js; Yii::import('system.vendors.zend-escaper.Escaper'); $escaper=new Escaper(Yii::app()->charset); if($forUrl) return $escaper->escapeUrl($js); else return $escaper->escapeJs($js); }
Quotes a javascript string. After processing, the string can be safely enclosed within a pair of quotation marks and serve as a javascript string. @param string $js string to be quoted @param boolean $forUrl whether this string is used as a URL @return string the quoted string
quote
php
yiisoft/yii
framework/web/helpers/CJavaScript.php
https://github.com/yiisoft/yii/blob/master/framework/web/helpers/CJavaScript.php
BSD-3-Clause
public static function jsonEncode($data) { return CJSON::encode($data); }
Returns the JSON representation of the PHP data. @param mixed $data the data to be encoded @return string the JSON representation of the PHP data.
jsonEncode
php
yiisoft/yii
framework/web/helpers/CJavaScript.php
https://github.com/yiisoft/yii/blob/master/framework/web/helpers/CJavaScript.php
BSD-3-Clause
public static function init($apiKey=null) { if($apiKey===null) return CHtml::scriptFile(self::$bootstrapUrl); else return CHtml::scriptFile(self::$bootstrapUrl.'?key='.$apiKey); }
Renders the jsapi script file. @param string $apiKey the API key. Null if you do not have a key. @return string the script tag that loads Google jsapi.
init
php
yiisoft/yii
framework/web/helpers/CGoogleApi.php
https://github.com/yiisoft/yii/blob/master/framework/web/helpers/CGoogleApi.php
BSD-3-Clause
protected static function nameValue($name, $value) { return self::encode(strval($name)) . ':' . self::encode($value); }
array-walking function for use in generating JSON-formatted name-value pairs @param string $name name of key to use @param mixed $value reference to an array element to be encoded @return string JSON-formatted name-value pair, like '"name":value' @access private
nameValue
php
yiisoft/yii
framework/web/helpers/CJSON.php
https://github.com/yiisoft/yii/blob/master/framework/web/helpers/CJSON.php
BSD-3-Clause
protected static function reduceString($str) { $str = preg_replace(array( // eliminate single line comments in '// ...' form '#^\s*//(.+)$#m', // eliminate multi-line comments in '/* ... */' form, at start of string '#^\s*/\*(.+)\*/#Us', // eliminate multi-line comments in '/* ... */' form, at end of string '#/\*(.+)\*/\s*$#Us' ), '', $str); // eliminate extraneous space return trim($str); }
reduce a string by removing leading and trailing comments and whitespace @param string $str string value to strip of comments and whitespace @return string string value stripped of comments and whitespace @access private
reduceString
php
yiisoft/yii
framework/web/helpers/CJSON.php
https://github.com/yiisoft/yii/blob/master/framework/web/helpers/CJSON.php
BSD-3-Clause
protected static function utf8ToUnicode( &$str ) { $unicode = array(); $values = array(); $lookingFor = 1; for ($i = 0; $i < strlen( $str ); $i++ ) { $thisValue = ord( $str[ $i ] ); if ( $thisValue < 128 ) $unicode[] = $thisValue; else { if ( count( $values ) == 0 ) $lookingFor = ( $thisValue < 224 ) ? 2 : 3; $values[] = $thisValue; if ( count( $values ) == $lookingFor ) { $number = ( $lookingFor == 3 ) ? ( ( $values[0] % 16 ) * 4096 ) + ( ( $values[1] % 64 ) * 64 ) + ( $values[2] % 64 ): ( ( $values[0] % 32 ) * 64 ) + ( $values[1] % 64 ); $unicode[] = $number; $values = array(); $lookingFor = 1; } } } return $unicode; }
This function returns any UTF-8 encoded text as a list of Unicode values: @param string $str string to convert @return string @author Scott Michael Reynen <[email protected]> @link http://www.randomchaos.com/document.php?source=php_and_unicode @see unicodeToUTF8()
utf8ToUnicode
php
yiisoft/yii
framework/web/helpers/CJSON.php
https://github.com/yiisoft/yii/blob/master/framework/web/helpers/CJSON.php
BSD-3-Clause
protected static function unicodeToUTF8( &$str ) { $utf8 = ''; foreach( $str as $unicode ) { if ( $unicode < 128 ) { $utf8.= chr( $unicode ); } elseif ( $unicode < 2048 ) { $utf8.= chr( 192 + ( ( $unicode - ( $unicode % 64 ) ) / 64 ) ); $utf8.= chr( 128 + ( $unicode % 64 ) ); } else { $utf8.= chr( 224 + ( ( $unicode - ( $unicode % 4096 ) ) / 4096 ) ); $utf8.= chr( 128 + ( ( ( $unicode % 4096 ) - ( $unicode % 64 ) ) / 64 ) ); $utf8.= chr( 128 + ( $unicode % 64 ) ); } } return $utf8; }
This function converts a Unicode array back to its UTF-8 representation @param string $str string to convert @return string @author Scott Michael Reynen <[email protected]> @link http://www.randomchaos.com/document.php?source=php_and_unicode @see utf8ToUnicode()
unicodeToUTF8
php
yiisoft/yii
framework/web/helpers/CJSON.php
https://github.com/yiisoft/yii/blob/master/framework/web/helpers/CJSON.php
BSD-3-Clause
protected static function utf8ToUTF16BE(&$str, $bom = false) { $out = $bom ? "\xFE\xFF" : ''; if(function_exists('mb_convert_encoding')) return $out.mb_convert_encoding($str,'UTF-16BE','UTF-8'); $uni = self::utf8ToUnicode($str); foreach($uni as $cp) $out .= pack('n',$cp); return $out; }
UTF-8 to UTF-16BE conversion. Maybe really UCS-2 without mb_string due to utf8ToUnicode limits @param string $str string to convert @param boolean $bom whether to output BOM header @return string
utf8ToUTF16BE
php
yiisoft/yii
framework/web/helpers/CJSON.php
https://github.com/yiisoft/yii/blob/master/framework/web/helpers/CJSON.php
BSD-3-Clause
protected static function utf16beToUTF8(&$str) { $uni = unpack('n*',$str); return self::unicodeToUTF8($uni); }
UTF-8 to UTF-16BE conversion. Maybe really UCS-2 without mb_string due to utf8ToUnicode limits @param string $str string to convert @return string
utf16beToUTF8
php
yiisoft/yii
framework/web/helpers/CJSON.php
https://github.com/yiisoft/yii/blob/master/framework/web/helpers/CJSON.php
BSD-3-Clause
public function getOn() { return $this->_on; }
Returns a value indicating under which scenarios this string is visible. If the value is empty, it means the string is visible under all scenarios. Otherwise, only when the model is in the scenario whose name can be found in this value, will the string 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/CFormStringElement.php
https://github.com/yiisoft/yii/blob/master/framework/web/form/CFormStringElement.php
BSD-3-Clause
public function render() { return $this->content; }
Renders this element. The default implementation simply returns {@link content}. @return string the string content
render
php
yiisoft/yii
framework/web/form/CFormStringElement.php
https://github.com/yiisoft/yii/blob/master/framework/web/form/CFormStringElement.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/CFormStringElement.php
https://github.com/yiisoft/yii/blob/master/framework/web/form/CFormStringElement.php
BSD-3-Clause
public function getRequired() { if($this->_required!==null) return $this->_required; else return $this->getParent()->getModel()->isAttributeRequired($this->name); }
Gets the value indicating whether this input is required. If this property is not set explicitly, it will be determined by calling {@link CModel::isAttributeRequired} for the associated model and attribute of this input. @return boolean whether this input is required.
getRequired
php
yiisoft/yii
framework/web/form/CFormInputElement.php
https://github.com/yiisoft/yii/blob/master/framework/web/form/CFormInputElement.php
BSD-3-Clause
public function render() { if($this->type==='hidden') return $this->renderInput(); $output=array( '{label}'=>$this->renderLabel(), '{input}'=>$this->renderInput(), '{hint}'=>$this->renderHint(), '{error}'=>!$this->getParent()->showErrors ? '' : $this->renderError(), ); return strtr($this->layout,$output); }
Renders everything for this input. The default implementation simply returns the result of {@link renderLabel}, {@link renderInput}, {@link renderHint}. When {@link CForm::showErrorSummary} is false, {@link renderError} is also called to show error messages after individual input fields. @return string the complete rendering result for this input, including label, input field, hint, and error.
render
php
yiisoft/yii
framework/web/form/CFormInputElement.php
https://github.com/yiisoft/yii/blob/master/framework/web/form/CFormInputElement.php
BSD-3-Clause
public function renderLabel() { $options = array( 'label'=>$this->getLabel(), 'required'=>$this->getRequired() ); if(!empty($this->attributes['id'])) $options['for']=$this->attributes['id']; return CHtml::activeLabel($this->getParent()->getModel(), $this->name, $options); }
Renders the label for this input. The default implementation returns the result of {@link CHtml activeLabelEx}. @return string the rendering result
renderLabel
php
yiisoft/yii
framework/web/form/CFormInputElement.php
https://github.com/yiisoft/yii/blob/master/framework/web/form/CFormInputElement.php
BSD-3-Clause
public function renderInput() { if(isset(self::$coreTypes[$this->type])) { $method=self::$coreTypes[$this->type]; if(strpos($method,'List')!==false) return CHtml::$method($this->getParent()->getModel(), $this->name, $this->items, $this->attributes); else return CHtml::$method($this->getParent()->getModel(), $this->name, $this->attributes); } else { $attributes=$this->attributes; $attributes['model']=$this->getParent()->getModel(); $attributes['attribute']=$this->name; ob_start(); $this->getParent()->getOwner()->widget($this->type, $attributes); return ob_get_clean(); } }
Renders the input field. The default implementation returns the result of the appropriate CHtml method or the widget. @return string the rendering result
renderInput
php
yiisoft/yii
framework/web/form/CFormInputElement.php
https://github.com/yiisoft/yii/blob/master/framework/web/form/CFormInputElement.php
BSD-3-Clause
public function renderHint() { return $this->hint===null ? '' : '<div class="hint">'.$this->hint.'</div>'; }
Renders the hint text for this input. The default implementation returns the {@link hint} property enclosed in a paragraph HTML tag. @return string the rendering result.
renderHint
php
yiisoft/yii
framework/web/form/CFormInputElement.php
https://github.com/yiisoft/yii/blob/master/framework/web/form/CFormInputElement.php
BSD-3-Clause
protected function evaluateVisible() { return $this->getParent()->getModel()->isAttributeSafe($this->name); }
Evaluates the visibility of this element. This method will check if the attribute associated with this input is safe for the current model scenario. @return boolean whether this element is visible.
evaluateVisible
php
yiisoft/yii
framework/web/form/CFormInputElement.php
https://github.com/yiisoft/yii/blob/master/framework/web/form/CFormInputElement.php
BSD-3-Clause
protected function init() { }
Initializes this form. This method is invoked at the end of the constructor. You may override this method to provide customized initialization (such as configuring the form object).
init
php
yiisoft/yii
framework/web/form/CForm.php
https://github.com/yiisoft/yii/blob/master/framework/web/form/CForm.php
BSD-3-Clause
public function submitted($buttonName='submit',$loadData=true) { $ret=$this->clicked($this->getUniqueId()) && $this->clicked($buttonName); if($ret && $loadData) $this->loadData(); return $ret; }
Returns a value indicating whether this form is submitted. @param string $buttonName the name of the submit button @param boolean $loadData whether to call {@link loadData} if the form is submitted so that the submitted data can be populated to the associated models. @return boolean whether this form is submitted. @see loadData
submitted
php
yiisoft/yii
framework/web/form/CForm.php
https://github.com/yiisoft/yii/blob/master/framework/web/form/CForm.php
BSD-3-Clause
public function clicked($name) { if(strcasecmp($this->getRoot()->method,'get')) return isset($_POST[$name]); else return isset($_GET[$name]); }
Returns a value indicating whether the specified button is clicked. @param string $name the button name @return boolean whether the button is clicked.
clicked
php
yiisoft/yii
framework/web/form/CForm.php
https://github.com/yiisoft/yii/blob/master/framework/web/form/CForm.php
BSD-3-Clause
public function validate() { $ret=true; foreach($this->getModels() as $model) $ret=$model->validate() && $ret; return $ret; }
Validates the models associated with this form. All models, including those associated with sub-forms, will perform the validation. You may use {@link CModel::getErrors()} to retrieve the validation error messages. @return boolean whether all models are valid
validate
php
yiisoft/yii
framework/web/form/CForm.php
https://github.com/yiisoft/yii/blob/master/framework/web/form/CForm.php
BSD-3-Clause
public function getOwner() { $owner=$this->getParent(); while($owner instanceof self) $owner=$owner->getParent(); return $owner; }
@return CBaseController the owner of this form. This refers to either a controller or a widget by which the form is created and rendered.
getOwner
php
yiisoft/yii
framework/web/form/CForm.php
https://github.com/yiisoft/yii/blob/master/framework/web/form/CForm.php
BSD-3-Clause
public function getModel($checkParent=true) { if(!$checkParent) return $this->_model; $form=$this; while($form->_model===null && $form->getParent() instanceof self) $form=$form->getParent(); return $form->_model; }
Returns the model that this form is associated with. @param boolean $checkParent whether to return parent's model if this form doesn't have model by itself. @return CModel the model associated with this form. If this form does not have a model, it will look for a model in its ancestors.
getModel
php
yiisoft/yii
framework/web/form/CForm.php
https://github.com/yiisoft/yii/blob/master/framework/web/form/CForm.php
BSD-3-Clause
public function getElements() { if($this->_elements===null) $this->_elements=new CFormElementCollection($this,false); return $this->_elements; }
Returns the input elements of this form. This includes text strings, input elements and sub-forms. Note that the returned result is a {@link CFormElementCollection} object, which means you can use it like an array. For more details, see {@link CMap}. @return CFormElementCollection the form elements.
getElements
php
yiisoft/yii
framework/web/form/CForm.php
https://github.com/yiisoft/yii/blob/master/framework/web/form/CForm.php
BSD-3-Clause
public function setElements($elements) { $collection=$this->getElements(); foreach($elements as $name=>$config) $collection->add($name,$config); }
Configures the input elements of this form. The configuration must be an array of input configuration array indexed by input name. Each input configuration array consists of name-value pairs that are used to initialize a {@link CFormStringElement} object (when 'type' is 'string'), a {@link CFormElement} object (when 'type' is a string ending with 'Form'), or a {@link CFormInputElement} object in all other cases. @param array $elements the elements configurations
setElements
php
yiisoft/yii
framework/web/form/CForm.php
https://github.com/yiisoft/yii/blob/master/framework/web/form/CForm.php
BSD-3-Clause
public function getButtons() { if($this->_buttons===null) $this->_buttons=new CFormElementCollection($this,true); return $this->_buttons; }
Returns the button elements of this form. Note that the returned result is a {@link CFormElementCollection} object, which means you can use it like an array. For more details, see {@link CMap}. @return CFormElementCollection the form elements.
getButtons
php
yiisoft/yii
framework/web/form/CForm.php
https://github.com/yiisoft/yii/blob/master/framework/web/form/CForm.php
BSD-3-Clause
public function setButtons($buttons) { $collection=$this->getButtons(); foreach($buttons as $name=>$config) $collection->add($name,$config); }
Configures the buttons of this form. The configuration must be an array of button configuration array indexed by button name. Each button configuration array consists of name-value pairs that are used to initialize a {@link CFormButtonElement} object. @param array $buttons the button configurations
setButtons
php
yiisoft/yii
framework/web/form/CForm.php
https://github.com/yiisoft/yii/blob/master/framework/web/form/CForm.php
BSD-3-Clause
public function render() { return $this->renderBegin() . $this->renderBody() . $this->renderEnd(); }
Renders the form. The default implementation simply calls {@link renderBegin}, {@link renderBody} and {@link renderEnd}. @return string the rendering result
render
php
yiisoft/yii
framework/web/form/CForm.php
https://github.com/yiisoft/yii/blob/master/framework/web/form/CForm.php
BSD-3-Clause
public function renderBegin() { if($this->getParent() instanceof self) return ''; else { $options=$this->activeForm; if(isset($options['class'])) { $class=$options['class']; unset($options['class']); } else $class='CActiveForm'; $options['action']=$this->action; $options['method']=$this->method; if(isset($options['htmlOptions'])) { foreach($this->attributes as $name=>$value) $options['htmlOptions'][$name]=$value; } else $options['htmlOptions']=$this->attributes; ob_start(); $this->_activeForm=$this->getOwner()->beginWidget($class, $options); return ob_get_clean() . "<div style=\"display:none\">".CHtml::hiddenField($this->getUniqueID(),1)."</div>\n"; } }
Renders the open tag of the form. The default implementation will render the open form tag. @return string the rendering result
renderBegin
php
yiisoft/yii
framework/web/form/CForm.php
https://github.com/yiisoft/yii/blob/master/framework/web/form/CForm.php
BSD-3-Clause
public function renderEnd() { if($this->getParent() instanceof self) return ''; else { ob_start(); $this->getOwner()->endWidget(); return ob_get_clean(); } }
Renders the close tag of the form. @return string the rendering result
renderEnd
php
yiisoft/yii
framework/web/form/CForm.php
https://github.com/yiisoft/yii/blob/master/framework/web/form/CForm.php
BSD-3-Clause
public function renderElement($element) { if(is_string($element)) { if(($e=$this[$element])===null && ($e=$this->getButtons()->itemAt($element))===null) return $element; else $element=$e; } if($element->getVisible()) { if($element instanceof CFormInputElement) { if($element->type==='hidden') return "<div style=\"display:none\">\n".$element->render()."</div>\n"; else return "<div class=\"row field_{$element->name}\">\n".$element->render()."</div>\n"; } elseif($element instanceof CFormButtonElement) return $element->render()."\n"; else return $element->render(); } return ''; }
Renders a single element which could be an input element, a sub-form, a string, or a button. @param mixed $element the form element to be rendered. This can be either a {@link CFormElement} instance or a string representing the name of the form element. @return string the rendering result
renderElement
php
yiisoft/yii
framework/web/form/CForm.php
https://github.com/yiisoft/yii/blob/master/framework/web/form/CForm.php
BSD-3-Clause
public function addedElement($name,$element,$forButtons) { }
This method is called after an element is added to the element collection. @param string $name the name of the element @param CFormElement $element the element that is added @param boolean $forButtons whether the element is added to the {@link buttons} collection. If false, it means the element is added to the {@link elements} collection.
addedElement
php
yiisoft/yii
framework/web/form/CForm.php
https://github.com/yiisoft/yii/blob/master/framework/web/form/CForm.php
BSD-3-Clause
public function removedElement($name,$element,$forButtons) { }
This method is called after an element is removed from the element collection. @param string $name the name of the element @param CFormElement $element the element that is removed @param boolean $forButtons whether the element is removed from the {@link buttons} collection If false, it means the element is removed from the {@link elements} collection.
removedElement
php
yiisoft/yii
framework/web/form/CForm.php
https://github.com/yiisoft/yii/blob/master/framework/web/form/CForm.php
BSD-3-Clause
protected function evaluateVisible() { foreach($this->getElements() as $element) if($element->getVisible()) return true; return false; }
Evaluates the visibility of this form. This method will check the visibility of the {@link elements}. If any one of them is visible, the form is considered as visible. Otherwise, it is invisible. @return boolean whether this form is visible.
evaluateVisible
php
yiisoft/yii
framework/web/form/CForm.php
https://github.com/yiisoft/yii/blob/master/framework/web/form/CForm.php
BSD-3-Clause
protected function getUniqueId() { if(isset($this->attributes['id'])) return 'yform_'.$this->attributes['id']; else return 'yform_'.sprintf('%x',crc32(serialize(array_keys($this->getElements()->toArray())))); }
Returns a unique ID that identifies this form in the current page. @return string the unique ID identifying this form
getUniqueId
php
yiisoft/yii
framework/web/form/CForm.php
https://github.com/yiisoft/yii/blob/master/framework/web/form/CForm.php
BSD-3-Clause
public function offsetExists($offset) { return $this->getElements()->contains($offset); }
Returns whether there is an element at the specified offset. This method is required by the interface ArrayAccess. @param mixed $offset the offset to check on @return boolean
offsetExists
php
yiisoft/yii
framework/web/form/CForm.php
https://github.com/yiisoft/yii/blob/master/framework/web/form/CForm.php
BSD-3-Clause
public function offsetGet($offset) { return $this->getElements()->itemAt($offset); }
Returns the element at the specified offset. This method is required by the interface ArrayAccess. @param mixed $offset the offset to retrieve element. @return mixed the element at the offset, null if no element is found at the offset
offsetGet
php
yiisoft/yii
framework/web/form/CForm.php
https://github.com/yiisoft/yii/blob/master/framework/web/form/CForm.php
BSD-3-Clause
public function offsetSet($offset,$item) { $this->getElements()->add($offset,$item); }
Sets the element at the specified offset. This method is required by the interface ArrayAccess. @param mixed $offset the offset to set element @param mixed $item the element value
offsetSet
php
yiisoft/yii
framework/web/form/CForm.php
https://github.com/yiisoft/yii/blob/master/framework/web/form/CForm.php
BSD-3-Clause
public function offsetUnset($offset) { $this->getElements()->remove($offset); }
Unsets the element at the specified offset. This method is required by the interface ArrayAccess. @param mixed $offset the offset to unset element
offsetUnset
php
yiisoft/yii
framework/web/form/CForm.php
https://github.com/yiisoft/yii/blob/master/framework/web/form/CForm.php
BSD-3-Clause
public function remove($key) { if(($item=parent::remove($key))!==null) $this->_form->removedElement($key,$item,$this->_forButtons); }
Removes the specified element by key. @param string $key the name of the element to be removed from the collection @throws CException
remove
php
yiisoft/yii
framework/web/form/CFormElementCollection.php
https://github.com/yiisoft/yii/blob/master/framework/web/form/CFormElementCollection.php
BSD-3-Clause
public function __toString() { return $this->render(); }
Converts the object to a string. This is a PHP magic method. The default implementation simply calls {@link render} and return the rendering result. @return string the string representation of this object.
__toString
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 configure($config) { if(is_string($config)) $config=require(Yii::getPathOfAlias($config).'.php'); if(is_array($config)) { foreach($config as $name=>$value) $this->$name=$value; } }
Configures this object with property initial values. @param mixed $config the configuration for this object. This can be an array representing the property names and their initial values. It can also be a string representing the file name of the PHP script that returns a configuration array.
configure
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 getVisible() { if($this->_visible===null) $this->_visible=$this->evaluateVisible(); return $this->_visible; }
Returns a value indicating whether this element is visible and should be rendered. This method will call {@link evaluateVisible} to determine the visibility of this element. @return boolean whether this element is visible and should be rendered.
getVisible
php
yiisoft/yii
framework/web/form/CFormElement.php
https://github.com/yiisoft/yii/blob/master/framework/web/form/CFormElement.php
BSD-3-Clause
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 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
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 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 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 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 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 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 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