예제 #1
0
 function __construct($typeid = 0, $sql = '', $template = '')
 {
     $this->TypeID = $typeid;
     $this->dsql = $GLOBALS['dsql'];
     $this->Template = $template;
     $this->SourceSql = $sql;
     $this->GetValues = array();
     $this->dtp = new DedeTagParse();
     $this->dtp->refObj = $this;
     $this->dtp->SetNameSpace('dede', '{', '}');
     $this->dtp2 = new DedeTagParse();
     $this->dtp2->SetNameSpace('field', '[', ']');
     //如果需要, 获得栏目信息
     if (!empty($typeid)) {
         $this->TypeLink = new TypeLink($typeid);
         $this->Fields = $this->TypeLink->TypeInfos;
         $this->Fields['id'] = $typeid;
         $this->Fields['position'] = $this->TypeLink->GetPositionLink(true);
         $this->Fields['title'] = ereg_replace("[<>]", " / ", $this->TypeLink->GetPositionLink(false));
         $this->Fields['rsslink'] = $GLOBALS['cfg_cmsurl'] . "/data/rss/" . $this->TypeID . ".xml";
         //设置环境变量
         SetSysEnv($this->TypeID, $this->Fields['typename'], 0, '', 'datalist');
         $this->Fields['typeid'] = $this->TypeID;
     }
     //设置一些全局参数的值
     foreach ($GLOBALS['PubFields'] as $k => $v) {
         $this->Fields[$k] = $v;
     }
 }
예제 #2
0
 /**
  *  php5构造函数
  *
  * @access    public
  * @param     int  $typeid  栏目ID
  * @param     int  $needtypelink  是否需要栏目连接
  * @return    void
  */
 function __construct($typeid = 0, $needtypelink = TRUE)
 {
     global $_sys_globals, $ftp;
     $this->TypeID = $typeid;
     $this->dsql = $GLOBALS['dsql'];
     $this->dtp = new DedeTagParse();
     $this->dtp->SetNameSpace("dede", "{", "}");
     $this->dtp->SetRefObj($this);
     $this->ftp =& $ftp;
     $this->remoteDir = '';
     if ($needtypelink) {
         $this->TypeLink = new TypeLink($typeid);
         if (is_array($this->TypeLink->TypeInfos)) {
             foreach ($this->TypeLink->TypeInfos as $k => $v) {
                 if (preg_match("/[^0-9]/", $k)) {
                     $this->Fields[$k] = $v;
                 }
             }
         }
         $_sys_globals['curfile'] = 'partview';
         $_sys_globals['typename'] = $this->Fields['typename'];
         //设置环境变量
         SetSysEnv($this->TypeID, $this->Fields['typename'], 0, '', 'partview');
     }
     SetSysEnv($this->TypeID, '', 0, '', 'partview');
     $this->Fields['typeid'] = $this->TypeID;
     //设置一些全局参数的值
     foreach ($GLOBALS['PubFields'] as $k => $v) {
         $this->Fields[$k] = $v;
     }
 }
