⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 inc_arclist_view.php

📁 强大的PHP内容管理系统尽量不要让站长把时间都花费在为您修正说明上。压缩包解压
💻 PHP
📖 第 1 页 / 共 3 页
字号:
<?php
require_once(dirname(__FILE__)."/inc_arcpart_view.php");
require_once(dirname(__FILE__)."/inc_pubtag_make.php");
/******************************************************
//Copyright 2004-2006 by DedeCms.com itprato
//本类的用途是用于浏览频道列表或对内容列表生成HTML
******************************************************/
@set_time_limit(0);
class ListView
{
	var $dsql;
	var $dtp;
	var $dtp2;
	var $TypeID;
	var $TypeLink;
	var $pageno;
	var $TotalPage;
	var $totalresult;
	var $PageSize;
	var $ChannelUnit;
	var $ListType;
	var $Fields;
	var $PartView;
	var $StartTime;
	var $maintable;
	var $addtable;
	var $areas;
	var $areaid;
	var $areaid2;
	var $sectors;
	var $sectorid;
	var $sectorid2;
	var $smalltypes;
	var $smalltypeid;
	var $topareas;
	var $subareas;
	var $mysmalltypes;
	var $TempletsFile;
	var $addSql;
	var $hasDmCache;
	//-------------------------------
	//php5构造函数
	//-------------------------------
	function __construct($typeid,$starttime=0,$areaid=0,$areaid2=0,$sectorid=0,$sectorid2=0,$smalltypeid=0)
 	{
 		$this->areaid = $areaid;
 		$this->areaid2 = $areaid2;
 		$this->sectorid = $sectorid;
 		$this->sectorid2 = $sectorid2;
 		$this->smalltypeid = $smalltypeid;
 		$this->TypeID = $typeid;
 		$this->dsql = new DedeSql(false);
 		$this->dtp = new DedeTagParse();
 		$this->dtp->SetNameSpace("dede","{","}");
 		$this->dtp2 = new DedeTagParse();
 		$this->dtp2->SetNameSpace("field","[","]");
 		$this->TypeLink = new TypeLink($typeid);
 		$this->ChannelUnit = new ChannelUnit($this->TypeLink->TypeInfos['channeltype']);

 		$this->maintable = $this->ChannelUnit->ChannelInfos['maintable'];
 		$this->topareas = $this->subareas = $this->areas = $this->sectors = $this->smalltypes = array();
 		$this->areas[0] = $this->sectors[0] = $this->smalltypes[0] = '不限';
		$this->topareas[0] = array("id"=>0 , "name"=>'不限');
 		$this->addtable = $this->ChannelUnit->ChannelInfos['addtable'];
 		$this->Fields = $this->TypeLink->TypeInfos;
 		
 		$this->hasDmCache = false;
 		
 		$this->Fields['id'] = $typeid;
 		$this->Fields['position'] = $this->TypeLink->GetPositionLink(true);
 		$this->Fields['title'] = ereg_replace("[<>]"," / ",$this->TypeLink->GetPositionLink(false));
 		
 		//设置一些全局参数的值
 		foreach($GLOBALS['PubFields'] as $k=>$v) $this->Fields[$k] = $v;
 		$this->Fields['rsslink'] = $GLOBALS['cfg_mainsite'].$GLOBALS['cfg_plus_dir']."/rss/".$this->TypeID.".xml";
 		
 		if($starttime==0) $this->StartTime = 0;
 		else $this->StartTime = GetMkTime($starttime);

    if($this->TypeLink->TypeInfos['ispart']<=2)
    {
 		    $this->PartView = new PartView($typeid);
 		    $this->CountRecord();
 		}
  }
  //php4构造函数
 	//---------------------------
 	function ListView($typeid,$starttime=0,$areaid=0,$areaid2=0,$sectorid=0,$sectorid2=0,$smalltypeid=0){
 		$this->__construct($typeid,$starttime,$areaid,$areaid2,$sectorid,$sectorid2,$smalltypeid);
 	}
 	
