/** * Build and return admin interface * * Any module providing an admin interface is required to have this function, which * returns a string containing the (x)html of it's admin interface. * @return string */ function getAdminInterface() { $this->addCSS('/modules/Templater/css/templates.css'); $templates = Template::getAllTemplates(); if (!isset($_REQUEST['template_id'])) { $this->smarty->assign('curtemplate', $templates[0]); } else { if (isset($_REQUEST['save'])) { $t = new Template($_REQUEST['template_id']); $t->setData(u($_REQUEST['editor'])); $t->setTimestamp(date('Y-m-d H:i:s')); $t->setId(null); $t->save(); $this->smarty->assign('curtemplate', $t); $templates = Template::getAllTemplates(); } else { if (isset($_REQUEST['switch_template'])) { $this->smarty->clear_assign('curtemplate'); $this->smarty->assign('curtemplate', new Template($_REQUEST['template'])); } else { if (isset($_REQUEST['switch_revision'])) { $this->smarty->clear_assign('curtemplate'); $this->smarty->assign('curtemplate', new Template($_REQUEST['revision'])); } else { $this->smarty->assign('curtemplate', new Template($_REQUEST['template_id'])); } } } } $this->smarty->assign('templates', $templates); return $this->smarty->fetch('admin/templates.tpl'); }
function loadTemplate() { import("view.Template"); $template = new Template($this->view); $template->setData($this->data); //$template->setLanguage($this->language); $template->setContent(implode("", file($this->view))); return $template->render(); }
/** * (non-PHPdoc) * @see Block_Abstract::render() */ public function render() { $this->_collectData(); $tpl = new Template(); $tpl->setData(array('config' => $this->_config, 'place' => $this->_config['place'], 'menuData' => $this->_data)); if (static::dependsOnPage) { $tpl->set('page', Page::getInstance()); $tpl->set('pagesTree', Model::factory('Page')->getTree()); } return $tpl->render(Application::getTemplatesPath() . $this->_template); }
protected function loadTemplateDataSource(Template &$template) { if ($this->benchmarkRendering) { $this->Benchmark->start('load-template-datasource-' . $template->getName()); } $locals = $template->getLocals(); $datasource = null; if (isset($locals['DataSource'])) { $datasource = $locals['DataSource']; } $this->Logger->debug('DataSource [' . $datasource . ']'); $data = null; if ($template->getData() !== null) { $data = $template->getData(); } if ($datasource != null && !empty($datasource)) { $preloadedData = $data !== null ? $data : array(); $data = $this->ControllerManager->invokeDatasource($datasource, $preloadedData, $locals); // datasources can change locals manually $template->setLocals($locals); // // if($module['name'] == $this->view && count($data) == 1) { // if(isset($data[0]['id'])) { // $this->globals['SingleID'] = $data[0]['id']; // $templateSetGlobals['SingleID'] = $data[0]['id']; // } // if(isset($data[0]['Slug'])) { // $module['SingleSlug'] = $data[0]['Slug']; // $this->globals['SingleSlug'] = $module['SingleSlug']; // $templateSetGlobals['SingleSlug'] = $data[0]['Slug']; // } // if(isset($data[0]['Type'])) { // $module['TypeSlug'] = $data[0]['Type']; // $this->globals['SingleType'] = $module['TypeSlug']; // $templateSetGlobals['SingleType'] = $data[0]['Type']; // } // if(isset($data[0]['Status'])) { // $this->globals['SingleStatus'] = $data[0]['Status']; // $templateSetGlobals['SingleStatus'] = $data[0]['Status']; // } // if(isset($data[0]['ActiveDate'])) { // $this->globals['SingleActiveDate'] = $data[0]['ActiveDate']; // $templateSetGlobals['SingleActiveDate'] = $data[0]['ActiveDate']; // } // $module['ElementName'] = $element; // $this->globals['SingleElement'] = $element; // $templateSetGlobals['SingleElement'] = $element; // } } if ($this->benchmarkRendering) { $this->Benchmark->end('load-template-datasource-' . $template->getName()); } $template->setData($data); return $template; }
public function newTemplate() { try { $model = new Template(); $this->data->template->entry = 'tpl_' . $this->data->template->entry; $model->setData($this->data->template); $model->save(); $this->renderPrompt('information', 'OK', "structure.editEntry('{$this->data->template->entry}');"); } catch (\Exception $e) { $this->renderPrompt('error', $e->getMessage()); } }