示例#1
0
 /**
  * 合并当前页面模板
  *
  *
  *
  */
 private function mergeCell()
 {
     if (!class_exists('publishconfig')) {
         include_once ROOT_PATH . 'lib/class/publishconfig.class.php';
     }
     $this->objPub = new publishconfig();
     if (!$this->arSiteInfo) {
         $this->arSiteInfo = $this->objPub->get_site_first('*', $this->intSiteId);
     }
     if ($this->intLayoutId) {
         if (!class_exists('layout')) {
             include CUR_CONF_PATH . 'lib/layout.class.php';
         }
         $objLayout = new layout();
         $this->arCellList = $objLayout->getLayoutCell($this->intLayoutId);
         return '';
     }
     if ($this->blPreset && $this->blPreset != 'false') {
         $deploy = common::get_template_cell($this->intSiteId, $this->intTemplateId, $this->strTemplateSign);
         $this->arCellList = $deploy['default_cell'];
         return;
     }
     if ($this->strTemplateSign && (!$this->blPreset || $this->blPreset === 'false')) {
         //快速专题  取出此专题的布局信息  内容类型存在时是列表页  列表页暂不支持布局
         if (!$this->intContentType) {
             $sql = "SELECT * FROM " . DB_PREFIX . "template_layout WHERE special_id = " . $this->intPageDataId;
             $templateLayout = $this->db->query_first($sql);
             $layoutIds = $templateLayout['layout_ids'];
             if ($layoutIds) {
                 $this->strLayoutIds = $layoutIds;
                 if (!class_exists('layout')) {
                     include CUR_CONF_PATH . 'lib/layout.class.php';
                 }
                 $objLayout = new layout();
                 $sql = "SELECT id, content, css, is_header, header_text, is_more, more_href,original_id \r\n                            FROM " . DB_PREFIX . "layout WHERE id IN(" . $layoutIds . ")";
                 $q = $this->db->query($sql);
                 $layoutInfo = array();
                 while ($row = $this->db->fetch_array($q)) {
                     $row = $objLayout->layout_namespace_and_header_process($row);
                     $layoutInfo[$row['id']] = $row;
                 }
                 $layoutIds = explode(',', $layoutIds);
                 $layouts = array();
                 if (is_array($layoutIds) && count($layoutIds) > 0) {
                     $layoutIds = array_reverse($layoutIds);
                     foreach ($layoutIds as $k => $v) {
                         $cells = array();
                         $cells = $objLayout->getLayoutCell($v);
                         $layoutInfo[$v]['cells'] = $cells;
                         $layouts[] = $layoutInfo[$v];
                     }
                 }
                 $this->arLayoutInfo = $layouts;
             }
         }
     } else {
         include_once CUR_CONF_PATH . 'lib/rebuild_deploy.class.php';
         $deploy = new rebuilddeploy();
         $deployTemplate = $deploy->get_deploy_templates($this->intSiteId, $this->intPageId, $this->intPageDataId);
         //赛选此客户端类型下该内容类型下部署的模板
         $this->strTemplateSign = $deployTemplate[$this->intClientType][$this->intContentType]['template_sign'];
         //没有部署模板时使用全局类型模板
         if (!$this->strTemplateSign) {
             $sql = "SELECT id, sign FROM " . DB_PREFIX . "templates WHERE site_id = 0 AND content_type = " . $this->intContentType;
             $arInfo = $this->db->query_first($sql);
             if (!$arInfo) {
                 return array('errmsg' => '该内容类型全局模板不存在');
             }
             $this->strTemplateSign = $arInfo['sign'];
             $this->intUseGlobalTemplate = 1;
         }
     }
     //模板合并机制更改  老机制多套系切换时有bug 20140831
     if (!$this->arSiteInfo) {
         $this->arSiteInfo = $this->objPub->get_site_first('tem_style', $this->intSiteId);
     }
     $this->strCurrStyle = $this->arSiteInfo['tem_style'];
     //使用默认套系
     if ($this->strDefaultStyle == $this->arSiteInfo['tem_style']) {
         //默认套系中该模板预设单元
         $condition = " AND c.template_style='" . $this->strDefaultStyle . "' AND c.template_sign IN('" . $this->strTemplateSign . "') AND c.original_id = 0";
         $arDefaultCell = common::get_cell($condition);
         //默认套系中页面单元
         $condition = " AND c.site_id = " . $this->intSiteId . " AND c.page_id=" . $this->intPageId . " AND c.page_data_id=" . $this->intPageDataId . " AND c.content_type = " . $this->intContentType . "\r\n                            AND c.template_style='" . $this->strDefaultStyle . "' AND c.template_sign IN('" . $this->strTemplateSign . "') AND c.original_id != 0";
         $defaultSetCell = common::get_cell($condition);
         //合并模板单元和页面单元 优先使用页面单元
         if (is_array($defaultSetCell) && count($defaultSetCell)) {
             foreach ($defaultSetCell as $k => $v) {
                 if (array_key_exists($k, $arDefaultCell)) {
                     $arDefaultCell[$k] = $defaultSetCell[$k];
                 }
             }
         }
     } else {
         $sql = "SELECT id FROM " . DB_PREFIX . "templates WHERE template_style = '" . $this->arSiteInfo['tem_style'] . "' AND sign = '" . $this->strTemplateSign . "'";
         $info = $this->db->query_first($sql);
         if (!$info['id']) {
             //默认套系中该模板预设单元
             $condition = " AND c.template_style='" . $this->strDefaultStyle . "' AND c.template_sign IN('" . $this->strTemplateSign . "') AND c.original_id = 0";
             $arDefaultCell = common::get_cell($condition);
             //默认套系中页面单元
             $condition = " AND c.site_id = " . $this->intSiteId . " AND c.page_id=" . $this->intPageId . " AND c.page_data_id=" . $this->intPageDataId . " AND c.content_type = " . $this->intContentType . "\r\n                            AND c.template_style='" . $this->strDefaultStyle . "' AND c.template_sign IN('" . $this->strTemplateSign . "') AND c.original_id != 0";
             $defaultSetCell = common::get_cell($condition);
             //合并模板单元和页面单元 优先使用页面单元
             if (is_array($defaultSetCell) && count($defaultSetCell)) {
                 foreach ($defaultSetCell as $k => $v) {
                     if (array_key_exists($k, $arDefaultCell)) {
                         $arDefaultCell[$k] = $defaultSetCell[$k];
                     }
                 }
             }
         } else {
             //当前使用套系模板预设单元
             $condition = " AND c.template_style='" . $this->arSiteInfo['tem_style'] . "' AND c.template_sign IN('" . $this->strTemplateSign . "')  AND c.original_id = 0";
             $arDefaultCell = common::get_cell($condition);
             //当前使用套系页面单元
             $condition = " AND c.site_id=" . $this->intSiteId . " AND c.page_id=" . $this->intPageId . " AND c.page_data_id=" . $this->intPageDataId . " AND c.content_type = " . $this->intContentType . "\r\n                            AND c.template_style='" . $this->arSiteInfo['tem_style'] . "' AND c.template_sign IN('" . $this->strTemplateSign . "') AND c.original_id != 0 ";
             $defaultSetCell = common::get_cell($condition);
             //合并模板预设单元和页面单元 优先使用页面单元
             if (is_array($defaultSetCell) && count($defaultSetCell) > 0) {
                 foreach ($defaultSetCell as $k => $v) {
                     if (array_key_exists($k, $arDefaultCell)) {
                         $arDefaultCell[$k] = $defaultSetCell[$k];
                     }
                 }
             }
         }
     }
     //模板合并机制更改  老机制多套系切换时bug 20140831
     //        //默认套系中该模板单元
     //        $condition      = " AND c.template_style='" . $this->strDefaultStyle . "' AND c.template_sign IN('" . $this->strTemplateSign . "') AND c.original_id = 0";
     //        $arDefaultCell  = common::get_cell($condition);
     //        //默认套系中页面单元
     //        $condition      = " AND c.site_id = " . $this->intSiteId . " AND c.page_id=" . $this->intPageId . " AND c.page_data_id=" . $this->intPageDataId . " AND c.content_type = " . $this->intContentType . "
     //                            AND c.template_style='" . $this->strDefaultStyle . "' AND c.template_sign IN('" . $this->strTemplateSign . "') AND c.original_id != 0";
     //        $defaultSetCell = common::get_cell($condition);
     //        //第一次合并  默认套系中的模板单元和默认套系中的页面单元
     //        if (is_array($defaultSetCell) && count($defaultSetCell))
     //        {
     //            foreach ($defaultSetCell as $k => $v)
     //            {
     //                if (array_key_exists($k, $arDefaultCell))
     //                {
     //                    $arDefaultCell[$k] = $defaultSetCell[$k];
     //                }
     //            }
     //        }
     //        //当前使用套系该模板单元
     //        if (!$this->arSiteInfo)
     //        {
     //            $this->arSiteInfo = $this->objPub->get_site_first('tem_style', $this->intSiteId);
     //        }
     //        $this->strCurrStyle = $this->arSiteInfo['tem_style'];
     //        $condition          = " AND c.template_style='" . $this->arSiteInfo['tem_style'] . "' AND c.template_sign IN('" . $this->strTemplateSign . "')  AND c.original_id = 0";
     //        $arUsingCell        = common::get_cell($condition);
     //        //第二次合并 第一次合并后的单元和当前使用套系模板单元
     //        if (is_array($arUsingCell) && count($arUsingCell) > 0)
     //        {
     //            foreach ($arUsingCell as $k => $v)
     //            {
     //                if (array_key_exists($k, $arDefaultCell))
     //                {
     //                    if ($arUsingCell[$k]['cell_mode'] || $arUsingCell[$k]['data_source'])
     //                    {
     //                        $arDefaultCell[$k] = $arUsingCell[$k];
     //                    }
     //                }
     //            }
     //        }
     //        //当前使用套系页面单元
     //        $condition      = " AND c.site_id=" . $this->intSiteId . " AND c.page_id=" . $this->intPageId . " AND c.page_data_id=" . $this->intPageDataId . " AND c.content_type = " . $this->intContentType . "
     //                            AND c.template_style='" . $this->arSiteInfo['tem_style'] . "' AND c.template_sign IN('" . $this->strTemplateSign . "') AND c.original_id != 0 ";
     //        $arUsingSetCell = common::get_cell($condition);
     //        //第三次合并  第二次合并后的单元和当前使用套系页面单元
     //        if (is_array($arUsingSetCell) && count($arUsingSetCell) > 0)
     //        {
     //            foreach ($arUsingSetCell as $k => $v)
     //            {
     //                if (array_key_exists($k, $arDefaultCell))
     //                {
     //                    $arDefaultCell[$k] = $arUsingSetCell[$k];
     //                }
     //            }
     //        }
     $this->arCellList = $arDefaultCell;
     return;
 }