Esempio n. 1
0
 /**
  * Verification callback to prepare a template. This isn't actually a verifier;
  * it just automatically compiles the template.
  *
  * @param string $string Uncompiled template
  *
  * @return boolean
  */
 protected function _verifyPrepareAdminTemplate($template)
 {
     $standardParse = true;
     $parsed = null;
     if (!$this->get('disable_modifications')) {
         $templateWithModifications = $this->_getModificationModel()->applyModificationsToTemplate($this->get('title'), $template, $modificationStatuses);
     } else {
         $modificationStatuses = null;
         $templateWithModifications = $template;
     }
     if ($modificationStatuses) {
         try {
             $compiler = new Brivium_AdminStyleSystem_Template_Compiler_Admin($templateWithModifications);
             $parsed = $compiler->lexAndParse();
             if ($this->getOption(self::OPTION_TEST_COMPILE)) {
                 $compiler->setFollowExternal(false);
                 $compiler->compileParsed($parsed, $this->get('title'), 0, 0);
             }
             $standardParse = false;
         } catch (XenForo_Template_Compiler_Exception $e) {
             foreach ($modificationStatuses as &$status) {
                 if (is_int($status)) {
                     $status = 'error_compile';
                 }
             }
         }
     }
     if ($standardParse) {
         try {
             $compiler = new Brivium_AdminStyleSystem_Template_Compiler_Admin($template);
             $parsed = $compiler->lexAndParse();
             if ($this->getOption(self::OPTION_TEST_COMPILE)) {
                 $compiler->setFollowExternal(false);
                 $compiler->compileParsed($parsed, $this->get('title'), 0, 0);
             }
         } catch (XenForo_Template_Compiler_Exception $e) {
             $this->error($e->getMessage(), 'template');
             return false;
         }
     }
     $this->set('template_parsed', serialize($parsed));
     $this->_modificationStatuses = $modificationStatuses;
     return true;
 }