/** * views method * * If $plugin is not null it will only include views directly in a plugin - it will exclude views * that would otherwise be inherited from the main app * * @param mixed $controllerName * @param mixed $plugin * @param array $excludePatterns * @return void * @access public */ public function views($controllerName, $plugin = null, $excludePatterns = array('/admin.*/'), $nameOnly = true) { if (is_array($controllerName)) { extract(am(array('controllerName' => null), $controllerName)); } $paths = Mi::_viewPaths($plugin); $folder = Inflector::underscore($controllerName); $files = array(); foreach ($paths as $i => &$path) { if (!strpos($path, DS . 'view')) { continue; } if ($plugin) { if (!strpos($path, 'plugins')) { unset($paths[$i]); continue; } $path .= $folder; } $files = Set::merge($files, Mi::files($path . $folder, null, '.*ctp')); } $return = array(); foreach ($files as $file) { if ($nameOnly) { $name = str_replace('.ctp', '', basename($file)); } else { $name = preg_replace('@^.*[\\\\/]views?[\\\\/]' . $folder . '[\\\\/]@', '', $file); $name = str_replace('.ctp', '', $name); } if (isset($return[$name])) { continue; } $return[$name] = $file; } ksort($return); return array_flip($return); }