1 | <?php |
||
7 | class View |
||
|
|||
8 | { |
||
9 | /** |
||
10 | * simply includes (=shows) the view. this is done from the controller. In the controller, you usually say |
||
11 | * $this->view->render('help/index'); to show (in this example) the view index.php in the folder help. |
||
12 | * Usually the Class and the method are the same like the view, but sometimes you need to show different views. |
||
13 | * @param string $filename Path of the to-be-rendered view, usually folder/file(.php) |
||
14 | * @param array $data Data to be used in the view |
||
15 | */ |
||
16 | public function render($filename, $data = null) |
||
28 | |||
29 | /** |
||
30 | * Similar to render, but accepts an array of separate views to render between the header and footer. Use like |
||
31 | * the following: $this->view->renderMulti(array('help/index', 'help/banner')); |
||
32 | * @param array $filenames Array of the paths of the to-be-rendered view, usually folder/file(.php) for each |
||
33 | * @param array $data Data to be used in the view |
||
34 | * @return bool |
||
35 | */ |
||
36 | public function renderMulti($filenames, $data = null) |
||
57 | |||
58 | /** |
||
59 | * Same like render(), but does not include header and footer |
||
60 | * @param string $filename Path of the to-be-rendered view, usually folder/file(.php) |
||
61 | * @param mixed $data Data to be used in the view |
||
62 | */ |
||
63 | public function renderWithoutHeaderAndFooter($filename, $data = null) |
||
73 | |||
74 | /** |
||
75 | * Renders pure JSON to the browser, useful for API construction |
||
76 | * @param $data |
||
77 | */ |
||
78 | public function renderJSON($data) |
||
83 | |||
84 | /** |
||
85 | * renders the feedback messages into the view |
||
86 | */ |
||
87 | public function renderFeedbackMessages() |
||
97 | |||
98 | /** |
||
99 | * Checks if the passed string is the currently active controller. |
||
100 | * Useful for handling the navigation's active/non-active link. |
||
101 | * |
||
102 | * @param string $filename |
||
103 | * @param string $navigation_controller |
||
104 | * |
||
105 | * @return bool Shows if the controller is used or not |
||
106 | */ |
||
107 | public static function checkForActiveController($filename, $navigation_controller) |
||
118 | |||
119 | /** |
||
120 | * Checks if the passed string is the currently active controller-action (=method). |
||
121 | * Useful for handling the navigation's active/non-active link. |
||
122 | * |
||
123 | * @param string $filename |
||
124 | * @param string $navigation_action |
||
125 | * |
||
126 | * @return bool Shows if the action/method is used or not |
||
127 | */ |
||
128 | public static function checkForActiveAction($filename, $navigation_action) |
||
139 | |||
140 | /** |
||
141 | * Checks if the passed string is the currently active controller and controller-action. |
||
142 | * Useful for handling the navigation's active/non-active link. |
||
143 | * |
||
144 | * @param string $filename |
||
145 | * @param string $navigation_controller_and_action |
||
146 | * |
||
147 | * @return bool |
||
148 | */ |
||
149 | public static function checkForActiveControllerAndAction($filename, $navigation_controller_and_action) |
||
165 | |||
166 | /** |
||
167 | * Converts characters to HTML entities |
||
168 | * This is important to avoid XSS attacks, and attempts to inject malicious code in your page. |
||
169 | * |
||
170 | * @param string $str The string. |
||
171 | * @return string |
||
172 | */ |
||
173 | public function encodeHTML($str){ |
||
176 | } |
||
177 |
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.