public function render($arrLayoutData = array()) { $arrBoxesResponseContents = array(); foreach ($this->arrPlaceholderBoxes as $strPlaceholderName => $arrBoxes) { $arrBoxesResponseContents[$strPlaceholderName] = array(); foreach ($arrBoxes as $objBox) { $objBoxResponse = $objBox->launch(); $arrBoxesResponseContents[$strPlaceholderName][] = $objBoxResponse->__toString(); } } $strLayoutFullName = get_called_class(); $arrLayoutFullNameTokens = explode('\\', $strLayoutFullName); $strLayoutName = array_pop($arrLayoutFullNameTokens); $strLayoutPath = sprintf('%s/layout/view/%s', Application::getInstance()->strDirectory, $strLayoutName); $objTemplater = Templater::createSpecifiedTemplater(Config::get('templater')); $objCurrentRoute = Router::getCurrentRoute(); if (!empty($objCurrentRoute)) { $arrLayoutData['route'] = array('name' => $objCurrentRoute->strRouteName, 'action' => $objCurrentRoute->strMethodName); } if (method_exists($this, 'launch')) { $arrLayoutData = array_merge($this->launch(), $arrLayoutData); } $strLayoutContent = $objTemplater->getTemplateFileContent($strLayoutPath, $arrLayoutData); foreach ($this->arrPlaceholderBoxes as $strPlaceholderName => $arrBoxes) { $strLayoutContent = str_replace(sprintf('[placeholder:%s]', $strPlaceholderName), join('', $arrBoxesResponseContents[$strPlaceholderName]), $strLayoutContent); } // removing unused placeholders $strLayoutContent = preg_replace('/\\[placeholder\\:([a-z\\-]+)\\]/', '', $strLayoutContent); // echo $strLayoutContent;exit(); // echo $strLayoutContent;exit(); return $strLayoutContent; }
public function launch() { $this->objTemplater = Templater::createSpecifiedTemplater(Config::get('templater')); $objCurrentRoute = $this->objRouter->dispath(); // $arrRequestParams = Request::getParams(); if (empty($objCurrentRoute)) { $objResponse = Board::launch('Error', 'notFound'); } else { $objResponse = Board::launch($objCurrentRoute->strRouteName, $objCurrentRoute->strMethodName); } // $objBoard->launch(); return $objResponse; // echo '<pre>'; // print_r($objResponse); // exit(); // $objResponse = $objCurrentRoute->launch(); // if (!empty($objResponse)) { // $objResponse->output($objCurrentRoute); // } // echo $objResponse; // $strOutput = $this->objTemplater->renderController($objController); // // $objResponse = new Response(); // $objResponse->setContent($strOutput); // return $objResponse; }