function perform() { $this->_view = new AdminTemplatedView($this->_blogInfo, "newglobaltemplate"); $this->_view->setValue("templateFolder", TemplateSetStorage::getBaseTemplateFolder()); $this->setCommonData(); return true; }
/** * constructor * * @param templateFolder Starting folder where we will look for files. If none * is specified, the default ./templates folder will be used (or the one that has * been configured in the "templates_folder" parameter in the plog_config table * @see FileFinder::FileFinder */ function TemplateFinder($templateFolder = null) { // if there is no template folder, use the default one if ($templateFolder == null) { $templateFolder = TemplateSetStorage::getBaseTemplateFolder(); } $this->_templateFolder = $templateFolder; $this->FileFinder($templateFolder); }
function perform() { $this->_templateId = $this->_request->getValue("templateId"); $ts = new TemplateSetStorage(); $blogId = $this->_blogInfo->getId(); $baseTemplateFolder = $ts->getBaseTemplateFolder(); $templateArchive = new zip_file($this->_templateId . ".zip"); $templateArchive->set_options(array('basedir' => $baseTemplateFolder, 'overwrite' => 1, 'inmemory' => 1)); $templateArchive->add_files($this->_templateId); $templateArchive->create_archive(); $templateArchive->download_file(); return true; }
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; }
/** * @private * Factored out from above... */ function _getTemplateFileInfo($templateName, $layout, $blogInfo) { // build the file name if ($blogInfo == null) { $templateFileName = $layout . '/' . $templateName . '.template'; $templateFolder = TemplateSetStorage::getBaseTemplateFolder(); } else { // // might be the case that the template is not local but global, so // by default, global templates will always have preference over // local templates. If the template is global, then // $baseTemplateFolder = TemplateSetStorage::getBaseTemplateFolder(); $globalTemplateFolder = $baseTemplateFolder . '/' . $layout; $localTemplateFolder = $baseTemplateFolder . '/' . BLOG_BASE_TEMPLATE_FOLDER . $blogInfo->getId() . '/' . $layout; //print("local = $localTemplateFolder - global = $globalTemplateFolder<br/>"); $templateFileName = $layout . '/' . $templateName . '.template'; if (!File::isDir($globalTemplateFolder)) { //$templateFileName = $layout."/".$templateName.".template"; $templateFolder = $baseTemplateFolder . '/' . BLOG_BASE_TEMPLATE_FOLDER . $blogInfo->getId(); } else { $templateFolder = $baseTemplateFolder . '/'; } } $result['templateFileName'] = $templateFileName; $result['templateFolder'] = $templateFolder; return $result; }
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; }
/** * returns the path where the admin templates are stored * * @return a path */ function getAdminTemplateFolder() { $templatePath = TemplateSetStorage::getBaseTemplateFolder() . "/admin"; return $templatePath; }