PageRenderTime 29ms CodeModel.GetById 9ms RepoModel.GetById 1ms app.codeStats 0ms

/lib/Cake/View/ThemeView.php

https://bitbucket.org/udeshika/fake_twitter
PHP | 74 lines | 28 code | 4 blank | 42 comment | 6 complexity | 2557bb3f70f7c43506ec91f045df43d9 MD5 | raw file
  1. <?php
  2. /**
  3. * A custom view class that is used for themeing
  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. App::uses('View', 'View');
  20. /**
  21. * Theme view class
  22. *
  23. * Allows the creation of multiple themes to be used in an app. Theme views are regular view files
  24. * that can provide unique HTML and static assets. If theme views are not found for the current view
  25. * the default app view files will be used. You can set `$this->theme` and `$this->viewClass = 'Theme'`
  26. * in your Controller to use the ThemeView.
  27. *
  28. * Example of theme path with `$this->theme = 'SuperHot';` Would be `app/View/Themed/SuperHot/Posts`
  29. *
  30. * @package Cake.View
  31. */
  32. class ThemeView extends View {
  33. /**
  34. * Constructor for ThemeView sets $this->theme.
  35. *
  36. * @param Controller $controller Controller object to be rendered.
  37. */
  38. public function __construct($controller) {
  39. parent::__construct($controller);
  40. if ($controller) {
  41. $this->theme = $controller->theme;
  42. }
  43. }
  44. /**
  45. * Return all possible paths to find view files in order
  46. *
  47. * @param string $plugin The name of the plugin views are being found for.
  48. * @param boolean $cached Set to true to force dir scan.
  49. * @return array paths
  50. * @todo Make theme path building respect $cached parameter.
  51. */
  52. protected function _paths($plugin = null, $cached = true) {
  53. $paths = parent::_paths($plugin, $cached);
  54. $themePaths = array();
  55. if (!empty($this->theme)) {
  56. $count = count($paths);
  57. for ($i = 0; $i < $count; $i++) {
  58. if (strpos($paths[$i], DS . 'Plugin' . DS) === false
  59. && strpos($paths[$i], DS . 'Cake' . DS . 'View') === false) {
  60. if ($plugin) {
  61. $themePaths[] = $paths[$i] . 'Themed'. DS . $this->theme . DS . 'Plugin' . DS . $plugin . DS;
  62. }
  63. $themePaths[] = $paths[$i] . 'Themed'. DS . $this->theme . DS;
  64. }
  65. }
  66. $paths = array_merge($themePaths, $paths);
  67. }
  68. return $paths;
  69. }
  70. }