/** * @see HtmlComponent */ public function Render() { // $template = $htmltag = $this->getTag(); $template = WebApplication::getApplication()->getTemplate(get_class($this)); $qid = \phpQuery::getDocumentID($htmltag); $doc = \phpQuery::newDocumentHTML($template); $htmltag->replaceWith($doc['body']->html()); //$htmltag->html($doc['body']->html()); \phpQuery::selectDocument($qid); $this->beforeRender(); parent::RenderImpl(); $this->afterRender(); }
/** * Обработка HTTP запроса * отделяет собственный ID с запроса и передает дочернему элементу * которому предназначен запрос */ public function RequestHandle() { if ($this->visible == false) { return; } $child = next(WebApplication::getApplication()->getRequest()->request_c); if ($this->components[$child] instanceof Requestable) { $this->components[$child]->RequestHandle(); } }
/** * @see Requestable */ public function RequestHandle() { $p = WebApplication::$app->getRequest()->request_params[$this->id]; if (!is_numeric($p[0])) { return; } $item = $this->list[$p[0]]; if (!is_array($item)) { return; } if ($item['type'] == 'click') { $this->selectedvalue = $item['value']; $this->setSelected($p[0]); $this->OnClick(); } if ($item['type'] == 'redirect') { WebApplication::getApplication()->getResponse()->Redirect($item['page'], $item['params']); } }
/** * Метод, выполняющий формирование выходного HTML потока * на основе текущено шаблона и данных елементов страницы */ private final function Render() { if ($this->request->isBinaryRequest()) { return; } $renderpage = $this->currentpage; if ($this->request->isAjaxRequest()) { $renderpage->renderAjax(); return; } //загружаем соответсвующий шаблон $template = $this->getTemplate(get_class($renderpage), $renderpage->layout); $doc = \phpQuery::newDocumentHTML($template); $basepage = get_parent_class($renderpage); // если страница не базовая а дочерняя if ($basepage !== "Zippy\\Html\\WebPage") { $basetemplate = WebApplication::getApplication()->getTemplate($basepage, $renderpage->layout); // if(count($renderpage->_tvars) >0){ // $m = new \Mustache_Engine(); // $basetemplate= $m->render($basetemplate, $renderpage->_tvars); // } $bdoc = \phpQuery::newDocumentHTML($basetemplate); //восстанавливаем по умолчанию $bdoc["childpage"]->replaceWith($doc['body']->html()); $links = $doc['head > link']; foreach ($links as $l) { pq('head')->append($l); } $script = $doc['head > script']; foreach ($script as $sc) { pq('head')->append($sc); } $script = $doc['head > title']; foreach ($script as $sc) { $bdoc['title']->remove(); pq('head')->append($sc); } $script = $doc['head > meta']; foreach ($script as $sc) { pq('head')->append($sc); } /* if (strlen($title) > 0) { $bdoc['description']->remove(); pq('head')->append("<description>{$description}</title>"); } if (strlen($title) > 0) { $bdoc['title']->remove(); pq('head')->append("<title>{$title}</title>"); } */ } $renderpage->Render(); if (strlen($renderpage->_title) > 0) { pq('title')->text($renderpage->_title); } if (strlen($renderpage->_keywords) > 0) { pq('meta[name="keywords"]')->attr('content', $renderpage->_keywords); } if (strlen($renderpage->_description) > 0) { pq('meta[name="description"]')->attr('content', $renderpage->_description); } $response = '<!DOCTYPE HTML>' . pq('html')->htmlOuter(); //HTML в выходной поток if (count($renderpage->_tvars) > 0) { //востанавливаем скобки в тегах $response = str_replace("\"%7B%7B", "\"{{", $response); $response = str_replace("%7D%7D\"", "}}\"", $response); $m = new \Mustache_Engine(); $response = $m->render($response, $renderpage->_tvars); } foreach ($this->macros as $name => $value) { $response = str_ireplace("{" . $name . "}", $value, $response); } $this->response->setContent($response); }