/** * 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; }