Ejemplo n.º 1
0
 function parseFirstLayerTag($templateid, $siteID = 0, $channelID = 0, $contentID = 0, $saveFilePath = '', $tagsArr = array(), $pagination = array('pageSize' => 20, 'totalCount' => 0, 'currentPage' => 1, 'urlPrefix' => '', 'urlSuffix' => ''), $obj = null, $type = '', $onlyTags = array(), $exceptTags = array())
 {
     if ($type == 'channel' && file_exists(ABS_PATH . 'templatesCache' . DIRECTORY_SEPARATOR . $templateid . '.channel.parsed.tpl.php')) {
         $templateHtml = file_get_contents(ABS_PATH . 'templatesCache' . DIRECTORY_SEPARATOR . $templateid . '.channel.parsed.tpl.php');
     } else {
         $templateHtml = file_get_contents(ABS_PATH . 'templatesCache' . DIRECTORY_SEPARATOR . $templateid . '.parsed.tpl.php');
     }
     //
     $dir = substr(__FILE__, 0, -7);
     $i = 0;
     if (!$tagsArr) {
         include ABS_PATH . 'templatesCache' . DIRECTORY_SEPARATOR . $templateid . '.tags.tpl.php';
     }
     if ($tagsArr) {
         foreach ($tagsArr as $tag) {
             $parseThisTag = true;
             if (count($onlyTags) && !in_array($tag['name'], $onlyTags)) {
                 //如果标签不在限制的解析标签中则不解析
                 $parseThisTag = false;
             }
             if (in_array($tag['name'], $exceptTags)) {
                 $parseThisTag = false;
             }
             if ($parseThisTag && bpBase::loadTagClass('tag_' . $tag['name'])) {
                 $thisTagClassName = 'tag_' . $tag['name'];
                 $thisTagClass = bpBase::loadTagClass('tag_' . $tag['name'], 1);
                 $returnStr = $thisTagClass->getValue($tag['string'], $tag['avs'], $siteID, $channelID, $contentID, $pagination, $obj);
                 $templateHtml = str_replace('<tag_' . $tag['name'] . '_' . $i . '/>', $returnStr, $templateHtml);
             }
             $i++;
         }
     }
     //保存路径
     if (!$saveFilePath) {
         if ($siteID < 100) {
             $thisSpecial = '';
             $specialIndex = '';
         } else {
             //专题首页
             $special_db = bpBase::loadModel('special_model');
             $thisSpecial = $special_db->get_one(array('id' => $siteID));
             $specialIndex = $thisSpecial['specialindex'];
         }
         $tplGPath = $this->createGeneratePath($templateid, $channelID, $contentID, $thisSpecial);
         $saveFilePath = ABS_PATH . $tplGPath;
     }
     //stag
     if (strExists($templateHtml, '[stl.')) {
         $stag = bpBase::loadAppClass('stag', 'template');
         $templateHtml = $stag->handleStag($templateHtml);
     }
     file_put_contents($saveFilePath, $templateHtml);
     return $templateHtml;
 }