/**
  * @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 Page::readData()
  */
 public function readData()
 {
     parent::readData();
     if (!count($_POST)) {
         $this->variables = $this->defaultVariables;
         // enable some functions by default
         $this->variables['container1.link.color.use'] = $this->variables['container1.background.color.use'] = 1;
         $this->variables['container2.link.color.use'] = $this->variables['container2.background.color.use'] = 1;
         $this->variables['container3.link.color.use'] = $this->variables['container3.background.color.use'] = 1;
         $this->variables['container4.link.color.use'] = $this->variables['container4.background.color.use'] = 1;
         $this->variables['global.favicon.use'] = $this->variables['page.background.image.use'] = 1;
         $this->variables['page.logo.image.use'] = $this->variables['page.title.font.color.use'] = 1;
         $this->variables['page.link.external.use'] = $this->variables['page.link.active.use'] = 1;
         $this->variables['buttons.small.caption.show'] = $this->variables['buttons.large.caption.show'] = 1;
         $this->variables['menu.main.caption.show'] = 1;
         $this->variables['menu.dropdown.link.color.use'] = $this->variables['menu.dropdown.background.color.use'] = 1;
         $this->variables['messages.sidebar.divider.use'] = $this->variables['messages.color.cycle'] = 1;
     }
     $this->fontStyles = array('normal' => WCF::getLanguage()->get('wcf.acp.style.editor.font.style.normal'), 'bold' => WCF::getLanguage()->get('wcf.acp.style.editor.font.style.bold'), 'italic' => WCF::getLanguage()->get('wcf.acp.style.editor.font.style.italic'), 'bold italic' => WCF::getLanguage()->get('wcf.acp.style.editor.font.style.boldAndItalic'));
     $this->templatePacks = TemplatePackEditor::getTemplatePacks();
 }