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

📄 inc_freelist_view.php

📁 强大的PHP内容管理系统尽量不要让站长把时间都花费在为您修正说明上。压缩包解压
💻 PHP
📖 第 1 页 / 共 2 页
字号:
<?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 FreeList
{
	var $dsql;
	var $dtp;
	var $TypeID;
	var $TypeLink;
	var $PageNo;
	var $TotalPage;
	var $TotalResult;
	var $PageSize;
	var $ChannelUnit;
	var $Fields;
	var $PartView;
	var $FLInfos;
	var $ListObj;
	var $TempletsFile;
	var $maintable;
	//-------------------------------
	//php5构造函数
	//-------------------------------
	function __construct($fid)
 	{
 		$this->FreeID = $fid;
 		$this->TypeLink = new TypeLink(0);

 		$this->dsql = new DedeSql(false);
 		$this->maintable = '#@__archives';

 		$this->TempletsFile = '';
 		$this->FLInfos = $this->dsql->GetOne("Select * From #@__freelist where aid='$fid' ");
 		$liststr = $this->FLInfos['listtag'];
 		//载入数据里保存的列表属性信息
 		$ndtp = new DedeTagParse();
 		$ndtp->SetNameSpace("dede","{","}");
 		$ndtp->LoadString($liststr);
 		$this->ListObj = $ndtp->GetTag('list');
 		$this->PageSize = $this->ListObj->GetAtt('pagesize');
 		if(empty($this->PageSize)) $this->PageSize = 30;
 		$channelid = $this->ListObj->GetAtt('channel');
 		if(empty($channelid)){
 			showmsg('必须指定频道','-1');exit();
 		}else{
 			$channelid = intval($channelid);
 			$channelinfo = $this->dsql->getone("select maintable from #@__channeltype where ID='$channelid'");
			$this->maintable = $channelinfo['maintable'];
 		}



 		//全局模板解析器
 		$this->dtp = new DedeTagParse();
 		$this->dtp->SetNameSpace("dede","{","}");

 		//设置一些全局参数的值
 		$this->Fields['aid'] = $this->FLInfos['aid'];
 		$this->Fields['title'] = $this->FLInfos['title'];
 		$this->Fields['position'] = $this->FLInfos['title'];
 		$this->Fields['keywords'] = $this->FLInfos['keyword'];
 		$this->Fields['description'] = $this->FLInfos['description'];
 		$channelid = $this->ListObj->GetAtt('channel');
 		if(!empty($channelid)){
 		   $this->Fields['channeltype'] = $channelid;
 		   $this->ChannelUnit = new ChannelUnit($channelid);
 	  }else{
 	  	 $this->Fields['channeltype'] = 0;
 	  }
 		foreach($GLOBALS['PubFields'] as $k=>$v) $this->Fields[$k] = $v;

 		$this->PartView = new PartView();

 		$this->CountRecord();

  }
  //php4构造函数
 	//---------------------------
 	function FreeList($fid){
 		$this->__construct($fid);
 	}
 	//---------------------------
 	//关闭相关资源
 	//---------------------------

 	function Close()
 	{
 		@$this->dsql->Close();
 		@$this->TypeLink->Close();
 		@$this->ChannelUnit->Close();
 		@$this->PartView->Close();
 	}
 	//------------------
 	//统计列表里的记录
 	//------------------
 	function CountRecord()
 	{
 		global $cfg_list_son;

 		//统计数据库记录
 		$this->TotalResult = -1;
 		if(isset($GLOBALS['TotalResult'])) $this->TotalResult = $GLOBALS['TotalResult'];
 		if(isset($GLOBALS['PageNo'])) $this->PageNo = $GLOBALS['PageNo'];
 		else $this->PageNo = 1;

 		//已经有总记录的值
 		if($this->TotalResult==-1)
 		{
 		  $addSql  = " arcrank > -1 And channel>-1 ";

 		  $typeid = $this->ListObj->GetAtt('typeid');
 		  $subday = $this->ListObj->GetAtt('subday');
 		  $listtype = $this->ListObj->GetAtt('type');
 		  $att = $this->ListObj->GetAtt('att');
 		  $channelid = $this->ListObj->GetAtt('channel');
 		  if(empty($channelid)) $channelid = 0;

 		  //是否指定栏目条件
 		  if(!empty($typeid)){
 		  	if($cfg_list_son=='N') $addSql .= " And (typeid='$typeid' or typeid2='$typeid') ";
 		    else $addSql .= " And (".$this->TypeLink->GetSunID($typeid,"{$this->maintable}",$this->Fields['channeltype'])." Or {$this->maintable}.typeid2='$typeid') ";
 		  }
 		  //自定义属性条件
 		  if($att!="") $orwhere .= "And arcatt='$att' ";

		  //文档的频道模型
		  if($channelid>0 && !eregi("spec",$listtype)) $addSql .= " And channel = '$channelid' ";

		  //推荐文档 带缩略图  专题文档
		  if(eregi("commend",$listtype)) $addSql .= " And iscommend > 10  ";
		  if(eregi("image",$listtype)) $addSql .= " And litpic <> ''  ";
		  if(eregi("spec",$listtype) || $channelid==-1) $addSql .= " And channel = -1  ";

 		  if(!empty($subday)){
 		  	 $starttime = time() - $subday * 86400;
 		  	 $addSql .= " And senddate > $starttime  ";
 		  }

 		  $keyword = $this->ListObj->GetAtt('keyword');
 		  if(!empty($keyword)) $addSql .= " And CONCAT(title,keywords) REGEXP '$keyword' ";

 		  $cquery = "Select count(*) as dd From {$this->maintable} where $addSql";
 			$row = $this->dsql->GetOne($cquery);
 			if(is_array($row)) $this->TotalResult = $row['dd'];
 			else $this->TotalResult = 0;
 		}
    $this->TotalPage = ceil($this->TotalResult/$this->PageSize);
 	}
 	//----------------------------
 	//载入模板
 	//--------------------------
 	function LoadTemplet(){
 		$tmpdir = $GLOBALS['cfg_basedir'].$GLOBALS['cfg_templets_dir'];
 		$tempfile = str_replace("{style}",$GLOBALS['cfg_df_style'],$this->FLInfos['templet']);
 		$tempfile = $tmpdir."/".$tempfile;
 		if(!file_exists($tempfile)){
 	  	 $tempfile = $tmpdir."/".$GLOBALS['cfg_df_style']."/list_free.htm";
 	  }
 		$this->dtp->LoadTemplate($tempfile);
 		$this->TempletsFile = ereg_replace("^".$GLOBALS['cfg_basedir'],'',$tempfile);
 	}
 	//------------------
 	//列表创建HTML
 	//------------------
 	function MakeHtml($startpage=1,$makepagesize=0)
 	{
 		$this->LoadTemplet();
 		$murl = "";
 		if(empty($startpage)) $startpage = 1;
 		$this->ParseTempletsFirst();
 		$totalpage = ceil($this->TotalResult/$this->PageSize);
 		if($totalpage==0) $totalpage = 1;
 		if($makepagesize>0) $endpage = $startpage+$makepagesize;
 		else $endpage = ($totalpage+1);
 		if($endpage>($totalpage+1)) $endpage = $totalpage;
 		$firstFile = '';

 		for($this->PageNo=$startpage;$this->PageNo<$endpage;$this->PageNo++)
 		{
 		  $this->ParseDMFields($this->PageNo,1);
 	    //文件名
 	    $makeFile = $this->GetMakeFileRule();
 	    if(!ereg("^/",$makeFile)) $makeFile = "/".$makeFile;
 	    $makeFile = str_replace('{page}',$this->PageNo,$makeFile);
 	    $murl = $makeFile;
 	    $makeFile = $GLOBALS['cfg_basedir'].$makeFile;
 	    $makeFile = ereg_replace("/{1,}","/",$makeFile);
 	    if($this->PageNo==1) $firstFile = $makeFile;
 	    //保存文件
 	    $this->dtp->SaveTo($makeFile);
 	    echo "成功创建:<a href='$murl' target='_blank'>".ereg_replace("/{1,}","/",$murl)."</a><br/>";
 	  }
 	  if($this->FLInfos['nodefault']==0)
 	  {
 	  	  $murl = '/'.str_replace('{cmspath}',$GLOBALS['cfg_cmspath'],$this->FLInfos['listdir']);
 	  	  $murl .= '/'.$this->FLInfos['defaultpage'];
 	  	  $indexfile = $GLOBALS['cfg_basedir'].$murl;
 	  	  $murl = ereg_replace("/{1,}","/",$murl);
 	  	  echo "复制:$firstFile 为 ".$this->FLInfos['defaultpage']." <br/>";
 	  	  copy($firstFile,$indexfile);
 	  }
 		$this->Close();
 		return $murl;
 	}
 	//------------------
 	//显示列表
 	//------------------
 	function Display()
 	{
 		$this->LoadTemplet();
 		$this->ParseTempletsFirst();
 		$this->ParseDMFields($this->PageNo,0);
 	  $this->Close();
 		$this->dtp->Display();
 	}
 	//------------------
 	//显示单独模板页面
 	//------------------
 	function DisplayPartTemplets()
 	{
 		$nmfa = 0;
 		$tmpdir = $GLOBALS['cfg_basedir'].$GLOBALS['cfg_templets_dir'];
 		if($this->Fields['ispart']==1)
 		{
 			$tempfile = str_replace("{tid}",$this->FreeID,$this->Fields['tempindex']);
 		  $tempfile = str_replace("{cid}",$this->ChannelUnit->ChannelInfos['nid'],$tempfile);
 			$tempfile = $tmpdir."/".$tempfile;
 			if(!file_exists($tempfile)){
 	  	  $tempfile = $tmpdir."/".$GLOBALS['cfg_df_style']."/index_default.htm";
 	    }
 			$this->PartView->SetTemplet($tempfile);
 		}else if($this->Fields['ispart']==2)
 		{
 			$tempfile = str_replace("{tid}",$this->FreeID,$this->Fields['tempone']);
 		  $tempfile = str_replace("{cid}",$this->ChannelUnit->ChannelInfos['nid'],$tempfile);
 			if(is_file($tmpdir."/".$tempfile)) $this->PartView->SetTemplet($tmpdir."/".$tempfile);
 			else{ $this->PartView->SetTemplet("这是没有使用模板的单独页!","string"); $nmfa = 1; }
 		}
	  CreateDir($this->Fields['typedir']);
 		$makeUrl = $this->GetMakeFileRule($this->Fields['ID'],"index",$this->Fields['typedir'],$this->Fields['defaultname'],$this->Fields['namerule2']);
 		$makeFile = $this->GetTruePath().$makeUrl;
	  if($nmfa==0){
	  	$this->PartView->Display();
	  }else{
 			if(!file_exists($makeFile)) $this->PartView->Display();
 			else include($makeFile);
 		}
	  $this->Close();
 	}
 	//--------------------------------
 	//解析模板,对固定的标记进行初始给值
 	//--------------------------------
 	function ParseTempletsFirst()
 	{
 	   //对公用标记的解析,这里对对象的调用均是用引用调用的,因此运算后会自动改变传递的对象的值
 	   MakePublicTag($this,$this->dtp,$this->PartView,$this->TypeLink,0,0,0);
 	}
 	//--------------------------------
 	//解析模板,对内容里的变动进行赋值
 	//--------------------------------
 	function ParseDMFields($PageNo,$ismake=1)
 	{
 		foreach($this->dtp->CTags as $tagid=>$ctag){
 			if($ctag->GetName()=="freelist"){
 				$limitstart = ($this->PageNo-1) * $this->PageSize;
 				$this->dtp->Assign($tagid,$this->GetList($limitstart,$ismake));
 			}
 			else if($ctag->GetName()=="pagelist"){
 				$list_len = trim($ctag->GetAtt("listsize"));
 				$ctag->GetAtt("listitem")=="" ? $listitem="info,index,pre,pageno,next,end,option" : $listitem=$ctag->GetAtt("listitem");
 				if($list_len=="") $list_len = 3;
 				if($ismake==0) $this->dtp->Assign($tagid,$this->GetPageListDM($list_len,$listitem));
 				else $this->dtp->Assign($tagid,$this->GetPageListST($list_len,$listitem));
 			}
 			else if($ctag->GetName()=="pageno"){
 				 $this->dtp->Assign($tagid,$PageNo);
 		  }
 	  }
  }
 	//----------------
 	//获得要创建的文件名称规则
 	//----------------
 	function GetMakeFileRule()
  {
	  $okfile = '';
	  $namerule = $this->FLInfos['namerule'];
	  $listdir = $this->FLInfos['listdir'];
	  $listdir = str_replace('{cmspath}',$GLOBALS['cfg_cmspath'],$listdir);
	  $okfile = str_replace('{listid}',$this->FLInfos['aid'],$namerule);
	  $okfile = str_replace('{listdir}',$listdir,$okfile);
	  $okfile = str_replace("\\","/",$okfile);
	  $mdir = ereg_replace("/([^/]*)$","",$okfile);
	  if(!ereg("/",$mdir) && ereg("\.",$mdir)){
	  	 return $okfile;
	  }else{
	  	 CreateDir($mdir,'','');
	     return $okfile;
	  }
  }
 	//----------------------------------
  //获得一个单列的文档列表
  //---------------------------------
  function GetList($limitstart,$ismake=1)
  {
    global $cfg_list_son;

		$col = $this->ListObj->GetAtt('col');
    if(empty($col)) $col = 1;
    $titlelen = $this->ListObj->GetAtt('titlelen');
    $infolen = $this->ListObj->GetAtt('infolen');
    $imgwidth = $this->ListObj->GetAtt('imgwidth');
    $imgheight = $this->ListObj->GetAtt('imgheight');
    $titlelen = AttDef($titlelen,60);
    $infolen = AttDef($infolen,250);
    $imgwidth = AttDef($imgwidth,80);
    $imgheight = AttDef($imgheight,80);

⌨️ 快捷键说明

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