diff --git a/cake/libs/configure.php b/cake/libs/configure.php index d19fbf2f9..c8695a478 100644 --- a/cake/libs/configure.php +++ b/cake/libs/configure.php @@ -171,29 +171,25 @@ class Configure extends Object { return false; } + $objects = array(); + if (empty($path)) { $pathVar = $type . 'Paths'; $path = $_this->{$pathVar}; } - $objects = array(); - $search = array_merge(array(APP), $_this->corePaths($type)); - - foreach ($search as $delete) { - if (is_array($path) && in_array($delete, $path)) { - $remove = array_flip($path); - unset($remove[$delete]); - $path = array_flip($remove); - } - } + $items = array(); foreach ((array)$path as $dir) { - $items = $_this->__list($dir, $types[$type]['suffix'], $extension); - $objects = array_merge($items, $objects); + if($type === 'file' || $type === 'class' || strpos($dir, $type) !== false) { + $items = $_this->__list($dir, $types[$type]['suffix'], $extension); + $objects = array_merge($items, array_diff($objects, $items)); + } } if ($type !== 'file') { $objects = array_map(array(&$Inflector, 'camelize'), $objects); } + $_this->__objects[$name] = $objects; $_this->__cache = true; } @@ -207,6 +203,7 @@ class Configure extends Object { * @return array List of directories or files in directory */ function __list($path, $suffix = false, $extension = false) { + $_this =& Configure::getInstance(); if (!class_exists('folder')) { uses('folder'); } @@ -443,42 +440,42 @@ class Configure extends Object { */ function corePaths($type = null) { $paths = Cache::read('core_paths', '_cake_core_'); - + $paths = false; if (!$paths) { $all = explode(PATH_SEPARATOR, ini_get('include_path')); $all = array_flip(array_flip((array_merge(array(CAKE_CORE_INCLUDE_PATH), $all)))); - + $used = array(); foreach ($all as $path) { $path = rtrim($path, DS); - - if ($path == '.') { + if ($path == '.' || in_array(realpath($path), $used)) { continue; } if (is_dir($path . DS . 'cake' . DS . 'libs' . DS . 'model')) { - $paths['model'][] = $path . DS . 'cake' . DS . 'libs' . DS . 'model'; + $paths['model'][] = $path . DS . 'cake' . DS . 'libs' . DS . 'model' . DS; } if (is_dir($path . DS . 'cake' . DS . 'libs' . DS . 'model' . DS . 'behaviors')) { - $paths['behavior'][] = $path . DS . 'cake' . DS . 'libs' . DS . 'model' . DS . 'behaviors'; + $paths['behavior'][] = $path . DS . 'cake' . DS . 'libs' . DS . 'model' . DS . 'behaviors' . DS; } if (is_dir($path . DS . 'cake' . DS . 'libs' . DS . 'controller')) { - $paths['controller'][] = $path . DS . 'cake' . DS . 'libs' . DS . 'controller'; + $paths['controller'][] = $path . DS . 'cake' . DS . 'libs' . DS . 'controller' . DS; } if (is_dir($path . DS . 'cake' . DS . 'libs' . DS . 'controller' . DS . 'components')) { - $paths['component'][] = $path . DS . 'cake' . DS . 'libs' . DS . 'controller' . DS . 'components'; + $paths['component'][] = $path . DS . 'cake' . DS . 'libs' . DS . 'controller' . DS . 'components' . DS; } if (is_dir($path . DS . 'cake' . DS . 'libs' . DS . 'view')) { - $paths['view'][] = $path . DS . 'cake' . DS . 'libs' . DS . 'view'; + $paths['view'][] = $path . DS . 'cake' . DS . 'libs' . DS . 'view' . DS; } if (is_dir($path . DS . 'cake' . DS . 'libs' . DS . 'view' . DS . 'helpers')) { - $paths['helper'][] = $path . DS . 'cake' . DS . 'libs' . DS . 'view' . DS . 'helpers'; + $paths['helper'][] = $path . DS . 'cake' . DS . 'libs' . DS . 'view' . DS . 'helpers' . DS; } if (is_dir($path . DS . 'cake' . DS . 'libs')) { - $paths['libs'][] = $path . DS . 'cake' . DS . 'libs'; + $paths['libs'][] = $path . DS . 'cake' . DS . 'libs' . DS; } if (is_dir($path . DS . 'cake')) { - $paths['cake'][] = $path . DS . 'cake'; - $paths['class'][] = $path . DS . 'cake'; + $paths['cake'][] = $path . DS . 'cake' . DS; + $paths['class'][] = $path . DS . 'cake' . DS; } + $used[] = $path; } Cache::write('core_paths', array_filter($paths), '_cake_core_'); } @@ -897,7 +894,7 @@ class App extends Object { } foreach ($_this->__paths[$path] as $directory) { - if ($_this->__load($directory . DS . $file)) { + if ($_this->__load($directory . DS . $file)) { return $directory . DS; } } diff --git a/cake/libs/controller/scaffold.php b/cake/libs/controller/scaffold.php index 0d36dbb20..b836cb2b7 100644 --- a/cake/libs/controller/scaffold.php +++ b/cake/libs/controller/scaffold.php @@ -187,6 +187,7 @@ class Scaffold extends Object { $this->controller->set(compact('modelClass', 'primaryKey', 'displayField', 'singularVar', 'pluralVar', 'singularHumanName', 'pluralHumanName', 'scaffoldFields', 'associations')); + $this->controller->view = 'scaffold'; $this->__scaffold($params); } /** @@ -211,7 +212,7 @@ class Scaffold extends Object { $this->controller->data = $this->ScaffoldModel->read(); $this->controller->set(Inflector::variable($this->controller->modelClass), $this->controller->data); - $this->controller->render($this->action, $this->layout, $this->__getViewFileName($params['action'])); + $this->controller->render($this->action, $this->layout); } elseif ($this->controller->_scaffoldError('view') === false) { return $this->__scaffoldError(); } @@ -227,7 +228,7 @@ class Scaffold extends Object { if ($this->controller->_beforeScaffold('index')) { $this->ScaffoldModel->recursive = 0; $this->controller->set(Inflector::variable($this->controller->name), $this->controller->paginate()); - $this->controller->render($this->action, $this->layout, $this->__getViewFileName($params['action'])); + $this->controller->render($this->action, $this->layout); } elseif ($this->controller->_scaffoldError('index') === false) { return $this->__scaffoldError(); } @@ -240,7 +241,7 @@ class Scaffold extends Object { * @access private */ function __scaffoldForm($action = 'edit') { - $this->controller->render($action, $this->layout, $this->__getViewFileName($action)); + $this->controller->render($action, $this->layout); } /** * Saves or updates the scaffolded model. @@ -443,66 +444,6 @@ class Scaffold extends Object { return $this->cakeError('missingDatabase', array(array('webroot' => $this->controller->webroot))); } } -/** - * Returns scaffold view filename of given action's template file (.ctp) as a string. - * - * @param string $action Controller action to find template filename for - * @return string Template filename - * @access private - */ - function __getViewFileName($action) { - $action = Inflector::underscore($action); - $scaffoldAction = 'scaffold.'.$action; - $paths = Configure::getInstance(); - - if (!is_null($this->webservices)) { - $type = strtolower($this->webservices) . DS; - } else { - $type = null; - } - - if (!is_null($this->plugin)) { - if (file_exists(APP . 'views' . DS . 'plugins' . DS . $this->plugin . DS . $this->subDir . $type . $scaffoldAction . $this->ext)) { - return APP . 'views' . DS . 'plugins' . DS . $this->plugin . DS . $this->subDir . $type . $scaffoldAction . $this->ext; - } elseif (file_exists(APP . 'views' . DS . 'plugins' . DS . $this->plugin . DS . $this->subDir . $type . $scaffoldAction . $this->ext)) { - return APP . 'views' . DS . 'plugins' . DS . $this->plugin . DS . $this->subDir . $type . $scaffoldAction . $this->ext; - } elseif (file_exists(APP . 'plugins' . DS . $this->plugin . DS . 'views' . DS . $this->viewPath . DS . $scaffoldAction . $this->ext)) { - return APP . 'plugins' . DS . $this->plugin . DS . 'views' . DS . $this->viewPath . DS . $scaffoldAction . $this->ext; - } elseif (file_exists(APP . 'views' . DS . 'plugins' . DS . $this->plugin . DS . $this->subDir . $type . $scaffoldAction . '.ctp')) { - return APP . 'views' . DS . 'plugins' . DS . $this->plugin . DS . $this->subDir . $type . $scaffoldAction . '.ctp'; - } elseif (file_exists(APP . 'views' . DS . 'plugins' . DS . $this->plugin . DS . $this->subDir . $type . $scaffoldAction . '.thtml')) { - return APP . 'views' . DS . 'plugins' . DS . $this->plugin . DS . $this->subDir . $type . $scaffoldAction . '.thtml'; - } elseif (file_exists(APP . 'views' . DS . 'plugins' . DS . 'scaffolds'. DS . $this->subDir . $type . $scaffoldAction . '.ctp')) { - return APP . 'views' . DS . 'plugins' . DS . 'scaffolds'. DS . $this->subDir . $type . $scaffoldAction . '.ctp'; - } elseif (file_exists(APP . 'views' . DS . 'plugins' . DS . 'scaffolds'. DS . $this->subDir . $type . $scaffoldAction . '.thtml')) { - return APP . 'views' . DS . 'plugins' . DS . 'scaffolds'. DS . $this->subDir . $type . $scaffoldAction . '.thtml'; - } elseif (file_exists(APP . 'plugins' . DS . $this->plugin . DS . 'views' . DS . $this->viewPath . DS . $scaffoldAction . '.ctp')) { - return APP . 'plugins' . DS . $this->plugin . DS . 'views' . DS . $this->viewPath . DS . $scaffoldAction . '.ctp'; - } elseif (file_exists(APP . 'plugins' . DS . $this->plugin . DS . 'views' . DS . $this->viewPath . DS . $scaffoldAction . '.thtml')) { - return APP . 'plugins' . DS . $this->plugin . DS . 'views' . DS . $this->viewPath . DS . $scaffoldAction . '.thtml'; - } - } - - foreach ($paths->viewPaths as $path) { - if (file_exists($path . $this->viewPath . DS . $this->subDir . $type . $scaffoldAction . $this->ext)) { - return $path . $this->viewPath . DS . $this->subDir . $type . $scaffoldAction . $this->ext; - } elseif (file_exists($path . 'scaffolds' . DS . $this->subDir . $type . $scaffoldAction . $this->ext)) { - return $path . 'scaffolds' . DS . $this->subDir . $type . $scaffoldAction . $this->ext; - } elseif (file_exists($path . $this->viewPath . DS . $this->subDir . $type . $scaffoldAction . '.ctp')) { - return $path . $this->viewPath . DS . $this->subDir . $type . $scaffoldAction . '.ctp'; - } elseif (file_exists($path . $this->viewPath . DS . $this->subDir . $type . $scaffoldAction . '.thtml')) { - return $path . $this->viewPath . DS . $this->subDir . $type . $scaffoldAction . '.thtml'; - } elseif (file_exists($path . 'scaffolds' . DS . $this->subDir . $type . $scaffoldAction . '.ctp')) { - return $path . 'scaffolds' . DS . $this->subDir . $type . $scaffoldAction . '.ctp'; - } elseif (file_exists($path . 'scaffolds' . DS . $this->subDir . $type . $scaffoldAction . '.thtml')) { - return $path . 'scaffolds' . DS . $this->subDir . $type . $scaffoldAction . '.thtml'; - } - } - if ($action === 'add') { - $action = 'edit'; - } - return LIBS . 'view' . DS . 'templates' . DS . 'scaffolds' . DS . $action . '.ctp'; - } /** * Returns associations for controllers models. * @@ -524,4 +465,62 @@ class Scaffold extends Object { return $associations; } } -?> +/** + * Scaffold View. + * + * @package cake + * @subpackage cake.cake.libs.controller +*/ +if (!class_exists('ThemeView')) { + App::import('View', 'Theme'); +} +class ScaffoldView extends ThemeView { +/** + * Override _getViewFileName + * + * @return string action + * @access protected + */ + function _getViewFileName($name = null) { + if ($name === null) { + $name = $this->action; + } + $name = Inflector::underscore($name); + $scaffoldAction = 'scaffold.'.$name; + + if (!is_null($this->webservices)) { + $subDir = strtolower($this->webservices) . DS; + } else { + $subDir = null; + } + if (!is_null($this->subDir)) { + $subDir = strtolower($this->subDir) . DS; + } else { + $subDir = null; + } + + if ($name === 'add') { + $name = 'edit'; + } + + $names[] = $this->viewPath . DS . $subDir . $scaffoldAction; + $names[] = 'scaffolds' . DS . $subDir . $name; + + $paths = $this->_paths($this->plugin); + + foreach ($paths as $path) { + foreach ($names as $name) { + if (file_exists($path . $name . $this->ext)) { + return $path . $name . $this->ext; + } elseif (file_exists($path . $name . '.ctp')) { + return $path . $name . '.thtml'; + } elseif (file_exists($path . $name . '.thtml')) { + return $path . $name . '.thtml'; + } + } + } + + return $this->_missingView($paths[0] . $name . $this->ext, 'missingView'); + } +} +?> \ No newline at end of file diff --git a/cake/libs/view/theme.php b/cake/libs/view/theme.php index d8c3aa6f2..bd137d2ff 100644 --- a/cake/libs/view/theme.php +++ b/cake/libs/view/theme.php @@ -64,6 +64,7 @@ class ThemeView extends View { if (is_dir(WWW_ROOT . 'themed' . DS . $this->theme)) { $this->themeWeb = 'themed/'. $this->theme .'/'; } + /* deprecated: as of 6128 the following properties are no longer needed */ $this->themeElement = 'themed'. DS . $this->theme . DS .'elements'. DS; $this->themeLayout = 'themed'. DS . $this->theme . DS .'layouts'. DS; $this->themePath = 'themed'. DS . $this->theme . DS; @@ -71,201 +72,28 @@ class ThemeView extends View { } /** - * Enter description here... + * Return all possible paths to find view files in order * - * @param unknown_type $code - * @param unknown_type $name - * @param unknown_type $message + * @param string $plugin + * @return array paths + * @access private */ - function error($code, $name, $message) { - $file = VIEWS . $this->themeLayout.'error'.$this->ext; - if (!file_exists($file)) { - $file = LAYOUTS.'error'.$this->ext; - } - header ("HTTP/1.0 {$code} {$name}"); - print ($this->_render($file, array('code' => $code, - 'name' => $name, - 'message' => $message))); - } -/** - * Renders 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. - * - * @link - * @param string $name Name of template file in the/app/views/elements/ folder - * @param array $params Array of data to be made available to the for rendered view (i.e. the Element) - * @return string Rendered output - */ - function renderElement($name, $params = array(), $loadHelpers = false) { + function _paths($plugin = null, $cached = true) { + $paths = parent::_paths($plugin, $cached); - if (isset($params['plugin'])) { - $reset = array('plugin' => $this->plugin, - 'pluginPath' => $this->pluginPath, - 'pluginPaths' => $this->pluginPaths); - $this->plugin = $params['plugin']; - $this->pluginPath = 'plugins' . DS . $this->plugin . DS; - $this->pluginPaths = array( - VIEWS . $this->pluginPath, - APP . $this->pluginPath . 'views' . DS, - ); - } - - $paths = Configure::getInstance(); - $viewPaths = array_merge($this->pluginPaths, $paths->viewPaths); - - $file = null; - foreach ($viewPaths as $path) { - if (file_exists($path . $this->themeElement . $name . $this->ext)) { - $file = $path . $this->themeElement . $name . $this->ext; - break; - } elseif (file_exists($path . $this->themeElement . $name . '.thtml')) { - $file = $path . $this->themeElement . $name . '.thtml'; - break; - } elseif (file_exists($path . 'elements' . DS . $name . $this->ext)) { - $file = $path . 'elements' . DS . $name . $this->ext; - break; - } elseif (file_exists($path . 'elements' . DS . $name . '.thtml')) { - $file = $path . 'elements' . DS . $name . '.thtml'; - break; + if (!empty($this->theme)) { + $count = count($paths); + for ($i = 0; $i < $count; $i++) { + $themePaths[] = $paths[$i] . 'themed'. DS . $this->theme . DS; } + $paths = array_merge($themePaths, $paths); } - if (is_null($file)) { - $file = fileExistsInPath(LIBS . 'view' . DS . 'templates' . DS . 'elements' . DS . $name. '.ctp'); + if(empty($this->__paths)) { + $this->__paths = $paths; } - if ($file) { - $params = array_merge_recursive($params, $this->loaded); - $return = $this->_render($file, array_merge($this->viewVars, $params), $loadHelpers); - } else { - if (!is_null($this->pluginPath)) { - $file = APP . $this->pluginPath . $this->themeElement . $name . $this->ext; - } else { - $file = VIEWS . $this->themeElement . $name . $this->ext; - } - - if (Configure::read() > 0) { - $return = 'Not Found: ' . $file; - } - } - - if (isset($params['plugin'])) { - $this->plugin = $reset['plugin']; - $this->pluginPath = $reset['pluginPath']; - $this->pluginPaths = $reset['pluginPaths']; - } - - return $return; - } - -/** - * Enter description here... - * - * @param unknown_type $action - * @return unknown - */ - function _getViewFileName($action) { - $action = Inflector::underscore($action); - - if (!is_null($this->webservices)) { - $type = strtolower($this->webservices) . DS; - } else { - $type = null; - } - - $position = strpos($action, '..'); - if ($position !== false) { - $action = explode('/', $action); - $i = array_search('..', $action); - unset($action[$i - 1]); - unset($action[$i]); - $action = '..' . DS . implode(DS, $action); - } - - $paths = Configure::getInstance(); - $viewPaths = array_merge($this->pluginPaths, $paths->viewPaths); - - $name = $this->viewPath . DS . $this->subDir . $type . $action; - foreach ($viewPaths as $path) { - if (file_exists($path . $this->themePath . $name . $this->ext)) { - return $path . $this->themePath . $name . $this->ext; - } elseif (file_exists($path . $this->themePath . $name . '.thtml')) { - return $path . $this->themePath . $name . '.thtml'; - } elseif (file_exists($path . $name . $this->ext)) { - return $path . $name . $this->ext; - } elseif (file_exists($path . $name . '.thtml')) { - return $path . $name . '.thtml'; - } - } - - if ($viewFileName = fileExistsInPath(LIBS . 'view' . DS . 'templates' . DS . 'errors' . DS . $type . $action . '.ctp')) { - return $viewFileName; - } elseif ($viewFileName = fileExistsInPath(LIBS . 'view' . DS . 'templates' . DS . $this->viewPath . DS . $type . $action . '.ctp')) { - return $viewFileName; - } else { - if (!is_null($this->pluginPath)) { - $viewFileName = APP . $this->pluginPath . $this->themePath . $name . $this->ext; - } else { - $viewFileName = VIEWS . $this->themePath . $name . $this->ext; - } - $this->_missingView($viewFileName, $action); - } - return false; - } - -/** - * Enter description here... - * - * @return unknown - */ - function _getLayoutFileName() { - if (isset($this->webservices) && !is_null($this->webservices)) { - $type = strtolower($this->webservices) . DS; - } else { - $type = null; - } - - if (!is_null($this->layoutPath)) { - $type = $this->layoutPath . DS; - } - - $paths = Configure::getInstance(); - $viewPaths = array_merge($this->pluginPaths, $paths->viewPaths); - - $name = $this->subDir . $type . $this->layout; - foreach ($viewPaths as $path) { - if (file_exists($path . $this->themeLayout . $name . $this->ext)) { - return $path . $this->themeLayout . $name . $this->ext; - } elseif (file_exists($path . $this->themeLayout . $name . '.thtml')) { - return $path . $this->themeLayout . $name . '.thtml'; - } elseif (file_exists($path . 'layouts' . DS . $name . $this->ext)) { - return $path . 'layouts' . DS . $name . $this->ext; - } elseif (file_exists($path . 'layouts' . DS . $name . '.thtml')) { - return $path . 'layouts' . DS . $name . '.thtml'; - } - } - - if (!is_null($this->pluginPath)) { - $layoutFileName = APP . $this->pluginPath . 'views' . DS . $this->themeLayout . $name . $this->ext; - } else { - $layoutFileName = VIEWS . $this->themeLayout . $name . $this->ext; - } - - $default = fileExistsInPath(LIBS . 'view' . DS . 'templates' . DS . 'layouts' . DS . $type . $this->layout . '.ctp'); - if (empty($default) && !empty($type)) { - $default = fileExistsInPath(LIBS . 'view' . DS . 'templates' . DS . 'layouts' . DS . $type . 'default.ctp'); - } - if (empty($default)) { - $default = fileExistsInPath(LIBS . 'view' . DS . 'templates' . DS . 'layouts' . DS . $this->layout . '.ctp'); - } - - if (!empty($default)) { - return $default; - } - return $layoutFileName; + return $paths; } } ?> \ No newline at end of file diff --git a/cake/libs/view/view.php b/cake/libs/view/view.php index 3934ff247..f85ca91e2 100644 --- a/cake/libs/view/view.php +++ b/cake/libs/view/view.php @@ -41,27 +41,32 @@ uses ('view' . DS . 'helper', 'class_registry'); */ class View extends Object { /** - * Name of the controller. + * Path parts for creating links in views. * - * @var string Name of controller + * @var string Base URL * @access public */ - var $name = null; - + var $base = null; /** * Stores the current URL (for links etc.) * * @var string Current URL */ var $here = null; - /** - * Not used. 2006-09 + * Name of the plugin. * - * @var unknown_type + * @link http://manual.cakephp.org/chapter/plugins + * @var string + */ + var $plugin = null; +/** + * Name of the controller. + * + * @var string Name of controller * @access public */ - var $parent = null; + var $name = null; /** * Action to be performed. * @@ -69,6 +74,116 @@ class View extends Object { * @access public */ var $action = null; +/** + * Array of parameter data + * + * @var array Parameter data + */ + var $params = array(); +/** + * Current passed params + * + * @var mixed + */ + var $passedArgs = array(); +/** + * Array of data + * + * @var array Parameter data + */ + var $data = array(); +/** + * An array of names of built-in helpers to include. + * + * @var mixed A single name as a string or a list of names as an array. + * @access public + */ + var $helpers = array('Html'); +/** + * Path to View. + * + * @var string Path to View + */ + var $viewPath = null; +/** + * Variables for the view + * + * @var array + * @access public + */ + var $viewVars = array(); +/** + * Name of layout to use with this View. + * + * @var string + * @access public + */ + var $layout = 'default'; +/** + * Path to Layout. + * + * @var string Path to Layout + */ + var $layoutPath = null; +/** + * Title HTML element of this View. + * + * @var string + * @access public + */ + var $pageTitle = false; +/** + * Turns on or off Cake's conventional mode of rendering views. On by default. + * + * @var boolean + * @access public + */ + var $autoRender = true; +/** + * Turns on or off Cake's conventional mode of finding layout files. On by default. + * + * @var boolean + * @access public + */ + var $autoLayout = true; +/** + * File extension. Defaults to Cake's template ".ctp". + * + * @var string + */ + var $ext = '.ctp'; +/** + * Sub-directory for this view file. + * + * @var string + */ + var $subDir = null; +/** + * Theme name. + * + * @var string + */ + var $themeWeb = null; +/** + * Used to define methods a controller that will be cached. + * + * @see Controller::$cacheAction + * @var mixed + * @access public + */ + var $cacheAction = false; +/** + * True when the view has been rendered. + * + * @var boolean + */ + var $hasRendered = null; +/** + * Array of loaded view helpers. + * + * @var array + */ + var $loaded = array(); /** * True if in scope of model-specific region * @@ -106,38 +221,18 @@ class View extends Object { */ var $modelId = null; /** - * An array of names of models the particular controller wants to use. - * - * @var mixed A single name as a string or a list of names as an array. - * @access protected - */ - var $uses = false; -/** - * An array of names of built-in helpers to include. - * - * @var mixed A single name as a string or a list of names as an array. - * @access protected - */ - var $helpers = array('Html'); -/** - * Path to View. - * - * @var string Path to View - */ - var $viewPath; -/** - * Path to Layout. - * - * @var string Path to Layout - */ - var $layoutPath = null; -/** - * Variables for the view + * List of generated DOM UUIDs * * @var array - * @access public */ - var $viewVars = array(); + var $uuids = array(); +/** + * List of variables to collect from the associated controller + * + * @var array + * @access protected + */ + var $__passedVars = array('viewVars', 'action', 'autoLayout', 'autoRender', 'ext', 'base', 'webroot', 'helpers', 'here', 'layout', 'name', 'pageTitle', 'layoutPath', 'viewPath', 'params', 'data', 'webservices', 'plugin', 'passedArgs', 'cacheAction'); /** * Scripts (and/or other tags) for the layout * @@ -146,123 +241,11 @@ class View extends Object { */ var $__scripts = array(); /** - * Title HTML element of this View. - * - * @var string - * @access public - */ - var $pageTitle = false; -/** - * An array of model objects. - * - * @var array Array of model objects. - * @access public - */ - var $models = array(); -/** - * Path parts for creating links in views. - * - * @var string Base URL - * @access public - */ - var $base = null; -/** - * Name of layout to use with this View. - * - * @var string - * @access public - */ - var $layout = 'default'; -/** - * Turns on or off Cake's conventional mode of rendering views. On by default. - * - * @var boolean - * @access public - */ - var $autoRender = true; -/** - * Turns on or off Cake's conventional mode of finding layout files. On by default. - * - * @var boolean - * @access public - */ - var $autoLayout = true; -/** - * Array of parameter data - * - * @var array Parameter data - */ - var $params = array(); -/** - * True when the view has been rendered. - * - * @var boolean - */ - var $hasRendered = null; -/** - * Array of loaded view helpers. + * Holds an array of paths. * * @var array */ - var $loaded = array(); -/** - * File extension. Defaults to Cake's template ".ctp". - * - * @var string - */ - var $ext = '.ctp'; -/** - * Sub-directory for this view file. - * - * @var string - */ - var $subDir = null; -/** - * Theme name. - * - * @var string - */ - var $themeWeb = null; -/** - * Plugin name. A Plugin is a sub-application. - * - * @link http://manual.cakephp.org/chapter/plugins - * @var string - */ - var $plugin = null; -/** - * Creates system path to plugin: plugins . DS . plugin_name . DS - * - * @var string - */ - var $pluginPath = null; -/** - * Holds an array of plugin paths. - * VIEWS . $this->pluginPath - * APP . $this->pluginPath . views . DS - * - * @var array - */ - var $pluginPaths = array(); -/** - * Current passed params - * - * @var mixed - */ - var $passedArgs = array(); -/** - * List of variables to collect from the associated controller - * - * @var array - * @access protected - */ - var $__passedVars = array('viewVars', 'action', 'autoLayout', 'autoRender', 'ext', 'base', 'webroot', 'helpers', 'here', 'layout', 'modelNames', 'name', 'pageTitle', 'layoutPath', 'viewPath', 'params', 'data', 'webservices', 'plugin', 'passedArgs', 'cacheAction'); -/** - * List of generated DOM UUIDs - * - * @var array - */ - var $uuids = array(); + var $__paths = array(); /** * Constructor * @@ -276,134 +259,13 @@ class View extends Object { $this->{$var} = $controller->{$var}; } } - if (!is_null($this->plugin)) { - $this->pluginPath = 'plugins'. DS . $this->plugin . DS; - $this->pluginPaths = array( - VIEWS . $this->pluginPath, - APP . $this->pluginPath . 'views' . DS, - ); - } + parent::__construct(); if($register) { ClassRegistry::addObject('view', $this); } } -/** - * Renders view for given action and layout. If $file is given, that is used - * for a view filename (e.g. customFunkyView.ctp). - * - * @param string $action Name of action to render for - * @param string $layout Layout to use - * @param string $file Custom filename for view - */ - function render($action = null, $layout = null, $file = null) { - - if (isset($this->hasRendered) && $this->hasRendered) { - return true; - } else { - $this->hasRendered = false; - } - - if (!$action) { - $action = $this->action; - } - $tempLayout = $this->layout; - - if ($layout) { - $this->layout = $layout; - } - - if ($file) { - $viewFileName = $file; - $this->_missingView($viewFileName, $action); - } else { - $viewFileName = $this->_getViewFileName($action); - } - - if ($viewFileName && !$this->hasRendered) { - if (substr($viewFileName, -3) === 'ctp' || substr($viewFileName, -5) === 'thtml') { - $out = View::_render($viewFileName, $this->viewVars); - } else { - $out = $this->_render($viewFileName, $this->viewVars); - } - - if ($out !== false) { - if ($this->layout && $this->autoLayout) { - $out = $this->renderLayout($out); - if (isset($this->loaded['cache']) && (($this->cacheAction != false)) && (Configure::read('Cache.check') === true)) { - $replace = array('', ''); - $out = str_replace($replace, '', $out); - } - } - - print $out; - $this->layout = $tempLayout; - $this->hasRendered = true; - } else { - $out = $this->_render($viewFileName, $this->viewVars); - trigger_error(sprintf(__("Error in view %s, got:
%s
", true), $viewFileName, $out), E_USER_ERROR); - } - return true; - } - } -/** - * Renders 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. - * - * @link - * @param string $name Name of template file in the/app/views/elements/ folder - * @param array $params Array of data to be made available to the for rendered view (i.e. the Element) - * @return string Rendered output - */ - function renderElement($name, $params = array(), $loadHelpers = false) { - - if (isset($params['plugin'])) { - $this->plugin = $params['plugin']; - $this->pluginPath = 'plugins' . DS . $this->plugin . DS; - $this->pluginPaths = array( - VIEWS . $this->pluginPath, - APP . $this->pluginPath . 'views' . DS, - ); - } - - $paths = Configure::getInstance(); - $viewPaths = array_merge($this->pluginPaths, $paths->viewPaths); - - $file = null; - foreach ($viewPaths as $path) { - if (file_exists($path . 'elements' . DS . $name . $this->ext)) { - $file = $path . 'elements' . DS . $name . $this->ext; - break; - } elseif (file_exists($path . 'elements' . DS . $name . '.thtml')) { - $file = $path . 'elements' . DS . $name . '.thtml'; - break; - } - } - - if (is_null($file)) { - $file = fileExistsInPath(LIBS . 'view' . DS . 'templates' . DS . 'elements' . DS . $name. '.ctp'); - } - - if ($file) { - $params = array_merge_recursive($params, $this->loaded); - return $this->_render($file, array_merge($this->viewVars, $params), $loadHelpers); - } - - if (!is_null($this->pluginPath)) { - $file = APP . $this->pluginPath . 'views' . DS . 'elements' . DS . $name . $this->ext; - } else { - $file = VIEWS . 'elements' . DS . $name . $this->ext; - } - - if (Configure::read() > 0) { - return "Not Found: " . $file; - } - } - /** * Wrapper for View::renderElement(); * @@ -442,20 +304,113 @@ class View extends Object { } return $this->renderElement($name, $params); } +/** + * Renders view for given action and layout. If $file is given, that is used + * for a view filename (e.g. customFunkyView.ctp). + * + * @param string $action Name of action to render for + * @param string $layout Layout to use + * @param string $file Custom filename for view + */ + function render($action = null, $layout = null, $file = null) { + + if (isset($this->hasRendered) && $this->hasRendered) { + return true; + } else { + $this->hasRendered = false; + } + + if (!$action) { + $action = $this->action; + } + + if ($layout === null) { + $layout = $this->layout; + } + + if ($file != null) { + $action = $file; + } + + $viewFileName = $this->_getViewFileName($action); + + if ($viewFileName && !$this->hasRendered) { + if (substr($viewFileName, -3) === 'ctp' || substr($viewFileName, -5) === 'thtml') { + $out = View::_render($viewFileName, $this->viewVars); + } else { + $out = $this->_render($viewFileName, $this->viewVars); + } + + if ($out !== false) { + if ($this->layout && $this->autoLayout) { + $out = $this->renderLayout($out, $layout); + if (isset($this->loaded['cache']) && (($this->cacheAction != false)) && (Configure::read('Cache.check') === true)) { + $replace = array('', ''); + $out = str_replace($replace, '', $out); + } + } + + print $out; + $this->hasRendered = true; + } else { + $out = $this->_render($viewFileName, $this->viewVars); + trigger_error(sprintf(__("Error in view %s, got:
%s
", true), $viewFileName, $out), E_USER_ERROR); + } + return true; + } + } +/** + * Renders 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. + * + * @link + * @param string $name Name of template file in the/app/views/elements/ folder + * @param array $params Array of data to be made available to the for rendered view (i.e. the Element) + * @return string Rendered output + */ + function renderElement($name, $params = array(), $loadHelpers = false) { + $file = $plugin = false; + if (isset($params['plugin'])) { + $plugin = $params['plugin']; + } + + $paths = $this->_paths($plugin); + foreach ($paths as $path) { + if (file_exists($path . 'elements' . DS . $name . $this->ext)) { + $file = $path . 'elements' . DS . $name . $this->ext; + break; + } elseif (file_exists($path . 'elements' . DS . $name . '.thtml')) { + $file = $path . 'elements' . DS . $name . '.thtml'; + break; + } + } + + if (is_file($file)) { + $params = array_merge_recursive($params, $this->loaded); + return $this->_render($file, array_merge($this->viewVars, $params), $loadHelpers); + } + + $file = $paths[0] . 'views' . DS . 'elements' . DS . $name . $this->ext; + if (Configure::read() > 0) { + return "Not Found: " . $file; + } + } /** * Renders a layout. Returns output from _render(). Returns false on error. * * @param string $content_for_layout Content to render in a view, wrapped by the surrounding layout. * @return mixed Rendered output, or false on error */ - function renderLayout($content_for_layout) { - $layout_fn = $this->_getLayoutFileName(); + function renderLayout($content_for_layout, $layout = null) { + $layout_fn = $this->_getLayoutFileName($layout); + $debug = ''; if (Configure::read() > 2 && isset($this->viewVars['cakeDebug'])) { $debug = View::_render(LIBS . 'view' . DS . 'templates' . DS . 'elements' . DS . 'dump.ctp', array('controller' => $this->viewVars['cakeDebug']), false); unset($this->viewVars['cakeDebug']); - } else { - $debug = ''; } if ($this->pageTitle !== false) { @@ -473,35 +428,56 @@ class View extends Object { ) ); - if (is_file($layout_fn)) { - if (empty($this->loaded) && !empty($this->helpers)) { - $loadHelpers = true; - } else { - $loadHelpers = false; - $data_for_layout = array_merge($data_for_layout, $this->loaded); - } - - if (substr($layout_fn, -3) === 'ctp' || substr($layout_fn, -5) === 'thtml') { - $out = View::_render($layout_fn, $data_for_layout, $loadHelpers, true); - } else { - $out = $this->_render($layout_fn, $data_for_layout, $loadHelpers); - } - - if ($out === false) { - $out = $this->_render($layout_fn, $data_for_layout); - trigger_error(sprintf(__("Error in layout %s, got:
%s
", true), $layout_fn, $out), E_USER_ERROR); - return false; - } else { - return $out; - } + if (empty($this->loaded) && !empty($this->helpers)) { + $loadHelpers = true; } else { - return $this->cakeError('missingLayout', array( - array( - 'layout' => $this->layout, - 'file' => $layout_fn, - 'base' => $this->base - ) - )); + $loadHelpers = false; + $data_for_layout = array_merge($data_for_layout, $this->loaded); + } + + if (substr($layout_fn, -3) === 'ctp' || substr($layout_fn, -5) === 'thtml') { + $out = View::_render($layout_fn, $data_for_layout, $loadHelpers, true); + } else { + $out = $this->_render($layout_fn, $data_for_layout, $loadHelpers); + } + + if ($out === false) { + $out = $this->_render($layout_fn, $data_for_layout); + trigger_error(sprintf(__("Error in layout %s, got:
%s
", true), $layout_fn, $out), E_USER_ERROR); + return false; + } + + return $out; + } +/** + * Render cached view + * + * @param string $filename the cache file to include + * @param string $timeStart the page render start time + */ + function renderCache($filename, $timeStart) { + ob_start(); + include ($filename); + + if (Configure::read() > 0 && $this->layout != 'xml') { + echo ""; + } + + $out = ob_get_clean(); + + if (preg_match('/^/', $out, $match)) { + if (time() >= $match['1']) { + @unlink($filename); + unset ($out); + return; + } else { + if ($this->layout === 'xml') { + header('Content-type: text/xml'); + } + $out = str_replace('', '', $out); + e($out); + die(); + } } } /** @@ -582,7 +558,6 @@ class View extends Object { * @return unknown */ function set($one, $two = null) { - $data = null; if (is_array($one)) { if (is_array($two)) { @@ -617,7 +592,7 @@ class View extends Object { function error($code, $name, $message) { header ("HTTP/1.1 {$code} {$name}"); print ($this->_render( - LAYOUTS . 'error.ctp', + $this->_getLayoutFileName('error'), array( 'code' => $code, 'name' => $name, @@ -626,111 +601,6 @@ class View extends Object { )); } -/************************************************************************** - * Private methods. - *************************************************************************/ - -/** - * 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 $action Controller action to find template filename for - * @return string Template filename - * @access private - */ - function _getViewFileName($action) { - $action = Inflector::underscore($action); - - if (!is_null($this->webservices)) { - $type = strtolower($this->webservices) . DS; - } else { - $type = null; - } - - $position = strpos($action, '..'); - if ($position !== false) { - $action = explode('/', $action); - $i = array_search('..', $action); - unset($action[$i - 1]); - unset($action[$i]); - $action = '..' . DS . implode(DS, $action); - } - - $paths = Configure::getInstance(); - $viewPaths = array_merge($this->pluginPaths, $paths->viewPaths); - - $name = $this->viewPath . DS . $this->subDir . $type . $action; - foreach ($viewPaths as $path) { - if (file_exists($path . $name . $this->ext)) { - return $path . $name . $this->ext; - } elseif (file_exists($path . $name . '.thtml')) { - return $path . $name . '.thtml'; - } - } - - if ($viewFileName = fileExistsInPath(LIBS . 'view' . DS . 'templates' . DS . 'errors' . DS . $type . $action . '.ctp')) { - return $viewFileName; - } elseif ($viewFileName = fileExistsInPath(LIBS . 'view' . DS . 'templates' . DS . $this->viewPath . DS . $type . $action . '.ctp')) { - return $viewFileName; - } else { - if (!is_null($this->pluginPath)) { - $viewFileName = APP . $this->pluginPath . 'views' . DS . $name . $this->ext; - } else { - $viewFileName = VIEWS . $name . $this->ext; - } - $this->_missingView($viewFileName, $action); - } - return false; - } - -/** - * Returns layout filename for this template as a string. - * - * @return string Filename for layout file (.ctp). - * @access private - */ - function _getLayoutFileName() { - if (isset($this->webservices) && !is_null($this->webservices)) { - $type = strtolower($this->webservices) . DS; - } else { - $type = null; - } - - if (!is_null($this->layoutPath)) { - $type = $this->layoutPath . DS; - } - - $paths = Configure::getInstance(); - $viewPaths = array_merge($this->pluginPaths, $paths->viewPaths); - - $name = $this->subDir . $type . $this->layout; - foreach ($viewPaths as $path) { - if (file_exists($path . 'layouts' . DS . $name . $this->ext)) { - return $path . 'layouts' . DS . $name . $this->ext; - } elseif (file_exists($path . 'layouts' . DS . $name . '.thtml')) { - return $path . 'layouts' . DS . $name . '.thtml'; - } - } - - if (!is_null($this->pluginPath)) { - $layoutFileName = APP . $this->pluginPath . 'views' . DS . 'layouts' . DS . $name . $this->ext; - } else { - $layoutFileName = VIEWS . 'layouts' . DS . $name . $this->ext; - } - - $default = fileExistsInPath(LIBS . 'view' . DS . 'templates' . DS . 'layouts' . DS . $type . $this->layout . '.ctp'); - if (empty($default) && !empty($type)) { - $default = fileExistsInPath(LIBS . 'view' . DS . 'templates' . DS . 'layouts' . DS . $type . 'default.ctp'); - } - if (empty($default)) { - $default = fileExistsInPath(LIBS . 'view' . DS . 'templates' . DS . 'layouts' . DS . $this->layout . '.ctp'); - } - - if (!empty($default)) { - return $default; - } - return $layoutFileName; - } - /** * Renders and returns output for given view filename with its * array of data. @@ -738,7 +608,7 @@ class View extends Object { * @param string $___viewFn Filename of the view * @param array $___dataForView Data to include in rendered view * @return string Rendered output - * @access private + * @access protected */ function _render($___viewFn, $___dataForView, $loadHelpers = true, $cached = false) { if ($this->helpers != false && $loadHelpers === true) { @@ -882,35 +752,90 @@ class View extends Object { return $loaded; } /** - * Render cached view + * 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 $filename the cache file to include - * @param string $timeStart the page render start time + * @param string $action Controller action to find template filename for + * @return string Template filename + * @access protected */ - function renderCache($filename, $timeStart) { - ob_start(); - include ($filename); - - if (Configure::read() > 0 && $this->layout != 'xml') { - echo ""; + function _getViewFileName($name = null) { + $subDir = null; + if (!is_null($this->webservices)) { + $subDir = strtolower($this->webservices) . DS; + } + if (!is_null($this->subDir)) { + $subDir = $this->subDir . DS; } - $out = ob_get_clean(); + if($name === null) { + $name = $this->action; + } - if (preg_match('/^/', $out, $match)) { - if (time() >= $match['1']) { - @unlink($filename); - unset ($out); - return; - } else { - if ($this->layout === 'xml') { - header('Content-type: text/xml'); + if(strpos($name, '/') === false && strpos($name, '..') === false) { + $name = $this->viewPath . DS . $subDir . Inflector::underscore($name); + } elseif (strpos($name, '/') !== false) { + if($name{0} === '/') { + if (is_file($name)) { + return $name; } - $out = str_replace('', '', $out); - e($out); - die(); + $name = trim($name, '/'); + if(DS !== '/') { + $name = implode(DS, explode('/', $name)); + } + } else { + if (is_file($name)) { + return $name; + } + return $this->_missingView($name, 'missingView'); + } + } elseif (strpos($name, '..') !== false) { + $name = explode('/', $name); + $i = array_search('..', $name); + unset($name[$i - 1]); + unset($name[$i]); + $name = '..' . DS . implode(DS, $name); + } + + $paths = $this->_paths($this->plugin); + foreach ($paths as $path) { + if (file_exists($path . $name . $this->ext)) { + return $path . $name . $this->ext; + } elseif (file_exists($path . $name . '.thtml')) { + return $path . $name . '.thtml'; } } + + return $this->_missingView($paths[0] . $name . $this->ext, 'missingView'); + } + +/** + * Returns layout filename for this template as a string. + * + * @return string Filename for layout file (.ctp). + * @access protected + */ + function _getLayoutFileName($name = null) { + if($name === null) { + $name = $this->layout; + } + $subDir = null; + if (!is_null($this->layoutPath)) { + $subDir = $this->layoutPath . DS; + } + + $paths = $this->_paths($this->plugin); + $file = 'layouts' . DS . $subDir . $name; + foreach ($paths as $path) { + if (file_exists($path . $file . $this->ext)) { + return $path . $file . $this->ext; + } elseif (file_exists($path . $file . '.thtml')) { + return $path . $file . '.thtml'; + } + } + + return $this->_missingView($paths[0] . $file . $this->ext, 'missingLayout'); } /** * Return a misssing view error message @@ -918,42 +843,69 @@ class View extends Object { * @param string $viewFileName the filename that should exist * @return cakeError */ - function _missingView($viewFileName = null, $action = null) { - if (!is_file($viewFileName) && !fileExistsInPath($viewFileName) || $viewFileName === '/' || $viewFileName === '\\') { - if (strpos($action, 'missingAction') !== false) { - $errorAction = 'missingAction'; - } else { - $errorAction = 'missingView'; - } - - foreach (array($this->name, 'errors') as $viewDir) { - $errorAction = Inflector::underscore($errorAction); - if (file_exists(VIEWS . $viewDir . DS . $errorAction . $this->ext)) { - $missingViewFileName = VIEWS . $viewDir . DS . $errorAction . $this->ext; - } elseif (file_exists(VIEWS . $viewDir . DS . $errorAction . '.thtml')) { - $missingViewFileName = VIEWS . $viewDir . DS . $errorAction . '.thtml'; - } elseif ($missingViewFileName = fileExistsInPath(LIBS . 'view' . DS . 'templates' . DS . $viewDir . DS . $errorAction . '.ctp')) { - } else { - $missingViewFileName = false; - } - $missingViewExists = is_file($missingViewFileName); - - if ($missingViewExists) { - break; - } - } - - if (strpos($action, 'missingView') === false) { - return $this->cakeError('missingView', array(array( - 'className' => $this->name, - 'action' => $this->action, - 'file' => $viewFileName, - 'base' => $this->base - ))); - exit(); + function _missingView($file, $error = 'missingView') { + $paths = $this->_paths($this->plugin); + $name = 'errors' . DS . Inflector::underscore($error); + foreach ($paths as $path) { + if (file_exists($path . $name . $this->ext)) { + $name = $path . $name . $this->ext; + break; + } elseif (file_exists($path . $name . '.thtml')) { + $name = $path . $name . '.thtml'; + break; } } + + if ($error === 'missingView') { + return $this->cakeError('missingView', array(array( + 'className' => $this->name, + 'action' => $this->action, + 'file' => $file, + 'base' => $this->base + ))); + } + if ($error === 'missingLayout') { + return $this->cakeError('missingLayout', array(array( + 'layout' => $this->layout, + 'file' => $file, + 'base' => $this->base + ))); + } + return $name; + } +/** + * Return all possible paths to find view files in order + * + * @param string $plugin + * @return array paths + * @access protected + */ + function _paths($plugin = null, $cached = true) { + if($plugin === null && $cached === true && !empty($this->__paths)) { + return $this->__paths; + } + $paths = array(); + $viewPaths = Configure::read('viewPaths'); + if ($plugin !== null) { + $count = count($viewPaths); + for ($i = 0; $i < $count; $i++) { + $paths[] = $viewPaths[$i] . 'plugins' . DS . $plugin . DS; + } + + $pluginPaths = Configure::read('pluginPaths'); + $count = count($pluginPaths); + for ($i = 0; $i < $count; $i++) { + $paths[] = $pluginPaths[$i] . $plugin . DS . 'views' . DS; + } + } + + $paths = array_merge($paths, $viewPaths); + + if(empty($this->__paths)) { + $this->__paths = $paths; + } + + return $paths; } } - ?> \ No newline at end of file diff --git a/cake/tests/cases/libs/configure.test.php b/cake/tests/cases/libs/configure.test.php index 9b03474e6..6a94bd91f 100644 --- a/cake/tests/cases/libs/configure.test.php +++ b/cake/tests/cases/libs/configure.test.php @@ -44,6 +44,24 @@ class ConfigureTest extends UnitTestCase { $this->assertTrue(in_array('Xml', $result)); $this->assertTrue(in_array('Cache', $result)); $this->assertTrue(in_array('HttpSocket', $result)); + + $result = $this->Configure->listObjects('model'); + $this->assertTrue(in_array('Model', $result)); + + $result = $this->Configure->listObjects('behavior'); + $this->assertTrue(in_array('Tree', $result)); + + $result = $this->Configure->listObjects('controller'); + $this->assertTrue(in_array('Pages', $result)); + + $result = $this->Configure->listObjects('component'); + $this->assertTrue(in_array('Auth', $result)); + + $result = $this->Configure->listObjects('view'); + $this->assertTrue(in_array('Media', $result)); + + $result = $this->Configure->listObjects('helper'); + $this->assertTrue(in_array('Html', $result)); } function tearDown() { diff --git a/cake/tests/cases/libs/controller/scaffold.test.php b/cake/tests/cases/libs/controller/scaffold.test.php index 21c418e5b..da859b7ca 100644 --- a/cake/tests/cases/libs/controller/scaffold.test.php +++ b/cake/tests/cases/libs/controller/scaffold.test.php @@ -27,6 +27,23 @@ * @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License */ uses('controller' . DS . 'scaffold'); +class ScaffoldMockController extends Controller { + + var $name = 'ScaffoldMock'; + + var $scaffold; +} +class ScaffoldMock extends CakeTestModel { + + var $useTable = 'posts'; + +} +class TestScaffoldView extends ScaffoldView { + + function testGetFilename($action) { + return $this->_getViewFileName($action); + } +} /** * Short description for class. * @@ -35,8 +52,21 @@ uses('controller' . DS . 'scaffold'); */ class ScaffoldTest extends CakeTestCase { - function skip() { - $this->skipif (true, 'ScaffoldTest not implemented'); + var $fixtures = array('core.post'); + + function setUp() { + $this->Controller = new ScaffoldMockController(); + } + + function tearDown() { + unset($this->Controller); + } + function testGetViewFilename() { + $this->Controller->action = 'index'; + $ScaffoldView =& new TestScaffoldView($this->Controller); + $result = $ScaffoldView->testGetFilename('index'); + $expected = TEST_CAKE_CORE_INCLUDE_PATH . 'libs' . DS . 'view' . DS . 'scaffolds' . DS . 'index.ctp'; + $this->assertEqual($result, $expected); } } ?> \ No newline at end of file diff --git a/cake/tests/cases/libs/view/theme.test.php b/cake/tests/cases/libs/view/theme.test.php new file mode 100644 index 000000000..b6a2c427f --- /dev/null +++ b/cake/tests/cases/libs/view/theme.test.php @@ -0,0 +1,165 @@ + + * Copyright 2005-2007, Cake Software Foundation, Inc. + * 1785 E. Sahara Avenue, Suite 490-204 + * Las Vegas, Nevada 89104 + * + * Licensed under The Open Group Test Suite License + * Redistributions of files must retain the above copyright notice. + * + * @filesource + * @copyright Copyright 2005-2007, Cake Software Foundation, Inc. + * @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests + * @package cake.tests + * @subpackage cake.tests.cases.libs + * @since CakePHP(tm) v 1.2.0.4206 + * @version $Revision$ + * @modifiedby $LastChangedBy$ + * @lastmodified $Date$ + * @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License + */ +uses('controller' . DS . 'controller', 'view'.DS.'theme'); + +class PostsController extends Controller { + var $name = 'Posts'; + function index() { + $this->set('testData', 'Some test data'); + $test2 = 'more data'; + $test3 = 'even more data'; + $this->set(compact('test2', 'test3')); + } +} + +class TestView extends ThemeView { + + function renderElement($name, $params = array()) { + return $name; + } + + function getViewFileName($name = null) { + return $this->_getViewFileName($name); + } + function getLayoutFileName($name = null) { + return $this->_getLayoutFileName($name); + } + + function cakeError($name, $params) { + return $name; + } +} + +/** + * Short description for class. + * + * @package cake.tests + * @subpackage cake.tests.cases.libs + */ +class ViewTest extends UnitTestCase { + + function setUp() { + Router::reload(); + $this->Controller = new Controller(); + $this->PostsController = new PostsController(); + $this->PostsController->index(); + $this->ThemeView = new View($this->PostsController); + } + + function testPluginGetTemplate() { + $this->Controller->plugin = 'test_plugin'; + $this->Controller->name = 'TestPlugin'; + $this->Controller->viewPath = 'test_plugin'; + $this->Controller->action = 'index'; + $this->Controller->theme = 'test_plugin_theme'; + + $ThemeView = new TestView($this->Controller); + Configure::write('pluginPaths', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)); + Configure::write('viewPaths', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS)); + + $expected = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS .'test_plugin' . DS . 'views' . DS . 'themed' . DS . 'test_plugin_theme' . DS .'test_plugin' . DS .'index.ctp'; + $result = $ThemeView->getViewFileName('index'); + $this->assertEqual($result, $expected); + + $expected = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS .'test_plugin' . DS . 'views' . DS . 'themed' . DS . 'test_plugin_theme' . DS . 'layouts' . DS .'default.ctp'; + $result = $ThemeView->getLayoutFileName(); + $this->assertEqual($result, $expected); + } + + function testGetTemplate() { + $this->Controller->plugin = null; + $this->Controller->name = 'Pages'; + $this->Controller->viewPath = 'pages'; + $this->Controller->action = 'display'; + $this->Controller->params['pass'] = array('home'); + + $ThemeView = new TestView($this->Controller); + $ThemeView->theme = 'test_theme'; + + Configure::write('pluginPaths', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)); + Configure::write('viewPaths', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS, TEST_CAKE_CORE_INCLUDE_PATH . 'libs' . DS . 'view' . DS)); + + $expected = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS .'pages' . DS .'home.ctp'; + $result = $ThemeView->getViewFileName('home'); + $this->assertEqual($result, $expected); + + $expected = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'themed' . DS . 'test_theme' . DS . 'posts' . DS .'index.ctp'; + $result = $ThemeView->getViewFileName('/posts/index'); + $this->assertEqual($result, $expected); + + $expected = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'themed' . DS . 'test_theme' . DS . 'layouts' . DS .'default.ctp'; + $result = $ThemeView->getLayoutFileName(); + $this->assertEqual($result, $expected); + + $ThemeView->layoutPath = 'rss'; + $expected = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'layouts' . DS . 'rss' . DS . 'default.ctp'; + $result = $ThemeView->getLayoutFileName(); + $this->assertEqual($result, $expected); + + $ThemeView->layoutPath = 'email' . DS . 'html'; + $expected = TEST_CAKE_CORE_INCLUDE_PATH . 'libs' . DS . 'view' . DS . 'layouts' . DS . 'email' . DS . 'html' . DS . 'default.ctp'; + $result = $ThemeView->getLayoutFileName(); + $this->assertEqual($result, $expected); + } + + function testMissingView() { + $this->Controller->plugin = null; + $this->Controller->name = 'Pages'; + $this->Controller->viewPath = 'pages'; + $this->Controller->action = 'display'; + $this->Controller->params['pass'] = array('home'); + + $ThemeView = new TestView($this->Controller); + + $expected = 'missingView'; + $result = $ThemeView->getViewFileName('does_not_exist'); + $this->assertEqual($result, $expected); + + } + + function testMissingLayout() { + $this->Controller->plugin = null; + $this->Controller->name = 'Posts'; + $this->Controller->viewPath = 'posts'; + $this->Controller->layout = 'whatever'; + + $ThemeView = new TestView($this->Controller); + $expected = 'missingLayout'; + $result = $ThemeView->getLayoutFileName(); + $this->assertEqual($result, $expected); + } + + function tearDown() { + unset($this->ThemeView); + unset($this->PostsController); + unset($this->Controller); + + } +} +?> \ No newline at end of file diff --git a/cake/tests/cases/libs/view/view.test.php b/cake/tests/cases/libs/view/view.test.php index b4c844e8f..823c37a7d 100644 --- a/cake/tests/cases/libs/view/view.test.php +++ b/cake/tests/cases/libs/view/view.test.php @@ -43,6 +43,17 @@ class TestView extends View { function renderElement($name, $params = array()) { return $name; } + + function getViewFileName($name = null) { + return $this->_getViewFileName($name); + } + function getLayoutFileName($name = null) { + return $this->_getLayoutFileName($name); + } + + function cakeError($name, $params) { + return $name; + } } /** @@ -55,31 +66,113 @@ class ViewTest extends UnitTestCase { function setUp() { Router::reload(); + $this->Controller = new Controller(); $this->PostsController = new PostsController(); $this->PostsController->index(); - $this->view = new View($this->PostsController); + $this->View = new View($this->PostsController); + } + + function testPluginGetTemplate() { + $this->Controller->plugin = 'test_plugin'; + $this->Controller->name = 'TestPlugin'; + $this->Controller->viewPath = 'test_plugin'; + $this->Controller->action = 'index'; + + $View = new TestView($this->Controller); + Configure::write('pluginPaths', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)); + Configure::write('viewPaths', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS)); + + $expected = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS .'test_plugin' . DS . 'views' . DS .'test_plugin' . DS .'index.ctp'; + $result = $View->getViewFileName('index'); + $this->assertEqual($result, $expected); + + $expected = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS .'test_plugin' . DS . 'views' . DS . 'layouts' . DS .'default.ctp'; + $result = $View->getLayoutFileName(); + $this->assertEqual($result, $expected); + } + + function testGetTemplate() { + $this->Controller->plugin = null; + $this->Controller->name = 'Pages'; + $this->Controller->viewPath = 'pages'; + $this->Controller->action = 'display'; + $this->Controller->params['pass'] = array('home'); + + $View = new TestView($this->Controller); + Configure::write('pluginPaths', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)); + Configure::write('viewPaths', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS, TEST_CAKE_CORE_INCLUDE_PATH . 'libs' . DS . 'view' . DS)); + + $expected = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS .'pages' . DS .'home.ctp'; + $result = $View->getViewFileName('home'); + $this->assertEqual($result, $expected); + + $expected = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS .'posts' . DS .'index.ctp'; + $result = $View->getViewFileName('/posts/index'); + $this->assertEqual($result, $expected); + + + $expected = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'layouts' . DS .'default.ctp'; + $result = $View->getLayoutFileName(); + $this->assertEqual($result, $expected); + + $View->layoutPath = 'rss'; + $expected = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'layouts' . DS . 'rss' . DS . 'default.ctp'; + $result = $View->getLayoutFileName(); + $this->assertEqual($result, $expected); + + $View->layoutPath = 'email' . DS . 'html'; + $expected = TEST_CAKE_CORE_INCLUDE_PATH . 'libs' . DS . 'view' . DS . 'layouts' . DS . 'email' . DS . 'html' . DS . 'default.ctp'; + $result = $View->getLayoutFileName(); + $this->assertEqual($result, $expected); + } + + function testMissingView() { + $this->Controller->plugin = null; + $this->Controller->name = 'Pages'; + $this->Controller->viewPath = 'pages'; + $this->Controller->action = 'display'; + $this->Controller->params['pass'] = array('home'); + + $View = new TestView($this->Controller); + + $expected = 'missingView'; + $result = $View->getViewFileName('does_not_exist'); + $this->assertEqual($result, $expected); + + } + + function testMissingLayout() { + $this->Controller->plugin = null; + $this->Controller->name = 'Posts'; + $this->Controller->viewPath = 'posts'; + $this->Controller->layout = 'whatever'; + + $View = new TestView($this->Controller); + $expected = 'missingLayout'; + $result = $View->getLayoutFileName(); + $this->assertEqual($result, $expected); } function testViewVars() { - $this->assertEqual($this->view->viewVars, array('testData' => 'Some test data', 'test2' => 'more data', 'test3' => 'even more data')); + $this->assertEqual($this->View->viewVars, array('testData' => 'Some test data', 'test2' => 'more data', 'test3' => 'even more data')); } function testUUIDGeneration() { - $result = $this->view->uuid('form', array('controller' => 'posts', 'action' => 'index')); + $result = $this->View->uuid('form', array('controller' => 'posts', 'action' => 'index')); $this->assertEqual($result, 'form0425fe3bad'); - $result = $this->view->uuid('form', array('controller' => 'posts', 'action' => 'index')); + $result = $this->View->uuid('form', array('controller' => 'posts', 'action' => 'index')); $this->assertEqual($result, 'forma9918342a7'); - $result = $this->view->uuid('form', array('controller' => 'posts', 'action' => 'index')); + $result = $this->View->uuid('form', array('controller' => 'posts', 'action' => 'index')); $this->assertEqual($result, 'form3ecf2e3e96'); } function testAddInlineScripts() { - $this->view->addScript('prototype.js'); - $this->view->addScript('prototype.js'); - $this->assertEqual($this->view->__scripts, array('prototype.js')); + $this->View->addScript('prototype.js'); + $this->View->addScript('prototype.js'); + $this->assertEqual($this->View->__scripts, array('prototype.js')); - $this->view->addScript('mainEvent', 'Event.observe(window, "load", function() { doSomething(); }, true);'); - $this->assertEqual($this->view->__scripts, array('prototype.js', 'mainEvent' => 'Event.observe(window, "load", function() { doSomething(); }, true);')); + $this->View->addScript('mainEvent', 'Event.observe(window, "load", function() { doSomething(); }, true);'); + $this->assertEqual($this->View->__scripts, array('prototype.js', 'mainEvent' => 'Event.observe(window, "load", function() { doSomething(); }, true);')); } function testElementCache() { @@ -124,8 +217,10 @@ class ViewTest extends UnitTestCase { } function tearDown() { - unset($this->view); + unset($this->View); unset($this->PostsController); + unset($this->Controller); + } } ?> \ No newline at end of file diff --git a/cake/tests/groups/view.group.php b/cake/tests/groups/view.group.php new file mode 100644 index 000000000..ea3a11cd7 --- /dev/null +++ b/cake/tests/groups/view.group.php @@ -0,0 +1,45 @@ + + * Copyright 2005-2007, Cake Software Foundation, Inc. + * 1785 E. Sahara Avenue, Suite 490-204 + * Las Vegas, Nevada 89104 + * + * Licensed under The Open Group Test Suite License + * Redistributions of files must retain the above copyright notice. + * + * @filesource + * @copyright Copyright 2005-2007, Cake Software Foundation, Inc. + * @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests + * @package cake.tests + * @subpackage cake.tests.groups + * @since CakePHP(tm) v 1.2.0.4206 + * @version $Revision$ + * @modifiedby $LastChangedBy$ + * @lastmodified $Date$ + * @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License + */ +/** AllCoreHelpersGroupTest + * + * This test group will run all test in the cases/libs/view/helpers directory. + * + * @package cake.tests + * @subpackage cake.tests.groups + */ +class AllCoreViewsGroupTest extends GroupTest { + + var $label = 'All core views'; + + function AllCoreViewsGroupTest() { + TestManager::addTestFile($this, CORE_TEST_CASES . DS . 'libs' . DS . 'view' . DS . 'view', + CORE_TEST_CASES . DS . 'libs' . DS . 'view' . DS . 'theme'); + } +} +?> \ No newline at end of file diff --git a/cake/tests/test_app/controllers/components/empty b/cake/tests/test_app/controllers/components/empty new file mode 100755 index 000000000..e69de29bb diff --git a/cake/tests/test_app/models/behaviors/empty b/cake/tests/test_app/models/behaviors/empty new file mode 100755 index 000000000..e69de29bb diff --git a/cake/tests/test_app/models/datasources/empty b/cake/tests/test_app/models/datasources/empty new file mode 100755 index 000000000..e69de29bb diff --git a/cake/tests/test_app/plugins/test_plugin/views/layouts/default.ctp b/cake/tests/test_app/plugins/test_plugin/views/layouts/default.ctp new file mode 100644 index 000000000..0437f2c6b --- /dev/null +++ b/cake/tests/test_app/plugins/test_plugin/views/layouts/default.ctp @@ -0,0 +1 @@ +test plugin default layout \ No newline at end of file diff --git a/cake/tests/test_app/plugins/test_plugin/views/test_plugin/index.ctp b/cake/tests/test_app/plugins/test_plugin/views/test_plugin/index.ctp new file mode 100644 index 000000000..6260ece2d --- /dev/null +++ b/cake/tests/test_app/plugins/test_plugin/views/test_plugin/index.ctp @@ -0,0 +1 @@ +test plugin index \ No newline at end of file diff --git a/cake/tests/test_app/plugins/test_plugin/views/themed/test_plugin_theme/layouts/default.ctp b/cake/tests/test_app/plugins/test_plugin/views/themed/test_plugin_theme/layouts/default.ctp new file mode 100644 index 000000000..9e1e449c2 --- /dev/null +++ b/cake/tests/test_app/plugins/test_plugin/views/themed/test_plugin_theme/layouts/default.ctp @@ -0,0 +1 @@ +test_plugin test_plugin_theme default layout \ No newline at end of file diff --git a/cake/tests/test_app/plugins/test_plugin/views/themed/test_plugin_theme/test_plugin/index.ctp b/cake/tests/test_app/plugins/test_plugin/views/themed/test_plugin_theme/test_plugin/index.ctp new file mode 100644 index 000000000..edf7ab4b2 --- /dev/null +++ b/cake/tests/test_app/plugins/test_plugin/views/themed/test_plugin_theme/test_plugin/index.ctp @@ -0,0 +1 @@ +test plugin index theme view \ No newline at end of file diff --git a/cake/tests/test_app/vendors/shells/tasks/empty b/cake/tests/test_app/vendors/shells/tasks/empty new file mode 100755 index 000000000..e69de29bb diff --git a/cake/tests/test_app/vendors/shells/templates/empty b/cake/tests/test_app/vendors/shells/templates/empty new file mode 100755 index 000000000..e69de29bb diff --git a/cake/tests/test_app/views/elements/empty b/cake/tests/test_app/views/elements/empty new file mode 100755 index 000000000..e69de29bb diff --git a/cake/tests/test_app/views/errors/empty b/cake/tests/test_app/views/errors/empty new file mode 100755 index 000000000..e69de29bb diff --git a/cake/tests/test_app/views/helpers/empty b/cake/tests/test_app/views/helpers/empty new file mode 100755 index 000000000..e69de29bb diff --git a/cake/tests/test_app/views/layouts/ajax.ctp b/cake/tests/test_app/views/layouts/ajax.ctp new file mode 100755 index 000000000..b69838d65 --- /dev/null +++ b/cake/tests/test_app/views/layouts/ajax.ctp @@ -0,0 +1,27 @@ + + * Copyright 2005-2007, Cake Software Foundation, Inc. + * 1785 E. Sahara Avenue, Suite 490-204 + * Las Vegas, Nevada 89104 + * + * Licensed under The MIT License + * Redistributions of files must retain the above copyright notice. + * + * @filesource + * @copyright Copyright 2005-2007, Cake Software Foundation, Inc. + * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project + * @package cake + * @subpackage cake.cake.libs.view.templates.layouts + * @since CakePHP(tm) v 0.10.0.1076 + * @version $Revision$ + * @modifiedby $LastChangedBy$ + * @lastmodified $Date$ + * @license http://www.opensource.org/licenses/mit-license.php The MIT License + */ +?> + \ No newline at end of file diff --git a/cake/tests/test_app/views/layouts/default.ctp b/cake/tests/test_app/views/layouts/default.ctp new file mode 100755 index 000000000..2433b0d35 --- /dev/null +++ b/cake/tests/test_app/views/layouts/default.ctp @@ -0,0 +1,68 @@ + + * Copyright 2005-2007, Cake Software Foundation, Inc. + * 1785 E. Sahara Avenue, Suite 490-204 + * Las Vegas, Nevada 89104 + * + * Licensed under The MIT License + * Redistributions of files must retain the above copyright notice. + * + * @filesource + * @copyright Copyright 2005-2007, Cake Software Foundation, Inc. + * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project + * @package cake + * @subpackage cake.cake.libs.view.templates.pages + * @since CakePHP(tm) v 0.10.0.1076 + * @version $Revision$ + * @modifiedby $LastChangedBy$ + * @lastmodified $Date$ + * @license http://www.opensource.org/licenses/mit-license.php The MIT License + */ +?> + + + + + <?php __('CakePHP: the rapid development php framework:'); ?> + <?php echo $title_for_layout;?> + + + charset();?> + + + + css('cake.generic');?> + + + +
+ +
+ check('Message.flash')): + $session->flash(); + endif; + ?> + + + +
+ +
+ + + \ No newline at end of file diff --git a/cake/tests/test_app/views/layouts/flash.ctp b/cake/tests/test_app/views/layouts/flash.ctp new file mode 100755 index 000000000..b39b71171 --- /dev/null +++ b/cake/tests/test_app/views/layouts/flash.ctp @@ -0,0 +1,45 @@ + + * Copyright 2005-2007, Cake Software Foundation, Inc. + * 1785 E. Sahara Avenue, Suite 490-204 + * Las Vegas, Nevada 89104 + * + * Licensed under The MIT License + * Redistributions of files must retain the above copyright notice. + * + * @filesource + * @copyright Copyright 2005-2007, Cake Software Foundation, Inc. + * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project + * @package cake + * @subpackage cake.cake.libs.view.templates.layouts + * @since CakePHP(tm) v 0.10.0.1076 + * @version $Revision$ + * @modifiedby $LastChangedBy$ + * @lastmodified $Date$ + * @license http://www.opensource.org/licenses/mit-license.php The MIT License + */ +?> + + + +<?php echo $page_title?> +charset(); ?> + + + + + + + +

+ + \ No newline at end of file diff --git a/cake/tests/test_app/views/layouts/js/default.ctp b/cake/tests/test_app/views/layouts/js/default.ctp new file mode 100755 index 000000000..d94dc903a --- /dev/null +++ b/cake/tests/test_app/views/layouts/js/default.ctp @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/cake/tests/test_app/views/layouts/rss/default.ctp b/cake/tests/test_app/views/layouts/rss/default.ctp new file mode 100755 index 000000000..94067f2bf --- /dev/null +++ b/cake/tests/test_app/views/layouts/rss/default.ctp @@ -0,0 +1,17 @@ +header(); + +if (!isset($channel)) { + $channel = array(); +} +if (!isset($channel['title'])) { + $channel['title'] = $title_for_layout; +} + +echo $rss->document( + $rss->channel( + array(), $channel, $content_for_layout + ) +); + +?> \ No newline at end of file diff --git a/cake/tests/test_app/views/layouts/xml/default.ctp b/cake/tests/test_app/views/layouts/xml/default.ctp new file mode 100755 index 000000000..c68870298 --- /dev/null +++ b/cake/tests/test_app/views/layouts/xml/default.ctp @@ -0,0 +1,2 @@ +header()); ?> + \ No newline at end of file diff --git a/cake/tests/test_app/views/pages/empty b/cake/tests/test_app/views/pages/empty new file mode 100755 index 000000000..e69de29bb diff --git a/cake/tests/test_app/views/pages/home.ctp b/cake/tests/test_app/views/pages/home.ctp new file mode 100644 index 000000000..689b1e86b --- /dev/null +++ b/cake/tests/test_app/views/pages/home.ctp @@ -0,0 +1,80 @@ +

Sweet, "Test App" got Baked by CakePHP!

+ + 0): + Debugger::checkSessionKey(); +endif; +?> +

+'; + __('Your tmp directory is writable.'); + echo ''; + else: + echo ''; + __('Your tmp directory is NOT writable.'); + echo ''; + endif; +?> +

+

+'; + echo sprintf(__('The %s is being used for caching. To change the config edit APP/config/core.php ', true), ''. $settings['engine'] . 'Engine'); + echo ''; + else: + echo ''; + __('Your cache is NOT working. Please check the settings in APP/config/core.php'); + echo ''; + endif; +?> +

+

+'; + __('Your database configuration file is present.'); + $filePresent = true; + echo ''; + else: + echo ''; + __('Your database configuration file is NOT present.'); + echo '
'; + __('Rename config/database.php.default to config/database.php'); + echo '
'; + endif; +?> +

+getDataSource('default'); +?> +

+isConnected()): + echo ''; + __('Cake is able to connect to the database.'); + echo ''; + else: + echo ''; + __('Cake is NOT able to connect to the database.'); + echo ''; + endif; +?> +

+ +

+

+', APP . 'views' . DS . 'layouts' . DS . 'default.ctp.
', APP . 'webroot' . DS . 'css'); +?> +

diff --git a/cake/tests/test_app/views/posts/index.ctp b/cake/tests/test_app/views/posts/index.ctp new file mode 100644 index 000000000..ff145eeed --- /dev/null +++ b/cake/tests/test_app/views/posts/index.ctp @@ -0,0 +1 @@ +posts index \ No newline at end of file diff --git a/cake/tests/test_app/views/scaffolds/empty b/cake/tests/test_app/views/scaffolds/empty new file mode 100755 index 000000000..e69de29bb diff --git a/cake/tests/test_app/views/themed/test_theme/layouts/default.ctp b/cake/tests/test_app/views/themed/test_theme/layouts/default.ctp new file mode 100644 index 000000000..89107d393 --- /dev/null +++ b/cake/tests/test_app/views/themed/test_theme/layouts/default.ctp @@ -0,0 +1 @@ +default test_theme layout \ No newline at end of file diff --git a/cake/tests/test_app/views/themed/test_theme/posts/index.ctp b/cake/tests/test_app/views/themed/test_theme/posts/index.ctp new file mode 100644 index 000000000..3ec978c95 --- /dev/null +++ b/cake/tests/test_app/views/themed/test_theme/posts/index.ctp @@ -0,0 +1 @@ +posts index themed view \ No newline at end of file