1 | <?php |
||
25 | class FController extends CController |
||
26 | { |
||
27 | public $breadcrumbs = array(); |
||
28 | |||
29 | /** |
||
30 | * @var array $activeUrl |
||
31 | */ |
||
32 | public $activeUrl = array(); |
||
33 | |||
34 | /** |
||
35 | * @var bool |
||
36 | */ |
||
37 | protected $rememberThisPage; |
||
38 | |||
39 | public function behaviors() |
||
40 | { |
||
41 | return array( |
||
42 | 'seo' => array('class' => 'SeoBehavior'), |
||
43 | 'controller' => array('class' => 'FControllerBehavior'), |
||
44 | 'textBlock' => array('class' => 'TextBlockBehavior'), |
||
45 | 'common' => array('class' => 'CommonBehavior'), |
||
46 | ); |
||
47 | } |
||
48 | |||
49 | public function actions() |
||
50 | { |
||
51 | return array( |
||
52 | 'captcha' => array( |
||
53 | 'class' => 'FCaptchaAction', |
||
54 | ), |
||
55 | ); |
||
56 | } |
||
57 | |||
58 | public function init() |
||
62 | |||
63 | public function renderOverride($view, $data = null, $return = false, $processOutput = false) |
||
78 | |||
79 | /** |
||
80 | * @param string $modelClass |
||
81 | * @param int $id |
||
82 | * |
||
83 | * @return CActiveRecord |
||
84 | * @throws CHttpException |
||
85 | */ |
||
86 | public function loadModel($modelClass, $id) |
||
87 | { |
||
88 | $model = $modelClass::model()->findByPk($id); |
||
89 | |||
90 | if( $model === null ) |
||
91 | throw new CHttpException(404, "The requested page of {$modelClass} does not exist."); |
||
92 | |||
93 | return $model; |
||
94 | } |
||
95 | |||
96 | /** |
||
97 | * @param string $view |
||
98 | * @param null $data |
||
99 | * @param bool $return |
||
100 | * |
||
101 | * @return string|null |
||
102 | * @throws CException |
||
103 | */ |
||
104 | public function render($view, $data = null, $return = false) |
||
105 | { |
||
106 | $this->onBeforeRender(new CEvent($this, array('data' => $data, 'view' => $view))); |
||
107 | |||
108 | if( $this->beforeRender($view) ) |
||
109 | { |
||
110 | $output = $this->renderPartial($view, $data, true); |
||
111 | |||
112 | if( ($layoutFile = $this->getLayoutFile($this->layout)) !== false ) |
||
113 | { |
||
114 | $this->onBeforeRenderLayout(new CEvent($this, array('content' => $output))); |
||
115 | $output = $this->renderFile($layoutFile, array('content' => $output), true); |
||
116 | } |
||
117 | |||
118 | $this->afterRender($view, $output); |
||
119 | $output = $this->processOutput($output); |
||
120 | |||
121 | if( $return ) |
||
122 | return $output; |
||
123 | else |
||
124 | echo $output; |
||
125 | } |
||
126 | |||
127 | return null; |
||
128 | } |
||
129 | |||
130 | public function onBeforeRender(CEvent $event) |
||
134 | |||
135 | public function onBeforeRenderLayout(CEvent $event) |
||
139 | |||
140 | /** |
||
141 | * http://help.yandex.ru/webmaster/?id=1111858#canonical |
||
142 | * |
||
143 | * @return string |
||
144 | */ |
||
145 | public function getCanonicalUrl() |
||
153 | |||
154 | /** |
||
155 | * @param bool $cutDefaultParams |
||
156 | * |
||
157 | * @return string |
||
158 | */ |
||
159 | public function getCurrentUrl($cutDefaultParams = true) |
||
163 | |||
164 | /** |
||
165 | * @param bool $cutDefaultParams |
||
166 | * |
||
167 | * @return string |
||
168 | */ |
||
169 | public function getCurrentAbsoluteUrl($cutDefaultParams = true) |
||
173 | |||
174 | /** |
||
175 | * @return string |
||
176 | */ |
||
177 | public function getCurrentRoute() |
||
186 | |||
187 | /** |
||
188 | * @param bool $cutDefaultParams |
||
189 | * |
||
190 | * @return string |
||
191 | */ |
||
192 | public function getActionUrl($cutDefaultParams = true) |
||
196 | |||
197 | /** |
||
198 | * @param bool $cutDefaultParams |
||
199 | * |
||
200 | * @return array |
||
201 | */ |
||
202 | public function getActionParams($cutDefaultParams = false) |
||
215 | |||
216 | /** |
||
217 | * @param string $route |
||
218 | * @param array $params |
||
219 | * @param string $ampersand |
||
220 | * |
||
221 | * @return string |
||
222 | */ |
||
223 | public function createUrl($route, $params = array(), $ampersand = '&') |
||
231 | |||
232 | /** |
||
233 | * @param CAction $action |
||
234 | * |
||
235 | * @return void |
||
236 | */ |
||
237 | protected function afterAction($action) |
||
246 | } |