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 generatePath($file,$hashByName=false)
{
if (is_file($file))
$pathForHashing=$hashByName ? dirname($file) : dirname($file).filemtime($file);
else
$pathForHashing=$hashByName ? $file : $file.filemtime($file);
return $this->hash($pathForHashing);
} | Generates path segments relative to basePath.
@param string $file for which public path will be created.
@param bool $hashByName whether the published directory should be named as the hashed basename.
@return string path segments without basePath.
@since 1.1.13 | generatePath | php | yiisoft/yii | framework/web/CAssetManager.php | https://github.com/yiisoft/yii/blob/master/framework/web/CAssetManager.php | BSD-3-Clause |
public function rewind()
{
$this->_key=reset($this->_keys);
} | Rewinds internal array pointer.
This method is required by the interface Iterator. | rewind | php | yiisoft/yii | framework/web/CHttpSessionIterator.php | https://github.com/yiisoft/yii/blob/master/framework/web/CHttpSessionIterator.php | BSD-3-Clause |
public function key()
{
return $this->_key;
} | Returns the key of the current array element.
This method is required by the interface Iterator.
@return mixed the key of the current array element | key | php | yiisoft/yii | framework/web/CHttpSessionIterator.php | https://github.com/yiisoft/yii/blob/master/framework/web/CHttpSessionIterator.php | BSD-3-Clause |
public function current()
{
return isset($_SESSION[$this->_key])?$_SESSION[$this->_key]:null;
} | Returns the current array element.
This method is required by the interface Iterator.
@return mixed the current array element | current | php | yiisoft/yii | framework/web/CHttpSessionIterator.php | https://github.com/yiisoft/yii/blob/master/framework/web/CHttpSessionIterator.php | BSD-3-Clause |
public function next()
{
do
{
$this->_key=next($this->_keys);
}
while(!isset($_SESSION[$this->_key]) && $this->_key!==false);
} | Moves the internal pointer to the next array element.
This method is required by the interface Iterator. | next | php | yiisoft/yii | framework/web/CHttpSessionIterator.php | https://github.com/yiisoft/yii/blob/master/framework/web/CHttpSessionIterator.php | BSD-3-Clause |
public function valid()
{
return $this->_key!==false;
} | Returns whether there is an element at current position.
This method is required by the interface Iterator.
@return boolean | valid | php | yiisoft/yii | framework/web/CHttpSessionIterator.php | https://github.com/yiisoft/yii/blob/master/framework/web/CHttpSessionIterator.php | BSD-3-Clause |
public function init()
{
parent::init();
if($this->autoStart)
$this->open();
register_shutdown_function(array($this,'close'));
} | Initializes the application component.
This method is required by IApplicationComponent and is invoked by application. | init | php | yiisoft/yii | framework/web/CHttpSession.php | https://github.com/yiisoft/yii/blob/master/framework/web/CHttpSession.php | BSD-3-Clause |
public function getUseCustomStorage()
{
return false;
} | Returns a value indicating whether to use custom session storage.
This method should be overridden to return true if custom session storage handler should be used.
If returning true, make sure the methods {@link openSession}, {@link closeSession}, {@link readSession},
{@link writeSession}, {@link destroySession}, and {@link gcSession} are overridden in child
class, because they will be used as the callback handlers.
The default implementation always return false.
@return boolean whether to use custom storage. | getUseCustomStorage | php | yiisoft/yii | framework/web/CHttpSession.php | https://github.com/yiisoft/yii/blob/master/framework/web/CHttpSession.php | BSD-3-Clause |
public function open()
{
if($this->getUseCustomStorage())
@session_set_save_handler(array($this,'openSession'),array($this,'closeSession'),array($this,'readSession'),array($this,'writeSession'),array($this,'destroySession'),array($this,'gcSession'));
@session_start();
if(YII_DEBUG && session_id()=='')
{
$message=Yii::t('yii','Failed to start session.');
if(function_exists('error_get_last'))
{
$error=error_get_last();
if(isset($error['message']))
$message=$error['message'];
}
Yii::log($message, CLogger::LEVEL_WARNING, 'system.web.CHttpSession');
}
} | Starts the session if it has not started yet. | open | php | yiisoft/yii | framework/web/CHttpSession.php | https://github.com/yiisoft/yii/blob/master/framework/web/CHttpSession.php | BSD-3-Clause |
public function close()
{
if(session_id()!=='')
@session_write_close();
} | Ends the current session and store session data. | close | php | yiisoft/yii | framework/web/CHttpSession.php | https://github.com/yiisoft/yii/blob/master/framework/web/CHttpSession.php | BSD-3-Clause |
public function destroy()
{
if(session_id()!=='')
{
@session_unset();
@session_destroy();
}
} | Frees all session variables and destroys all data registered to a session. | destroy | php | yiisoft/yii | framework/web/CHttpSession.php | https://github.com/yiisoft/yii/blob/master/framework/web/CHttpSession.php | BSD-3-Clause |
public function regenerateID($deleteOldSession=false)
{
if($this->getIsStarted())
session_regenerate_id($deleteOldSession);
} | Updates the current session id with a newly generated one .
Please refer to {@link https://php.net/session_regenerate_id} for more details.
@param boolean $deleteOldSession Whether to delete the old associated session file or not.
@since 1.1.8 | regenerateID | php | yiisoft/yii | framework/web/CHttpSession.php | https://github.com/yiisoft/yii/blob/master/framework/web/CHttpSession.php | BSD-3-Clause |
public function openSession($savePath,$sessionName)
{
return true;
} | Session open handler.
This method should be overridden if {@link useCustomStorage} is set true.
Do not call this method directly.
@param string $savePath session save path
@param string $sessionName session name
@return boolean whether session is opened successfully | openSession | php | yiisoft/yii | framework/web/CHttpSession.php | https://github.com/yiisoft/yii/blob/master/framework/web/CHttpSession.php | BSD-3-Clause |
public function closeSession()
{
return true;
} | Session close handler.
This method should be overridden if {@link useCustomStorage} is set true.
Do not call this method directly.
@return boolean whether session is closed successfully | closeSession | php | yiisoft/yii | framework/web/CHttpSession.php | https://github.com/yiisoft/yii/blob/master/framework/web/CHttpSession.php | BSD-3-Clause |
public function readSession($id)
{
return '';
} | Session read handler.
This method should be overridden if {@link useCustomStorage} is set true.
Do not call this method directly.
@param string $id session ID
@return string the session data | readSession | php | yiisoft/yii | framework/web/CHttpSession.php | https://github.com/yiisoft/yii/blob/master/framework/web/CHttpSession.php | BSD-3-Clause |
public function writeSession($id,$data)
{
return true;
} | Session write handler.
This method should be overridden if {@link useCustomStorage} is set true.
Do not call this method directly.
@param string $id session ID
@param string $data session data
@return boolean whether session write is successful | writeSession | php | yiisoft/yii | framework/web/CHttpSession.php | https://github.com/yiisoft/yii/blob/master/framework/web/CHttpSession.php | BSD-3-Clause |
public function destroySession($id)
{
return true;
} | Session destroy handler.
This method should be overridden if {@link useCustomStorage} is set true.
Do not call this method directly.
@param string $id session ID
@return boolean whether session is destroyed successfully | destroySession | php | yiisoft/yii | framework/web/CHttpSession.php | https://github.com/yiisoft/yii/blob/master/framework/web/CHttpSession.php | BSD-3-Clause |
public function gcSession($maxLifetime)
{
return true;
} | Session GC (garbage collection) handler.
This method should be overridden if {@link useCustomStorage} is set true.
Do not call this method directly.
@param integer $maxLifetime the number of seconds after which data will be seen as 'garbage' and cleaned up.
@return boolean whether session is GCed successfully | gcSession | php | yiisoft/yii | framework/web/CHttpSession.php | https://github.com/yiisoft/yii/blob/master/framework/web/CHttpSession.php | BSD-3-Clause |
public function getIterator()
{
return new CHttpSessionIterator;
} | Returns an iterator for traversing the session variables.
This method is required by the interface IteratorAggregate.
@return CHttpSessionIterator an iterator for traversing the session variables. | getIterator | php | yiisoft/yii | framework/web/CHttpSession.php | https://github.com/yiisoft/yii/blob/master/framework/web/CHttpSession.php | BSD-3-Clause |
public function getCount()
{
return count($_SESSION);
} | Returns the number of items in the session.
@return integer the number of session variables | getCount | php | yiisoft/yii | framework/web/CHttpSession.php | https://github.com/yiisoft/yii/blob/master/framework/web/CHttpSession.php | BSD-3-Clause |
public function count()
{
return $this->getCount();
} | Returns the number of items in the session.
This method is required by Countable interface.
@return integer number of items in the session. | count | php | yiisoft/yii | framework/web/CHttpSession.php | https://github.com/yiisoft/yii/blob/master/framework/web/CHttpSession.php | BSD-3-Clause |
public function get($key,$defaultValue=null)
{
return isset($_SESSION[$key]) ? $_SESSION[$key] : $defaultValue;
} | Returns the session variable value with the session variable name.
This method is very similar to {@link itemAt} and {@link offsetGet},
except that it will return $defaultValue if the session variable does not exist.
@param mixed $key the session variable name
@param mixed $defaultValue the default value to be returned when the session variable does not exist.
@return mixed the session variable value, or $defaultValue if the session variable does not exist.
@since 1.1.2 | get | php | yiisoft/yii | framework/web/CHttpSession.php | https://github.com/yiisoft/yii/blob/master/framework/web/CHttpSession.php | BSD-3-Clause |
public function itemAt($key)
{
return isset($_SESSION[$key]) ? $_SESSION[$key] : null;
} | Returns the session variable value with the session variable name.
This method is exactly the same as {@link offsetGet}.
@param mixed $key the session variable name
@return mixed the session variable value, null if no such variable exists | itemAt | php | yiisoft/yii | framework/web/CHttpSession.php | https://github.com/yiisoft/yii/blob/master/framework/web/CHttpSession.php | BSD-3-Clause |
public function add($key,$value)
{
$_SESSION[$key]=$value;
} | Adds a session variable.
Note, if the specified name already exists, the old value will be removed first.
@param mixed $key session variable name
@param mixed $value session variable value | add | php | yiisoft/yii | framework/web/CHttpSession.php | https://github.com/yiisoft/yii/blob/master/framework/web/CHttpSession.php | BSD-3-Clause |
public function offsetExists($offset)
{
return isset($_SESSION[$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/CHttpSession.php | https://github.com/yiisoft/yii/blob/master/framework/web/CHttpSession.php | BSD-3-Clause |
public function offsetGet($offset)
{
return isset($_SESSION[$offset]) ? $_SESSION[$offset] : null;
} | 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/CHttpSession.php | https://github.com/yiisoft/yii/blob/master/framework/web/CHttpSession.php | BSD-3-Clause |
public function offsetSet($offset,$item)
{
$_SESSION[$offset]=$item;
} | 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/CHttpSession.php | https://github.com/yiisoft/yii/blob/master/framework/web/CHttpSession.php | BSD-3-Clause |
public function offsetUnset($offset)
{
unset($_SESSION[$offset]);
} | This method is required by the interface ArrayAccess.
@param mixed $offset the offset to unset element | offsetUnset | php | yiisoft/yii | framework/web/CHttpSession.php | https://github.com/yiisoft/yii/blob/master/framework/web/CHttpSession.php | BSD-3-Clause |
public function __construct($scenario='')
{
$this->setScenario($scenario);
$this->init();
$this->attachBehaviors($this->behaviors());
$this->afterConstruct();
} | Constructor.
@param string $scenario name of the scenario that this model is used in.
See {@link CModel::scenario} on how scenario is used by models.
@see getScenario | __construct | php | yiisoft/yii | framework/web/CFormModel.php | https://github.com/yiisoft/yii/blob/master/framework/web/CFormModel.php | BSD-3-Clause |
public function init()
{
} | Initializes this model.
This method is invoked in the constructor right after {@link scenario} is set.
You may override this method to provide code that is needed to initialize the model (e.g. setting
initial property values.) | init | php | yiisoft/yii | framework/web/CFormModel.php | https://github.com/yiisoft/yii/blob/master/framework/web/CFormModel.php | BSD-3-Clause |
public function getDataProvider()
{
return $this->_dataProvider;
} | Returns the data provider to iterate over
@return CDataProvider the data provider to iterate over | getDataProvider | php | yiisoft/yii | framework/web/CDataProviderIterator.php | https://github.com/yiisoft/yii/blob/master/framework/web/CDataProviderIterator.php | BSD-3-Clause |
public function getTotalItemCount()
{
return $this->_totalItemCount;
} | Gets the total number of items to iterate over
@return integer the total number of items to iterate over | getTotalItemCount | php | yiisoft/yii | framework/web/CDataProviderIterator.php | https://github.com/yiisoft/yii/blob/master/framework/web/CDataProviderIterator.php | BSD-3-Clause |
public function current()
{
return $this->_items[$this->_currentIndex];
} | Gets the current item in the list.
This method is required by the Iterator interface.
@return mixed the current item in the list | current | php | yiisoft/yii | framework/web/CDataProviderIterator.php | https://github.com/yiisoft/yii/blob/master/framework/web/CDataProviderIterator.php | BSD-3-Clause |
public function key()
{
$pageSize=$this->_dataProvider->getPagination()->getPageSize();
return $this->_currentPage*$pageSize+$this->_currentIndex;
} | Gets the key of the current item.
This method is required by the Iterator interface.
@return integer the key of the current item | key | php | yiisoft/yii | framework/web/CDataProviderIterator.php | https://github.com/yiisoft/yii/blob/master/framework/web/CDataProviderIterator.php | BSD-3-Clause |
public function next()
{
$pageSize=$this->_dataProvider->getPagination()->getPageSize();
$this->_currentIndex++;
if($this->_currentIndex >= $pageSize)
{
$this->_currentPage++;
$this->_currentIndex=0;
$this->loadPage();
}
} | Moves the pointer to the next item in the list.
This method is required by the Iterator interface. | next | php | yiisoft/yii | framework/web/CDataProviderIterator.php | https://github.com/yiisoft/yii/blob/master/framework/web/CDataProviderIterator.php | BSD-3-Clause |
public function rewind()
{
$this->_currentIndex=0;
$this->_currentPage=0;
$this->loadPage();
} | Rewinds the iterator to the start of the list.
This method is required by the Iterator interface. | rewind | php | yiisoft/yii | framework/web/CDataProviderIterator.php | https://github.com/yiisoft/yii/blob/master/framework/web/CDataProviderIterator.php | BSD-3-Clause |
public function valid()
{
return $this->key() < $this->_totalItemCount;
} | Checks if the current position is valid or not.
This method is required by the Iterator interface.
@return boolean true if this index is valid | valid | php | yiisoft/yii | framework/web/CDataProviderIterator.php | https://github.com/yiisoft/yii/blob/master/framework/web/CDataProviderIterator.php | BSD-3-Clause |
public function count()
{
return $this->_totalItemCount;
} | Gets the total number of items in the dataProvider.
This method is required by the Countable interface.
@return integer the total number of items | count | php | yiisoft/yii | framework/web/CDataProviderIterator.php | https://github.com/yiisoft/yii/blob/master/framework/web/CDataProviderIterator.php | BSD-3-Clause |
public static function getInstance($model, $attribute)
{
return self::getInstanceByName(CHtml::resolveName($model, $attribute));
} | Returns an instance of the specified uploaded file.
The file should be uploaded using {@link CHtml::activeFileField}.
@param CModel $model the model instance
@param string $attribute the attribute name. For tabular file uploading, this can be in the format of "[$i]attributeName", where $i stands for an integer index.
@return CUploadedFile the instance of the uploaded file.
Null is returned if no file is uploaded for the specified model attribute.
@see getInstanceByName | getInstance | php | yiisoft/yii | framework/web/CUploadedFile.php | https://github.com/yiisoft/yii/blob/master/framework/web/CUploadedFile.php | BSD-3-Clause |
public static function getInstances($model, $attribute)
{
return self::getInstancesByName(CHtml::resolveName($model, $attribute));
} | Returns all uploaded files for the given model attribute.
@param CModel $model the model instance
@param string $attribute the attribute name. For tabular file uploading, this can be in the format of "[$i]attributeName", where $i stands for an integer index.
@return CUploadedFile[] array of CUploadedFile objects.
Empty array is returned if no available file was found for the given attribute. | getInstances | php | yiisoft/yii | framework/web/CUploadedFile.php | https://github.com/yiisoft/yii/blob/master/framework/web/CUploadedFile.php | BSD-3-Clause |
public static function getInstanceByName($name)
{
if(null===self::$_files)
self::prefetchFiles();
return isset(self::$_files[$name]) && self::$_files[$name]->getError()!=UPLOAD_ERR_NO_FILE ? self::$_files[$name] : null;
} | Returns an instance of the specified uploaded file.
The name can be a plain string or a string like an array element (e.g. 'Post[imageFile]', or 'Post[0][imageFile]').
@param string $name the name of the file input field.
@return CUploadedFile the instance of the uploaded file.
Null is returned if no file is uploaded for the specified name. | getInstanceByName | php | yiisoft/yii | framework/web/CUploadedFile.php | https://github.com/yiisoft/yii/blob/master/framework/web/CUploadedFile.php | BSD-3-Clause |
public static function getInstancesByName($name)
{
if(null===self::$_files)
self::prefetchFiles();
$len=strlen($name);
$results=array();
foreach(array_keys(self::$_files) as $key)
if(0===strncmp($key, $name.'[', $len+1) && self::$_files[$key]->getError()!=UPLOAD_ERR_NO_FILE)
$results[] = self::$_files[$key];
return $results;
} | Returns an array of instances starting with specified array name.
If multiple files were uploaded and saved as 'Files[0]', 'Files[1]',
'Files[n]'..., you can have them all by passing 'Files' as array name.
@param string $name the name of the array of files
@return CUploadedFile[] the array of CUploadedFile objects. Empty array is returned
if no adequate upload was found. Please note that this array will contain
all files from all subarrays regardless how deeply nested they are. | getInstancesByName | php | yiisoft/yii | framework/web/CUploadedFile.php | https://github.com/yiisoft/yii/blob/master/framework/web/CUploadedFile.php | BSD-3-Clause |
public static function reset()
{
self::$_files=null;
} | Cleans up the loaded CUploadedFile instances.
This method is mainly used by test scripts to set up a fixture.
@since 1.1.4 | reset | php | yiisoft/yii | framework/web/CUploadedFile.php | https://github.com/yiisoft/yii/blob/master/framework/web/CUploadedFile.php | BSD-3-Clause |
protected static function prefetchFiles()
{
self::$_files = array();
if(!isset($_FILES) || !is_array($_FILES))
return;
foreach($_FILES as $class=>$info)
self::collectFilesRecursive($class, $info['name'], $info['tmp_name'], $info['type'], $info['size'], $info['error']);
} | Initially processes $_FILES superglobal for easier use.
Only for internal usage. | prefetchFiles | php | yiisoft/yii | framework/web/CUploadedFile.php | https://github.com/yiisoft/yii/blob/master/framework/web/CUploadedFile.php | BSD-3-Clause |
public function __construct($name,$tempName,$type,$size,$error)
{
$this->_name=$name;
$this->_tempName=$tempName;
$this->_type=$type;
$this->_size=$size;
$this->_error=$error;
} | Constructor.
Use {@link getInstance} to get an instance of an uploaded file.
@param string $name the original name of the file being uploaded
@param string $tempName the path of the uploaded file on the server.
@param string $type the MIME-type of the uploaded file (such as "image/gif").
@param integer $size the actual size of the uploaded file in bytes
@param integer $error the error code | __construct | php | yiisoft/yii | framework/web/CUploadedFile.php | https://github.com/yiisoft/yii/blob/master/framework/web/CUploadedFile.php | BSD-3-Clause |
public function __toString()
{
return $this->_name;
} | String output.
This is PHP magic method that returns string representation of an object.
The implementation here returns the uploaded file's name.
@return string the string representation of the object | __toString | php | yiisoft/yii | framework/web/CUploadedFile.php | https://github.com/yiisoft/yii/blob/master/framework/web/CUploadedFile.php | BSD-3-Clause |
public function saveAs($file,$deleteTempFile=true)
{
if($this->_error==UPLOAD_ERR_OK)
{
if($deleteTempFile)
return move_uploaded_file($this->_tempName,$file);
elseif(is_uploaded_file($this->_tempName))
return copy($this->_tempName, $file);
else
return false;
}
else
return false;
} | Saves the uploaded file.
Note: this method uses php's move_uploaded_file() method. As such, if the target file ($file)
already exists it is overwritten.
@param string $file the file path used to save the uploaded file
@param boolean $deleteTempFile whether to delete the temporary file after saving.
If true, you will not be able to save the uploaded file again in the current request.
@return boolean true whether the file is saved successfully
In some exceptional cases such as not enough permissions to write to the path specified
PHP warning is triggered. | saveAs | php | yiisoft/yii | framework/web/CUploadedFile.php | https://github.com/yiisoft/yii/blob/master/framework/web/CUploadedFile.php | BSD-3-Clause |
public function getTempName()
{
return $this->_tempName;
} | @return string the path of the uploaded file on the server.
Note, this is a temporary file which will be automatically deleted by PHP
after the current request is processed. | getTempName | php | yiisoft/yii | framework/web/CUploadedFile.php | https://github.com/yiisoft/yii/blob/master/framework/web/CUploadedFile.php | BSD-3-Clause |
public function getType()
{
return $this->_type;
} | @return string the MIME-type of the uploaded file (such as "image/gif").
Since this MIME type is not checked on the server side, do not take this value for granted.
Instead, use {@link CFileHelper::getMimeType} to determine the exact MIME type. | getType | php | yiisoft/yii | framework/web/CUploadedFile.php | https://github.com/yiisoft/yii/blob/master/framework/web/CUploadedFile.php | BSD-3-Clause |
public function getError()
{
return $this->_error;
} | Returns an error code describing the status of this file uploading.
@return integer the error code
@see https://www.php.net/manual/en/features.file-upload.errors.php | getError | php | yiisoft/yii | framework/web/CUploadedFile.php | https://github.com/yiisoft/yii/blob/master/framework/web/CUploadedFile.php | BSD-3-Clause |
public function getExtensionName()
{
return CFileHelper::getExtension($this->_name);
} | @return string the file extension name for {@link name}.
The extension name does not include the dot character. An empty string
is returned if {@link name} does not have an extension name. | getExtensionName | php | yiisoft/yii | framework/web/CUploadedFile.php | https://github.com/yiisoft/yii/blob/master/framework/web/CUploadedFile.php | BSD-3-Clause |
public function renderInternal($_viewFile_,$_data_=null,$_return_=false)
{
// we use special variable names here to avoid conflict when extracting data
if(is_array($_data_))
extract($_data_,EXTR_PREFIX_SAME,'data');
else
$data=$_data_;
if($_return_)
{
ob_start();
ob_implicit_flush(false);
require($_viewFile_);
return ob_get_clean();
}
else
require($_viewFile_);
} | Renders a view file.
This method includes the view file as a PHP script
and captures the display result if required.
@param string $_viewFile_ view file
@param array $_data_ data to be extracted and made available to the view file
@param boolean $_return_ whether the rendering result should be returned as a string
@return string the rendering result. Null if the rendering result is not required. | renderInternal | php | yiisoft/yii | framework/web/CBaseController.php | https://github.com/yiisoft/yii/blob/master/framework/web/CBaseController.php | BSD-3-Clause |
public function endClip()
{
$this->endWidget('CClipWidget');
} | Ends recording a clip.
This method is an alias to {@link endWidget}. | endClip | php | yiisoft/yii | framework/web/CBaseController.php | https://github.com/yiisoft/yii/blob/master/framework/web/CBaseController.php | BSD-3-Clause |
public function endCache()
{
$this->endWidget('COutputCache');
} | Ends fragment caching.
This is an alias to {@link endWidget}.
@see beginCache | endCache | php | yiisoft/yii | framework/web/CBaseController.php | https://github.com/yiisoft/yii/blob/master/framework/web/CBaseController.php | BSD-3-Clause |
public function endContent()
{
$this->endWidget('CContentDecorator');
} | Ends the rendering of content.
@see beginContent | endContent | php | yiisoft/yii | framework/web/CBaseController.php | https://github.com/yiisoft/yii/blob/master/framework/web/CBaseController.php | BSD-3-Clause |
public function processRequest()
{
if(is_array($this->catchAllRequest) && isset($this->catchAllRequest[0]))
{
$route=$this->catchAllRequest[0];
foreach(array_splice($this->catchAllRequest,1) as $name=>$value)
$_GET[$name]=$value;
}
else
$route=$this->getUrlManager()->parseUrl($this->getRequest());
$this->runController($route);
} | Processes the current request.
It first resolves the request into controller and action,
and then creates the controller to perform the action. | processRequest | php | yiisoft/yii | framework/web/CWebApplication.php | https://github.com/yiisoft/yii/blob/master/framework/web/CWebApplication.php | BSD-3-Clause |
protected function registerCoreComponents()
{
parent::registerCoreComponents();
$components=array(
'session'=>array(
'class'=>'CHttpSession',
),
'assetManager'=>array(
'class'=>'CAssetManager',
),
'user'=>array(
'class'=>'CWebUser',
),
'themeManager'=>array(
'class'=>'CThemeManager',
),
'authManager'=>array(
'class'=>'CPhpAuthManager',
),
'clientScript'=>array(
'class'=>'CClientScript',
),
'widgetFactory'=>array(
'class'=>'CWidgetFactory',
),
);
$this->setComponents($components);
} | Registers the core application components.
This method overrides the parent implementation by registering additional core components.
@see setComponents | registerCoreComponents | php | yiisoft/yii | framework/web/CWebApplication.php | https://github.com/yiisoft/yii/blob/master/framework/web/CWebApplication.php | BSD-3-Clause |
public function getViewRenderer()
{
return $this->getComponent('viewRenderer');
} | Returns the view renderer.
If this component is registered and enabled, the default
view rendering logic defined in {@link CBaseController} will
be replaced by this renderer.
@return IViewRenderer the view renderer. | getViewRenderer | php | yiisoft/yii | framework/web/CWebApplication.php | https://github.com/yiisoft/yii/blob/master/framework/web/CWebApplication.php | BSD-3-Clause |
public function getClientScript()
{
return $this->getComponent('clientScript');
} | Returns the client script manager.
@return CClientScript the client script manager | getClientScript | php | yiisoft/yii | framework/web/CWebApplication.php | https://github.com/yiisoft/yii/blob/master/framework/web/CWebApplication.php | BSD-3-Clause |
public function runController($route)
{
if(($ca=$this->createController($route))!==null)
{
list($controller,$actionID)=$ca;
$oldController=$this->_controller;
$this->_controller=$controller;
$controller->init();
$controller->run($actionID);
$this->_controller=$oldController;
}
else
throw new CHttpException(404,Yii::t('yii','Unable to resolve the request "{route}".',
array('{route}'=>$route===''?$this->defaultController:$route)));
} | Creates the controller and performs the specified action.
@param string $route the route of the current request. See {@link createController} for more details.
@throws CHttpException if the controller could not be created. | runController | php | yiisoft/yii | framework/web/CWebApplication.php | https://github.com/yiisoft/yii/blob/master/framework/web/CWebApplication.php | BSD-3-Clause |
public function createController($route,$owner=null)
{
if($owner===null)
$owner=$this;
if((array)$route===$route || ($route=trim($route,'/'))==='')
$route=$owner->defaultController;
$caseSensitive=$this->getUrlManager()->caseSensitive;
$route.='/';
while(($pos=strpos($route,'/'))!==false)
{
$id=substr($route,0,$pos);
if(!preg_match('/^\w+$/',$id))
return null;
if(!$caseSensitive)
$id=strtolower($id);
$route=(string)substr($route,$pos+1);
if(!isset($basePath)) // first segment
{
if(isset($owner->controllerMap[$id]))
{
return array(
Yii::createComponent($owner->controllerMap[$id],$id,$owner===$this?null:$owner),
$this->parseActionParams($route),
);
}
if(($module=$owner->getModule($id))!==null)
return $this->createController($route,$module);
$basePath=$owner->getControllerPath();
$controllerID='';
}
else
$controllerID.='/';
$className=ucfirst($id).'Controller';
$classFile=$basePath.DIRECTORY_SEPARATOR.$className.'.php';
if($owner->controllerNamespace!==null)
$className=$owner->controllerNamespace.'\\'.str_replace('/','\\',$controllerID).$className;
if(is_file($classFile))
{
if(!class_exists($className,false))
require($classFile);
if(class_exists($className,false) && is_subclass_of($className,'CController'))
{
$id[0]=strtolower($id[0]);
return array(
new $className($controllerID.$id,$owner===$this?null:$owner),
$this->parseActionParams($route),
);
}
return null;
}
$controllerID.=$id;
$basePath.=DIRECTORY_SEPARATOR.$id;
}
} | Creates a controller instance based on a route.
The route should contain the controller ID and the action ID.
It may also contain additional GET variables. All these must be concatenated together with slashes.
This method will attempt to create a controller in the following order:
<ol>
<li>If the first segment is found in {@link controllerMap}, the corresponding
controller configuration will be used to create the controller;</li>
<li>If the first segment is found to be a module ID, the corresponding module
will be used to create the controller;</li>
<li>Otherwise, it will search under the {@link controllerPath} to create
the corresponding controller. For example, if the route is "admin/user/create",
then the controller will be created using the class file "protected/controllers/admin/UserController.php".</li>
</ol>
@param string $route the route of the request.
@param CWebModule $owner the module that the new controller will belong to. Defaults to null, meaning the application
instance is the owner.
@return array the controller instance and the action ID. Null if the controller class does not exist or the route is invalid. | createController | php | yiisoft/yii | framework/web/CWebApplication.php | https://github.com/yiisoft/yii/blob/master/framework/web/CWebApplication.php | BSD-3-Clause |
protected function parseActionParams($pathInfo)
{
if(($pos=strpos($pathInfo,'/'))!==false)
{
$manager=$this->getUrlManager();
$manager->parsePathInfo((string)substr($pathInfo,$pos+1));
$actionID=substr($pathInfo,0,$pos);
return $manager->caseSensitive ? $actionID : strtolower($actionID);
}
else
return $pathInfo;
} | Parses a path info into an action ID and GET variables.
@param string $pathInfo path info
@return string action ID | parseActionParams | php | yiisoft/yii | framework/web/CWebApplication.php | https://github.com/yiisoft/yii/blob/master/framework/web/CWebApplication.php | BSD-3-Clause |
public function beforeControllerAction($controller,$action)
{
return true;
} | The pre-filter for controller actions.
This method is invoked before the currently requested controller action and all its filters
are executed. You may override this method with logic that needs to be done
before all controller actions.
@param CController $controller the controller
@param CAction $action the action
@return boolean whether the action should be executed. | beforeControllerAction | php | yiisoft/yii | framework/web/CWebApplication.php | https://github.com/yiisoft/yii/blob/master/framework/web/CWebApplication.php | BSD-3-Clause |
public function afterControllerAction($controller,$action)
{
} | The post-filter for controller actions.
This method is invoked after the currently requested controller action and all its filters
are executed. You may override this method with logic that needs to be done
after all controller actions.
@param CController $controller the controller
@param CAction $action the action | afterControllerAction | php | yiisoft/yii | framework/web/CWebApplication.php | https://github.com/yiisoft/yii/blob/master/framework/web/CWebApplication.php | BSD-3-Clause |
public function findModule($id)
{
if(($controller=$this->getController())!==null && ($module=$controller->getModule())!==null)
{
do
{
if(($m=$module->getModule($id))!==null)
return $m;
} while(($module=$module->getParentModule())!==null);
}
if(($m=$this->getModule($id))!==null)
return $m;
} | Do not call this method. This method is used internally to search for a module by its ID.
@param string $id module ID
@return CWebModule the module that has the specified ID. Null if no module is found. | findModule | php | yiisoft/yii | framework/web/CWebApplication.php | https://github.com/yiisoft/yii/blob/master/framework/web/CWebApplication.php | BSD-3-Clause |
protected function init()
{
parent::init();
// preload 'request' so that it has chance to respond to onBeginRequest event.
$this->getRequest();
} | Initializes the application.
This method overrides the parent implementation by preloading the 'request' component. | init | php | yiisoft/yii | framework/web/CWebApplication.php | https://github.com/yiisoft/yii/blob/master/framework/web/CWebApplication.php | BSD-3-Clause |
public function getViewPath()
{
if($this->_viewPath===null)
{
$class=new ReflectionClass(get_class($this));
$this->_viewPath=dirname($class->getFileName()).DIRECTORY_SEPARATOR.'views';
}
return $this->_viewPath;
} | Returns the directory containing view files for this controller.
This method overrides the parent implementation by specifying the view path
to be the "views" subdirectory under the directory containing the controller
class file.
@return string the directory containing the view files for this controller. | getViewPath | php | yiisoft/yii | framework/web/CExtController.php | https://github.com/yiisoft/yii/blob/master/framework/web/CExtController.php | BSD-3-Clause |
public function __construct($modelClass=null)
{
$this->modelClass=$modelClass;
} | Constructor.
@param string $modelClass the class name of data models that need to be sorted.
This should be a child class of {@link CActiveRecord}. | __construct | php | yiisoft/yii | framework/web/CSort.php | https://github.com/yiisoft/yii/blob/master/framework/web/CSort.php | BSD-3-Clause |
public function applyOrder($criteria)
{
$order=$this->getOrderBy($criteria);
if(!empty($order))
{
if(!empty($criteria->order))
$criteria->order.=', ';
$criteria->order.=$order;
}
} | Modifies the query criteria by changing its {@link CDbCriteria::order} property.
This method will use {@link directions} to determine which columns need to be sorted.
They will be put in the ORDER BY clause. If the criteria already has non-empty {@link CDbCriteria::order} value,
the new value will be appended to it.
@param CDbCriteria $criteria the query criteria | applyOrder | php | yiisoft/yii | framework/web/CSort.php | https://github.com/yiisoft/yii/blob/master/framework/web/CSort.php | BSD-3-Clause |
public function resolveLabel($attribute)
{
$definition=$this->resolveAttribute($attribute);
if(is_array($definition))
{
if(isset($definition['label']))
return $definition['label'];
}
elseif(is_string($definition))
$attribute=$definition;
if($this->modelClass!==null)
return $this->getModel($this->modelClass)->getAttributeLabel($attribute);
else
return $attribute;
} | Resolves the attribute label for the specified attribute.
This will invoke {@link CActiveRecord::getAttributeLabel} to determine what label to use.
If the attribute refers to a virtual attribute declared in {@link attributes},
then the label given in the {@link attributes} will be returned instead.
@param string $attribute the attribute name.
@return string the attribute label | resolveLabel | php | yiisoft/yii | framework/web/CSort.php | https://github.com/yiisoft/yii/blob/master/framework/web/CSort.php | BSD-3-Clause |
public function getDirections()
{
if($this->_directions===null)
{
$this->_directions=array();
if(isset($_GET[$this->sortVar]) && is_string($_GET[$this->sortVar]))
{
$attributes=explode($this->separators[0],$_GET[$this->sortVar]);
foreach($attributes as $attribute)
{
if(($pos=strrpos($attribute,$this->separators[1]))!==false)
{
$descending=substr($attribute,$pos+1)===$this->descTag;
if($descending)
$attribute=substr($attribute,0,$pos);
}
else
$descending=false;
if(($this->resolveAttribute($attribute))!==false)
{
$this->_directions[$attribute]=$descending;
if(!$this->multiSort)
return $this->_directions;
}
}
}
if($this->_directions===array() && is_array($this->defaultOrder))
$this->_directions=$this->defaultOrder;
}
return $this->_directions;
} | Returns the currently requested sort information.
@return array sort directions indexed by attribute names.
Sort direction can be either CSort::SORT_ASC for ascending order or
CSort::SORT_DESC for descending order. | getDirections | php | yiisoft/yii | framework/web/CSort.php | https://github.com/yiisoft/yii/blob/master/framework/web/CSort.php | BSD-3-Clause |
public function getDirection($attribute)
{
$this->getDirections();
return isset($this->_directions[$attribute]) ? $this->_directions[$attribute] : null;
} | Returns the sort direction of the specified attribute in the current request.
@param string $attribute the attribute name
@return mixed Sort direction of the attribute. Can be either CSort::SORT_ASC
for ascending order or CSort::SORT_DESC for descending order. Value is null
if the attribute doesn't need to be sorted. | getDirection | php | yiisoft/yii | framework/web/CSort.php | https://github.com/yiisoft/yii/blob/master/framework/web/CSort.php | BSD-3-Clause |
public function createUrl($controller,$directions)
{
$sorts=array();
foreach($directions as $attribute=>$descending)
$sorts[]=$descending ? $attribute.$this->separators[1].$this->descTag : $attribute;
$params=$this->params===null ? $_GET : $this->params;
$params[$this->sortVar]=implode($this->separators[0],$sorts);
return $controller->createUrl($this->route,$params);
} | Creates a URL that can lead to generating sorted data.
@param CController $controller the controller that will be used to create the URL.
@param array $directions the sort directions indexed by attribute names.
The sort direction can be either CSort::SORT_ASC for ascending order or
CSort::SORT_DESC for descending order.
@return string the URL for sorting | createUrl | php | yiisoft/yii | framework/web/CSort.php | https://github.com/yiisoft/yii/blob/master/framework/web/CSort.php | BSD-3-Clause |
protected function getModel($className)
{
return CActiveRecord::model($className);
} | Given active record class name returns new model instance.
@param string $className active record class name.
@return CActiveRecord active record model instance.
@since 1.1.14 | getModel | php | yiisoft/yii | framework/web/CSort.php | https://github.com/yiisoft/yii/blob/master/framework/web/CSort.php | BSD-3-Clause |
protected function createLink($attribute,$label,$url,$htmlOptions)
{
return CHtml::link($label,$url,$htmlOptions);
} | Creates a hyperlink based on the given label and URL.
You may override this method to customize the link generation.
@param string $attribute the name of the attribute that this link is for
@param string $label the label of the hyperlink
@param string $url the URL
@param array $htmlOptions additional HTML options
@return string the generated hyperlink | createLink | php | yiisoft/yii | framework/web/CSort.php | https://github.com/yiisoft/yii/blob/master/framework/web/CSort.php | BSD-3-Clause |
public function init()
{
parent::init();
$this->processRules();
} | Initializes the application component. | init | php | yiisoft/yii | framework/web/CUrlManager.php | https://github.com/yiisoft/yii/blob/master/framework/web/CUrlManager.php | BSD-3-Clause |
public function addRules($rules,$append=true)
{
if ($append)
{
foreach($rules as $pattern=>$route)
$this->_rules[]=$this->createUrlRule($route,$pattern);
}
else
{
$rules=array_reverse($rules);
foreach($rules as $pattern=>$route)
array_unshift($this->_rules, $this->createUrlRule($route,$pattern));
}
} | Adds new URL rules.
In order to make the new rules effective, this method must be called BEFORE
{@link CWebApplication::processRequest}.
@param array $rules new URL rules (pattern=>route).
@param boolean $append whether the new URL rules should be appended to the existing ones. If false,
they will be inserted at the beginning.
@since 1.1.4 | addRules | php | yiisoft/yii | framework/web/CUrlManager.php | https://github.com/yiisoft/yii/blob/master/framework/web/CUrlManager.php | BSD-3-Clause |
protected function createUrlRule($route,$pattern)
{
if(is_array($route) && isset($route['class']))
return $route;
else
{
$urlRuleClass=Yii::import($this->urlRuleClass,true);
return new $urlRuleClass($route,$pattern);
}
} | Creates a URL rule instance.
The default implementation returns a CUrlRule object.
@param mixed $route the route part of the rule. This could be a string or an array
@param string $pattern the pattern part of the rule
@return CUrlRule the URL rule instance
@since 1.1.0 | createUrlRule | php | yiisoft/yii | framework/web/CUrlManager.php | https://github.com/yiisoft/yii/blob/master/framework/web/CUrlManager.php | BSD-3-Clause |
protected function createUrlDefault($route,$params,$ampersand)
{
if($this->getUrlFormat()===self::PATH_FORMAT)
{
$url=rtrim($this->getBaseUrl().'/'.$route,'/');
if($this->appendParams)
{
$url=rtrim($url.'/'.$this->createPathInfo($params,'/','/'),'/');
return $route==='' ? $url : $url.$this->urlSuffix;
}
else
{
if($route!=='')
$url.=$this->urlSuffix;
$query=$this->createPathInfo($params,'=',$ampersand);
return $query==='' ? $url : $url.'?'.$query;
}
}
else
{
$url=$this->getBaseUrl();
if(!$this->showScriptName)
$url.='/';
if($route!=='')
{
$url.='?'.$this->routeVar.'='.$route;
if(($query=$this->createPathInfo($params,'=',$ampersand))!=='')
$url.=$ampersand.$query;
}
elseif(($query=$this->createPathInfo($params,'=',$ampersand))!=='')
$url.='?'.$query;
return $url;
}
} | Creates a URL based on default settings.
@param string $route the controller and the action (e.g. article/read)
@param array $params list of GET parameters
@param string $ampersand the token separating name-value pairs in the URL.
@return string the constructed URL | createUrlDefault | php | yiisoft/yii | framework/web/CUrlManager.php | https://github.com/yiisoft/yii/blob/master/framework/web/CUrlManager.php | BSD-3-Clause |
public function parsePathInfo($pathInfo)
{
if($pathInfo==='')
return;
$segs=explode('/',$pathInfo.'/');
$n=count($segs);
for($i=0;$i<$n-1;$i+=2)
{
$key=$segs[$i];
if($key==='') continue;
$value=$segs[$i+1];
if(($pos=strpos($key,'['))!==false && ($m=preg_match_all('/\[(.*?)\]/',$key,$matches))>0)
{
$name=substr($key,0,$pos);
for($j=$m-1;$j>=0;--$j)
{
if($matches[1][$j]==='')
$value=array($value);
else
$value=array($matches[1][$j]=>$value);
}
if(isset($_GET[$name]) && is_array($_GET[$name]))
$value=CMap::mergeArray($_GET[$name],$value);
$_REQUEST[$name]=$_GET[$name]=$value;
}
else
$_REQUEST[$key]=$_GET[$key]=$value;
}
} | Parses a path info into URL segments and saves them to $_GET and $_REQUEST.
@param string $pathInfo path info | parsePathInfo | php | yiisoft/yii | framework/web/CUrlManager.php | https://github.com/yiisoft/yii/blob/master/framework/web/CUrlManager.php | BSD-3-Clause |
public function removeUrlSuffix($pathInfo,$urlSuffix)
{
if($urlSuffix!=='' && substr($pathInfo,-strlen($urlSuffix))===$urlSuffix)
return substr($pathInfo,0,-strlen($urlSuffix));
else
return $pathInfo;
} | Removes the URL suffix from path info.
@param string $pathInfo path info part in the URL
@param string $urlSuffix the URL suffix to be removed
@return string path info with URL suffix removed. | removeUrlSuffix | php | yiisoft/yii | framework/web/CUrlManager.php | https://github.com/yiisoft/yii/blob/master/framework/web/CUrlManager.php | BSD-3-Clause |
public function getBaseUrl()
{
if($this->_baseUrl!==null)
return $this->_baseUrl;
else
{
if($this->showScriptName)
$this->_baseUrl=Yii::app()->getRequest()->getScriptUrl();
else
$this->_baseUrl=Yii::app()->getRequest()->getBaseUrl();
return $this->_baseUrl;
}
} | Returns the base URL of the application.
@return string the base URL of the application (the part after host name and before query string).
If {@link showScriptName} is true, it will include the script name part.
Otherwise, it will not, and the ending slashes are stripped off. | getBaseUrl | php | yiisoft/yii | framework/web/CUrlManager.php | https://github.com/yiisoft/yii/blob/master/framework/web/CUrlManager.php | BSD-3-Clause |
public function setBaseUrl($value)
{
$this->_baseUrl=$value;
} | Sets the base URL of the application (the part after host name and before query string).
This method is provided in case the {@link baseUrl} cannot be determined automatically.
The ending slashes should be stripped off. And you are also responsible to remove the script name
if you set {@link showScriptName} to be false.
@param string $value the base URL of the application
@since 1.1.1 | setBaseUrl | php | yiisoft/yii | framework/web/CUrlManager.php | https://github.com/yiisoft/yii/blob/master/framework/web/CUrlManager.php | BSD-3-Clause |
public function getUrlFormat()
{
return $this->_urlFormat;
} | Returns the URL format.
@return string the URL format. Defaults to 'path'. Valid values include 'path' and 'get'.
Please refer to the guide for more details about the difference between these two formats. | getUrlFormat | php | yiisoft/yii | framework/web/CUrlManager.php | https://github.com/yiisoft/yii/blob/master/framework/web/CUrlManager.php | BSD-3-Clause |
protected function escapeRegexpSpecialChars($matches)
{
return preg_quote($matches[0]);
} | Callback for preg_replace_callback in counstructor | escapeRegexpSpecialChars | php | yiisoft/yii | framework/web/CUrlManager.php | https://github.com/yiisoft/yii/blob/master/framework/web/CUrlManager.php | BSD-3-Clause |
public function init()
{
parent::init();
if($this->enableSkin && $this->skinPath===null)
$this->skinPath=Yii::app()->getViewPath().DIRECTORY_SEPARATOR.'skins';
} | Initializes the application component.
This method overrides the parent implementation by resolving the skin path. | init | php | yiisoft/yii | framework/web/CWidgetFactory.php | https://github.com/yiisoft/yii/blob/master/framework/web/CWidgetFactory.php | BSD-3-Clause |
protected function getSkin($className,$skinName)
{
if(!isset($this->_skins[$className][$skinName]))
{
$skinFile=$this->skinPath.DIRECTORY_SEPARATOR.$className.'.php';
if(is_file($skinFile))
$this->_skins[$className]=require($skinFile);
else
$this->_skins[$className]=array();
if(($theme=Yii::app()->getTheme())!==null)
{
$skinFile=$theme->getSkinPath().DIRECTORY_SEPARATOR.$className.'.php';
if(is_file($skinFile))
{
$skins=require($skinFile);
foreach($skins as $name=>$skin)
$this->_skins[$className][$name]=$skin;
}
}
if(!isset($this->_skins[$className][$skinName]))
$this->_skins[$className][$skinName]=array();
}
return $this->_skins[$className][$skinName];
} | Returns the skin for the specified widget class and skin name.
@param string $className the widget class name
@param string $skinName the widget skin name
@return array the skin (name=>value) for the widget | getSkin | php | yiisoft/yii | framework/web/CWidgetFactory.php | https://github.com/yiisoft/yii/blob/master/framework/web/CWidgetFactory.php | BSD-3-Clause |
public function reset()
{
$this->hasScripts=false;
$this->coreScripts=array();
$this->cssFiles=array();
$this->css=array();
$this->scriptFiles=array();
$this->scripts=array();
$this->metaTags=array();
$this->linkTags=array();
$this->recordCachingAction('clientScript','reset',array());
} | Cleans all registered scripts. | reset | php | yiisoft/yii | framework/web/CClientScript.php | https://github.com/yiisoft/yii/blob/master/framework/web/CClientScript.php | BSD-3-Clause |
public function render(&$output)
{
if(!$this->hasScripts)
return;
$this->renderCoreScripts();
if(!empty($this->scriptMap))
$this->remapScripts();
$this->unifyScripts();
$this->renderHead($output);
if($this->enableJavaScript)
{
$this->renderBodyBegin($output);
$this->renderBodyEnd($output);
}
} | Renders the registered scripts.
This method is called in {@link CController::render} when it finishes
rendering content. CClientScript thus gets a chance to insert script tags
at <code>head</code> and <code>body</code> sections in the HTML output.
@param string $output the existing output that needs to be inserted with script tags | render | php | yiisoft/yii | framework/web/CClientScript.php | https://github.com/yiisoft/yii/blob/master/framework/web/CClientScript.php | BSD-3-Clause |
public function getCoreScriptUrl()
{
if($this->_baseUrl!==null)
return $this->_baseUrl;
else
return $this->_baseUrl=Yii::app()->getAssetManager()->publish(YII_PATH.'/web/js/source');
} | Returns the base URL of all core javascript files.
If the base URL is not explicitly set, this method will publish the whole directory
'framework/web/js/source' and return the corresponding URL.
@return string the base URL of all core javascript files | getCoreScriptUrl | php | yiisoft/yii | framework/web/CClientScript.php | https://github.com/yiisoft/yii/blob/master/framework/web/CClientScript.php | BSD-3-Clause |
public function setCoreScriptUrl($value)
{
$this->_baseUrl=$value;
} | Sets the base URL of all core javascript files.
This setter is provided in case when core javascript files are manually published
to a pre-specified location. This may save asset publishing time for large-scale applications.
@param string $value the base URL of all core javascript files. | setCoreScriptUrl | php | yiisoft/yii | framework/web/CClientScript.php | https://github.com/yiisoft/yii/blob/master/framework/web/CClientScript.php | BSD-3-Clause |
public function getPackageBaseUrl($name)
{
if(!isset($this->coreScripts[$name]))
return false;
$package=$this->coreScripts[$name];
if(isset($package['baseUrl']))
{
$baseUrl=$package['baseUrl'];
if($baseUrl==='' || $baseUrl[0]!=='/' && strpos($baseUrl,'://')===false)
$baseUrl=Yii::app()->getRequest()->getBaseUrl().'/'.$baseUrl;
$baseUrl=rtrim($baseUrl,'/');
}
elseif(isset($package['basePath']))
$baseUrl=Yii::app()->getAssetManager()->publish(Yii::getPathOfAlias($package['basePath']));
else
$baseUrl=$this->getCoreScriptUrl();
return $this->coreScripts[$name]['baseUrl']=$baseUrl;
} | Returns the base URL for a registered package with the specified name.
If needed, this method may publish the assets of the package and returns the published base URL.
@param string $name the package name
@return string the base URL for the named package. False is returned if the package is not registered yet.
@see registerPackage
@since 1.1.8 | getPackageBaseUrl | php | yiisoft/yii | framework/web/CClientScript.php | https://github.com/yiisoft/yii/blob/master/framework/web/CClientScript.php | BSD-3-Clause |
public function hasPackage($name)
{
if(isset($this->coreScripts[$name]))
return true;
if(isset($this->packages[$name]))
return true;
else
{
if($this->corePackages===null)
$this->corePackages=require(YII_PATH.'/web/js/packages.php');
if(isset($this->corePackages[$name]))
return true;
}
return false;
} | Checks if package is available.
@param string $name the name of the script package.
@return bool
@since 1.1.18
@see registerPackage | hasPackage | php | yiisoft/yii | framework/web/CClientScript.php | https://github.com/yiisoft/yii/blob/master/framework/web/CClientScript.php | BSD-3-Clause |
public function registerCss($id,$css,$media='')
{
$this->hasScripts=true;
$this->css[$id]=array($css,$media);
$params=func_get_args();
$this->recordCachingAction('clientScript','registerCss',$params);
return $this;
} | Registers a piece of CSS code.
@param string $id ID that uniquely identifies this piece of CSS code
@param string $css the CSS code
@param string $media media that the CSS code should be applied to. If empty, it means all media types.
@return static the CClientScript object itself (to support method chaining, available since version 1.1.5). | registerCss | php | yiisoft/yii | framework/web/CClientScript.php | https://github.com/yiisoft/yii/blob/master/framework/web/CClientScript.php | BSD-3-Clause |
public function isCssFileRegistered($url)
{
return isset($this->cssFiles[$url]);
} | Checks whether the CSS file has been registered.
@param string $url URL of the CSS file
@return boolean whether the CSS file is already registered | isCssFileRegistered | php | yiisoft/yii | framework/web/CClientScript.php | https://github.com/yiisoft/yii/blob/master/framework/web/CClientScript.php | BSD-3-Clause |
public function isCssRegistered($id)
{
return isset($this->css[$id]);
} | Checks whether the CSS code has been registered.
@param string $id ID that uniquely identifies the CSS code
@return boolean whether the CSS code is already registered | isCssRegistered | php | yiisoft/yii | framework/web/CClientScript.php | https://github.com/yiisoft/yii/blob/master/framework/web/CClientScript.php | BSD-3-Clause |
public function isScriptFileRegistered($url,$position=self::POS_HEAD)
{
return isset($this->scriptFiles[$position][$url]);
} | Checks whether the JavaScript file has been registered.
@param string $url URL of the javascript file
@param integer $position the position of the JavaScript code. Valid values include the following:
<ul>
<li>CClientScript::POS_HEAD : the script is inserted in the head section right before the title element.</li>
<li>CClientScript::POS_BEGIN : the script is inserted at the beginning of the body section.</li>
<li>CClientScript::POS_END : the script is inserted at the end of the body section.</li>
</ul>
@return boolean whether the javascript file is already registered | isScriptFileRegistered | php | yiisoft/yii | framework/web/CClientScript.php | https://github.com/yiisoft/yii/blob/master/framework/web/CClientScript.php | BSD-3-Clause |
public function isScriptRegistered($id,$position=self::POS_READY)
{
return isset($this->scripts[$position][$id]);
} | Checks whether the JavaScript code has been registered.
@param string $id ID that uniquely identifies the JavaScript code
@param integer $position the position of the JavaScript code. Valid values include the following:
<ul>
<li>CClientScript::POS_HEAD : the script is inserted in the head section right before the title element.</li>
<li>CClientScript::POS_BEGIN : the script is inserted at the beginning of the body section.</li>
<li>CClientScript::POS_END : the script is inserted at the end of the body section.</li>
<li>CClientScript::POS_LOAD : the script is inserted in the window.onload() function.</li>
<li>CClientScript::POS_READY : the script is inserted in the jQuery's ready function.</li>
</ul>
@return boolean whether the javascript code is already registered | isScriptRegistered | php | yiisoft/yii | framework/web/CClientScript.php | https://github.com/yiisoft/yii/blob/master/framework/web/CClientScript.php | BSD-3-Clause |
protected function recordCachingAction($context,$method,$params)
{
if(($controller=Yii::app()->getController())!==null)
$controller->recordCachingAction($context,$method,$params);
} | Records a method call when an output cache is in effect.
This is a shortcut to Yii::app()->controller->recordCachingAction.
In case when controller is absent, nothing is recorded.
@param string $context a property name of the controller. It refers to an object
whose method is being called. If empty it means the controller itself.
@param string $method the method name
@param array $params parameters passed to the method
@see COutputCache | recordCachingAction | php | yiisoft/yii | framework/web/CClientScript.php | https://github.com/yiisoft/yii/blob/master/framework/web/CClientScript.php | BSD-3-Clause |
public function addPackage($name,$definition)
{
$this->packages[$name]=$definition;
return $this;
} | Adds a package to packages list.
@param string $name the name of the script package.
@param array $definition the definition array of the script package,
@see CClientScript::packages.
@return static the CClientScript object itself (to support method chaining, available since version 1.1.10).
@since 1.1.9 | addPackage | php | yiisoft/yii | framework/web/CClientScript.php | https://github.com/yiisoft/yii/blob/master/framework/web/CClientScript.php | BSD-3-Clause |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.