@@ 205-227 (lines=23) @@ | ||
202 | * @param boolean $_return_ whether the rendering result should be returned as a string |
|
203 | * @return string the rendering result. Null if the rendering result is not required. |
|
204 | */ |
|
205 | private function _renderInternal($_viewFile_, $_data_ = null, $_return_ = false) |
|
206 | { |
|
207 | // we use special variable names here to avoid conflict when extracting data |
|
208 | if (is_array($_data_)) |
|
209 | { |
|
210 | extract($_data_, EXTR_PREFIX_SAME, 'data'); |
|
211 | } |
|
212 | else |
|
213 | { |
|
214 | $data = $_data_; |
|
215 | } |
|
216 | if ($_return_) |
|
217 | { |
|
218 | ob_start(); |
|
219 | ob_implicit_flush(false); |
|
220 | require($_viewFile_); |
|
221 | return ob_get_clean(); |
|
222 | } |
|
223 | else |
|
224 | { |
|
225 | require($_viewFile_); |
|
226 | } |
|
227 | } |
|
228 | ||
229 | /** |
|
230 | * Create and run widget. Use this in templates to properly initialize widgets. |
@@ 33-56 (lines=24) @@ | ||
30 | * @param bool $_return_ |
|
31 | * @return string |
|
32 | */ |
|
33 | public function render($_viewFile_, $_data_, $_return_ = false) |
|
34 | { |
|
35 | $_viewFile_ = sprintf('%s.php', $_viewFile_); |
|
36 | // we use special variable names here to avoid conflict when extracting data |
|
37 | if (is_array($_data_)) |
|
38 | { |
|
39 | extract($_data_, EXTR_PREFIX_SAME, 'data'); |
|
40 | } |
|
41 | else |
|
42 | { |
|
43 | $data = $_data_; |
|
44 | } |
|
45 | if ($_return_) |
|
46 | { |
|
47 | ob_start(); |
|
48 | ob_implicit_flush(false); |
|
49 | require($_viewFile_); |
|
50 | return ob_get_clean(); |
|
51 | } |
|
52 | else |
|
53 | { |
|
54 | require($_viewFile_); |
|
55 | } |
|
56 | } |
|
57 | ||
58 | } |
|
59 |