public function testSaveCustomFile() { // create custom file first $this->request->set('file', 'theme/sometheme/test.tpl'); $this->request->set('code', 'test code'); $response = $this->controller->save(); // edit the file $this->request->set('file', 'theme/sometheme/test.tpl'); $this->request->set('code', 'test code'); $response = $this->controller->save(); $template = new Template('test.tpl', 'sometheme'); $this->assertEquals($template->getCode(), 'test code'); $this->assertEquals($template->getFileName(), 'theme/sometheme/test.tpl'); $template->restoreOriginal(); }
private function getTemplateForm(Template $template) { $form = new Form($this->getValidator('template', $this->request)); $form->setData($template->toArray()); $form->set('code', ''); $form->set('fileName', $template->getFileName()); return $form; }
/** * deletes customized template * removes: * customized template file * customized template file for each theme (if exists) * backups (for customized template file, and each theme) */ public function delete() { if ($this->isCustomFile() == false) { throw new Exception('Only custom files can be deleted'); } $filesToRemove[] = Template::getCustomizedFilePath($this->file); $filesToRemove = array_merge($filesToRemove, $this->getBackups(false)); $otherThemes = $this->getOtherThemes(); foreach ($otherThemes as $key => $themename) { if ($key == '') { continue; } $template = new Template($this->file, $themename); $filesToRemove[] = Template::getCustomizedFilePath($template->getFileName()); $filesToRemove = array_merge($filesToRemove, $template->getBackups(false)); } $filesToRemove = array_values($filesToRemove); while ($fn = array_pop($filesToRemove)) { if (is_readable($fn)) { unlink($fn); } } return true; }
function testThemeTemplateToAnotherTheme() { $template = new Template('theme/default/layout/frontend.tpl', 'sometheme'); $this->assertEquals($template->getFileName(), 'theme/sometheme/layout/frontend.tpl'); }