function perform() { // get a list with all the global template sets $ts = new TemplateSets(); $globalTemplates = $ts->getGlobalTemplateSets(); foreach ($globalTemplates as $template) { if ($template->getName() == $this->_newTemplateId) { $this->_view = new PluginSiteTemplateSetsListView($this->_blogInfo); $this->_view->setErrorMessage($this->_locale->tr("error_duplicate_templateset_name")); $this->setCommonData(); return false; } } $ts = new TemplateSetStorage(); $blogId = $this->_blogInfo->getId(); $sourceTemplateFolder = $ts->getTemplateFolder($this->_templateId); $newTemplateFolder = $ts->getBaseTemplateFolder() . "/" . $this->_newTemplateId; if (MyFile::copyDir($sourceTemplateFolder, $newTemplateFolder)) { $ts->addTemplate($this->_newTemplateId); } else { File::deleteDir($newTemplateFolder); $this->_view = new PluginSiteTemplateSetsListView($this->_blogInfo); $this->_view->setErrorMessage($this->_locale->tr("error_copying_templateset")); $this->setCommonData(); return false; } // if everything went ok... $this->_session->setValue("blogInfo", $this->_blogInfo); $this->saveSession(); $this->_view = new PluginSiteTemplateSetsListView($this->_blogInfo); $this->_view->setSuccessMessage($this->_locale->tr("templateeditor_templateset_copyed_ok")); $this->setCommonData(); // clear the cache CacheControl::resetBlogCache($this->_blogInfo->getId()); return true; }
function _addTemplateCode($templateName) { $ts = new TemplateSetStorage(); // make sure that the template is valid $templateSandbox = new TemplateSandbox(); $valid = $templateSandbox->checkTemplateFolder($templateName, $ts->getBaseTemplateFolder()); if ($valid < 0) { $this->_errorMessage = $this->_locale->pr('error_installing_template', $templateName) . ': ' . $this->_checkTemplateSandboxResult($valid) . '<br/>'; $result = false; } else { // otherwise, we can add it without problems $ts->addTemplate($templateName); $this->_successMessage = $this->_locale->pr('template_installed_ok', $templateName) . '<br/>'; $result = true; } $this->setCommonData(); return $result; }
/** * @private */ function _addTemplateCode($templateName) { $config =& Config::getConfig(); $templateFolder = $config->getValue("template_folder"); $ts = new TemplateSetStorage(); $this->_view = new AdminBlogTemplateSetsListView($this->_blogInfo); // make sure that the template is valid $templateSandbox = new TemplateSandbox(); $valid = $templateSandbox->checkTemplateFolder($templateName, $ts->getBlogBaseTemplateFolder($this->_blogInfo->getId())); if ($valid < 0) { $this->_errorMessage = $this->_locale->pr('error_installing_template', $templateName) . ': ' . AdminAddTemplateAction::_checkTemplateSandboxResult($valid) . '<br/>'; $result = false; } else { // otherwise, we can add it without problems $ts->addTemplate($templateName, $this->_blogInfo->getId()); $this->_successMessage = $this->_locale->pr("template_installed_ok", $templateName); $result = true; } $this->setCommonData(); return $result; }