當前位置: 首頁>>代碼示例>>PHP>>正文


PHP XenForo_Template_Compiler::getIncludedTemplates方法代碼示例

本文整理匯總了PHP中XenForo_Template_Compiler::getIncludedTemplates方法的典型用法代碼示例。如果您正苦於以下問題:PHP XenForo_Template_Compiler::getIncludedTemplates方法的具體用法?PHP XenForo_Template_Compiler::getIncludedTemplates怎麽用?PHP XenForo_Template_Compiler::getIncludedTemplates使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在XenForo_Template_Compiler的用法示例。


在下文中一共展示了XenForo_Template_Compiler::getIncludedTemplates方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: compileAndInsertParsedTemplate

 /**
  * Compiles the specified parsed template and updates the compiled table
  * and included templates list.
  *
  * @param integer $templateMapId The map ID of the template being compiled (for includes)
  * @param string|array $parsedTemplate Parsed form of the template
  * @param string $title Title of the template
  * @param integer $compileStyleId Style ID of the template
  * @param boolean $doDbWrite If non null, controls whether the DB write/template cache is written
  *
  * @return array|bool
  */
 public function compileAndInsertParsedTemplate($templateMapId, $parsedTemplate, $title, $compileStyleId, $doDbWrite = null)
 {
     $isCss = substr($title, -4) == '.css';
     if ($doDbWrite === null) {
         $doDbWrite = $isCss || $compileStyleId;
     }
     $compiler = new XenForo_Template_Compiler('');
     $languages = $this->getModelFromCache('XenForo_Model_Language')->getAllLanguages();
     $db = $this->_getDb();
     $compiledCache = array();
     if ($isCss) {
         $compiledTemplate = $compiler->compileParsed($parsedTemplate, $title, $compileStyleId, 0);
         $compiledCache[0] = $compiledTemplate;
         if ($doDbWrite) {
             $this->_insertCompiledTemplateRecord($compileStyleId, 0, $title, $compiledTemplate);
         }
     } else {
         foreach ($languages as $language) {
             $compiledTemplate = $compiler->compileParsed($parsedTemplate, $title, $compileStyleId, $language['language_id']);
             $compiledCache[$language['language_id']] = $compiledTemplate;
             if ($doDbWrite) {
                 $this->_insertCompiledTemplateRecord($compileStyleId, $language['language_id'], $title, $compiledTemplate);
             }
         }
     }
     $mapIdQuoted = $db->quote($templateMapId);
     $ins = array();
     $includedTemplateIds = array();
     foreach ($compiler->getIncludedTemplates() as $includedMapId) {
         $ins[] = '(' . $mapIdQuoted . ', ' . $db->quote($includedMapId) . ')';
         $includedTemplateIds[] = $includedMapId;
     }
     if ($doDbWrite) {
         $db->delete('xf_template_include', 'source_map_id = ' . $db->quote($templateMapId));
         if ($ins) {
             $db->query("\r\n\t\t\t\t\tINSERT IGNORE INTO xf_template_include\r\n\t\t\t\t\t\t(source_map_id, target_map_id)\r\n\t\t\t\t\tVALUES\r\n\t\t\t\t\t\t" . implode(',', $ins));
         }
     }
     $ins = array();
     $includedPhraseTitles = array();
     foreach ($compiler->getIncludedPhrases() as $includedPhrase) {
         if (strlen($includedPhrase) > 75) {
             continue;
             // too long, can't be a valid phrase
         }
         $ins[] = '(' . $mapIdQuoted . ', ' . $db->quote($includedPhrase) . ')';
         $includedPhraseTitles[] = $includedPhrase;
     }
     if ($doDbWrite) {
         $db->delete('xf_template_phrase', 'template_map_id = ' . $db->quote($templateMapId));
         if ($ins) {
             $db->query("\r\n\t\t\t\t\tINSERT IGNORE INTO xf_template_phrase\r\n\t\t\t\t\t\t(template_map_id, phrase_title)\r\n\t\t\t\t\tVALUES\r\n\t\t\t\t\t\t" . implode(',', $ins));
         }
     }
     return array('includedTemplateIds' => $includedTemplateIds, 'failedTemplateIncludes' => $compiler->getFailedTemplateIncludes(), 'includedPhraseTitles' => $includedPhraseTitles, 'compiledCache' => $compiledCache, 'doDbWrite' => $doDbWrite);
 }
開發者ID:namgiangle90,項目名稱:tokyobaito,代碼行數:68,代碼來源:Template.php

示例2: compileAndInsertParsedTemplate

    /**
     * Compiles the specified parsed template and updates the compiled table
     * and included templates list.
     *
     * @param integer $templateMapId The map ID of the template being compiled (for includes)
     * @param string|array $parsedTemplate Parsed form of the template
     * @param string $title Title of the template
     * @param integer $compileStyleId Style ID of the template
     */
    public function compileAndInsertParsedTemplate($templateMapId, $parsedTemplate, $title, $compileStyleId)
    {
        $isCss = substr($title, -4) == '.css';
        if (!$compileStyleId && !$isCss) {
            return;
            // skip compiling master templates, but compile css we need it
        }
        $compiler = new XenForo_Template_Compiler('');
        $languages = $this->getModelFromCache('XenForo_Model_Language')->getAllLanguages();
        $db = $this->_getDb();
        if ($isCss) {
            $compiledTemplate = $compiler->compileParsed($parsedTemplate, $title, $compileStyleId, 0);
            $db->query('
				INSERT INTO xf_template_compiled
					(style_id, language_id, title, template_compiled)
				VALUES
					(?, ?, ?, ?)
				ON DUPLICATE KEY UPDATE template_compiled = VALUES(template_compiled)
			', array($compileStyleId, 0, $title, $compiledTemplate));
        } else {
            foreach ($languages as $language) {
                $compiledTemplate = $compiler->compileParsed($parsedTemplate, $title, $compileStyleId, $language['language_id']);
                $db->query('
					INSERT INTO xf_template_compiled
						(style_id, language_id, title, template_compiled)
					VALUES
						(?, ?, ?, ?)
					ON DUPLICATE KEY UPDATE template_compiled = VALUES(template_compiled)
				', array($compileStyleId, $language['language_id'], $title, $compiledTemplate));
            }
        }
        $db->delete('xf_template_include', 'source_map_id = ' . $db->quote($templateMapId));
        foreach ($compiler->getIncludedTemplates() as $includedMapId) {
            $db->insert('xf_template_include', array('source_map_id' => $templateMapId, 'target_map_id' => $includedMapId));
            //TODO: this system doesn't handle includes for templates that don't exist yet
        }
        $db->delete('xf_template_phrase', 'template_map_id = ' . $db->quote($templateMapId));
        foreach ($compiler->getIncludedPhrases() as $includedPhrase) {
            $db->insert('xf_template_phrase', array('template_map_id' => $templateMapId, 'phrase_title' => $includedPhrase));
        }
    }
開發者ID:hahuunguyen,項目名稱:DTUI_201105,代碼行數:50,代碼來源:Template.php


注:本文中的XenForo_Template_Compiler::getIncludedTemplates方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。