예제 #3
0
 function __construct($typeid, $searchArr = array())
 {
     global $dsql;
     $this->TypeID = $typeid;
     $this->dsql = $dsql;
     $this->CrossID = '';
     $this->IsReplace = false;
     $this->IsError = false;
     $this->dtp = new DedeTagParse();
     $this->dtp->SetRefObj($this);
     $this->sAddTable = false;
     $this->dtp->SetNameSpace("dede", "{", "}");
     $this->dtp2 = new DedeTagParse();
     $this->dtp2->SetNameSpace("field", "[", "]");
     $this->TypeLink = new TypeLink($typeid);
     $this->searchArr = $searchArr;
     if (!is_array($this->TypeLink->TypeInfos)) {
         $this->IsError = true;
     }
     if (!$this->IsError) {
         $this->ChannelUnit = new ChannelUnit($this->TypeLink->TypeInfos['channeltype']);
         $this->Fields = $this->TypeLink->TypeInfos;
         $this->Fields['id'] = $typeid;
         $this->Fields['position'] = $this->TypeLink->GetPositionLink(true);
         $this->Fields['title'] = ereg_replace("[<>]", " / ", $this->TypeLink->GetPositionLink(false));
         //获得附加表和列表字段信息
         $this->AddTable = $this->ChannelUnit->ChannelInfos['addtable'];
         $listfield = trim($this->ChannelUnit->ChannelInfos['listfields']);
         $this->ListFields = explode(',', $listfield);
         //设置一些全局参数的值
         foreach ($GLOBALS['PubFields'] as $k => $v) {
             $this->Fields[$k] = $v;
         }
         $this->Fields['rsslink'] = $GLOBALS['cfg_cmsurl'] . "/data/rss/" . $this->TypeID . ".xml";
         //设置环境变量
         SetSysEnv($this->TypeID, $this->Fields['typename'], 0, '', 'list');
         $this->Fields['typeid'] = $this->TypeID;
         //获得交叉栏目ID
         if ($this->TypeLink->TypeInfos['cross'] > 0 && $this->TypeLink->TypeInfos['ispart'] == 0) {
             $selquery = '';
             if ($this->TypeLink->TypeInfos['cross'] == 1) {
                 $selquery = "Select id,topid From `#@__arctype` where typename like '{$this->Fields['typename']}' And id<>'{$this->TypeID}' And topid<>'{$this->TypeID}'  ";
             } else {
                 $this->Fields['crossid'] = ereg_replace('[^0-9,]', '', trim($this->Fields['crossid']));
                 if ($this->Fields['crossid'] != '') {
                     $selquery = "Select id,topid From `#@__arctype` where id in({$this->Fields['crossid']}) And id<>{$this->TypeID} And topid<>{$this->TypeID}  ";
                 }
             }
             if ($selquery != '') {
                 $this->dsql->SetQuery($selquery);
                 $this->dsql->Execute();
                 while ($arr = $this->dsql->GetArray()) {
                     $this->CrossID .= $this->CrossID == '' ? $arr['id'] : ',' . $arr['id'];
                 }
             }
         }
     }
     //!error
 }