 	//
 	function LoadDmCatCache()
 	{
 		//载入地区、行业、小分类数据表
 		$this->dsql->Execute('ar',"select * from #@__area ");
 		while($row=$this->dsql->GetArray('ar'))
 		{
 				if(!empty($this->areaid2) && $row['id'] == $this->areaid2){
 					 $this->areaid = $row['reid'];
 				}
 				if($row['reid'] == 0){
 					 $this->topareas[] = $row;
 				}else{
 					 $this->subareas[$row['reid']][] = $row;
 				}
 				$this->areas[$row['id']] = $row['name'];
 		}
 		
 	  $this->dsql->Execute('ar',"select * from #@__sectors");
 	  while($row=$this->dsql->GetArray('ar')){
 			$this->sectors[$row['id']] = $row['name'];
 		}

 		$this->dsql->Execute('ar',"select * from #@__smalltypes");
 		$this->mysmalltypes = array();
 		$mysmalltypesarray = explode(',',$this->Fields['smalltypes']);
 		$this->mysmalltypes[0] = array("id"=>0, "name"=>'不限');
 		while($row=$this->dsql->GetArray('ar'))
 		{
 				if(@in_array($row['id'], $mysmalltypesarray)){
 					$this->mysmalltypes[] = $row;
 				}
 				$this->smalltypes[$row['id']] = $row['name'];
 		}
 		$this->hasDmCache = true;
 	}
 
