Package | system.web.renderers |
---|---|
Inheritance | abstract class CViewRenderer » CApplicationComponent » CComponent |
Implements | IApplicationComponent, IViewRenderer |
Subclasses | CPradoViewRenderer |
Since | 1.0 |
Version | $Id$ |
Source Code | framework/web/renderers/CViewRenderer.php |
Property | Type | Description | Defined By |
---|---|---|---|
behaviors | array | the behaviors that should be attached to this component. | CApplicationComponent |
fileExtension | string | the extension name of the view file. | CViewRenderer |
filePermission | integer | the chmod permission for temporary directories and files generated during parsing. | CViewRenderer |
isInitialized | boolean | whether this application component has been initialized (i.e., init() is invoked. | CApplicationComponent |
useRuntimePath | boolean | whether to store the parsing results in the application's runtime directory. | CViewRenderer |
Method | Description | Defined By |
---|---|---|
__call() | Calls the named method which is not a class method. | CComponent |
__get() | Returns a property value, an event handler list or a behavior based on its name. | CComponent |
__isset() | Checks if a property value is null. | CComponent |
__set() | Sets value of a component property. | CComponent |
__unset() | Sets a component property to be null. | CComponent |
asa() | Returns the named behavior object. | CComponent |
attachBehavior() | Attaches a behavior to this component. | CComponent |
attachBehaviors() | Attaches a list of behaviors to the component. | CComponent |
attachEventHandler() | Attaches an event handler to an event. | CComponent |
canGetProperty() | Determines whether a property can be read. | CComponent |
canSetProperty() | Determines whether a property can be set. | CComponent |
detachBehavior() | Detaches a behavior from the component. | CComponent |
detachBehaviors() | Detaches all behaviors from the component. | CComponent |
detachEventHandler() | Detaches an existing event handler. | CComponent |
disableBehavior() | Disables an attached behavior. | CComponent |
disableBehaviors() | Disables all behaviors attached to this component. | CComponent |
enableBehavior() | Enables an attached behavior. | CComponent |
enableBehaviors() | Enables all behaviors attached to this component. | CComponent |
getEventHandlers() | Returns the list of attached event handlers for an event. | CComponent |
getIsInitialized() | Checks whether this application component has been initialized (i.e., init() is invoked.) | CApplicationComponent |
hasEvent() | Determines whether an event is defined. | CComponent |
hasEventHandler() | Checks whether the named event has attached handlers. | CComponent |
hasProperty() | Determines whether a property is defined. | CComponent |
init() | Initializes the application component. | CApplicationComponent |
raiseEvent() | Raises an event. | CComponent |
renderFile() | Renders a view file. | CViewRenderer |
Method | Description | Defined By |
---|---|---|
generateViewFile() | Parses the source view file and saves the results as another file. | CViewRenderer |
getViewFile() | Generates the resulting view file path. | CViewRenderer |
the extension name of the view file. Defaults to '.php'.
the chmod permission for temporary directories and files generated during parsing. Defaults to 0755 (owner rwx, group rx and others rx).
whether to store the parsing results in the application's runtime directory. Defaults to true. If false, the parsing results will be saved as files under the same directory as the source view files and the file names will be the source file names appended with letter 'c'.
abstract protected void generateViewFile(string $sourceFile, string $viewFile)
| ||
$sourceFile | string | the source view file path |
$viewFile | string | the resulting view file path |
abstract protected function generateViewFile($sourceFile,$viewFile);
Parses the source view file and saves the results as another file.
protected string getViewFile(string $file)
| ||
$file | string | source view file path |
{return} | string | resulting view file path |
protected function getViewFile($file)
{
if($this->useRuntimePath)
{
$crc=sprintf('%x', crc32(get_class($this).Yii::getVersion().dirname($file)));
$viewFile=Yii::app()->getRuntimePath().DIRECTORY_SEPARATOR.'views'.DIRECTORY_SEPARATOR.$crc.DIRECTORY_SEPARATOR.basename($file);
if(!is_file($viewFile))
@mkdir(dirname($viewFile),$this->filePermission,true);
return $viewFile;
}
else
return $file.'c';
}
Generates the resulting view file path.
public mixed renderFile(CBaseController $context, string $sourceFile, mixed $data, boolean $return)
| ||
$context | CBaseController | the controller or widget who is rendering the view file. |
$sourceFile | string | the view file path |
$data | mixed | the data to be passed to the view |
$return | boolean | whether the rendering result should be returned |
{return} | mixed | the rendering result, or null if the rendering result is not needed. |
public function renderFile($context,$sourceFile,$data,$return)
{
if(!is_file($sourceFile) || ($file=realpath($sourceFile))===false)
throw new CException(Yii::t('yii','View file "{file}" does not exist.',array('{file}'=>$sourceFile)));
$viewFile=$this->getViewFile($sourceFile);
if(@filemtime($sourceFile)>@filemtime($viewFile))
{
$this->generateViewFile($sourceFile,$viewFile);
@chmod($viewFile,$this->filePermission);
}
return $context->renderInternal($viewFile,$data,$return);
}
Renders a view file. This method is required by IViewRenderer.
Signup or Login in order to comment.