예제 #4
0
 /**
  *  php5构造函数
  *
  * @access    public
  * @param     int  $typeid  栏目ID
  * @param     int  $uppage  上一页
  * @return    string
  */
 function __construct($typeid, $uppage = 1)
 {
     global $dsql, $ftp;
     $this->TypeID = $typeid;
     $this->dsql =& $dsql;
     $this->CrossID = '';
     $this->IsReplace = false;
     $this->IsError = false;
     $this->dtp = new DedeTagParse();
     $this->dtp->SetRefObj($this);
     $this->dtp->SetNameSpace("dede", "{", "}");
     $this->dtp2 = new DedeTagParse();
     $this->dtp2->SetNameSpace("field", "[", "]");
     $this->TypeLink = new TypeLink($typeid);
     $this->upPageType = $uppage;
     $this->ftp =& $ftp;
     $this->remoteDir = '';
     $this->TotalResult = is_numeric($this->TotalResult) ? $this->TotalResult : "";
     if (!is_array($this->TypeLink->TypeInfos)) {
         $this->IsError = true;
     }
     if (!$this->IsError) {
         $this->ChannelUnit = new ChannelUnit($this->TypeLink->TypeInfos['channeltype']);
         $this->Fields = $this->TypeLink->TypeInfos;
         $this->Fields['id'] = $typeid;
         $this->Fields['position'] = $this->TypeLink->GetPositionLink(true);
         $this->Fields['title'] = preg_replace("/[<>]/", " / ", $this->TypeLink->GetPositionLink(false));
         //设置一些全局参数的值
         foreach ($GLOBALS['PubFields'] as $k => $v) {
             $this->Fields[$k] = $v;
         }
         $this->Fields['rsslink'] = $GLOBALS['cfg_cmsurl'] . "/data/rss/" . $this->TypeID . ".xml";
         //设置环境变量
         SetSysEnv($this->TypeID, $this->Fields['typename'], 0, '', 'list');
         $this->Fields['typeid'] = $this->TypeID;
         //获得交叉栏目ID
         if ($this->TypeLink->TypeInfos['cross'] > 0 && $this->TypeLink->TypeInfos['ispart'] == 0) {
             $selquery = '';
             if ($this->TypeLink->TypeInfos['cross'] == 1) {
                 $selquery = "SELECT id,topid FROM `#@__arctype` WHERE typename LIKE '{$this->Fields['typename']}' AND id<>'{$this->TypeID}' AND topid<>'{$this->TypeID}'  ";
             } else {
                 $this->Fields['crossid'] = preg_replace('/[^0-9,]/', '', trim($this->Fields['crossid']));
                 if ($this->Fields['crossid'] != '') {
                     $selquery = "SELECT id,topid FROM `#@__arctype` WHERE id in({$this->Fields['crossid']}) AND id<>{$this->TypeID} AND topid<>{$this->TypeID}  ";
                 }
             }
             if ($selquery != '') {
                 $this->dsql->SetQuery($selquery);
                 $this->dsql->Execute();
                 while ($arr = $this->dsql->GetArray()) {
                     $this->CrossID .= $this->CrossID == '' ? $arr['id'] : ',' . $arr['id'];
                 }
             }
         }
     }
     //!error
 }
 /**
  *  解析附加表的内容
  *
  * @access    public
  * @return    void
  */
 function ParAddTable()
 {
     //读取附加表信息,并把附加表的资料经过编译处理后导入到$this->Fields中,以方便在模板中用 {dede:field name='fieldname' /} 标记统一调用
     if ($this->ChannelUnit->ChannelInfos['addtable'] != '') {
         $row = $this->addTableRow;
         if ($this->ChannelUnit->ChannelInfos['issystem'] == -1) {
             $this->Fields['title'] = $row['title'];
             $this->Fields['senddate'] = $this->Fields['pubdate'] = $row['senddate'];
             $this->Fields['mid'] = $this->Fields['adminid'] = $row['mid'];
             $this->Fields['ismake'] = 1;
             $this->Fields['arcrank'] = 0;
             $this->Fields['money'] = 0;
             $this->Fields['filename'] = '';
         }
         if (is_array($row)) {
             foreach ($row as $k => $v) {
                 $row[strtolower($k)] = $v;
             }
         }
         if (is_array($this->ChannelUnit->ChannelFields) && !empty($this->ChannelUnit->ChannelFields)) {
             foreach ($this->ChannelUnit->ChannelFields as $k => $arr) {
                 if (isset($row[$k])) {
                     if (!empty($arr['rename'])) {
                         $nk = $arr['rename'];
                     } else {
                         $nk = $k;
                     }
                     $cobj = $this->GetCurTag($k);
                     if (is_object($cobj)) {
                         foreach ($this->dtp->CTags as $ctag) {
                             if ($ctag->GetTagName() == 'field' && $ctag->GetAtt('name') == $k) {
                                 //带标识的专题节点
                                 if ($ctag->GetAtt('noteid') != '') {
                                     $this->Fields[$k . '_' . $ctag->GetAtt('noteid')] = $this->ChannelUnit->MakeField($k, $row[$k], $ctag);
                                 } else {
                                     if ($ctag->GetAtt('type') != '') {
                                         $this->Fields[$k . '_' . $ctag->GetAtt('type')] = $this->ChannelUnit->MakeField($k, $row[$k], $ctag);
                                     } else {
                                         $this->Fields[$nk] = $this->ChannelUnit->MakeField($k, $row[$k], $ctag);
                                     }
                                 }
                             }
                         }
                     } else {
                         $this->Fields[$nk] = $row[$k];
                     }
                     if ($arr['type'] == 'htmltext' && $GLOBALS['cfg_keyword_replace'] == 'Y' && !empty($this->Fields['keywords'])) {
                         $this->Fields[$nk] = $this->ReplaceKeyword($this->Fields['keywords'], $this->Fields[$nk]);
                     }
                 }
             }
             //End foreach
         }
         //设置全局环境变量
         $this->Fields['typename'] = $this->TypeLink->TypeInfos['typename'];
         @SetSysEnv($this->Fields['typeid'], $this->Fields['typename'], $this->Fields['id'], $this->Fields['title'], 'archives');
     }
     //完成附加表信息读取
     unset($row);
     //处理要分页显示的字段
     $this->SplitTitles = array();
     if ($this->SplitPageField != '' && ($GLOBALS['cfg_arcsptitle'] = 'Y' && isset($this->Fields[$this->SplitPageField]))) {
         $this->SplitFields = explode("#p#", $this->Fields[$this->SplitPageField]);
         $i = 1;
         foreach ($this->SplitFields as $k => $v) {
             $tmpv = cn_substr($v, 50);
             $pos = strpos($tmpv, '#e#');
             if ($pos > 0) {
                 $st = trim(cn_substr($tmpv, $pos));
                 if ($st == "" || $st == "副标题" || $st == "分页标题") {
                     $this->SplitFields[$k] = preg_replace("/^(.*)#e#/is", "", $v);
                     continue;
                 } else {
                     $this->SplitFields[$k] = preg_replace("/^(.*)#e#/is", "", $v);
                     $this->SplitTitles[$k] = $st;
                 }
             } else {
                 continue;
             }
             $i++;
         }
         $this->TotalPage = count($this->SplitFields);
         $this->Fields['totalpage'] = $this->TotalPage;
     }
     //处理默认缩略图等
     if (isset($this->Fields['litpic'])) {
         if ($this->Fields['litpic'] == '-' || $this->Fields['litpic'] == '') {
             $this->Fields['litpic'] = $GLOBALS['cfg_cmspath'] . '/images/defaultpic.gif';
         }
         if (!preg_match("#^http:\\/\\/#i", $this->Fields['litpic']) && $GLOBALS['cfg_multi_site'] == 'Y') {
             $this->Fields['litpic'] = $GLOBALS['cfg_mainsite'] . $this->Fields['litpic'];
         }
         $this->Fields['picname'] = $this->Fields['litpic'];
         //模板里直接使用{dede:field name='image'/}获取缩略图
         $this->Fields['image'] = !preg_match('/jpg|gif|png/i', $this->Fields['picname']) ? '' : "<img src='{$this->Fields['picname']}' />";
     }
     // 处理投票选项
     if (isset($this->Fields['voteid']) && !empty($this->Fields['voteid'])) {
         $this->Fields['vote'] = '';
         $voteid = $this->Fields['voteid'];
         $this->Fields['vote'] = "<script language='javascript' src='{$GLOBALS['cfg_cmspath']}/data/vote/vote_{$voteid}.js'></script>";
         if ($GLOBALS['cfg_multi_site'] == 'Y') {
             $this->Fields['vote'] = "<script language='javascript' src='{$GLOBALS['cfg_mainsite']}/data/vote/vote_{$voteid}.js'></script>";
         }
     }
     if (isset($this->Fields['goodpost']) && isset($this->Fields['badpost'])) {
         //digg
         if ($this->Fields['goodpost'] + $this->Fields['badpost'] == 0) {
             $this->Fields['goodper'] = $this->Fields['badper'] = 0;
         } else {
             $this->Fields['goodper'] = number_format($this->Fields['goodpost'] / ($this->Fields['goodpost'] + $this->Fields['badpost']), 3) * 100;
             $this->Fields['badper'] = 100 - $this->Fields['goodper'];
         }
     }
 }