 	//---------------------------
 	//关闭相关资源
 	//---------------------------
 	function Close()
 	{
 		$this->dsql->Close();
 		$this->TypeLink->Close();
 		$this->ChannelUnit->Close();
 		if(is_object($this->PartView)) $this->PartView->Close();
 	}
 	//------------------
 	//统计列表里的记录
 	//------------------
 	function CountRecord()
 	{
 		global $cfg_list_son;
 		//统计数据库记录
 		$this->totalresult = -1;
 		if(isset($GLOBALS['totalresult'])) $this->totalresult = intval($GLOBALS['totalresult']);
 		if(isset($GLOBALS['pageno'])) $this->pageno = intval($GLOBALS['pageno']);
 		else $this->pageno = 1;
 		
 		//分析条件
	  $this->addSql  = " arc.arcrank > -1 ";
		
		if($cfg_list_son=='N'){
				$this->addSql .= " And (arc.typeid='".$this->TypeID."' or arc.typeid2='".$this->TypeID."') ";
		}else{
				$idlist = $this->TypeLink->GetSunID($this->TypeID,'',$this->Fields['channeltype'],true);
				if(ereg(',',$idlist)){	 
					$this->addSql .= " And (arc.typeid in ($idlist) Or arc.typeid2='{$this->TypeID}') ";
				}else{  
					$this->addSql .= " And (arc.typeid='{$this->TypeID}' Or arc.typeid2='{$this->TypeID}') ";
				}
		}
		
		if($this->areaid2 != 0){
				$this->addSql .= "and arc.areaid2=$this->areaid2 ";
		}else if($this->areaid != 0){
				$this->addSql .= "and arc.areaid=$this->areaid ";
    }
    
		if($this->sectorid2 != 0){
				$this->addSql .= "and arc.sectorid2=$this->sectorid2 ";
		}else if($this->sectorid != 0){
				$this->addSql .= "and arc.sectorid=$this->sectorid ";
		}
		
		if($this->smalltypeid != 0){
				$this->addSql .= "and arc.smalltypeid=$this->smalltypeid ";
		}
		
		if($this->StartTime>0){
				$this->addSql .= " And arc.senddate>'".$this->StartTime."'";
		}
		
		if($this->totalresult==-1)
 		{
		   $cquery = "Select count(*) as dd From `{$this->maintable}` arc where ".$this->addSql;
		   $row = $this->dsql->GetOne($cquery);
		   $this->totalresult = $row['dd'];
		}
 		//初始化列表模板,并统计页面总数
 		$tempfile = $GLOBALS['cfg_basedir'].$GLOBALS['cfg_templets_dir']."/".$this->TypeLink->TypeInfos['templist'];
 		$tempfile = str_replace("{tid}",$this->TypeID,$tempfile);
 		$tempfile = str_replace("{cid}",$this->ChannelUnit->ChannelInfos['nid'],$tempfile);
		if(!file_exists($tempfile)){
			$tempfile = $GLOBALS['cfg_basedir'].$GLOBALS['cfg_templets_dir']."/".$GLOBALS['cfg_df_style']."/list_article.htm";
		}
 		if(!file_exists($tempfile)||!is_file($tempfile)){
 			echo "模板文件:'".$tempfile."' 不存在,无法解析文档!";
 			exit();
 		}
 		$this->dtp->LoadTemplate($tempfile);
 		$this->TempletsFile = ereg_replace("^".$GLOBALS['cfg_basedir'],'',$tempfile);
 		$ctag = $this->dtp->GetTag('page');
 		if(!is_object($ctag)){ $ctag = $this->dtp->GetTag('list'); }
 		if(!is_object($ctag)) $this->PageSize = 20;
 		else{
 		  if($ctag->GetAtt("pagesize")!='') $this->PageSize = $ctag->GetAtt('pagesize');
      else $this->PageSize = 20;
    }
    $this->TotalPage = ceil($this->totalresult/$this->PageSize);
 	}
 	//------------------
 	//列表创建HTML
 	//------------------
 	function MakeHtml($startpage=1,$makepagesize=0)
 	{
 		if(empty($startpage)) $startpage = 1;
 		//创建封面模板文件
 		if($this->TypeLink->TypeInfos['isdefault']==-1){
 			echo '这个类目是动态类目!';
 			return '';
 	  }
 	  //单独页面
 		else if($this->TypeLink->TypeInfos['ispart']>0)
 		{
 			$reurl = $this->MakePartTemplets();
 			return $reurl;
 		}
 		//跳转网址
 		else if($this->TypeLink->TypeInfos['ispart']>2){
 			echo "这个类目是跳转网址!";
 			return $this->TypeLink->TypeInfos['typedir'];
 		}

 		//$this->CountRecord();
 		//初步给固定值的标记赋值
 		$this->ParseTempletsFirst();
 		$totalpage = ceil($this->totalresult/$this->PageSize);

 		if($totalpage==0) $totalpage = 1;

 		CreateDir($this->Fields['typedir'],$this->Fields['siterefer'],$this->Fields['sitepath']);

 		$murl = "";

 		if($makepagesize>0) $endpage = $startpage+$makepagesize;
 		else $endpage = ($totalpage+1);

 		if($endpage>($totalpage+1)) $endpage = $totalpage;

 		$ttmk = 0;
 		$rs = '';
 		for($this->pageno=$startpage;$this->pageno<$endpage;$this->pageno++)
 		{
 		  $ttmk++;
 		  $this->ParseDMFields($this->pageno,1);
 	    $makeFile = $this->GetMakeFileRule($this->Fields['ID'],"list",$this->Fields['typedir'],"",$this->Fields['namerule2']);
 	    $makeFile = str_replace("{page}",$this->pageno,$makeFile);
 	    $murl = $makeFile;
 	    if(!ereg("^/",$makeFile)) $makeFile = "/".$makeFile;
 	    $makeFile = $this->GetTruePath().$makeFile;
 	    $makeFile = ereg_replace("/{1,}","/",$makeFile);
 	    $murl = $this->GetTrueUrl($murl);
 	    $this->dtp->SaveTo($makeFile);
 	    $rs .= "<br/><a href='$murl' target='_blank'>$murl</a>";
 	  }
 	  echo "共创建:($ttmk) 文件 $rs";
 	  if($startpage==1)
 	  {
 	    //如果列表启用封面文件,复制这个文件第一页
 	    if($this->TypeLink->TypeInfos['isdefault']==1
 	      && $this->TypeLink->TypeInfos['ispart']==0)
 	    {
 	  	  $onlyrule = $this->GetMakeFileRule($this->Fields['ID'],"list",$this->Fields['typedir'],"",$this->Fields['namerule2']);
 	  	  $onlyrule = str_replace("{page}","1",$onlyrule);
 	  	  $list_1 = $this->GetTruePath().$onlyrule;
 	  	  $murl = $this->Fields['typedir']."/".$this->Fields['defaultname'];
 	  	  $indexname = $this->GetTruePath().$murl;
 	  	  copy($list_1,$indexname);
 	  	  echo "<br>复制:$onlyrule 为 ".$this->Fields['defaultname'];
 	    }
 	  }
 		$this->Close();
 		return $murl;
 	}
 	//------------------
 	//显示列表
 	//------------------
 	function Display()
 	{
 		//ispart = 3 跳转网址
 		if($this->TypeLink->TypeInfos['ispart']>2)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -