/** * 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'); }
public function testExportImport() { $c = new ChartOfTemplates(); $T = new Template(); $T->setId('T'); $c->addTemplate($T); $str = serialize($c); $c2 = unserialize($str); $this->assertTrue($c2->exists('T')); $this->assertEquals($T, $c2->getTemplate('T')); }