These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | /** |
||
3 | * Copyright (c) 2013-2016 |
||
4 | * |
||
5 | * @category Library |
||
6 | * @package Dwoo\Adapters\CakePHP |
||
7 | * @author Jordi Boggiano <[email protected]> |
||
8 | * @author David Sanchez <[email protected]> |
||
9 | * @copyright 2008-2013 Jordi Boggiano |
||
10 | * @copyright 2013-2016 David Sanchez |
||
11 | * @license http://dwoo.org/LICENSE Modified BSD License |
||
12 | * @version 1.3.0 |
||
13 | * @date 2016-09-19 |
||
14 | * @link http://dwoo.org/ |
||
15 | */ |
||
16 | |||
17 | App::import('vendor', 'dwoo', array('file' => 'dwoo/dwooAutoload.php')); |
||
18 | |||
19 | /** |
||
20 | * Dwoo adapter for CakePHP. |
||
21 | * |
||
22 | * Based on SmartyView by Mark John S. Buenconsejo <[email protected]> |
||
23 | * |
||
24 | * This software is provided 'as-is', without any express or implied warranty. |
||
25 | * In no event will the authors be held liable for any damages arising from the use of this software. |
||
26 | * |
||
27 | * This file is released under the LGPL |
||
28 | * "GNU Lesser General Public License" |
||
29 | * More information can be found here: |
||
30 | * {@link http://www.gnu.org/copyleft/lesser.html} |
||
31 | * |
||
32 | * @author Mark John S. Buenconsejo <[email protected]> |
||
33 | * @author Giangi <[email protected]> |
||
34 | * @author Jordi Boggiano <[email protected]> |
||
35 | * @copyright Copyright (c) 2008, Jordi Boggiano |
||
36 | * @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License |
||
37 | * |
||
38 | * @link http://dwoo.org/ |
||
39 | * |
||
40 | * @version 1.1.0 |
||
41 | * @date 2009-07-18 |
||
42 | */ |
||
43 | class DwooView extends View |
||
0 ignored issues
–
show
|
|||
44 | { |
||
45 | protected $_sv_template_dir; |
||
46 | protected $_sv_layout_dir; |
||
47 | protected $_sv_compile_dir; |
||
48 | protected $_sv_cache_dir; |
||
49 | protected $_sv_compile_id; |
||
50 | |||
51 | protected $_dwoo; |
||
52 | |||
53 | public $sv_processedTpl; |
||
54 | |||
55 | public function __construct(&$controller) |
||
56 | { |
||
57 | parent::__construct($controller); |
||
58 | |||
59 | $this->ext = '.tpl'; |
||
60 | |||
61 | $this->_sv_template_dir = array( |
||
62 | VIEWS.$this->viewPath.DS.$this->subDir, |
||
63 | VIEWS.$this->viewPath, |
||
64 | VIEWS, |
||
65 | ); |
||
66 | |||
67 | $this->_sv_layout_dir = array( |
||
68 | LAYOUTS.$this->subDir, |
||
69 | VIEWS, |
||
70 | ); |
||
71 | |||
72 | $this->_sv_compile_dir = TMP.'dwoo'.DS.'compile'; |
||
73 | $this->_sv_cache_dir = TMP.'dwoo'.DS.'cache'; |
||
74 | |||
75 | $this->_dwoo = new Dwoo_Core($this->_sv_compile_dir, $this->_sv_cache_dir); |
||
76 | |||
77 | $this->_sv_compile_id = $controller->name; |
||
78 | |||
79 | $this->_dwoo->sv_this = $this; |
||
80 | $this->_dwoo->setSecurityPolicy(); |
||
81 | |||
82 | return; |
||
83 | } |
||
84 | |||
85 | /** |
||
86 | * changes the template directory. |
||
87 | */ |
||
88 | public function setTemplateDir($path = VIEW) |
||
89 | { |
||
90 | $old = $this->_sv_template_dir; |
||
91 | $this->_sv_template_dir = $path; |
||
92 | |||
93 | return $old; |
||
94 | } |
||
95 | |||
96 | public function getTemplateDir() |
||
97 | { |
||
98 | return $this->_sv_template_dir; |
||
99 | } |
||
100 | |||
101 | public function _render($___viewFn, $___data_for_view, $___play_safe = true, $loadHelpers = true) |
||
102 | { |
||
103 | // let's determine if this is a layout call or a template call |
||
104 | // and change the template dir accordingly |
||
105 | $layout = false; |
||
106 | if (isset($___data_for_view['content_for_layout'])) { |
||
107 | $this->_sv_template_dir = $this->_sv_layout_dir; |
||
108 | $layout = true; |
||
109 | } |
||
110 | |||
111 | $tpl = new Dwoo_Template_File($___viewFn); |
||
112 | $data = $___data_for_view; |
||
113 | |||
114 | $data['view'] = $this; |
||
115 | |||
116 | if ($this->helpers != false && $loadHelpers === true) { |
||
117 | $loadedHelpers = array(); |
||
118 | $loadedHelpers = $this->_loadHelpers($loadedHelpers, $this->helpers); |
||
119 | |||
120 | foreach (array_keys($loadedHelpers) as $helper) { |
||
121 | $camelBackedHelper = strtolower(substr($helper, 0, 1)).substr($helper, 1); |
||
122 | |||
123 | ${$camelBackedHelper} = $loadedHelpers[$helper]; |
||
124 | |||
125 | if (is_array(${$camelBackedHelper}->helpers) && !empty(${$camelBackedHelper}->helpers)) { |
||
126 | $subHelpers = ${$camelBackedHelper}->helpers; |
||
127 | foreach ($subHelpers as $subHelper) { |
||
128 | ${$camelBackedHelper}->{$subHelper} = $loadedHelpers[$subHelper]; |
||
129 | } |
||
130 | } |
||
131 | |||
132 | if (isset($this->passedArgs)) { |
||
133 | ${$camelBackedHelper}->passedArgs = $this->passedArgs; |
||
134 | } |
||
135 | |||
136 | $this->loaded[$camelBackedHelper] = ${$camelBackedHelper}; |
||
137 | |||
138 | $data[$camelBackedHelper] = ${$camelBackedHelper}; |
||
139 | } |
||
140 | } |
||
141 | |||
142 | if ($this->helpers != false && $loadHelpers === true) { |
||
143 | foreach ($loadedHelpers as $helper) { |
||
144 | if (is_object($helper)) { |
||
145 | if (is_subclass_of($helper, 'Helper') || is_subclass_of($helper, 'helper')) { |
||
146 | $helper->beforeRender(); |
||
147 | } |
||
148 | } |
||
149 | } |
||
150 | } |
||
151 | |||
152 | return $this->_dwoo->get($tpl, $data); |
||
153 | } |
||
154 | |||
155 | public function get() |
||
156 | { |
||
157 | return $this->_dwoo; |
||
158 | } |
||
159 | } |
||
160 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.