'personal'), 'personal') * addConditionGet(array('module' => 'login'), 'login') */ public function addConditionGet($get, Filter $layout) { $this->addCondition(rcurry(array($this, 'checkGet'), $get), $layout); } /** * Условие для аякс запросов. Тоже самое что и addConditionGet но еще проверяется является ли запрос ajax */ public function addConditionXHR($get, Filter $layout) { $this->addCondition(rcurry(array($this, 'checkXHR'), $get), $layout); } public function checkGet($request, $get) { if (is_array($get)) { foreach ($get as $key => $value) { if ($request->get($key) != $value) { return false; } } } return true; } public function checkXHR($request, $get) { return $request->isAjax() && $this->checkGet($request, $get); } /** * Добавляет есловие в общем виде * @parma $get function(HttpRequest) Функция * @parma $layout Layout Макет */ public function addCondition($get, Filter $layout) { $this->condition [] = array($get, $layout); } /** * Выбирает и применяет макет для страницы */ public function execute(HttpRequest $request) { foreach ($this->condition as $condition) { if (call_user_func($condition[0], $request)) { $layout = $condition[1]; $view = $layout->execute($request); if ($view instanceof View_Composite) { echo $view->render(); } else { echo $view; } return null; } } } } /** * Самый простой макет */ class LayoutNone extends Filter { function execute(HttpRequest $request) { return $this->processor->execute($request); } }