public function layoutAction() { $request = $this->getRequest(); $template = $request->getParam('template_id'); $this->view->template = $template; $pageId = $request->getParam('page_id'); $page = Modules_Core_Services_Page::getById($pageId); if (null == $page) { return; } $page['template_id'] = $template; $this->view->pageData = $page; $blocksData = array(); $dataFile = TEMPLATE_DIR . DS . $template . DS . 'data' . DS . $page['route'] . '.xml'; if (file_exists($dataFile)) { $blocksData = Modules_Core_Services_Page::importXml($dataFile); } $this->view->blocksData = $blocksData; if ($request->isPost()) { $this->setNoRender(); $this->disableLayout(); $blocks = $request->getPost('blocks'); $newBlocks = array(); if ($blocks) { foreach ($blocks as $index => $block) { if (isset($block['type']) && $block['type'] == 'widget') { $block['action'] = 'show'; } else { $block['type'] = 'action'; } $block['load'] = isset($block['load']) && $block['load'] == 'ajax' ? 'ajax' : 'php'; $block['cache']['enable'] = isset($block['cache']['enable']) && $block['cache']['enable'] == 'true' ? 'true' : 'false'; $block['cache']['timeout'] = isset($block['cache']['timeout']) && $block['cache']['timeout'] > 0 ? $block['cache']['timeout'] : 0; $newBlocks['block'][] = $block; } } $content = utf8_decode(Gio_Core_Array::toXml($newBlocks, 'pages')); Gio_Core_File::writeToFile($dataFile, $content); $this->getResponse()->setBody('RESULT_OK'); return; } $layoutFile = TEMPLATE_DIR . DS . $template . DS . 'layouts' . DS . $page['route'] . '.phtml'; if (!file_exists($layoutFile)) { return; } $blocks = Modules_Core_Services_Page::import($layoutFile); $this->view->blocks = $blocks; }