找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 815|回复: 0

[分享] dede列表页分页英文调用方法

[复制链接]
发表于 2018-2-23 09:23:06 | 显示全部楼层 |阅读模式 来自 河南省新乡市
使用于英文模板的dede分页代码,可以让分页默认中文变成英文的方式。
修改arc.listview.class.php 在include/arc.listview.class.php

调用方法
     
  1.    {dede:pagelist listsize='5'/}
  2.          {dede:pagelist pagelang='en' listsize='5'/}
  3. pagelang:en为英文,cn为中文,默认语言中文
  4. <?php
  5. if(!defined('DEDEINC')) exit('Request Error!');
  6. require_once(DEDEINC.'/arc.partview.class.php');
  7. require_once(DEDEINC.'/ftp.class.php'); 仿站
  8. @set_time_limit(0);
  9. class ListView
  10. {
  11. var $dsql;
  12. var $dtp;
  13. var $dtp2;
  14. var $TypeID;
  15. var $TypeLink;
  16. var $PageNo;
  17. var $TotalPage;
  18. var $TotalResult;
  19. var $PageSize;
  20. var $ChannelUnit;
  21. var $ListType;
  22. var $Fields;
  23. var $PartView;
  24. var $upPageType;
  25. var $addSql;
  26. var $IsError;
  27. var $CrossID;
  28. var $IsReplace;
  29. var $ftp;
  30. var $remoteDir;
  31. var $pagelang;

  32. //php5构造函数
  33. function __construct($typeid,$uppage=1)
  34. {
  35.   global $dsql,$ftp;
  36.   $this->TypeID = $typeid;
  37.   $this->dsql = &$dsql;
  38.   $this->CrossID = '';
  39.   $this->IsReplace = false;
  40.   $this->IsError = false;
  41.   $this->dtp = new DedeTagParse();

  42.   $this->dtp->SetRefObj($this);
  43.   $this->dtp->SetNameSpace("dede", "{", "}");
  44.   $this->dtp2 = new DedeTagParse();
  45.   $this->dtp2->SetNameSpace("field","[","]");
  46.   $this->TypeLink = new TypeLink($typeid);
  47.   $this->upPageType = $uppage;
  48.   $this->ftp = &$ftp;;
  49.   $this->remoteDir = '';
  50.   $this->TotalResult = is_numeric($this->TotalResult)? $this->TotalResult : "";
  51.   
  52.   if(!is_array($this->TypeLink->TypeInfos))
  53.   {
  54.    $this->IsError = true;
  55.   }
  56.   if(!$this->IsError)
  57.   {
  58.    $this->ChannelUnit = new ChannelUnit($this->TypeLink->TypeInfos['channeltype']);
  59.    $this->Fields = $this->TypeLink->TypeInfos; www.copyie.com
  60.    $this->Fields['id'] = $typeid;
  61.    $this->Fields['position'] = $this->TypeLink->GetPositionLink(true);
  62.    $this->Fields['title'] = ereg_replace("[<>]"," / ",$this->TypeLink->GetPositionLink(false));
  63.    //设置一些全局参数的值
  64.    foreach($GLOBALS['PubFields'] as $k=>$v) $this->Fields[$k] = $v;
  65.    $this->Fields['rsslink'] = $GLOBALS['cfg_cmsurl']."/data/rss/".$this->TypeID.".xml";
  66.    //设置环境变量
  67.    SetSysEnv($this->TypeID,$this->Fields['typename'],0,'','list');
  68.    $this->Fields['typeid'] = $this->TypeID;
  69.    //获得交叉栏目ID
  70.    if($this->TypeLink->TypeInfos['cross']>0 && $this->TypeLink->TypeInfos['ispart']==0)
  71.    {
  72.     $selquery = '';
  73.     if($this->TypeLink->TypeInfos['cross']==1)
  74.     {
  75.      $selquery = "Select id,topid From `dedecp_arctype` where typename like '{$this->Fields['typename']}' And id<>'{$this->TypeID}' And topid<>'{$this->TypeID}'  ";
  76.     }
  77.     else
  78.     {
  79.      $this->Fields['crossid'] = ereg_replace('[^0-9,]','',trim($this->Fields['crossid']));
  80.      if($this->Fields['crossid']!='')
  81.      {
  82.       $selquery = "Select id,topid From `dedecp_arctype` where id in({$this->Fields['crossid']}) And id<>{$this->TypeID} And topid<>{$this->TypeID}  ";
  83.      }
  84.     }
  85.     if($selquery!='')
  86.     {
  87.      $this->dsql->SetQuery($selquery);
  88.      $this->dsql->Execute();
  89.      while($arr = $this->dsql->GetArray())
  90.      {
  91.       $this->CrossID .= ($this->CrossID=='' ? $arr['id'] : ','.$arr['id']);
  92.      }
  93.     }
  94.    } www.copyie.com
  95.   }//!error
  96. }
  97. //php4构造函数
  98. function ListView($typeid,$uppage=0){
  99.   $this->__construct($typeid,$uppage);
  100. }
  101. //关闭相关资源
  102. function Close()
  103. {
  104. } www.copyie.com
  105. //统计列表里的记录
  106. function CountRecord()
  107. {
  108.   global $cfg_list_son,$cfg_need_typeid2;
  109.   if(empty($cfg_need_typeid2)) $cfg_need_typeid2 = 'N';
  110.   
  111.   //统计数据库记录
  112.   $this->TotalResult = -1;
  113.   if(isset($GLOBALS['TotalResult'])) $this->TotalResult = $GLOBALS['TotalResult'];
  114.   if(isset($GLOBALS['PageNo'])) $this->PageNo = $GLOBALS['PageNo'];
  115.   else $this->PageNo = 1;
  116.   $this->addSql  = " arc.arcrank > -1 ";
  117.   
  118.   $typeid2like = " '%,{$this->TypeID},%' ";
  119.   if($cfg_list_son=='N')
  120.   {
  121.    
  122.    if($cfg_need_typeid2=='N')
  123.    {
  124.     if($this->CrossID=='') $this->addSql .= " And (arc.typeid='".$this->TypeID."') ";

  125.     else $this->addSql .= " And (arc.typeid in({$this->CrossID},{$this->TypeID})) ";
  126.    }
  127.    else
  128.    {
  129.     if($this->CrossID=='') $this->addSql .= " And ( (arc.typeid='".$this->TypeID."') OR CONCAT(',', arc.typeid2, ',') like $typeid2like) ";
  130.     else $this->addSql .= " And ( arc.typeid in({$this->CrossID},{$this->TypeID}) OR CONCAT(',', arc.typeid2, ',') like $typeid2like) ";
  131.    }
  132.   }
  133.   else
  134.   {
  135.    $sonids = GetSonIds($this->TypeID,$this->Fields['channeltype']);
  136.    if(!preg_match("/,/", $sonids)) {
  137.     $sonidsCon = " arc.typeid = '$sonids' ";
  138.    }
  139.    else {
  140.     $sonidsCon = " arc.typeid in($sonids) ";
  141.    }
  142.    if($cfg_need_typeid2=='N')
  143.    {
  144.     if($this->CrossID=='') $this->addSql .= " And ( $sonidsCon ) ";
  145.     else $this->addSql .= " And ( arc.typeid in ({$sonids},{$this->CrossID}) ) ";
  146.    }
  147.    else
  148.    {
  149.     if($this->CrossID=='') $this->addSql .= " And ( $sonidsCon OR CONCAT(',', arc.typeid2, ',') like $typeid2like  ) ";
  150.     else $this->addSql .= " And ( arc.typeid in ({$sonids},{$this->CrossID}) OR CONCAT(',', arc.typeid2, ',') like $typeid2like ) ";
  151.    }
  152.   }
  153.   if($this->TotalResult==-1)
  154.   {
  155.    $cquery = "Select count(*) as dd From `dedecp_arctiny` arc where ".$this->addSql;
  156.    $row = $this->dsql->GetOne($cquery);
  157.    if(is_array($row))
  158.    {
  159.     $this->TotalResult = $row['dd'];
  160.    }
  161.    else
  162.    {
  163.     $this->TotalResult = 0;
  164.    }
  165.   }
  166.   //初始化列表模板,并统计页面总数
  167.   $tempfile = $GLOBALS['cfg_basedir'].$GLOBALS['cfg_templets_dir']."/".$this->TypeLink->TypeInfos['templist'];
  168.   $tempfile = str_replace("{tid}",$this->TypeID,$tempfile);
  169.   $tempfile = str_replace("{cid}",$this->ChannelUnit->ChannelInfos['nid'],$tempfile);
  170.   if(!file_exists($tempfile))
  171.   {
  172.    $tempfile = $GLOBALS['cfg_basedir'].$GLOBALS['cfg_templets_dir']."/".$GLOBALS['cfg_df_style']."/list_default.htm";
  173.   }
  174.   if(!file_exists($tempfile)||!is_file($tempfile))
  175.   {
  176.    echo "模板文件不存在,无法解析文档!";
  177.    exit();
  178.   }
  179.   $this->dtp->LoadTemplate($tempfile);
  180.   $ctag = $this->dtp->GetTag("page");
  181.   if(!is_object($ctag))
  182.   {
  183.    $ctag = $this->dtp->GetTag("list");
  184.   }
  185.   if(!is_object($ctag))
  186.   {
  187.    $this->PageSize = 20;
  188.   }
  189.   else
  190.   {
  191.    if($ctag->GetAtt("pagesize")!="")
  192.    {
  193.     $this->PageSize = $ctag->GetAtt("pagesize");
  194.    }
  195.    else
  196.    {
  197.     $this->PageSize = 20;
  198.    }
  199.   }
  200.   $this->TotalPage = ceil($this->TotalResult/$this->PageSize);
  201. }
  202. //列表创建HTML
  203. function MakeHtml($startpage=1,$makepagesize=0,$isremote=0)
  204. {
  205.   global $cfg_remote_site;
  206.   if(empty($startpage))
  207.   {
  208.    $startpage = 1;
  209.   }
  210.   //创建封面模板文件
  211.   if($this->TypeLink->TypeInfos['isdefault']==-1)
  212.   {
  213.    echo '这个类目是动态类目!';
  214.    return '../plus/list.php?tid='.$this->TypeLink->TypeInfos['id'];
  215.   }
  216.   //单独页面
  217.   else if($this->TypeLink->TypeInfos['ispart']>0)
  218.   {
  219.    $reurl = $this->MakePartTemplets();
  220.    return $reurl;
  221.   }
  222.   $this->CountRecord();
  223.   //初步给固定值的标记赋值
  224.   $this->ParseTempletsFirst();
  225.   $totalpage = ceil($this->TotalResult/$this->PageSize);
  226.   if($totalpage==0)
  227.   {
  228.    $totalpage = 1;
  229.   }
  230.   CreateDir(MfTypedir($this->Fields['typedir']));
  231.   $murl = '';
  232.   if($makepagesize > 0)
  233.   {
  234.    $endpage = $startpage+$makepagesize;
  235.   }
  236.   else
  237.   {
  238.    $endpage = ($totalpage+1);
  239.   }
  240.   if( $endpage >= $totalpage+1 )
  241.   {
  242.    $endpage = $totalpage+1;
  243.   }
  244.   if($endpage==1)
  245.   {
  246.    $endpage = 2;
  247.   }
  248.   for($this->PageNo=$startpage; $this->PageNo < $endpage; $this->PageNo++) 仿站
  249.   {
  250.    $this->ParseDMFields($this->PageNo,1);
  251.    $makeFile = $this->GetMakeFileRule($this->Fields['id'],'list',$this->Fields['typedir'],'',$this->Fields['namerule2']);
  252.    $makeFile = str_replace("{page}",$this->PageNo,$makeFile);
  253.    $murl = $makeFile;
  254.    if(!ereg("^/",$makeFile))
  255.    {
  256.     $makeFile = "/".$makeFile;
  257.    }
  258.    $makeFile = $this->GetTruePath().$makeFile;
  259.    $makeFile = ereg_replace("/{1,}","/",$makeFile);
  260.    $murl = $this->GetTrueUrl($murl);
  261.    $this->dtp->SaveTo($makeFile);
  262.    //如果启用远程发布则需要进行判断
  263.    if($cfg_remote_site=='Y'&& $isremote == 1)
  264.    {
  265.      //分析远程文件路径
  266.      $remotefile = str_replace(DEDEROOT, '',$makeFile);
  267.         $localfile = '..'.$remotefile;
  268.         $remotedir = preg_replace('/[^\/]*\.html/', '',$remotefile);
  269.       //不相等则说明已经切换目录则可以创建镜像
  270.         $this->ftp->rmkdir($remotedir);
  271.        $this->ftp->upload($localfile, $remotefile, 'acii');
  272.     }
  273.   }
  274.   if($startpage==1)
  275.   {
  276.    //如果列表启用封面文件,复制这个文件第一页
  277.    if($this->TypeLink->TypeInfos['isdefault']==1
  278.    && $this->TypeLink->TypeInfos['ispart']==0)
  279.    {
  280.     $onlyrule = $this->GetMakeFileRule($this->Fields['id'],"list",$this->Fields['typedir'],'',$this->Fields['namerule2']);

  281.     $onlyrule = str_replace("{page}","1",$onlyrule);
  282.     $list_1 = $this->GetTruePath().$onlyrule;
  283.     $murl = MfTypedir($this->Fields['typedir']).'/'.$this->Fields['defaultname'];
  284.     //如果启用远程发布则需要进行判断
  285.     if($cfg_remote_site=='Y'&& $isremote == 1)
  286.     {
  287.       //分析远程文件路径
  288.      $remotefile = $murl;
  289.      $localfile = '..'.$remotefile;
  290.      $remotedir = preg_replace('/[^\/]*\.html/', '',$remotefile);
  291.      //不相等则说明已经切换目录则可以创建镜像
  292.           $this->ftp->rmkdir($remotedir);
  293.        $this->ftp->upload($localfile, $remotefile, 'acii');
  294.      }
  295.     $indexname = $this->GetTruePath().$murl;
  296.     copy($list_1,$indexname);
  297.    }
  298.   }
  299.   return $murl;
  300. }
  301. //显示列表
  302. function Display()
  303. {
  304.   if($this->TypeLink->TypeInfos['ispart']>0)
  305.   {
  306.    $this->DisplayPartTemplets();
  307.    return ;
  308.   }
  309.   $this->CountRecord();
  310.   if((empty($this->PageNo) || $this->PageNo==1)
  311.   && $this->TypeLink->TypeInfos['ispart']==1)
  312.   {
  313.    $tmpdir = $GLOBALS['cfg_basedir'].$GLOBALS['cfg_templets_dir'];
  314.    $tempfile = str_replace("{tid}",$this->TypeID,$this->Fields['tempindex']);
  315.    $tempfile = str_replace("{cid}",$this->ChannelUnit->ChannelInfos['nid'],$tempfile);
  316.    $tempfile = $tmpdir."/".$tempfile;
  317.    if(!file_exists($tempfile))
  318.    {
  319.     $tempfile = $tmpdir."/".$GLOBALS['cfg_df_style']."/index_default.htm";
  320.    }
  321.    $this->dtp->LoadTemplate($tempfile);
  322.   }
  323.   $this->ParseTempletsFirst();
  324.   $this->ParseDMFields($this->PageNo,0);
  325.   $this->dtp->Display();
  326. }
  327. //创建单独模板页面
  328. function MakePartTemplets()
  329. {
  330.   $this->PartView = new PartView($this->TypeID,false);
  331.   $this->PartView->SetTypeLink($this->TypeLink);
  332.   $nmfa = 0;
  333.   $tmpdir = $GLOBALS['cfg_basedir'].$GLOBALS['cfg_templets_dir'];
  334.   if($this->Fields['ispart']==1)
  335.   {
  336.    $tempfile = str_replace("{tid}",$this->TypeID,$this->Fields['tempindex']);
  337.    $tempfile = str_replace("{cid}",$this->ChannelUnit->ChannelInfos['nid'],$tempfile);
  338.    $tempfile = $tmpdir."/".$tempfile;
  339.    if(!file_exists($tempfile))
  340.    {
  341.     $tempfile = $tmpdir."/".$GLOBALS['cfg_df_style']."/index_default.htm";
  342.    }
  343.    $this->PartView->SetTemplet($tempfile);

  344.   }
  345.   else if($this->Fields['ispart']==2)
  346.   {
  347.    //跳转网址
  348.    return $this->Fields['typedir'];
  349.   }
  350.   CreateDir(MfTypedir($this->Fields['typedir']));
  351.   $makeUrl = $this->GetMakeFileRule($this->Fields['id'],"index",MfTypedir($this->Fields['typedir']),$this->Fields['defaultname'],$this->Fields['namerule2']);
  352.   $makeUrl = ereg_replace("/{1,}","/",$makeUrl);
  353.   $makeFile = $this->GetTruePath().$makeUrl;
  354.   if($nmfa==0)
  355.   {
  356.    $this->PartView->SaveToHtml($makeFile);
  357.    //如果启用远程发布则需要进行判断
  358.    if($GLOBALS['cfg_remote_site']=='Y'&& $isremote == 1)
  359.    {
  360.        //分析远程文件路径
  361.        $remotefile = str_replace(DEDEROOT, '',$makeFile);
  362.             $localfile = '..'.$remotefile;
  363.             $remotedir = preg_replace('/[^\/]*\.html/', '',$remotefile);
  364.           //不相等则说明已经切换目录则可以创建镜像
  365.             $this->ftp->rmkdir($remotedir);
  366.          $this->ftp->upload($localfile, $remotefile, 'acii');
  367.     }
  368.   }
  369.   else
  370.   {
  371.    if(!file_exists($makeFile))
  372.    {
  373.     $this->PartView->SaveToHtml($makeFile);
  374.     //如果启用远程发布则需要进行判断
  375.     if($cfg_remote_site=='Y'&& $isremote == 1)
  376.     {
  377.         //分析远程文件路径
  378.         $remotefile = str_replace(DEDEROOT, '',$makeFile);
  379.              $localfile = '..'.$remotefile;
  380.              $remotedir = preg_replace('/[^\/]*\.html/', '',$remotefile);
  381.            //不相等则说明已经切换目录则可以创建镜像
  382.              $this->ftp->rmkdir($remotedir);
  383.           $this->ftp->upload($localfile, $remotefile, 'acii');
  384.      }
  385.    }
  386.   }
  387.   return $this->GetTrueUrl($makeUrl);
  388. }
  389. //显示单独模板页面
  390. function DisplayPartTemplets()
  391. {
  392.   $this->PartView = new PartView($this->TypeID,false);
  393.   $this->PartView->SetTypeLink($this->TypeLink);
  394.   $nmfa = 0;
  395.   $tmpdir = $GLOBALS['cfg_basedir'].$GLOBALS['cfg_templets_dir'];
  396.   if($this->Fields['ispart']==1)
  397.   {
  398.    //封面模板
  399.    $tempfile = str_replace("{tid}",$this->TypeID,$this->Fields['tempindex']);
  400.    $tempfile = str_replace("{cid}",$this->ChannelUnit->ChannelInfos['nid'],$tempfile);
  401.    $tempfile = $tmpdir."/".$tempfile;
  402.    if(!file_exists($tempfile))
  403.    {
  404.     $tempfile = $tmpdir."/".$GLOBALS['cfg_df_style']."/index_default.htm";
  405.    }
  406.    $this->PartView->SetTemplet($tempfile);
  407.   }
  408.   else if($this->Fields['ispart']==2)
  409.   {
  410.    //跳转网址
  411.    $gotourl = $this->Fields['typedir'];
  412.    header("Location:$gotourl");
  413.    exit();
  414.   }
  415.   CreateDir(MfTypedir($this->Fields['typedir']));
  416.   $makeUrl = $this->GetMakeFileRule($this->Fields['id'],"index",MfTypedir($this->Fields['typedir']),$this->Fields['defaultname'],$this->Fields['namerule2']);
  417.   $makeFile = $this->GetTruePath().$makeUrl;
  418.   if($nmfa==0)
  419.   {
  420.    $this->PartView->Display();
  421.   }
  422.   else
  423.   {
  424.    if(!file_exists($makeFile))
  425.    {
  426.     $this->PartView->Display();
  427.    }
  428.    else
  429.    {
  430.     include($makeFile);
  431.    }
  432.   }
  433. }
  434. //获得站点的真实根路径
  435. function GetTruePath()
  436. {
  437.   $truepath = $GLOBALS["cfg_basedir"];
  438.   return $truepath;
  439. }
  440. //获得真实连接路径
  441. function GetTrueUrl($nurl)
  442. {
  443.   if($this->Fields['moresite']==1)
  444.   {
  445.    if($this->Fields['sitepath']!='')
  446.    {
  447.     $nurl = ereg_replace("^".$this->Fields['sitepath'],'',$nurl);
  448.    }
  449.    $nurl = $this->Fields['siteurl'].$nurl;
  450.   }
  451.   return $nurl;
  452. }
  453. //解析模板,对固定的标记进行初始给值
  454. function ParseTempletsFirst()
  455. {
  456.   if(isset($this->TypeLink->TypeInfos['reid']))
  457.   {
  458.    $GLOBALS['envs']['reid'] = $this->TypeLink->TypeInfos['reid'];
  459.   }
  460.   $GLOBALS['envs']['typeid'] = $this->TypeID;
  461.   $GLOBALS['envs']['topid'] = GetTopid($this->Fields['typeid']);
  462.   $GLOBALS['envs']['cross'] = 1;
  463.   MakeOneTag($this->dtp,$this);
  464. } www.copyie.com
  465. //解析模板,对内容里的变动进行赋值
  466. function ParseDMFields($PageNo,$ismake=1)
  467. {
  468.   //替换第二页后的内容
  469.   if(($PageNo>1 || strlen($this->Fields['content'])<10 ) && !$this->IsReplace)
  470.   {
  471.    $this->dtp->SourceString = str_replace('[cmsreplace]','display:none',$this->dtp->SourceString);
  472.    $this->IsReplace = true;
  473.   }
  474.   foreach($this->dtp->CTags as $tagid=>$ctag)
  475.   {
  476.    if($ctag->GetName()=="list")
  477.    {
  478.     $limitstart = ($this->PageNo-1) * $this->PageSize;
  479.     $row = $this->PageSize;
  480.     if(trim($ctag->GetInnerText())=="")
  481.     {
  482.      $InnerText = GetSysTemplets("list_fulllist.htm");

  483.     }
  484.     else
  485.     {
  486.      $InnerText = trim($ctag->GetInnerText());
  487.     }
  488.     $this->dtp->Assign($tagid,
  489.     $this->GetArcList(
  490.     $limitstart,
  491.     $row,
  492.     $ctag->GetAtt("col"),
  493.     $ctag->GetAtt("titlelen"),
  494.     $ctag->GetAtt("infolen"),
  495.     $ctag->GetAtt("imgwidth"),
  496.     $ctag->GetAtt("imgheight"),
  497.     $ctag->GetAtt("listtype"),
  498.     $ctag->GetAtt("orderby"),
  499.     $InnerText,
  500.     $ctag->GetAtt("tablewidth"),
  501.     $ismake,
  502.     $ctag->GetAtt("orderway")
  503.     )
  504.     );
  505.    }
  506.    else if($ctag->GetName()=="pagelist")
  507.    {
  508.     $list_len = trim($ctag->GetAtt("listsize"));
  509.     $pagelang = trim($ctag->GetAtt("pagelang"));
  510.     $ctag->GetAtt("listitem")=="" ? $listitem="index,pre,pageno,next,end,option" : $listitem=$ctag->GetAtt("listitem");
  511.      if($pagelang=="")
  512.        {
  513.            $pagelang = 'cn';
  514.        }
  515.      
  516.     if($list_len=="")
  517.     {
  518.      $list_len = 3;
  519.     }
  520.    
  521.     if($ismake==0)
  522.     {
  523.      $this->dtp->Assign($tagid,$this->GetPageListDM($list_len,$listitem,$pagelang));
  524.     }
  525.     else
  526.     {
  527.      $this->dtp->Assign($tagid,$this->GetPageListST($list_len,$listitem,$pagelang));
  528.     }
  529.    }
  530.    else if($PageNo!=1 && $ctag->GetName()=='field' && $ctag->GetAtt('display')!='')
  531.    {
  532.     $this->dtp->Assign($tagid,'');
  533.    }
  534.   }
  535. } www.copyie.com
  536. //获得要创建的文件名称规则
  537. function GetMakeFileRule($typeid,$wname,$typedir,$defaultname,$namerule2)
  538. {
  539.   $typedir = MfTypedir($typedir);
  540.   if($wname=='index')
  541.   {
  542.    return $typedir.'/'.$defaultname;
  543.   }
  544.   else
  545.   {
  546.    $namerule2 = str_replace('{tid}',$typeid,$namerule2);
  547.    $namerule2 = str_replace('{typedir}',$typedir,$namerule2);
  548.    return $namerule2;
  549.   }
  550. }
  551. //获得一个单列的文档列表
  552. function GetArcList($limitstart=0,$row=10,$col=1,$titlelen=30,$infolen=250,
  553. $imgwidth=120,$imgheight=90,$listtype="all",$orderby="default",$innertext="",$tablewidth="100",$ismake=1,$orderWay='desc')
  554. {
  555.   global $cfg_list_son;
  556.   
  557.   $typeid=$this->TypeID;
  558.   
  559.   if($row=='') $row = 10;
  560.   if($limitstart=='') $limitstart = 0;
  561.   if($titlelen=='') $titlelen = 100;
  562.   if($infolen=='') $infolen = 250;
  563.   if($imgwidth=='') $imgwidth = 120;
  564.   if($imgheight=='') $imgheight = 120;
  565.   if($listtype=='') $listtype = 'all';
  566.   if($orderWay=='') $orderWay = 'desc';
  567.   
  568.   if($orderby=='') {
  569.    $orderby='default';
  570.   }
  571.   else {
  572.    $orderby=strtolower($orderby); 仿站
  573.   }
  574.   
  575.   $tablewidth = str_replace('%','',$tablewidth);
  576.   if($tablewidth=='') $tablewidth=100;
  577.   if($col=='') $col=1;
  578.   $colWidth = ceil(100/$col);
  579.   $tablewidth = $tablewidth.'%';
  580.   $colWidth = $colWidth.'%';
  581.   
  582.   $innertext = trim($innertext);
  583.   if($innertext=='') {
  584.    $innertext = GetSysTemplets('list_fulllist.htm');
  585.   } 仿站
  586.   //排序方式
  587.   $ordersql = '';
  588.   if($orderby=="senddate" || $orderby=="id") {
  589.    $ordersql=" order by arc.id $orderWay";
  590.   }
  591.   else if($orderby=="hot" || $orderby=="click") {
  592.    $ordersql = " order by arc.click $orderWay";
  593.   }
  594.   else if($orderby=="lastpost") {
  595.    $ordersql = "  order by arc.lastpost $orderWay";
  596.   }else if($orderby=="weight") {
  597.    $ordersql = "  order by arc.weight $orderWay";
  598.   }
  599.   else {
  600.    $ordersql=" order by arc.sortrank $orderWay";
  601.   }
  602.   //获得附加表的相关信息
  603.   $addtable  = $this->ChannelUnit->ChannelInfos['addtable'];
  604.   if($addtable!="")
  605.   {
  606.    $addJoin = " left join `$addtable` on arc.id = ".$addtable.'.aid ';
  607.    $addField = '';
  608.    $fields = explode(',',$this->ChannelUnit->ChannelInfos['listfields']);
  609.    foreach($fields as $k=>$v)
  610.    {
  611.     $nfields[$v] = $k;
  612.    }
  613.    if(is_array($this->ChannelUnit->ChannelFields) && !empty($this->ChannelUnit->ChannelFields))
  614.    {
  615.     foreach($this->ChannelUnit->ChannelFields as $k=>$arr)
  616.     {
  617.      if(isset($nfields[$k]))

  618.      {
  619.       if(!empty($arr['rename'])) {
  620.        $addField .= ','.$addtable.'.'.$k.' as '.$arr['rename'];
  621.       }
  622.       else {
  623.        $addField .= ','.$addtable.'.'.$k;
  624.       }
  625.      }
  626.     }
  627.    }
  628.   }
  629.   else
  630.   {
  631.    $addField = '';
  632.    $addJoin = '';
  633.   }
  634.   //如果不用默认的sortrank或id排序,使用联合查询(数据量大时非常缓慢)
  635.   if(ereg('hot|click|lastpost|weight',$orderby))
  636.   {
  637.    $query = "Select arc.*,tp.typedir,tp.typename,tp.isdefault,tp.defaultname,
  638.      tp.namerule,tp.namerule2,tp.ispart,tp.moresite,tp.siteurl,tp.sitepath
  639.      $addField
  640.      from `dedecp_archives` arc
  641.      left join `dedecp_arctype` tp on arc.typeid=tp.id
  642.      $addJoin
  643.      where {$this->addSql} $ordersql limit $limitstart,$row";
  644.   }
  645.   //普通情况先从arctiny表查出ID,然后按ID查询(速度非常快)
  646.   else
  647.   {
  648.    $t1 = ExecTime();
  649.    $ids = array();
  650.    $query = "Select id From `dedecp_arctiny` arc where {$this->addSql} $ordersql limit $limitstart,$row "; 仿站
  651.    $this->dsql->SetQuery($query);
  652.    $this->dsql->Execute();
  653.    while($arr=$this->dsql->GetArray())
  654.    {
  655.     $ids[] = $arr['id'];
  656.    }
  657.    $idstr = join(',',$ids);
  658.    if($idstr=='')
  659.    {
  660.     return '';
  661.    }
  662.    else
  663.    {
  664.     $query = "Select arc.*,tp.typedir,tp.typename,tp.corank,tp.isdefault,tp.defaultname,
  665.         tp.namerule,tp.namerule2,tp.ispart,tp.moresite,tp.siteurl,tp.sitepath
  666.         $addField
  667.         from `dedecp_archives` arc left join `dedecp_arctype` tp on arc.typeid=tp.id
  668.         $addJoin
  669.         where arc.id in($idstr) $ordersql ";
  670.    }
  671.    $t2 = ExecTime();
  672.    //echo $t2-$t1;
  673.   }
  674.   $this->dsql->SetQuery($query);
  675.   $this->dsql->Execute('al');
  676.   $t2 = ExecTime(); www.copyie.com
  677.   //echo $t2-$t1;
  678.   $artlist = '';
  679.   $this->dtp2->LoadSource($innertext);
  680.   $GLOBALS['autoindex'] = 0;
  681.   for($i=0;$i<$row;$i++)
  682.   {
  683.    if($col>1)
  684.    {
  685.     $artlist .= "<div>\r\n";
  686.    }
  687.    for($j=0;$j<$col;$j++)
  688.    {
  689.     if($row = $this->dsql->GetArray("al"))
  690.     {
  691.      $GLOBALS['autoindex']++;
  692.      $ids[$row['id']] = $row['id']; 仿站
  693.      //处理一些特殊字段
  694.      $row['infos'] = cn_substr($row['description'],$infolen);
  695.      $row['id'] =  $row['id'];
  696.      if($row['corank'] > 0 && $row['arcrank']==0)
  697.      {
  698.       $row['arcrank'] = $row['corank'];
  699.      } www.copyie.com
  700.      $row['filename'] = $row['arcurl'] = GetFileUrl($row['id'],$row['typeid'],$row['senddate'],$row['title'],$row['ismake'],
  701.      $row['arcrank'],$row['namerule'],$row['typedir'],$row['money'],$row['filename'],$row['moresite'],$row['siteurl'],$row['sitepath']);
  702.      $row['typeurl'] = GetTypeUrl($row['typeid'],MfTypedir($row['typedir']),$row['isdefault'],$row['defaultname'],
  703.      $row['ispart'],$row['namerule2'],$row['moresite'],$row['siteurl'],$row['sitepath']);
  704.      if($row['litpic'] == '-' || $row['litpic'] == '')
  705.      {
  706.       $row['litpic'] = $GLOBALS['cfg_cmspath'].'/images/defaultpic.gif';
  707.      }
  708.      if(!eregi("^http://",$row['litpic']) && $GLOBALS['cfg_multi_site'] == 'Y')
  709.      { www.copyie.com
  710.       $row['litpic'] = $GLOBALS['cfg_mainsite'].$row['litpic'];
  711.      }
  712.      $row['picname'] = $row['litpic'];
  713.      $row['stime'] = GetDateMK($row['pubdate']);
  714.      $row['typelink'] = "<a href='".$row['typeurl']."'>".$row['typename']."</a>";
  715.      $row['image'] = "<img src='".$row['picname']."' border='0' width='$imgwidth' height='$imgheight' alt='".ereg_replace("['><]","",$row['title'])."'>";
  716.      $row['imglink'] = "<a href='".$row['filename']."'>".$row['image']."</a>";
  717.      $row['fulltitle'] = $row['title'];
  718.      $row['title'] = cn_substr($row['title'],$titlelen);
  719.      if($row['color']!='')
  720.      {
  721.       $row['title'] = "<font color='".$row['color']."'>".$row['title']."</font>";
  722.      }
  723.      if(ereg('c',$row['flag']))
  724.      {
  725.       $row['title'] = "<b>".$row['title']."</b>";
  726.      }
  727.      $row['textlink'] = "<a href='".$row['filename']."'>".$row['title']."</a>";
  728.      $row['plusurl'] = $row['phpurl'] = $GLOBALS['cfg_phpurl'];
  729.      $row['memberurl'] = $GLOBALS['cfg_memberurl'];
  730.      $row['templeturl'] = $GLOBALS['cfg_templeturl'];
  731.      //编译附加表里的数据
  732.      foreach($row as $k=>$v)
  733.      {
  734.       $row[strtolower($k)] = $v;
  735.      }
  736.      foreach($this->ChannelUnit->ChannelFields as $k=>$arr)
  737.      {
  738.       if(isset($row[$k]))
  739.       {
  740.        $row[$k] = $this->ChannelUnit->MakeField($k,$row[$k]);
  741.       }
  742.      }
  743.      if(is_array($this->dtp2->CTags))
  744.      {
  745.       foreach($this->dtp2->CTags as $k=>$ctag)
  746.       {
  747.        if($ctag->GetName()=='array') 仿站
  748.        {
  749.         //传递整个数组,在runphp模式中有特殊作用
  750.         $this->dtp2->Assign($k,$row);
  751.        }
  752.        else
  753.        {
  754.         if(isset($row[$ctag->GetName()]))
  755.         {
  756.          $this->dtp2->Assign($k,$row[$ctag->GetName()]);
  757.         }
  758.         else
  759.         {
  760.          $this->dtp2->Assign($k,'');
  761.         }
  762.        }
  763.       }
  764.      }
  765.      $artlist .= $this->dtp2->GetResult();
  766.     }//if hasRow
  767.    }//Loop Col
  768.    if($col>1)
  769.    {
  770.     $i += $col - 1;
  771.     $artlist .= " </div>\r\n";
  772.    }
  773.   }//Loop Line
  774.   $t3 = ExecTime();
  775.   //echo ($t3-$t2);
  776.   $this->dsql->FreeResult('al');
  777.   return $artlist;
  778. } www.copyie.com
  779. //获取静态的分页列表
  780. function GetPageListST($list_len,$listitem="index,end,pre,next,pageno",$pagelang)
  781. {
  782.      /*****************************************************************************************/
  783.        if($pagelang=='cn'){
  784.                  $uahome="首页";
  785.                 $uaprevious="上一页";
  786.                    $uanext="下一页";
  787.                    $ualastpage="末页";
  788.                    $uapage="页";
  789.                    $uatotal="共";

  790.                    $uarecords="条记录";
  791.                    }else{
  792.                      $uahome=" Home ";
  793.                    $uaprevious=" Previous ";
  794.                    $uanext=" Next ";
  795.                    $ualastpage=" Last Page ";
  796.                    $uapage=" Page ";
  797.                    $uatotal=" Total ";
  798.                    $uarecords=" Records. ";
  799.                  }
  800.      
  801.   $prepage = $nextpage = '';
  802.   $prepagenum = $this->PageNo-1;
  803.   $nextpagenum = $this->PageNo+1;
  804.   if($list_len=='' || ereg("[^0-9]",$list_len))
  805.   {
  806.    $list_len=3;
  807.   }
  808.   $totalpage = ceil($this->TotalResult/$this->PageSize);
  809.   if($totalpage<=1 && $this->TotalResult>0)
  810.   {
  811.         return "<li><span class="pageinfo">".$uatotal." <strong>1</strong> ".$uapage." <strong>".$this->TotalResult."</strong> ".$uarecords."</span></li>\r\n";
  812.   }
  813.   if($this->TotalResult == 0)
  814.   {
  815.         return "<li><span class="pageinfo">".$uatotal." <strong>0</strong> ".$uapage." <strong>".$this->TotalResult."</strong> ".$uarecords."</span></li>\r\n";
  816.   
  817.   }
  818.   $purl = $this->GetCurUrl();
  819.         $maininfo = "<li><span class="pageinfo">".$uatotal." <strong>{$totalpage}</strong> ".$uapage." <strong>".$this->TotalResult."</strong> ".$uarecords."</span></li>\r\n";
  820.      
  821.   $tnamerule = $this->GetMakeFileRule($this->Fields['id'],"list",$this->Fields['typedir'],$this->Fields['defaultname'],$this->Fields['namerule2']);
  822.   $tnamerule = ereg_replace('^(.*)/','',$tnamerule);




  823.   //获得上一页和主页的链接
  824.   if($this->PageNo != 1)
  825.   {
  826.    $prepage.="<li><a href='".str_replace("{page}",$prepagenum,$tnamerule)."'>".$uaprevious."</a></li>\r\n";
  827.    $indexpage="<li><a href='".str_replace("{page}",1,$tnamerule)."'>".$uahome."</a></li>\r\n";
  828.   }
  829.   else
  830.   {
  831.    $indexpage="<li>".$uahome."</li>\r\n";
  832.   }
  833.   //下一页,未页的链接
  834.   if($this->PageNo!=$totalpage && $totalpage>1)
  835.   {
  836.    $nextpage.="<li><a href='".str_replace("{page}",$nextpagenum,$tnamerule)."'>".$uanext."</a></li>\r\n";
  837.    $endpage="<li><a href='".str_replace("{page}",$totalpage,$tnamerule)."'>".$ualastpage."</a></li>\r\n";
  838.   }
  839.   else
  840.   {
  841.    $endpage="<li>".$ualastpage."</li>\r\n";
  842.   }
  843.   //option链接
  844.   $optionlist = '';
  845.   $optionlen = strlen($totalpage);
  846.   $optionlen = $optionlen*12 + 18;
  847.   if($optionlen < 36) $optionlen = 36;
  848.   if($optionlen > 100) $optionlen = 100;
  849.   $optionlist = "<li><select name='sldd' style='width:{$optionlen}px' onchange='location.href=this.options[this.selectedIndex].value;'>\r\n";
  850.   for($mjj=1;$mjj<=$totalpage;$mjj++)
  851.   {
  852.    if($mjj==$this->PageNo)
  853.    {
  854.     $optionlist .= "<option value='".str_replace("{page}",$mjj,$tnamerule)."' selected>$mjj</option>\r\n";
  855.    }
  856.    else
  857.    {
  858.     $optionlist .= "<option value='".str_replace("{page}",$mjj,$tnamerule)."'>$mjj</option>\r\n";
  859.    }
  860.   } www.copyie.com
  861.   $optionlist .= "</select></li>\r\n";
  862.   //获得数字链接
  863.   $listdd="";
  864.   $total_list = $list_len * 2 + 1;
  865.   if($this->PageNo >= $total_list)
  866.   {
  867.    $j = $this->PageNo-$list_len;
  868.    $total_list = $this->PageNo+$list_len;
  869.    if($total_list>$totalpage)
  870.    {
  871.     $total_list=$totalpage;
  872.    }
  873.   }
  874.   else
  875.   {
  876.    $j=1;
  877.    if($total_list>$totalpage)
  878.    {
  879.     $total_list=$totalpage;
  880.    }
  881.   }
  882.   for($j;$j<=$total_list;$j++)
  883.   {
  884.    if($j==$this->PageNo)
  885.    {
  886.     $listdd.= "<li class="thisclass">$j</li>\r\n"; www.copyie.com
  887.    }
  888.    else
  889.    {
  890.     $listdd.="<li><a href='".str_replace("{page}",$j,$tnamerule)."'>".$j."</a></li>\r\n";
  891.    }
  892.   }
  893.   $plist = '';
  894.   if(eregi('index',$listitem)) $plist .= $indexpage;
  895.   if(eregi('pre',$listitem)) $plist .= $prepage;
  896.   if(eregi('pageno',$listitem)) $plist .= $listdd;
  897.   if(eregi('next',$listitem)) $plist .= $nextpage;
  898.   if(eregi('end',$listitem)) $plist .= $endpage;
  899.   if(eregi('option',$listitem)) $plist .= $optionlist;
  900.   if(eregi('info',$listitem)) $plist .= $maininfo;
  901.   
  902.   return $plist;
  903. }
  904. //获取动态的分页列表
  905. function GetPageListDM($list_len,$listitem="index,end,pre,next,pageno",$pagelang)
  906. {
  907. /*****************************************************************************************/
  908.        if($pagelang=='cn'){
  909.                  $uahome="首页";
  910.                 $uaprevious="上一页";
  911.                    $uanext="下一页";
  912.                    $ualastpage="末页";
  913.                    $uapage="页";
  914.                    $uatotal="共"; www.copyie.com
  915.                    $uarecords="条记录";
  916.                    }else{
  917.                      $uahome=" Home ";
  918.                    $uaprevious=" Previous ";
  919.                    $uanext=" Next ";
  920.                    $ualastpage=" Last Page ";
  921.                    $uapage=" Page ";
  922.                    $uatotal=" Total ";

  923.                    $uarecords=" Records. ";
  924.                  }
  925.   global $cfg_rewrite;
  926.   $prepage = $nextpage = '';
  927.   $prepagenum = $this->PageNo-1;
  928.   $nextpagenum = $this->PageNo+1;
  929.   if($list_len=='' || ereg("[^0-9]",$list_len))
  930.   {
  931.    $list_len=3;
  932.   }
  933.   $totalpage = ceil($this->TotalResult/$this->PageSize);
  934.   if($totalpage<=1 && $this->TotalResult>0)
  935.   {
  936.    return "<li><span class="pageinfo">".$uatotal." 1 ".$uapage."/".$this->TotalResult."".$uarecords."</span></li>\r\n";
  937.   }
  938.   if($this->TotalResult == 0)
  939.   {
  940.    return "<li><span class="pageinfo">".$uatotal." 0 ".$uapage."/".$this->TotalResult."".$uarecords."</span></li>\r\n";
  941.   }
  942.   $maininfo = "<li><span class="pageinfo">".$uatotal." <strong>{$totalpage}</strong>".$uapage."<strong>".$this->TotalResult."</strong>".$uarecords."</span></li>\r\n";
  943.   
  944.   $purl = $this->GetCurUrl();
  945.   if($cfg_rewrite == 'Y')
  946.   {
  947.    $nowurls = ereg_replace("\-", ".php?", $purl);
  948.    $nowurls = explode("?", $nowurls);
  949.    $purl = $nowurls[0];
  950.   } 仿站
  951.   $geturl = "tid=".$this->TypeID."&TotalResult=".$this->TotalResult."&";
  952.   $purl .= '?'.$geturl;
  953.   
  954.   $optionlist = '';
  955.   //$hidenform = "<input type='hidden' name='tid' value='".$this->TypeID."'>\r\n";
  956.   //$hidenform .= "<input type='hidden' name='TotalResult' value='".$this->TotalResult."'>\r\n"; www.copyie.com
  957.   //获得上一页和下一页的链接
  958.   if($this->PageNo != 1)
  959.   {
  960.    $prepage.="<li><a href='".$purl."PageNo=$prepagenum'>".$uaprevious."</a></li>\r\n";
  961.    $indexpage="<li><a href='".$purl."PageNo=1'>".$uahome."</a></li>\r\n";
  962.   }
  963.   else
  964.   {
  965.    $indexpage="<li><a>".$uahome."</a></li>\r\n";
  966.   }
  967.   if($this->PageNo!=$totalpage && $totalpage>1)
  968.   {
  969.    $nextpage.="<li><a href='".$purl."PageNo=$nextpagenum'>".$uanext."</a></li>\r\n";
  970.    $endpage="<li><a href='".$purl."PageNo=$totalpage'>".$ualastpage."</a></li>\r\n";

  971.   }
  972.   else
  973.   {
  974.    $endpage="<li><a>".$ualastpage."</a></li>\r\n";
  975.   } 仿站

  976.   //获得数字链接
  977.   $listdd="";
  978.   $total_list = $list_len * 2 + 1;
  979.   if($this->PageNo >= $total_list)
  980.   {
  981.    $j = $this->PageNo-$list_len;
  982.    $total_list = $this->PageNo+$list_len;
  983.    if($total_list>$totalpage)
  984.    {
  985.     $total_list=$totalpage;
  986.    }
  987.   }
  988.   else
  989.   {
  990.    $j=1;
  991.    if($total_list>$totalpage)
  992.    {
  993.     $total_list=$totalpage;
  994.    }
  995.   }
  996.   for($j;$j<=$total_list;$j++)
  997.   {
  998.    if($j==$this->PageNo)
  999.    {
  1000.     $listdd.= "<li class="thisclass"><a>$j</a></li>\r\n";

  1001.    }
  1002.    else
  1003.    {
  1004.     $listdd.="<li><a href='".$purl."PageNo=$j'>".$j."</a></li>\r\n";
  1005.    }
  1006.   }
  1007.   $plist = '';
  1008.   if(eregi('index',$listitem)) $plist .= $indexpage;
  1009.   if(eregi('pre',$listitem)) $plist .= $prepage;
  1010.   if(eregi('pageno',$listitem)) $plist .= $listdd;
  1011.   if(eregi('next',$listitem)) $plist .= $nextpage;
  1012.   if(eregi('end',$listitem)) $plist .= $endpage;
  1013.   if(eregi('option',$listitem)) $plist .= $optionlist;
  1014.   if(eregi('info',$listitem)) $plist .= $maininfo;
  1015.   
  1016.   if($cfg_rewrite == 'Y')
  1017.   {
  1018.    $plist = str_replace('.php?tid=', '-', $plist);
  1019.    $plist = str_replace('&TotalResult=', '-', $plist);
  1020.    $plist = preg_replace("/&PageNo=(\d+)/i",'-\\1.html',$plist);
  1021.   }
  1022.   return $plist;
  1023. }
  1024. //获得当前的页面文件的url
  1025. function GetCurUrl()
  1026. {
  1027.   if(!empty($_SERVER['REQUEST_URI']))
  1028.   {
  1029.    $nowurl = $_SERVER['REQUEST_URI'];
  1030.    $nowurls = explode('?', $nowurl);
  1031.    $nowurl = $nowurls[0];
  1032.   }
  1033.   else
  1034.   {
  1035.    $nowurl = $_SERVER['PHP_SELF'];
  1036.   }
  1037.   return $nowurl;
  1038. }
  1039. }//End Class
  1040. ?>
复制代码

发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;

如何回报帮助你解决问题的坛友,好办法就是点击帖子下方的评分按钮给对方加【金币】不会扣除自己的积分,做一个热心并受欢迎的人!

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则 需要先绑定手机号

关闭

站长推荐上一条 /1 下一条

QQ|侵权投诉|广告报价|手机版|小黑屋|西部数码代理|飘仙建站论坛 ( 豫ICP备2022021143号-1 )

GMT+8, 2024-3-29 20:11 , Processed in 0.050694 second(s), 8 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表