View.php 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755
  1. <?php
  2. /**
  3. * Methods for displaying presentation data in the view.
  4. *
  5. * PHP 5
  6. *
  7. * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
  8. * Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org)
  9. *
  10. * Licensed under The MIT License
  11. * Redistributions of files must retain the above copyright notice.
  12. *
  13. * @copyright Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org)
  14. * @link http://cakephp.org CakePHP(tm) Project
  15. * @package Cake.View
  16. * @since CakePHP(tm) v 0.10.0.1076
  17. * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
  18. */
  19. /**
  20. * Included libraries.
  21. */
  22. App::uses('HelperCollection', 'View');
  23. App::uses('Router', 'Routing');
  24. /**
  25. * View, the V in the MVC triad. View interacts with Helpers and view variables passed
  26. * in from the controller to render the results of the controller action. Often this is HTML,
  27. * but can also take the form of JSON, XML, PDF's or streaming files.
  28. *
  29. * CakePHP uses a two-step-view pattern. This means that the view content is rendered first,
  30. * and then inserted into the selected layout. A special `$content_for_layout` variable is available
  31. * in the layout, and it contains the rendered view. This also means you can pass data from the view to the
  32. * layout using `$this->set()`
  33. *
  34. * @package Cake.View
  35. */
  36. class View extends Object {
  37. /**
  38. * Helpers collection
  39. *
  40. * @var HelperCollection
  41. */
  42. public $Helpers;
  43. /**
  44. * Name of the plugin.
  45. *
  46. * @link http://manual.cakephp.org/chapter/plugins
  47. * @var string
  48. */
  49. public $plugin = null;
  50. /**
  51. * Name of the controller.
  52. *
  53. * @var string Name of controller
  54. */
  55. public $name = null;
  56. /**
  57. * Current passed params
  58. *
  59. * @var mixed
  60. */
  61. public $passedArgs = array();
  62. /**
  63. * An array of names of built-in helpers to include.
  64. *
  65. * @var mixed A single name as a string or a list of names as an array.
  66. */
  67. public $helpers = array('Html');
  68. /**
  69. * Path to View.
  70. *
  71. * @var string Path to View
  72. */
  73. public $viewPath = null;
  74. /**
  75. * Variables for the view
  76. *
  77. * @var array
  78. */
  79. public $viewVars = array();
  80. /**
  81. * Name of view to use with this View.
  82. *
  83. * @var string
  84. */
  85. public $view = null;
  86. /**
  87. * Name of layout to use with this View.
  88. *
  89. * @var string
  90. */
  91. public $layout = 'default';
  92. /**
  93. * Path to Layout.
  94. *
  95. * @var string Path to Layout
  96. */
  97. public $layoutPath = null;
  98. /**
  99. * Turns on or off Cake's conventional mode of applying layout files. On by default.
  100. * Setting to off means that layouts will not be automatically applied to rendered views.
  101. *
  102. * @var boolean
  103. */
  104. public $autoLayout = true;
  105. /**
  106. * File extension. Defaults to Cake's template ".ctp".
  107. *
  108. * @var string
  109. */
  110. public $ext = '.ctp';
  111. /**
  112. * Sub-directory for this view file. This is often used for extension based routing.
  113. * for example with an `xml` extension, $subDir would be `xml/`
  114. *
  115. * @var string
  116. */
  117. public $subDir = null;
  118. /**
  119. * Theme name. If you are using themes, you should remember to use ThemeView as well.
  120. *
  121. * @var string
  122. */
  123. public $theme = null;
  124. /**
  125. * Used to define methods a controller that will be cached.
  126. *
  127. * @see Controller::$cacheAction
  128. * @var mixed
  129. */
  130. public $cacheAction = false;
  131. /**
  132. * holds current errors for the model validation
  133. *
  134. * @var array
  135. */
  136. public $validationErrors = array();
  137. /**
  138. * True when the view has been rendered.
  139. *
  140. * @var boolean
  141. */
  142. public $hasRendered = false;
  143. /**
  144. * List of generated DOM UUIDs
  145. *
  146. * @var array
  147. */
  148. public $uuids = array();
  149. /**
  150. * Holds View output.
  151. *
  152. * @var string
  153. */
  154. public $output = false;
  155. /**
  156. * An instance of a CakeRequest object that contains information about the current request.
  157. * This object contains all the information about a request and several methods for reading
  158. * additional information about the request.
  159. *
  160. * @var CakeRequest
  161. */
  162. public $request;
  163. /**
  164. * The Cache configuration View will use to store cached elements. Changing this will change
  165. * the default configuration elements are stored under. You can also choose a cache config
  166. * per element.
  167. *
  168. * @var string
  169. * @see View::element()
  170. */
  171. public $elementCache = 'default';
  172. /**
  173. * List of variables to collect from the associated controller
  174. *
  175. * @var array
  176. */
  177. private $__passedVars = array(
  178. 'viewVars', 'autoLayout', 'ext', 'helpers', 'view', 'layout', 'name',
  179. 'layoutPath', 'viewPath', 'request', 'plugin', 'passedArgs', 'cacheAction'
  180. );
  181. /**
  182. * Scripts (and/or other <head /> tags) for the layout
  183. *
  184. * @var array
  185. */
  186. protected $_scripts = array();
  187. /**
  188. * Holds an array of paths.
  189. *
  190. * @var array
  191. */
  192. private $__paths = array();
  193. /**
  194. * boolean to indicate that helpers have been loaded.
  195. *
  196. * @var boolean
  197. */
  198. protected $_helpersLoaded = false;
  199. /**
  200. * Constructor
  201. *
  202. * @param Controller $controller A controller object to pull View::__passedArgs from.
  203. */
  204. public function __construct($controller) {
  205. if (is_object($controller)) {
  206. $count = count($this->__passedVars);
  207. for ($j = 0; $j < $count; $j++) {
  208. $var = $this->__passedVars[$j];
  209. $this->{$var} = $controller->{$var};
  210. }
  211. }
  212. $this->Helpers = new HelperCollection($this);
  213. parent::__construct();
  214. }
  215. /**
  216. * Renders a piece of PHP with provided parameters and returns HTML, XML, or any other string.
  217. *
  218. * This realizes the concept of Elements, (or "partial layouts") and the $params array is used to send
  219. * data to be used in the element. Elements can be cached improving performance by using the `cache` option.
  220. *
  221. * @param string $name Name of template file in the/app/View/Elements/ folder
  222. * @param array $data Array of data to be made available to the rendered view (i.e. the Element)
  223. * @param array $options Array of options. Possible keys are:
  224. * - `cache` - Can either be `true`, to enable caching using the config in View::$elementCache. Or an array
  225. * If an array, the following keys can be used:
  226. * - `config` - Used to store the cached element in a custom cache configuration.
  227. * - `key` - Used to define the key used in the Cache::write(). It will be prefixed with `element_`
  228. * - `plugin` - Load an element from a specific plugin.
  229. * - `callbacks` - Set to true to fire beforeRender and afterRender helper callbacks for this element.
  230. * Defaults to false.
  231. * @return string Rendered Element
  232. */
  233. public function element($name, $data = array(), $options = array()) {
  234. $file = $plugin = $key = null;
  235. $callbacks = false;
  236. if (isset($options['plugin'])) {
  237. $plugin = Inflector::camelize($options['plugin']);
  238. }
  239. if (isset($this->plugin) && !$plugin) {
  240. $plugin = $this->plugin;
  241. }
  242. if (isset($options['callbacks'])) {
  243. $callbacks = $options['callbacks'];
  244. }
  245. if (isset($options['cache'])) {
  246. $underscored = null;
  247. if ($plugin) {
  248. $underscored = Inflector::underscore($plugin);
  249. }
  250. $keys = array_merge(array($underscored, $name), array_keys($options), array_keys($data));
  251. $caching = array(
  252. 'config' => $this->elementCache,
  253. 'key' => implode('_', $keys)
  254. );
  255. if (is_array($options['cache'])) {
  256. $defaults = array(
  257. 'config' => $this->elementCache,
  258. 'key' => $caching['key']
  259. );
  260. $caching = array_merge($defaults, $options['cache']);
  261. }
  262. $key = 'element_' . $caching['key'];
  263. $contents = Cache::read($key, $caching['config']);
  264. if ($contents !== false) {
  265. return $contents;
  266. }
  267. }
  268. $file = $this->_getElementFilename($name, $plugin);
  269. if ($file) {
  270. if (!$this->_helpersLoaded) {
  271. $this->loadHelpers();
  272. }
  273. if ($callbacks) {
  274. $this->Helpers->trigger('beforeRender', array($file));
  275. }
  276. $element = $this->_render($file, array_merge($this->viewVars, $data));
  277. if ($callbacks) {
  278. $this->Helpers->trigger('afterRender', array($file, $element));
  279. }
  280. if (isset($options['cache'])) {
  281. Cache::write($key, $element, $caching['config']);
  282. }
  283. return $element;
  284. }
  285. $file = 'Elements' . DS . $name . $this->ext;
  286. if (Configure::read('debug') > 0) {
  287. return "Element Not Found: " . $file;
  288. }
  289. }
  290. /**
  291. * Renders view for given view file and layout.
  292. *
  293. * Render triggers helper callbacks, which are fired before and after the view are rendered,
  294. * as well as before and after the layout. The helper callbacks are called
  295. *
  296. * - `beforeRender`
  297. * - `afterRender`
  298. * - `beforeLayout`
  299. * - `afterLayout`
  300. *
  301. * If View::$autoRender is false and no `$layout` is provided, the view will be returned bare.
  302. *
  303. * @param string $view Name of view file to use
  304. * @param string $layout Layout to use.
  305. * @return string Rendered Element
  306. * @throws CakeException if there is an error in the view.
  307. */
  308. public function render($view = null, $layout = null) {
  309. if ($this->hasRendered) {
  310. return true;
  311. }
  312. if (!$this->_helpersLoaded) {
  313. $this->loadHelpers();
  314. }
  315. $this->output = null;
  316. if ($view !== false && $viewFileName = $this->_getViewFileName($view)) {
  317. $this->Helpers->trigger('beforeRender', array($viewFileName));
  318. $this->output = $this->_render($viewFileName);
  319. $this->Helpers->trigger('afterRender', array($viewFileName));
  320. }
  321. if ($layout === null) {
  322. $layout = $this->layout;
  323. }
  324. if ($this->output === false) {
  325. throw new CakeException(__d('cake_dev', "Error in view %s, got no content.", $viewFileName));
  326. }
  327. if ($layout && $this->autoLayout) {
  328. $this->output = $this->renderLayout($this->output, $layout);
  329. }
  330. $this->hasRendered = true;
  331. return $this->output;
  332. }
  333. /**
  334. * Renders a layout. Returns output from _render(). Returns false on error.
  335. * Several variables are created for use in layout.
  336. *
  337. * - `title_for_layout` - A backwards compatible place holder, you should set this value if you want more control.
  338. * - `content_for_layout` - contains rendered view file
  339. * - `scripts_for_layout` - contains scripts added to header
  340. *
  341. * @param string $content_for_layout Content to render in a view, wrapped by the surrounding layout.
  342. * @param string $layout Layout name
  343. * @return mixed Rendered output, or false on error
  344. * @throws CakeException if there is an error in the view.
  345. */
  346. public function renderLayout($content_for_layout, $layout = null) {
  347. $layoutFileName = $this->_getLayoutFileName($layout);
  348. if (empty($layoutFileName)) {
  349. return $this->output;
  350. }
  351. if (!$this->_helpersLoaded) {
  352. $this->loadHelpers();
  353. }
  354. $this->Helpers->trigger('beforeLayout', array($layoutFileName));
  355. $this->viewVars = array_merge($this->viewVars, array(
  356. 'content_for_layout' => $content_for_layout,
  357. 'scripts_for_layout' => implode("\n\t", $this->_scripts),
  358. ));
  359. if (!isset($this->viewVars['title_for_layout'])) {
  360. $this->viewVars['title_for_layout'] = Inflector::humanize($this->viewPath);
  361. }
  362. $this->output = $this->_render($layoutFileName);
  363. if ($this->output === false) {
  364. throw new CakeException(__d('cake_dev', "Error in layout %s, got no content.", $layoutFileName));
  365. }
  366. $this->Helpers->trigger('afterLayout', array($layoutFileName));
  367. return $this->output;
  368. }
  369. /**
  370. * Render cached view. Works in concert with CacheHelper and Dispatcher to
  371. * render cached view files.
  372. *
  373. * @param string $filename the cache file to include
  374. * @param string $timeStart the page render start time
  375. * @return boolean Success of rendering the cached file.
  376. */
  377. public function renderCache($filename, $timeStart) {
  378. ob_start();
  379. include ($filename);
  380. if (Configure::read('debug') > 0 && $this->layout != 'xml') {
  381. echo "<!-- Cached Render Time: " . round(microtime(true) - $timeStart, 4) . "s -->";
  382. }
  383. $out = ob_get_clean();
  384. if (preg_match('/^<!--cachetime:(\\d+)-->/', $out, $match)) {
  385. if (time() >= $match['1']) {
  386. @unlink($filename);
  387. unset ($out);
  388. return false;
  389. } else {
  390. if ($this->layout === 'xml') {
  391. header('Content-type: text/xml');
  392. }
  393. $commentLength = strlen('<!--cachetime:' . $match['1'] . '-->');
  394. echo substr($out, $commentLength);
  395. return true;
  396. }
  397. }
  398. }
  399. /**
  400. * Returns a list of variables available in the current View context
  401. *
  402. * @return array Array of the set view variable names.
  403. */
  404. public function getVars() {
  405. return array_keys($this->viewVars);
  406. }
  407. /**
  408. * Returns the contents of the given View variable(s)
  409. *
  410. * @param string $var The view var you want the contents of.
  411. * @return mixed The content of the named var if its set, otherwise null.
  412. */
  413. public function getVar($var) {
  414. if (!isset($this->viewVars[$var])) {
  415. return null;
  416. } else {
  417. return $this->viewVars[$var];
  418. }
  419. }
  420. /**
  421. * Adds a script block or other element to be inserted in $scripts_for_layout in
  422. * the `<head />` of a document layout
  423. *
  424. * @param string $name Either the key name for the script, or the script content. Name can be used to
  425. * update/replace a script element.
  426. * @param string $content The content of the script being added, optional.
  427. * @return void
  428. */
  429. public function addScript($name, $content = null) {
  430. if (empty($content)) {
  431. if (!in_array($name, array_values($this->_scripts))) {
  432. $this->_scripts[] = $name;
  433. }
  434. } else {
  435. $this->_scripts[$name] = $content;
  436. }
  437. }
  438. /**
  439. * Generates a unique, non-random DOM ID for an object, based on the object type and the target URL.
  440. *
  441. * @param string $object Type of object, i.e. 'form' or 'link'
  442. * @param string $url The object's target URL
  443. * @return string
  444. */
  445. public function uuid($object, $url) {
  446. $c = 1;
  447. $url = Router::url($url);
  448. $hash = $object . substr(md5($object . $url), 0, 10);
  449. while (in_array($hash, $this->uuids)) {
  450. $hash = $object . substr(md5($object . $url . $c), 0, 10);
  451. $c++;
  452. }
  453. $this->uuids[] = $hash;
  454. return $hash;
  455. }
  456. /**
  457. * Allows a template or element to set a variable that will be available in
  458. * a layout or other element. Analagous to Controller::set().
  459. *
  460. * @param mixed $one A string or an array of data.
  461. * @param mixed $two Value in case $one is a string (which then works as the key).
  462. * Unused if $one is an associative array, otherwise serves as the values to $one's keys.
  463. * @return void
  464. */
  465. public function set($one, $two = null) {
  466. $data = null;
  467. if (is_array($one)) {
  468. if (is_array($two)) {
  469. $data = array_combine($one, $two);
  470. } else {
  471. $data = $one;
  472. }
  473. } else {
  474. $data = array($one => $two);
  475. }
  476. if ($data == null) {
  477. return false;
  478. }
  479. $this->viewVars = $data + $this->viewVars;
  480. }
  481. /**
  482. * Magic accessor for helpers. Provides access to attributes that were deprecated.
  483. *
  484. * @param string $name Name of the attribute to get.
  485. * @return mixed
  486. */
  487. public function __get($name) {
  488. if (isset($this->Helpers->{$name})) {
  489. return $this->Helpers->{$name};
  490. }
  491. switch ($name) {
  492. case 'base':
  493. case 'here':
  494. case 'webroot':
  495. case 'data':
  496. return $this->request->{$name};
  497. case 'action':
  498. return isset($this->request->params['action']) ? $this->request->params['action'] : '';
  499. case 'params':
  500. return $this->request;
  501. }
  502. return null;
  503. }
  504. /**
  505. * Interact with the HelperCollection to load all the helpers.
  506. *
  507. * @return void
  508. */
  509. public function loadHelpers() {
  510. $helpers = HelperCollection::normalizeObjectArray($this->helpers);
  511. foreach ($helpers as $name => $properties) {
  512. list($plugin, $class) = pluginSplit($properties['class']);
  513. $this->{$class} = $this->Helpers->load($properties['class'], $properties['settings']);
  514. }
  515. $this->_helpersLoaded = true;
  516. }
  517. /**
  518. * Renders and returns output for given view filename with its
  519. * array of data.
  520. *
  521. * @param string $___viewFn Filename of the view
  522. * @param array $___dataForView Data to include in rendered view. If empty the current View::$viewVars will be used.
  523. * @return string Rendered output
  524. */
  525. protected function _render($___viewFn, $___dataForView = array()) {
  526. if (empty($___dataForView)) {
  527. $___dataForView = $this->viewVars;
  528. }
  529. extract($___dataForView, EXTR_SKIP);
  530. ob_start();
  531. include $___viewFn;
  532. return ob_get_clean();
  533. }
  534. /**
  535. * Loads a helper. Delegates to the `HelperCollection::load()` to load the helper
  536. *
  537. * @param string $helperName Name of the helper to load.
  538. * @param array $settings Settings for the helper
  539. * @return Helper a constructed helper object.
  540. * @see HelperCollection::load()
  541. */
  542. public function loadHelper($helperName, $settings = array()) {
  543. return $this->Helpers->load($helperName, $settings);
  544. }
  545. /**
  546. * Returns filename of given action's template file (.ctp) as a string.
  547. * CamelCased action names will be under_scored! This means that you can have
  548. * LongActionNames that refer to long_action_names.ctp views.
  549. *
  550. * @param string $name Controller action to find template filename for
  551. * @return string Template filename
  552. * @throws MissingViewException when a view file could not be found.
  553. */
  554. protected function _getViewFileName($name = null) {
  555. $subDir = null;
  556. if (!is_null($this->subDir)) {
  557. $subDir = $this->subDir . DS;
  558. }
  559. if ($name === null) {
  560. $name = $this->view;
  561. }
  562. $name = str_replace('/', DS, $name);
  563. if (strpos($name, DS) === false && $name[0] !== '.') {
  564. $name = $this->viewPath . DS . $subDir . Inflector::underscore($name);
  565. } elseif (strpos($name, DS) !== false) {
  566. if ($name[0] === DS || $name[1] === ':') {
  567. if (is_file($name)) {
  568. return $name;
  569. }
  570. $name = trim($name, DS);
  571. } else if ($name[0] === '.') {
  572. $name = substr($name, 3);
  573. } else {
  574. $name = $this->viewPath . DS . $subDir . $name;
  575. }
  576. }
  577. $paths = $this->_paths($this->plugin);
  578. $exts = $this->_getExtensions();
  579. foreach ($exts as $ext) {
  580. foreach ($paths as $path) {
  581. if (file_exists($path . $name . $ext)) {
  582. return $path . $name . $ext;
  583. }
  584. }
  585. }
  586. $defaultPath = $paths[0];
  587. if ($this->plugin) {
  588. $pluginPaths = App::path('plugins');
  589. foreach ($paths as $path) {
  590. if (strpos($path, $pluginPaths[0]) === 0) {
  591. $defaultPath = $path;
  592. break;
  593. }
  594. }
  595. }
  596. throw new MissingViewException(array('file' => $defaultPath . $name . $this->ext));
  597. }
  598. /**
  599. * Returns layout filename for this template as a string.
  600. *
  601. * @param string $name The name of the layout to find.
  602. * @return string Filename for layout file (.ctp).
  603. * @throws MissingLayoutException when a layout cannot be located
  604. */
  605. protected function _getLayoutFileName($name = null) {
  606. if ($name === null) {
  607. $name = $this->layout;
  608. }
  609. $subDir = null;
  610. if (!is_null($this->layoutPath)) {
  611. $subDir = $this->layoutPath . DS;
  612. }
  613. $paths = $this->_paths($this->plugin);
  614. $file = 'Layouts' . DS . $subDir . $name;
  615. $exts = $this->_getExtensions();
  616. foreach ($exts as $ext) {
  617. foreach ($paths as $path) {
  618. if (file_exists($path . $file . $ext)) {
  619. return $path . $file . $ext;
  620. }
  621. }
  622. }
  623. throw new MissingLayoutException(array('file' => $paths[0] . $file . $this->ext));
  624. }
  625. /**
  626. * Get the extensions that view files can use.
  627. *
  628. * @return array Array of extensions view files use.
  629. * @access protected
  630. */
  631. protected function _getExtensions() {
  632. $exts = array($this->ext);
  633. if ($this->ext !== '.ctp') {
  634. array_push($exts, '.ctp');
  635. }
  636. return $exts;
  637. }
  638. /**
  639. * Finds an element filename, returns false on failure.
  640. *
  641. * @param string $name The name of the element to find.
  642. * @param string $plugin The plugin name the element is in.
  643. * @return mixed Either a string to the element filename or false when one can't be found.
  644. */
  645. protected function _getElementFileName($name, $plugin = null) {
  646. $paths = $this->_paths($plugin);
  647. $exts = $this->_getExtensions();
  648. foreach ($exts as $ext) {
  649. foreach ($paths as $path) {
  650. if (file_exists($path . 'Elements' . DS . $name . $ext)) {
  651. return $path . 'Elements' . DS . $name . $ext;
  652. }
  653. }
  654. }
  655. return false;
  656. }
  657. /**
  658. * Return all possible paths to find view files in order
  659. *
  660. * @param string $plugin Optional plugin name to scan for view files.
  661. * @param boolean $cached Set to true to force a refresh of view paths.
  662. * @return array paths
  663. */
  664. protected function _paths($plugin = null, $cached = true) {
  665. if ($plugin === null && $cached === true && !empty($this->__paths)) {
  666. return $this->__paths;
  667. }
  668. $paths = array();
  669. $viewPaths = App::path('View');
  670. $corePaths = array_flip(App::core('View'));
  671. if (!empty($plugin)) {
  672. $count = count($viewPaths);
  673. for ($i = 0; $i < $count; $i++) {
  674. if (!isset($corePaths[$viewPaths[$i]])) {
  675. $paths[] = $viewPaths[$i] . 'Plugins' . DS . $plugin . DS;
  676. }
  677. }
  678. $paths = array_merge($paths, App::path('View', $plugin));
  679. }
  680. $this->__paths = array_unique(array_merge($paths, $viewPaths, array_keys($corePaths)));
  681. return $this->__paths;
  682. }
  683. }