| Name | Size | Mode | Actions |
|---|---|---|---|
| Elements/ | - | 0755 | rm |
| Errors/ | - | 0755 | rm |
| Helper/ | - | 0755 | rm |
| Scaffolds/ | - | 0755 | rm |
| Helper.php | 28841 | 0644 | editdlrm |
| HelperCollection.php | 6608 | 0644 | editdlrm |
| JsonView.php | 5400 | 0644 | editdlrm |
| MediaView.php | 3262 | 0644 | editdlrm |
| ScaffoldView.php | 2425 | 0644 | editdlrm |
| ThemeView.php | 918 | 0644 | editdlrm |
| View.php | 35481 | 0644 | editdlrm |
| ViewBlock.php | 6034 | 0644 | editdlrm |
| XmlView.php | 4420 | 0644 | editdlrm |
/home/desid573/book.familycab.com.au/pdd/lib/Cake/View/View.php (35481B)
` of a document layout * * @param string $name Either the key name for the script, or the script content. Name can be used to * update/replace a script element. * @param string $content The content of the script being added, optional. * @return void * @deprecated 3.0.0 Will be removed in 3.0. Superseded by blocks functionality. * @see View::start() */ public function addScript($name, $content = null) { if (empty($content)) { if (!in_array($name, array_values($this->_scripts))) { $this->_scripts[] = $name; } } else { $this->_scripts[$name] = $content; } } /** * Generates a unique, non-random DOM ID for an object, based on the object type and the target URL. * * @param string $object Type of object, i.e. 'form' or 'link' * @param string $url The object's target URL * @return string */ public function uuid($object, $url) { $c = 1; $url = Router::url($url); $hash = $object . substr(md5($object . $url), 0, 10); while (in_array($hash, $this->uuids)) { $hash = $object . substr(md5($object . $url . $c), 0, 10); $c++; } $this->uuids[] = $hash; return $hash; } /** * Allows a template or element to set a variable that will be available in * a layout or other element. Analogous to Controller::set(). * * @param string|array $one A string or an array of data. * @param string|array $two 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. * @return void */ public function set($one, $two = null) { $data = null; if (is_array($one)) { if (is_array($two)) { $data = array_combine($one, $two); } else { $data = $one; } } else { $data = array($one => $two); } if (!$data) { return false; } $this->viewVars = $data + $this->viewVars; } /** * Retrieve the current view type * * @return string */ public function getCurrentType() { return $this->_currentType; } /** * Magic accessor for helpers. Provides access to attributes that were deprecated. * * @param string $name Name of the attribute to get. * @return mixed */ public function __get($name) { switch ($name) { case 'base': case 'here': case 'webroot': case 'data': return $this->request->{$name}; case 'action': return $this->request->params['action']; case 'params': return $this->request; case 'output': return $this->Blocks->get('content'); } if (isset($this->Helpers->{$name})) { $this->{$name} = $this->Helpers->{$name}; return $this->Helpers->{$name}; } return $this->{$name}; } /** * Magic accessor for deprecated attributes. * * @param string $name Name of the attribute to set. * @param mixed $value Value of the attribute to set. * @return mixed */ public function __set($name, $value) { switch ($name) { case 'output': return $this->Blocks->set('content', $value); default: $this->{$name} = $value; } } /** * Magic isset check for deprecated attributes. * * @param string $name Name of the attribute to check. * @return bool */ public function __isset($name) { if (isset($this->{$name})) { return true; } $magicGet = array('base', 'here', 'webroot', 'data', 'action', 'params', 'output'); if (in_array($name, $magicGet)) { return $this->__get($name) !== null; } return false; } /** * Interact with the HelperCollection to load all the helpers. * * @return void */ public function loadHelpers() { $helpers = HelperCollection::normalizeObjectArray($this->helpers); foreach ($helpers as $properties) { list(, $class) = pluginSplit($properties['class']); $this->{$class} = $this->Helpers->load($properties['class'], $properties['settings']); } } /** * Renders and returns output for given view filename with its * array of data. Handles parent/extended views. * * @param string $viewFile Filename of the view * @param array $data Data to include in rendered view. If empty the current View::$viewVars will be used. * @return string Rendered output * @triggers View.beforeRenderFile $this, array($viewFile) * @triggers View.afterRenderFile $this, array($viewFile, $content) * @throws CakeException when a block is left open. */ protected function _render($viewFile, $data = array()) { if (empty($data)) { $data = $this->viewVars; } $this->_current = $viewFile; $initialBlocks = count($this->Blocks->unclosed()); $eventManager = $this->getEventManager(); $beforeEvent = new CakeEvent('View.beforeRenderFile', $this, array($viewFile)); $eventManager->dispatch($beforeEvent); $content = $this->_evaluate($viewFile, $data); $afterEvent = new CakeEvent('View.afterRenderFile', $this, array($viewFile, $content)); $afterEvent->modParams = 1; $eventManager->dispatch($afterEvent); $content = $afterEvent->data[1]; if (isset($this->_parents[$viewFile])) { $this->_stack[] = $this->fetch('content'); $this->assign('content', $content); $content = $this->_render($this->_parents[$viewFile]); $this->assign('content', array_pop($this->_stack)); } $remainingBlocks = count($this->Blocks->unclosed()); if ($initialBlocks !== $remainingBlocks) { throw new CakeException(__d('cake_dev', 'The "%s" block was left open. Blocks are not allowed to cross files.', $this->Blocks->active())); } return $content; } /** * Sandbox method to evaluate a template / view script in. * * @param string $viewFile Filename of the view * @param array $dataForView Data to include in rendered view. * If empty the current View::$viewVars will be used. * @return string Rendered output */ protected function _evaluate($viewFile, $dataForView) { $this->__viewFile = $viewFile; extract($dataForView); ob_start(); include $this->__viewFile; unset($this->__viewFile); return ob_get_clean(); } /** * Loads a helper. Delegates to the `HelperCollection::load()` to load the helper * * @param string $helperName Name of the helper to load. * @param array $settings Settings for the helper * @return Helper a constructed helper object. * @see HelperCollection::load() */ public function loadHelper($helperName, $settings = array()) { return $this->Helpers->load($helperName, $settings); } /** * Returns 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. * * @param string $name Controller action to find template filename for * @return string Template filename * @throws MissingViewException when a view file could not be found. */ protected function _getViewFileName($name = null) { $subDir = null; if ($this->subDir !== null) { $subDir = $this->subDir . DS; } if ($name === null) { $name = $this->view; } $name = str_replace('/', DS, $name); list($plugin, $name) = $this->pluginSplit($name); if (strpos($name, DS) === false && $name[0] !== '.') { $name = $this->viewPath . DS . $subDir . Inflector::underscore($name); } elseif (strpos($name, DS) !== false) { if ($name[0] === DS || $name[1] === ':') { $name = trim($name, DS); } elseif ($name[0] === '.') { $name = substr($name, 3); } elseif (!$plugin || $this->viewPath !== $this->name) { $name = $this->viewPath . DS . $subDir . $name; } } $paths = $this->_paths($plugin); $exts = $this->_getExtensions(); foreach ($exts as $ext) { foreach ($paths as $path) { if (file_exists($path . $name . $ext)) { return $path . $name . $ext; } } } throw new MissingViewException(array('file' => $name . $this->ext)); } /** * Splits a dot syntax plugin name into its plugin and filename. * If $name does not have a dot, then index 0 will be null. * It checks if the plugin is loaded, else filename will stay unchanged for filenames containing dot * * @param string $name The name you want to plugin split. * @param bool $fallback If true uses the plugin set in the current CakeRequest when parsed plugin is not loaded * @return array Array with 2 indexes. 0 => plugin name, 1 => filename */ public function pluginSplit($name, $fallback = true) { $plugin = null; list($first, $second) = pluginSplit($name); if (CakePlugin::loaded($first) === true) { $name = $second; $plugin = $first; } if (isset($this->plugin) && !$plugin && $fallback) { $plugin = $this->plugin; } return array($plugin, $name); } /** * Returns layout filename for this template as a string. * * @param string $name The name of the layout to find. * @return string Filename for layout file (.ctp). * @throws MissingLayoutException when a layout cannot be located */ protected function _getLayoutFileName($name = null) { if ($name === null) { $name = $this->layout; } $subDir = null; if ($this->layoutPath !== null) { $subDir = $this->layoutPath . DS; } list($plugin, $name) = $this->pluginSplit($name); $paths = $this->_paths($plugin); $file = 'Layouts' . DS . $subDir . $name; $exts = $this->_getExtensions(); foreach ($exts as $ext) { foreach ($paths as $path) { if (file_exists($path . $file . $ext)) { return $path . $file . $ext; } } } throw new MissingLayoutException(array('file' => $file . $this->ext)); } /** * Get the extensions that view files can use. * * @return array Array of extensions view files use. */ protected function _getExtensions() { $exts = array($this->ext); if ($this->ext !== '.ctp') { $exts[] = '.ctp'; } return $exts; } /** * Finds an element filename, returns false on failure. * * @param string $name The name of the element to find. * @return mixed Either a string to the element filename or false when one can't be found. */ protected function _getElementFileName($name) { list($plugin, $name) = $this->pluginSplit($name); $paths = $this->_paths($plugin); $exts = $this->_getExtensions(); foreach ($exts as $ext) { foreach ($paths as $path) { if (file_exists($path . 'Elements' . DS . $name . $ext)) { return $path . 'Elements' . DS . $name . $ext; } } } return false; } /** * Return all possible paths to find view files in order * * @param string $plugin Optional plugin name to scan for view files. * @param bool $cached Set to false to force a refresh of view paths. Default true. * @return array paths */ protected function _paths($plugin = null, $cached = true) { if ($cached === true) { if ($plugin === null && !empty($this->_paths)) { return $this->_paths; } if ($plugin !== null && isset($this->_pathsForPlugin[$plugin])) { return $this->_pathsForPlugin[$plugin]; } } $paths = array(); $viewPaths = App::path('View'); $corePaths = array_merge(App::core('View'), App::core('Console/Templates/skel/View')); if (!empty($plugin)) { $count = count($viewPaths); for ($i = 0; $i < $count; $i++) { if (!in_array($viewPaths[$i], $corePaths)) { $paths[] = $viewPaths[$i] . 'Plugin' . DS . $plugin . DS; } } $paths = array_merge($paths, App::path('View', $plugin)); } $paths = array_unique(array_merge($paths, $viewPaths)); if (!empty($this->theme)) { $theme = Inflector::camelize($this->theme); $themePaths = array(); foreach ($paths as $path) { if (strpos($path, DS . 'Plugin' . DS) === false) { if ($plugin) { $themePaths[] = $path . 'Themed' . DS . $theme . DS . 'Plugin' . DS . $plugin . DS; } $themePaths[] = $path . 'Themed' . DS . $theme . DS; } } $paths = array_merge($themePaths, $paths); } $paths = array_merge($paths, $corePaths); if ($plugin !== null) { return $this->_pathsForPlugin[$plugin] = $paths; } return $this->_paths = $paths; } /** * Checks if an element is cached and returns the cached data if present * * @param string $name Element name * @param string $data Data * @param array $options Element options * @return string|null */ protected function _elementCache($name, $data, $options) { $plugin = null; list($plugin, $name) = $this->pluginSplit($name); $underscored = null; if ($plugin) { $underscored = Inflector::underscore($plugin); } $keys = array_merge(array($underscored, $name), array_keys($options), array_keys($data)); $this->elementCacheSettings = array( 'config' => $this->elementCache, 'key' => implode('_', $keys) ); if (is_array($options['cache'])) { $defaults = array( 'config' => $this->elementCache, 'key' => $this->elementCacheSettings['key'] ); $this->elementCacheSettings = array_merge($defaults, $options['cache']); } $this->elementCacheSettings['key'] = 'element_' . $this->elementCacheSettings['key']; return Cache::read($this->elementCacheSettings['key'], $this->elementCacheSettings['config']); } /** * Renders an element and fires the before and afterRender callbacks for it * and writes to the cache if a cache is used * * @param string $file Element file path * @param array $data Data to render * @param array $options Element options * @return string * @triggers View.beforeRender $this, array($file) * @triggers View.afterRender $this, array($file, $element) */ protected function _renderElement($file, $data, $options) { $current = $this->_current; $restore = $this->_currentType; $this->_currentType = static::TYPE_ELEMENT; if ($options['callbacks']) { $this->getEventManager()->dispatch(new CakeEvent('View.beforeRender', $this, array($file))); } $element = $this->_render($file, array_merge($this->viewVars, $data)); if ($options['callbacks']) { $this->getEventManager()->dispatch(new CakeEvent('View.afterRender', $this, array($file, $element))); } $this->_currentType = $restore; $this->_current = $current; if (isset($options['cache'])) { Cache::write($this->elementCacheSettings['key'], $element, $this->elementCacheSettings['config']); } return $element; } }