MediaView Class Info:
- Class Declaration:
class MediaView extends View
- File name:
- cake/libs/view/media.php
- Description:
Methods to display or download any type of file
PHP versions 4 and 5
CakePHP(tm) : Rapid Development Framework (http://cakephp.org) Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
Licensed under The MIT License Redistributions of files must retain the above copyright notice.
- Class Inheritance
- Copyright
Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
- Link
- http://cakephp.org CakePHP(tm) Project
- Package
- cake
- Subpackage
- cake.cake.libs.view
- Since
CakePHP(tm) v 1.2.0.5714
- License
MIT License (http://www.opensource.org/licenses/mit-license.php)
Properties:
-
action string Name of action
Action to be performed.
-
association string
Name of association model this view context is attached to
-
autoLayout boolean
Turns on or off Cake's conventional mode of finding layout files. On by default.
-
autoRender boolean
Turns on or off Cake's conventional mode of rendering views. On by default.
-
base string Base URL
Path parts for creating links in views.
-
cacheAction mixed
Used to define methods a controller that will be cached.
-
data array Parameter data
Array of data
-
ext string
File extension. Defaults to Cake's template ".ctp".
-
field string
Name of current model field this view context is attached to
-
fieldSuffix string
Suffix of current field this view context is attached to
-
hasRendered boolean
True when the view has been rendered.
-
_headers array
Holds headers sent to browser before rendering media
-
helpers mixed A single name as a string or a list of names as an array.
An array of names of built-in helpers to include.
-
here string Current URL
Stores the current URL (for links etc.)
-
layout string
Name of layout to use with this View.
-
layoutPath string Path to Layout
Path to Layout.
-
loaded array
Array of loaded view helpers.
-
mimeType array
Holds known mime type mappings
-
model string
Name of current model this view context is attached to
-
modelId mixed
The current model ID this view context is attached to
-
modelScope boolean
True if in scope of model-specific region
-
name string Name of controller
Name of the controller.
-
output string
Holds View output.
-
params array Parameter data
Array of parameter data
-
passedArgs mixed
Current passed params
-
__passedVars array
List of variables to collect from the associated controller
-
plugin string
Name of the plugin.
-
subDir string
Sub-directory for this view file.
-
theme string
Theme name.
-
uuids array
List of generated DOM UUIDs
-
validationErrors array
holds current errors for the model validation
-
viewPath string Path to View
Path to View.
-
viewVars array
Variables for the view
Method Summary:
- addScript( $name, $content = NULL )
- cakeError( $method, $messages = array ( ) )
- _clearBuffer( )
- __construct( $controller )
- dispatchMethod( $method, $params = array ( ) )
- element( $name, $params = array ( ), $loadHelpers = false )
- entity( )
- error( $code, $name, $message )
- _flushBuffer( )
- _getLayoutFileName( $name = NULL )
- getVar( $var )
- getVars( )
- _getViewFileName( $name = NULL )
- _header( $header, $boolean = true )
- _isActive( )
- _loadHelpers( $loaded, $helpers, $parent = NULL )
- log( $msg, $type = 2 )
- _missingView( $file, $error = 'missingView' )
- Object( )
- _output( )
- _paths( $plugin = NULL, $cached = true )
- _persist( $name, $return, $object, $type = NULL )
- _render( $___viewFn, $___dataForView, $loadHelpers = true, $cached = false )
- render( )
- renderCache( $filename, $timeStart )
- renderLayout( $content_for_layout, $layout = NULL )
- requestAction( $url, $extra = array ( ) )
- _savePersistent( $name, $object )
- set( $one, $two = NULL )
- _set( $properties = array ( ) )
- _stop( $status = 0 )
- toString( )
- _triggerHelpers( $callback )
- uuid( $object, $url )
addScript
topAdds a script block or other element to be inserted in $scripts_for_layout in
the <head /> of a document layout
- Parameters:
-
-
string $name required
Either the key name for the script, or the script content. Name can be used to update/replace a script element.
-
string $content optional NULL
The content of the script being added, optional.
-
- Method defined in:
- cake/libs/view/view.php on line 587
- Return
void
- Access
public
cakeError
topUsed to report user friendly errors. If there is a file app/error.php or app/app_error.php this file will be loaded error.php is the AppError class it should extend ErrorHandler class.
- Parameters:
-
-
string $method required
Method to be called in the error class (AppError or ErrorHandler classes)
-
array $messages optional array ( )
Message that is to be displayed by the error class
-
- Method defined in:
- cake/libs/object.php on line 187
- Return
error message
- Access
public
_clearBuffer
topClears the contents of the topmost output buffer and discards them
- Method defined in:
- cake/libs/view/media.php on line 273
- Return
boolean
- Access
protected
__construct
topConstructor
- Parameters:
-
-
object $controller required
-
- Method defined in:
- cake/libs/view/media.php on line 98
dispatchMethod
topCalls a method on this object with the given parameters. Provides an OO wrapper
for call_user_func_array
- Parameters:
-
-
string $method required
Name of the method to call
-
array $params optional array ( )
Parameter list to use when calling $method
-
- Method defined in:
- cake/libs/object.php on line 107
- Return
mixed Returns the result of the method call
- Access
public
element
topRenders a piece of PHP with provided parameters and returns HTML, XML, or any other string.
This realizes the concept of Elements, (or "partial layouts") and the $params array is used to send data to be used in the Element. Elements can be cached through use of the cache key.
Special params
cache- enable caching for this element accepts boolean or strtotime compatible string. Can also be an array. Ifcacheis an array,timeis used to specify duration of cache.keycan be used to create unique cache files.plugin- Load an element from a specific plugin.
- Parameters:
-
-
string $name required
Name of template file in the/app/views/elements/ folder
-
array $params optional array ( )
Array of data to be made available to the for rendered view (i.e. the Element)
-
$loadHelpers optional false
-
- Method defined in:
- cake/libs/view/view.php on line 343
- Return
string Rendered Element
- Access
public
entity
topReturns the entity reference of the current context as an array of identity parts
- Method defined in:
- cake/libs/view/view.php on line 623
- Return
array An array containing the identity elements of an entity
- Access
public
error
topDisplays an error page to the user. Uses layouts/error.ctp to render the page.
- Parameters:
-
-
integer $code required
HTTP Error code (for instance: 404)
-
string $name required
Name of the error (for instance: Not Found)
-
string $message required
Error message as a web page
-
- Method defined in:
- cake/libs/view/view.php on line 678
- Access
public
_flushBuffer
topFlushes the contents of the output buffer
- Method defined in:
- cake/libs/view/media.php on line 281
- Access
protected
_getLayoutFileName
topReturns layout filename for this template as a string.
- Parameters:
-
-
string $name optional NULL
The name of the layout to find.
-
- Method defined in:
- cake/libs/view/view.php on line 890
- Return
string Filename for layout file (.ctp).
- Access
protected
getVar
topReturns the contents of the given View variable(s)
- Parameters:
-
-
string $var required
The view var you want the contents of.
-
- Method defined in:
- cake/libs/view/view.php on line 569
- Return
mixed The content of the named var if its set, otherwise null.
- Access
public
getVars
topReturns a list of variables available in the current View context
- Method defined in:
- cake/libs/view/view.php on line 558
- Return
array Array of the set view variable names.
- Access
public
_getViewFileName
topReturns filename of given action's template file (.ctp) as a string. CamelCased action names will be under_scored! This means that you can have LongActionNames that refer to long_action_names.ctp views.
- Parameters:
-
-
string $name optional NULL
Controller action to find template filename for
-
- Method defined in:
- cake/libs/view/view.php on line 830
- Return
string Template filename
- Access
protected
_header
topMethod to set headers
- Parameters:
-
-
mixed $header required
-
boolean $boolean optional true
-
- Method defined in:
- cake/libs/view/media.php on line 233
- Access
protected
_isActive
topReturns true if connection is still active
- Method defined in:
- cake/libs/view/media.php on line 264
- Return
boolean
- Access
protected
_loadHelpers
topLoads helpers, with their dependencies.
- Parameters:
-
-
array $loaded required
List of helpers that are already loaded.
-
array $helpers required
List of helpers to load.
-
string $parent optional NULL
holds name of helper, if loaded helper has helpers
-
- Method defined in:
- cake/libs/view/view.php on line 763
- Return
array Array containing the loaded helpers.
- Access
protected
log
topConvience method to write a message to CakeLog. See CakeLog::write() for more information on writing to logs.
- Parameters:
-
-
string $msg required
Log message
-
integer $type optional 2
Error type constant. Defined in app/config/core.php.
-
- Method defined in:
- cake/libs/object.php on line 148
- Return
boolean Success of log write
- Access
public
_missingView
topReturn a misssing view error message
- Parameters:
-
-
$file required
-
$error optional 'missingView'
-
- Method defined in:
- cake/libs/view/view.php on line 923
- Return
false
- Access
protected
Object
topA hack to support __construct() on PHP 4 Hint: descendant classes have no PHP4 class_name() constructors, so this constructor gets called first and calls the top-layer __construct() which (if present) should call parent::__construct()
- Method defined in:
- cake/libs/object.php on line 43
- Return
Object
_output
top_paths
topReturn all possible paths to find view files in order
- Parameters:
-
-
string $plugin optional NULL
Optional plugin name to scan for view files.
-
boolean $cached optional true
Set to true to force a refresh of view paths.
-
- Method defined in:
- cake/libs/view/view.php on line 950
- Return
array paths
- Access
protected
_persist
topChecks for a persistent class file, if found file is opened and true returned If file is not found a file is created and false returned If used in other locations of the model you should choose a unique name for the persistent file There are many uses for this method, see manual for examples
- Parameters:
-
-
string $name required
name of the class to persist
-
$return required
-
string $object required
the object to persist
-
$type optional NULL
-
- Method defined in:
- cake/libs/object.php on line 218
- Return
boolean Success
- Access
protected
- Todo
add examples to manual
_render
topRenders and returns output for given view filename with its array of data.
- Parameters:
-
-
string $___viewFn required
Filename of the view
-
array $___dataForView required
Data to include in rendered view
-
boolean $loadHelpers optional true
Boolean to indicate that helpers should be loaded.
-
boolean $cached optional false
Whether or not to trigger the creation of a cache file.
-
- Method defined in:
- cake/libs/view/view.php on line 697
- Return
string Rendered output
- Access
protected
render
topDisplay or download the given file
- Method defined in:
- cake/libs/view/media.php on line 107
- Return
unknown
renderCache
topRender cached view. Works in concert with CacheHelper and Dispatcher to render cached view files.
- Parameters:
-
-
string $filename required
the cache file to include
-
string $timeStart required
the page render start time
-
- Method defined in:
- cake/libs/view/view.php on line 527
- Return
boolean Success of rendering the cached file.
- Access
public
renderLayout
topRenders a layout. Returns output from _render(). Returns false on error. Several variables are created for use in layout.
title_for_layout- A backwards compatible place holder, you should set this value if you want more control.content_for_layout- contains rendered view filescripts_for_layout- contains scripts added to header
- Parameters:
-
-
string $content_for_layout required
Content to render in a view, wrapped by the surrounding layout.
-
$layout optional NULL
-
- Method defined in:
- cake/libs/view/view.php on line 459
- Return
mixed Rendered output, or false on error
- Access
public
requestAction
topCalls a controller's method from any location. Can be used to connect controllers together or tie plugins into a main application. requestAction can be used to return rendered views or fetch the return value from controller actions.
- Parameters:
-
-
mixed $url required
String or array-based url.
-
array $extra optional array ( )
if array includes the key "return" it sets the AutoRender to true.
-
- Method defined in:
- cake/libs/object.php on line 80
- Return
mixed Boolean true or false on success/failure, or contents of rendered action if 'return' is set in $extra.
- Access
public
_savePersistent
topYou should choose a unique name for the persistent file
There are many uses for this method, see manual for examples
- Parameters:
-
-
string $name required
name used for object to cache
-
object $object required
the object to persist
-
- Method defined in:
- cake/libs/object.php on line 247
- Return
boolean true on save, throws error if file can not be created
- Access
protected
set
topAllows a template or element to set a variable that will be available in a layout or other element. Analagous to Controller::set.
- Parameters:
-
-
mixed $one required
A string or an array of data.
-
mixed $two optional NULL
Value in case $one is a string (which then works as the key). Unused if $one is an associative array, otherwise serves as the values to $one's keys.
-
- Method defined in:
- cake/libs/view/view.php on line 653
- Return
void
- Access
public
_set
topAllows setting of multiple properties of the object in a single line of code. Will only set properties that are part of a class declaration.
- Parameters:
-
-
array $properties optional array ( )
An associative array containing properties and corresponding values.
-
- Method defined in:
- cake/libs/object.php on line 166
- Return
void
- Access
protected
_stop
topStop execution of the current script. Wraps exit() making testing easier.
- Parameters:
-
-
$status optional 0
-
- Method defined in:
- cake/libs/object.php on line 135
- Return
void
- Access
public
toString
topObject-to-string conversion. Each class can override this method as necessary.
- Method defined in:
- cake/libs/object.php on line 64
- Return
string The name of this class
- Access
public
_triggerHelpers
topFire a callback on all loaded Helpers. All helpers must implement this method, it is not checked before being called. You can add additional helper callbacks in AppHelper.
- Parameters:
-
-
string $callback required
name of callback fire.
-
- Method defined in:
- cake/libs/view/view.php on line 503
- Access
protected
- Return
void
uuid
topGenerates a unique, non-random DOM ID for an object, based on the object type and the target URL.
- Parameters:
-
-
string $object required
Type of object, i.e. 'form' or 'link'
-
string $url required
The object's target URL
-
- Method defined in:
- cake/libs/view/view.php on line 605
- Return
string
- Access
public