/** * @see Form::save() */ public function save() { AbstractForm::save(); // create template pack if (count($this->templatePacks) == 0) { $this->templatePackID = TemplatePackEditor::create($this->templatePackName, $this->templatePackFolderName); // get available template packs $this->templatePacks = TemplatePackEditor::getTemplatePacks(); } // save template if ($this->copy) { $this->template = TemplateEditor::create($this->tplName, $this->source, $this->templatePackID, $this->template->packageID); } else { $this->template->update($this->tplName, $this->source, $this->templatePackID); } $this->templateID = $this->template->templateID; // reset cache WCF::getCache()->clear(WCF_DIR . 'cache', 'cache.templates-*.php'); $this->saved(); $this->copy = 0; WCF::getTPL()->assign('success', true); }
/** * @see Form::validate() */ public function validate() { parent::validate(); if (count($this->templatePacks) > 0) { if (!$this->templatePackID) { throw new UserInputException('templatePackID'); } // template pack if ($this->templatePackID) { $templatePack = new TemplatePackEditor($this->templatePackID); if (!$templatePack->templatePackID) { throw new UserInputException('templatePackID'); } } } else { if (empty($this->templatePackName)) { throw new UserInputException('templatePackName'); } if (empty($this->templatePackFolderName)) { throw new UserInputException('templatePackFolderName'); } // create template pack $this->templatePackID = TemplatePackEditor::create($this->templatePackName, FileUtil::addTrailingSlash($this->templatePackFolderName)); // get available template packs $this->templatePacks = TemplatePackEditor::getTemplatePacks(); // reset values $this->templatePackName = $this->templatePackFolderName = ''; } // template name $this->validateTemplateName(); }
/** * @see Form::save() */ public function save() { parent::save(); // save pack $this->templatePackID = TemplatePackEditor::create($this->templatePackName, $this->templatePackFolderName, $this->parentTemplatePackID); // reset cache WCF::getCache()->clear(WCF_DIR . 'cache', 'cache.templatePacks.php'); $this->saved(); // reset values $this->templatePackName = $this->templatePackFolderName = ''; $this->parentTemplatePackID = 0; WCF::getTPL()->assign('success', true); }