热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

如何进行dedecms

这篇文章给大家介绍如何进行dedecms列表页支持noflag属性的分析,内容非常详细,感兴趣的小伙伴们可以参考借鉴,希望对大家能有所帮助。搜索noflag即可解决问题!

这篇文章给大家介绍如何进行dedecms 列表页支持noflag属性的分析,内容非常详细,感兴趣的小伙伴们可以参考借鉴,希望对大家能有所帮助。

搜索 noflag 即可解决问题!

/**

 * 文档列表类

 *

 * @version        $Id: arc.listview.class.php 2 15:15 2010年7月7日Z tianya $

 * @package        DedeCMS.Libraries

 * @copyright      Copyright (c) 2007 - 2010, DesDev, Inc.

 * @license        http://help.dedecms.com/usersguide/license.html

 * @link           http://www.dedecms.com

 */

require_once(DEDEINC.'/arc.partview.class.php');

require_once(DEDEINC.'/ftp.class.php');

helper('cache');

@set_time_limit(0);

/**

 * 自由列表类

 *

 * @package          ListView

 * @subpackage       DedeCMS.Libraries

 * @link             http://www.dedecms.com

 */

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 $upPageType;

    var $addSql;

    var $IsError;

    var $CrossID;

    var $IsReplace;

    var $ftp;

    var $remoteDir;

    var $noflag;

    /**

     *  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->noflag = '';

        $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[&#39;title&#39;] = preg_replace("/[<>]/", " / ", $this->TypeLink->GetPositionLink(false));

            //设置一些全局参数的值

            foreach($GLOBALS[&#39;PubFields&#39;] as $k=>$v) $this->Fields[$k] = $v;

            $this->Fields[&#39;rsslink&#39;] = $GLOBALS[&#39;cfg_cmsurl&#39;]."/data/rss/".$this->TypeID.".xml";

            //设置环境变量

            SetSysEnv($this->TypeID,$this->Fields[&#39;typename&#39;],0,&#39;&#39;,&#39;list&#39;);

            $this->Fields[&#39;typeid&#39;] = $this->TypeID;

            //获得交叉栏目ID

            if($this->TypeLink->TypeInfos[&#39;cross&#39;]>0 && $this->TypeLink->TypeInfos[&#39;ispart&#39;]==0)

            {

                $selquery = &#39;&#39;;

                if($this->TypeLink->TypeInfos[&#39;cross&#39;]==1)

                {

                    $selquery = "SELECT id,topid FROM `#@__arctype` WHERE typename LIKE &#39;{$this->Fields[&#39;typename&#39;]}&#39; AND id<>&#39;{$this->TypeID}&#39; AND topid<>&#39;{$this->TypeID}&#39;  ";

                }

                else

                {

                    $this->Fields[&#39;crossid&#39;] = preg_replace(&#39;/[^0-9,]/&#39;, &#39;&#39;, trim($this->Fields[&#39;crossid&#39;]));

                    if($this->Fields[&#39;crossid&#39;]!=&#39;&#39;)

                    {

                        $selquery = "SELECT id,topid FROM `#@__arctype` WHERE id in({$this->Fields[&#39;crossid&#39;]}) AND id<>{$this->TypeID} AND topid<>{$this->TypeID}  ";

                    }

                }

                if($selquery!=&#39;&#39;)

                {

                    $this->dsql->SetQuery($selquery);

                    $this->dsql->Execute();

                    while($arr = $this->dsql->GetArray())

                    {

                        $this->CrossID .= ($this->CrossID==&#39;&#39; ? $arr[&#39;id&#39;] : &#39;,&#39;.$arr[&#39;id&#39;]);

                    }

                }

            }

        }//!error

    }

    //php4构造函数

    function ListView($typeid,$uppage=0){

        $this->__construct($typeid,$uppage);

    }

    //关闭相关资源

    function Close()

    {

    }

    /**

     *  统计列表里的记录

     *

     * @access    public

     * @param     string

     * @return    string

     */

    function CountRecord()

    {

        global $cfg_list_son,$cfg_need_typeid2,$cfg_cross_sectypeid;

        if(empty($cfg_need_typeid2)) $cfg_need_typeid2 = &#39;N&#39;;

        //统计数据库记录

        $this->TotalResult = -1;

        if(isset($GLOBALS[&#39;TotalResult&#39;])) $this->TotalResult = $GLOBALS[&#39;TotalResult&#39;];

        if(isset($GLOBALS[&#39;PageNo&#39;])) $this->PageNo = $GLOBALS[&#39;PageNo&#39;];

        else $this->PageNo = 1;

        $this->addSql  = " arc.arcrank > -1 ";

        $typeid2like = " &#39;%,{$this->TypeID},%&#39; ";

        if($cfg_list_son==&#39;N&#39;)

        {

            if($cfg_need_typeid2==&#39;N&#39;)

            {

                if($this->CrossID==&#39;&#39;) $this->addSql .= " AND (arc.typeid=&#39;".$this->TypeID."&#39;) ";

                else $this->addSql .= " AND (arc.typeid in({$this->CrossID},{$this->TypeID})) ";

            }

            else

            {

                if($this->CrossID==&#39;&#39;) 

{

$this->addSql .= " AND ( (arc.typeid=&#39;".$this->TypeID."&#39;) OR CONCAT(&#39;,&#39;, arc.typeid2, &#39;,&#39;) LIKE $typeid2like) ";

} else {

if($cfg_cross_sectypeid == &#39;Y&#39;)

{

$typeid2Clike = " &#39;%,{$this->CrossID},%&#39; ";

$this->addSql .= " AND ( arc.typeid IN({$this->CrossID},{$this->TypeID}) OR CONCAT(&#39;,&#39;, arc.typeid2, &#39;,&#39;) LIKE $typeid2like OR CONCAT(&#39;,&#39;, arc.typeid2, &#39;,&#39;) LIKE $typeid2Clike)";

} else {

$this->addSql .= " AND ( arc.typeid IN({$this->CrossID},{$this->TypeID}) OR CONCAT(&#39;,&#39;, arc.typeid2, &#39;,&#39;) LIKE $typeid2like)";

}

}

            }

        }

        else

        {

            $sOnids= GetSonIds($this->TypeID,$this->Fields[&#39;channeltype&#39;]);

            if(!preg_match("/,/", $sonids)) {

                $sOnidsCon= " arc.typeid = &#39;$sonids&#39; ";

            }

            else {

                $sOnidsCon= " arc.typeid IN($sonids) ";

            }

            if($cfg_need_typeid2==&#39;N&#39;)

            {

                if($this->CrossID==&#39;&#39;) $this->addSql .= " AND ( $sonidsCon ) ";

                else $this->addSql .= " AND ( arc.typeid IN ({$sonids},{$this->CrossID}) ) ";

            }

            else

            {

                if($this->CrossID==&#39;&#39;) 

{

$this->addSql .= " AND ( $sonidsCon OR CONCAT(&#39;,&#39;, arc.typeid2, &#39;,&#39;) like $typeid2like  ) ";

} else {

if($cfg_cross_sectypeid == &#39;Y&#39;)

{

$typeid2Clike = " &#39;%,{$this->CrossID},%&#39; ";

$this->addSql .= " AND ( arc.typeid IN ({$sonids},{$this->CrossID}) OR CONCAT(&#39;,&#39;, arc.typeid2, &#39;,&#39;) LIKE $typeid2like OR CONCAT(&#39;,&#39;, arc.typeid2, &#39;,&#39;) LIKE $typeid2Clike) ";

} else {

$this->addSql .= " AND ( arc.typeid IN ({$sonids},{$this->CrossID}) OR CONCAT(&#39;,&#39;, arc.typeid2, &#39;,&#39;) LIKE $typeid2like) ";

}

}

            }

        }

        if($this->TotalResult==-1)

        {

            $cquery = "SELECT COUNT(*) AS dd FROM `#@__arctiny` arc WHERE ".$this->addSql;

            $row = $this->dsql->GetOne($cquery);

            if(is_array($row))

            {

                $this->TotalResult = $row[&#39;dd&#39;];

            }

            else

            {

                $this->TotalResult = 0;

            }

        }

        //初始化列表模板,并统计页面总数

        $tempfile = $GLOBALS[&#39;cfg_basedir&#39;].$GLOBALS[&#39;cfg_templets_dir&#39;]."/".$this->TypeLink->TypeInfos[&#39;templist&#39;];

        $tempfile = str_replace("{tid}", $this->TypeID, $tempfile);

        $tempfile = str_replace("{cid}", $this->ChannelUnit->ChannelInfos[&#39;nid&#39;], $tempfile);

        if ( defined(&#39;DEDEMOB&#39;) )

        {

            $tempfile =str_replace(&#39;.htm&#39;,&#39;_m.htm&#39;,$tempfile);

        }

        if(!file_exists($tempfile))

        {

            $tempfile = $GLOBALS[&#39;cfg_basedir&#39;].$GLOBALS[&#39;cfg_templets_dir&#39;]."/".$GLOBALS[&#39;cfg_df_style&#39;]."/list_default.htm";

            if ( defined(&#39;DEDEMOB&#39;) )

            {

                $tempfile =str_replace(&#39;.htm&#39;,&#39;_m.htm&#39;,$tempfile);

            }

        }

        if(!file_exists($tempfile)||!is_file($tempfile))

        {

            echo "模板文件不存在,无法解析文档!";

            exit();

        }

        $this->dtp->LoadTemplate($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

     *

     * @access    public

     * @param     string  $startpage  开始页面

     * @param     string  $makepagesize  创建文件数目

     * @param     string  $isremote  是否为远程

     * @return    string

     */

    function MakeHtml($startpage=1, $makepagesize=0, $isremote=0)

    {

        global $cfg_remote_site;

        if(empty($startpage))

        {

            $startpage = 1;

        }

        //创建封面模板文件

        if($this->TypeLink->TypeInfos[&#39;isdefault&#39;]==-1)

        {

            echo &#39;这个类目是动态类目!&#39;;

            return &#39;../plus/list.php?tid=&#39;.$this->TypeLink->TypeInfos[&#39;id&#39;];

        }

        //单独页面

        else if($this->TypeLink->TypeInfos[&#39;ispart&#39;]>0)

        {

            $reurl = $this->MakePartTemplets();

            return $reurl;

        }

        $this->CountRecord();

        //初步给固定值的标记赋值

        $this->ParseTempletsFirst();

        $totalpage = ceil($this->TotalResult/$this->PageSize);

        if($totalpage==0)

        {

            $totalpage = 1;

        }

        CreateDir(MfTypedir($this->Fields[&#39;typedir&#39;]));

        $murl = &#39;&#39;;

        if($makepagesize > 0)

        {

            $endpage = $startpage+$makepagesize;

        }

        else

        {

            $endpage = ($totalpage+1);

        }

        if( $endpage >= $totalpage+1 )

        {

            $endpage = $totalpage+1;

        }

        if($endpage==1)

        {

            $endpage = 2;

        }

        for($this->PageNo=$startpage; $this->PageNo <$endpage; $this->PageNo++)

        {

/*顾涛*/

if($this->PageNo>1){

 $tempfile = $GLOBALS[&#39;cfg_basedir&#39;].$GLOBALS[&#39;cfg_templets_dir&#39;]."/".$GLOBALS[&#39;cfg_df_style&#39;]."/list_article2.htm";

 $this->dtp->LoadTemplate($tempfile);

 $this->ParseTempletsFirst();

}

            $this->ParseDMFields($this->PageNo,1);

            $makeFile = $this->GetMakeFileRule($this->Fields[&#39;id&#39;],&#39;list&#39;,$this->Fields[&#39;typedir&#39;],&#39;&#39;,$this->Fields[&#39;namerule2&#39;]);

            $makeFile = str_replace("{page}", $this->PageNo, $makeFile);

            $murl = $makeFile;

            if(!preg_match("/^///", $makeFile))

            {

                $makeFile = "/".$makeFile;

            }

            $makeFile = $this->GetTruePath().$makeFile;

            $makeFile = preg_replace("///{1,}/", "/", $makeFile);

            $murl = $this->GetTrueUrl($murl);

            $this->dtp->SaveTo($makeFile);

            //如果启用远程发布则需要进行判断

            if($cfg_remote_site==&#39;Y&#39;&& $isremote == 1)

            {

                //分析远程文件路径

                $remotefile = str_replace(DEDEROOT, &#39;&#39;,$makeFile);

                $localfile = &#39;..&#39;.$remotefile;

                $remotedir = preg_replace(&#39;/[^//]*/.html/&#39;, &#39;&#39;,$remotefile);

                //不相等则说明已经切换目录则可以创建镜像

                $this->ftp->rmkdir($remotedir);

                $this->ftp->upload($localfile, $remotefile, &#39;acii&#39;);

            }

        }

        if($startpage==1)

        {

            //如果列表启用封面文件,复制这个文件第一页

            if($this->TypeLink->TypeInfos[&#39;isdefault&#39;]==1

            && $this->TypeLink->TypeInfos[&#39;ispart&#39;]==0)

            {

                $Onlyrule= $this->GetMakeFileRule($this->Fields[&#39;id&#39;],"list",$this->Fields[&#39;typedir&#39;],&#39;&#39;,$this->Fields[&#39;namerule2&#39;]);

                $Onlyrule= str_replace("{page}","1",$onlyrule);

                $list_1 = $this->GetTruePath().$onlyrule;

                $murl = MfTypedir($this->Fields[&#39;typedir&#39;]).&#39;/&#39;.$this->Fields[&#39;defaultname&#39;];

                //如果启用远程发布则需要进行判断

                if($cfg_remote_site==&#39;Y&#39;&& $isremote == 1)

                {

                    //分析远程文件路径

                    $remotefile = $murl;

                    $localfile = &#39;..&#39;.$remotefile;

                    $remotedir = preg_replace(&#39;/[^//]*/.html/&#39;, &#39;&#39;,$remotefile);

                    //不相等则说明已经切换目录则可以创建镜像

                    $this->ftp->rmkdir($remotedir);

                    $this->ftp->upload($localfile, $remotefile, &#39;acii&#39;);

                }

                $indexname = $this->GetTruePath().$murl;

                copy($list_1,$indexname);

            }

        }

        return $murl;

    }

    /**

     *  显示列表

     *

     * @access    public

     * @return    void

     */

    function Display()

    {

        if($this->TypeLink->TypeInfos[&#39;ispart&#39;]>0)

        {

            $this->DisplayPartTemplets();

            return ;

        }

        $this->CountRecord();

        if((empty($this->PageNo) || $this->PageNo==1)

        && $this->TypeLink->TypeInfos[&#39;ispart&#39;]==1)

        {

            $tmpdir = $GLOBALS[&#39;cfg_basedir&#39;].$GLOBALS[&#39;cfg_templets_dir&#39;];

            $tempfile = str_replace("{tid}",$this->TypeID,$this->Fields[&#39;tempindex&#39;]);

            $tempfile = str_replace("{cid}",$this->ChannelUnit->ChannelInfos[&#39;nid&#39;],$tempfile);

            $tempfile = $tmpdir."/".$tempfile;

            if ( defined(&#39;DEDEMOB&#39;) )

            {

                $tempfile =str_replace(&#39;.htm&#39;,&#39;_m.htm&#39;,$tempfile);

            }

            if(!file_exists($tempfile))

            {

                $tempfile = $tmpdir."/".$GLOBALS[&#39;cfg_df_style&#39;]."/index_default.htm";

                if ( defined(&#39;DEDEMOB&#39;) )

                {

                    $tempfile =str_replace(&#39;.htm&#39;,&#39;_m.htm&#39;,$tempfile);

                }

            }

            $this->dtp->LoadTemplate($tempfile);

        }

/*顾涛*/

if($this->PageNo>1){

$tempfile = $tmpdir."/".$GLOBALS[&#39;cfg_df_style&#39;]."/list_article2.htm";

$this->dtp->LoadTemplate($tempfile);

}

        $this->ParseTempletsFirst();

        $this->ParseDMFields($this->PageNo,0);

        $this->dtp->Display();

    }

    /**

     *  创建单独模板页面

     *

     * @access    public

     * @return    string

     */

    function MakePartTemplets()

    {

        $this->PartView = new PartView($this->TypeID,false);

        $this->PartView->SetTypeLink($this->TypeLink);

        $nmfa = 0;

        $tmpdir = $GLOBALS[&#39;cfg_basedir&#39;].$GLOBALS[&#39;cfg_templets_dir&#39;];

        if($this->Fields[&#39;ispart&#39;]==1)

        {

            $tempfile = str_replace("{tid}",$this->TypeID,$this->Fields[&#39;tempindex&#39;]);

            $tempfile = str_replace("{cid}",$this->ChannelUnit->ChannelInfos[&#39;nid&#39;],$tempfile);

            $tempfile = $tmpdir."/".$tempfile;

            if ( defined(&#39;DEDEMOB&#39;) )

            {

                $tempfile =str_replace(&#39;.htm&#39;,&#39;_m.htm&#39;,$tempfile);

            }

            if(!file_exists($tempfile))

            {

                $tempfile = $tmpdir."/".$GLOBALS[&#39;cfg_df_style&#39;]."/index_default.htm";

                if ( defined(&#39;DEDEMOB&#39;) )

                {

                    $tempfile =str_replace(&#39;.htm&#39;,&#39;_m.htm&#39;,$tempfile);

                }

            }

            $this->PartView->SetTemplet($tempfile);

        }

        else if($this->Fields[&#39;ispart&#39;]==2)

        {

            //跳转网址

            return $this->Fields[&#39;typedir&#39;];

        }

        CreateDir(MfTypedir($this->Fields[&#39;typedir&#39;]));

        $makeUrl = $this->GetMakeFileRule($this->Fields[&#39;id&#39;],"index",MfTypedir($this->Fields[&#39;typedir&#39;]),$this->Fields[&#39;defaultname&#39;],$this->Fields[&#39;namerule2&#39;]);

        $makeUrl = preg_replace("///{1,}/", "/", $makeUrl);

        $makeFile = $this->GetTruePath().$makeUrl;

        if($nmfa==0)

        {

            $this->PartView->SaveToHtml($makeFile);

            //如果启用远程发布则需要进行判断

            if($GLOBALS[&#39;cfg_remote_site&#39;]==&#39;Y&#39;&& $isremote == 1)

            {

                //分析远程文件路径

                $remotefile = str_replace(DEDEROOT, &#39;&#39;,$makeFile);

                $localfile = &#39;..&#39;.$remotefile;

                $remotedir = preg_replace(&#39;/[^//]*/.html/&#39;, &#39;&#39;,$remotefile);

                //不相等则说明已经切换目录则可以创建镜像

                $this->ftp->rmkdir($remotedir);

                $this->ftp->upload($localfile, $remotefile, &#39;acii&#39;);

            }

        }

        else

        {

            if(!file_exists($makeFile))

            {

                $this->PartView->SaveToHtml($makeFile);

                //如果启用远程发布则需要进行判断

                if($cfg_remote_site==&#39;Y&#39;&& $isremote == 1)

                {

                    //分析远程文件路径

                    $remotefile = str_replace(DEDEROOT, &#39;&#39;,$makeFile);

                    $localfile = &#39;..&#39;.$remotefile;

                    $remotedir = preg_replace(&#39;/[^//]*/.html/&#39;, &#39;&#39;,$remotefile);

                    //不相等则说明已经切换目录则可以创建镜像

                    $this->ftp->rmkdir($remotedir);

                    $this->ftp->upload($localfile, $remotefile, &#39;acii&#39;);

              }

            }

        }

        return $this->GetTrueUrl($makeUrl);

    }

    /**

     *  显示单独模板页面

     *

     * @access    public

     * @param     string

     * @return    string

     */

    function DisplayPartTemplets()

    {

        $this->PartView = new PartView($this->TypeID,false);

        $this->PartView->SetTypeLink($this->TypeLink);

        $nmfa = 0;

        $tmpdir = $GLOBALS[&#39;cfg_basedir&#39;].$GLOBALS[&#39;cfg_templets_dir&#39;];

        if($this->Fields[&#39;ispart&#39;]==1)

        {

            //封面模板

            $tempfile = str_replace("{tid}",$this->TypeID,$this->Fields[&#39;tempindex&#39;]);

            $tempfile = str_replace("{cid}",$this->ChannelUnit->ChannelInfos[&#39;nid&#39;],$tempfile);

            $tempfile = $tmpdir."/".$tempfile;

            if ( defined(&#39;DEDEMOB&#39;) )

            {

                $tempfile =str_replace(&#39;.htm&#39;,&#39;_m.htm&#39;,$tempfile);

            }

            if(!file_exists($tempfile))

            {

                $tempfile = $tmpdir."/".$GLOBALS[&#39;cfg_df_style&#39;]."/index_default.htm";

                if ( defined(&#39;DEDEMOB&#39;) )

                {

                    $tempfile =str_replace(&#39;.htm&#39;,&#39;_m.htm&#39;,$tempfile);

                }

            }

            $this->PartView->SetTemplet($tempfile);

        }

        else if($this->Fields[&#39;ispart&#39;]==2)

        {

            //跳转网址

            $gotourl = $this->Fields[&#39;typedir&#39;];

            header("Location:$gotourl");

            exit();

        }

        CreateDir(MfTypedir($this->Fields[&#39;typedir&#39;]));

        $makeUrl = $this->GetMakeFileRule($this->Fields[&#39;id&#39;],"index",MfTypedir($this->Fields[&#39;typedir&#39;]),$this->Fields[&#39;defaultname&#39;],$this->Fields[&#39;namerule2&#39;]);

        $makeFile = $this->GetTruePath().$makeUrl;

        if($nmfa==0)

        {

            $this->PartView->Display();

        }

        else

        {

            if(!file_exists($makeFile))

            {

                $this->PartView->Display();

            }

            else

            {

                include($makeFile);

            }

        }

    }

    /**

     *  获得站点的真实根路径

     *

     * @access    public

     * @return    string

     */

    function GetTruePath()

    {

        $truepath = $GLOBALS["cfg_basedir"];

        return $truepath;

    }

    /**

     *  获得真实连接路径

     *

     * @access    public

     * @param     string  $nurl  地址

     * @return    string

     */

    function GetTrueUrl($nurl)

    {

        if($this->Fields[&#39;moresite&#39;]==1)

        {

            if($this->Fields[&#39;sitepath&#39;]!=&#39;&#39;)

            {

                $nurl = preg_replace("/^".$this->Fields[&#39;sitepath&#39;]."/", &#39;&#39;, $nurl);

            }

            $nurl = $this->Fields[&#39;siteurl&#39;].$nurl;

        }

        return $nurl;

    }

    /**

     *  解析模板,对固定的标记进行初始给值

     *

     * @access    public

     * @return    string

     */

    function ParseTempletsFirst()

    {

        if(isset($this->TypeLink->TypeInfos[&#39;reid&#39;]))

        {

            $GLOBALS[&#39;envs&#39;][&#39;reid&#39;] = $this->TypeLink->TypeInfos[&#39;reid&#39;];

        }

        $GLOBALS[&#39;envs&#39;][&#39;typeid&#39;] = $this->TypeID;

        $GLOBALS[&#39;envs&#39;][&#39;topid&#39;] = GetTopid($this->Fields[&#39;typeid&#39;]);

        $GLOBALS[&#39;envs&#39;][&#39;cross&#39;] = 1;

        MakeOneTag($this->dtp,$this);

    }

    /**

     *  解析模板,对内容里的变动进行赋值

     *

     * @access    public

     * @param     int  $PageNo  页数

     * @param     int  $ismake  是否编译

     * @return    string

     */

    function ParseDMFields($PageNo,$ismake=1)

    {

        //替换第二页后的内容

        if(($PageNo>1 || strlen($this->Fields[&#39;content&#39;])<10 ) && !$this->IsReplace)

        {

            $this->dtp->SourceString = str_replace(&#39;[cmsreplace]&#39;,&#39;display:none&#39;,$this->dtp->SourceString);

            $this->IsReplace = true;

        }

        foreach($this->dtp->CTags as $tagid=>$ctag)

        {

            if($ctag->GetName()=="list")

            {

                $limitstart = ($this->PageNo-1) * $this->PageSize;

                $row = $this->PageSize;

                if(trim($ctag->GetInnerText())=="")

                {

                    $InnerText = GetSysTemplets("list_fulllist.htm");

                }

                else

                {

                    $InnerText = trim($ctag->GetInnerText());

                }

                $this->dtp->Assign($tagid,

                $this->GetArcList(

                $limitstart,

                $row,

                $ctag->GetAtt("col"),

                $ctag->GetAtt("titlelen"),

                $ctag->GetAtt("infolen"),

                $ctag->GetAtt("imgwidth"),

                $ctag->GetAtt("imgheight"),

                $ctag->GetAtt("listtype"),

                $ctag->GetAtt("orderby"),

                $InnerText,

                $ctag->GetAtt("tablewidth"),

                $ismake,

                $ctag->GetAtt("orderway"),

$ctag->GetAtt("noflag")

                )

                );

            }

            else if($ctag->GetName()=="pagelist")

            {

                $list_len = trim($ctag->GetAtt("listsize"));

                $ctag->GetAtt("listitem")=="" ? $listitem="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($PageNo!=1 && $ctag->GetName()==&#39;field&#39; && $ctag->GetAtt(&#39;display&#39;)!=&#39;&#39;)

            {

                $this->dtp->Assign($tagid,&#39;&#39;);

            }

        }

    }

    /**

     *  获得要创建的文件名称规则

     *

     * @access    public

     * @param     int  $typeid  栏目ID

     * @param     string  $wname

     * @param     string  $typedir  栏目目录

     * @param     string  $defaultname  默认名称

     * @param     string  $namerule2  栏目规则

     * @return    string

     */

    function GetMakeFileRule($typeid,$wname,$typedir,$defaultname,$namerule2)

    {

        $typedir = MfTypedir($typedir);

        if($wname==&#39;index&#39;)

        {

            return $typedir.&#39;/&#39;.$defaultname;

        }

        else

        {

            $namerule2 = str_replace(&#39;{tid}&#39;,$typeid,$namerule2);

            $namerule2 = str_replace(&#39;{typedir}&#39;,$typedir,$namerule2);

            return $namerule2;

        }

    }

    /**

     *  获得一个单列的文档列表

     *

     * @access    public

     * @param     int  $limitstart  限制开始  

     * @param     int  $row  行数 

     * @param     int  $col  列数

     * @param     int  $titlelen  标题长度

     * @param     int  $infolen  描述长度

     * @param     int  $imgwidth  图片宽度

     * @param     int  $imgheight  图片高度

     * @param     string  $listtype  列表类型

     * @param     string  $orderby  排列顺序

     * @param     string  $innertext  底层模板

     * @param     string  $tablewidth  表格宽度

     * @param     string  $ismake  是否编译

     * @param     string  $orderWay  排序方式

     * @return    string

     */

    function GetArcList($limitstart=0,$row=10,$col=1,$titlelen=30,$infolen=250,

    $imgall",$orderby="default",$innertext="",$table,$ismake=1,$orderWay=&#39;desc&#39;,$noflag="")

    {

        global $cfg_list_son,$cfg_digg_update;

        if($noflag!="")

{

$noflags = explode(&#39;,&#39;, $noflag);

$noflagsql = &#39;&#39;;

for($i=0;$i

{

$noflagsql .= "And arc.flag not like &#39;%{$noflags[$i]}%&#39; ";

}

}

else

{

$noflagsql .= "";

}

        $typeid=$this->TypeID;

        if($row==&#39;&#39;) $row = 10;

        if($limitstart==&#39;&#39;) $limitstart = 0;

        if($titlelen==&#39;&#39;) $titlelen = 100;

        if($infolen==&#39;&#39;) $infolen = 250;

        if($imgwidth==&#39;&#39;) $imgwidth = 120;

        if($imgheight==&#39;&#39;) $imgheight = 120;

        if($listtype==&#39;&#39;) $listtype = &#39;all&#39;;

        if($orderWay==&#39;&#39;) $orderWay = &#39;desc&#39;;

        if($orderby==&#39;&#39;) {

            $orderby=&#39;default&#39;;

        }

        else {

            $orderby=strtolower($orderby);

        }

        $tablewidth = str_replace(&#39;%&#39;,&#39;&#39;,$tablewidth);

        if($tablewidth==&#39;&#39;) $tablewidth=100;

        if($col==&#39;&#39;) $col=1;

        $colWidth = ceil(100/$col);

        $tablewidth = $tablewidth.&#39;%&#39;;

        $colWidth = $colWidth.&#39;%&#39;;

        $innertext = trim($innertext);

        if($innertext==&#39;&#39;) {

            $innertext = GetSysTemplets(&#39;list_fulllist.htm&#39;);

        }

        //排序方式

        $ordersql = &#39;&#39;;

        if($orderby=="senddate" || $orderby=="id") {

            $ordersql=" ORDER BY arc.id $orderWay";

        }

        else if($orderby=="hot" || $orderby=="click") {

            $ordersql = " ORDER BY arc.click $orderWay";

        }

        else if($orderby=="lastpost") {

            $ordersql = "  ORDER BY arc.lastpost $orderWay";

        }

else if($orderby=="weight") { 

$ordersql = " order by arc.weight $orderWay"; 

}

        else {

            $ordersql=" ORDER BY arc.sortrank $orderWay";

        }

        //获得附加表的相关信息

        $addtable  = $this->ChannelUnit->ChannelInfos[&#39;addtable&#39;];

        if($addtable!="")

        {

            $addJoin = " LEFT JOIN `$addtable` ON arc.id = ".$addtable.&#39;.aid &#39;;

            $addField = &#39;&#39;;

            $fields = explode(&#39;,&#39;,$this->ChannelUnit->ChannelInfos[&#39;listfields&#39;]);

            foreach($fields as $k=>$v)

            {

                $nfields[$v] = $k;

            }

            if(is_array($this->ChannelUnit->ChannelFields) && !empty($this->ChannelUnit->ChannelFields))

            {

                foreach($this->ChannelUnit->ChannelFields as $k=>$arr)

                {

                    if(isset($nfields[$k]))

                    {

                        if(!empty($arr[&#39;rename&#39;])) {

                            $addField .= &#39;,&#39;.$addtable.&#39;.&#39;.$k.&#39; as &#39;.$arr[&#39;rename&#39;];

                        }

                        else {

                            $addField .= &#39;,&#39;.$addtable.&#39;.&#39;.$k;

                        }

                    }

                }

            }

        }

        else

        {

            $addField = &#39;&#39;;

            $addJoin = &#39;&#39;;

        }

        //如果不用默认的sortrank或id排序,使用联合查询(数据量大时非常缓慢)

        if(preg_match(&#39;/hot|click|weight|lastpost/&#39;, $orderby))

        {

            $query = "SELECT arc.*,tp.typedir,tp.typename,tp.isdefault,tp.defaultname,

           tp.namerule,tp.namerule2,tp.ispart,tp.moresite,tp.siteurl,tp.sitepath

           $addField

           FROM `#@__archives` arc

           LEFT JOIN `#@__arctype` tp ON arc.typeid=tp.id

           $addJoin

           WHERE {$this->addSql} $noflagsql $ordersql LIMIT $limitstart,$row";

        }

        //普通情况先从arctiny表查出ID,然后按ID查询(速度非常快)

        else

        {

            $t1 = ExecTime();

            $ids = array();

            $query = "SELECT id FROM `#@__arctiny` arc WHERE {$this->addSql} $ordersql LIMIT $limitstart,$row ";

$this->dsql->SetQuery($query);

            $this->dsql->Execute();

            while($arr=$this->dsql->GetArray())

            {

                $ids[] = $arr[&#39;id&#39;];

            }

            $idstr = join(&#39;,&#39;,$ids);

            if($idstr==&#39;&#39;)

            {

                return &#39;&#39;;

            }

            else

            {

                $query = "SELECT arc.*,tp.typedir,tp.typename,tp.corank,tp.isdefault,tp.defaultname,

                       tp.namerule,tp.namerule2,tp.ispart,tp.moresite,tp.siteurl,tp.sitepath

                       $addField

                       FROM `#@__archives` arc LEFT JOIN `#@__arctype` tp ON arc.typeid=tp.id

                       $addJoin

                       WHERE arc.id in($idstr) $noflagsql $ordersql ";

            }

            $t2 = ExecTime();

            //echo $t2-$t1;

        }

        $this->dsql->SetQuery($query);

        $this->dsql->Execute(&#39;al&#39;);

        $t2 = ExecTime();

        //echo $t2-$t1;

        $artlist = &#39;&#39;;

        $this->dtp2->LoadSource($innertext);

        $GLOBALS[&#39;autoindex&#39;] = 0;

        for($i=0;$i<$row;$i++)

        {

            if($col>1)

            {

                $artlist .= "/r/n";

            }

        }//Loop Line

        $t3 = ExecTime();

        //echo ($t3-$t2);

        $this->dsql->FreeResult(&#39;al&#39;);

        return $artlist;

    }

    /**

     *  获取静态的分页列表

     *

     * @access    public

     * @param     string  $list_len  列表宽度

     * @param     string  $list_len  列表样式

     * @return    string

     */

    function GetPageListST($list_len,$listitem="index,end,pre,next,pageno")

    {

        $prepage = $nextpage = &#39;&#39;;

        $prepagenum = $this->PageNo-1;

        $nextpagenum = $this->PageNo+1;

        if($list_len==&#39;&#39; || preg_match("/[^0-9]/", $list_len))

        {

            $list_len=3;

        }

        $totalpage = ceil($this->TotalResult/$this->PageSize);

        if($totalpage<=1 && $this->TotalResult>0)

        {

            return "1".$this->TotalResult."条记录/r/n";

        }

        if($this->TotalResult == 0)

        {

            return "0".$this->TotalResult."条记录/r/n";

        }

        $purl = $this->GetCurUrl();

        $maininfo = "{$totalpage}".$this->TotalResult."/r/n";

        $tnamerule = $this->GetMakeFileRule($this->Fields[&#39;id&#39;],"list",$this->Fields[&#39;typedir&#39;],$this->Fields[&#39;defaultname&#39;],$this->Fields[&#39;namerule2&#39;]);

        $tnamerule = preg_replace("/^(.*)///", &#39;&#39;, $tnamerule);

        //获得上一页和主页的链接

        if($this->PageNo != 1)

        {

            $prepage.="上一页/r/n";

            $indexpage="首页/r/n";

        }

        else

        {

            $indexpage="首页/r/n";

        }

        //下一页,未页的链接

        if($this->PageNo!=$totalpage && $totalpage>1)

        {

            $nextpage.="下一页/r/n";

            $endpage="末页/r/n";

        }

        else

        {

            $endpage="末页/r/n";

        }

        //option链接

        $optiOnlist= &#39;&#39;;

        $optiOnlen= strlen($totalpage);

        $optiOnlen= $optionlen*12 + 18;

        if($optionlen <36) $optiOnlen= 36;

        if($optionlen > 100) $optiOnlen= 100;

        $optiOnlist= "/r/n";

        //获得数字链接

        $listdd="";

        $total_list = $list_len * 2 + 1;

        if($this->PageNo >= $total_list)

        {

            $j = $this->PageNo-$list_len;

            $total_list = $this->PageNo+$list_len;

            if($total_list>$totalpage)

            {

                $total_list=$totalpage;

            }

        }

        else

        {

            $j=1;

            if($total_list>$totalpage)

            {

                $total_list=$totalpage;

            }

        }

        for($j;$j<=$total_list;$j++)

        {

            if($j==$this->PageNo)

            {

                $listdd.= "$j/r/n";

            }

            else

            {

                $listdd.="".$j."/r/n";

            }

        }

        $plist = &#39;&#39;;

        if(preg_match(&#39;/index/i&#39;, $listitem)) $plist .= $indexpage;

        if(preg_match(&#39;/pre/i&#39;, $listitem)) $plist .= $prepage;

        if(preg_match(&#39;/pageno/i&#39;, $listitem)) $plist .= $listdd;

        if(preg_match(&#39;/next/i&#39;, $listitem)) $plist .= $nextpage;

        if(preg_match(&#39;/end/i&#39;, $listitem)) $plist .= $endpage;

        if(preg_match(&#39;/option/i&#39;, $listitem)) $plist .= $optionlist;

        if(preg_match(&#39;/info/i&#39;, $listitem)) $plist .= $maininfo;

        return $plist;

    }

    /**

     *  获取动态的分页列表

     *

     * @access    public

     * @param     string  $list_len  列表宽度

     * @param     string  $list_len  列表样式

     * @return    string

     */

    function GetPageListDM($list_len,$listitem="index,end,pre,next,pageno")

    {

        global $cfg_rewrite;

        $prepage = $nextpage = &#39;&#39;;

        $prepagenum = $this->PageNo-1;

        $nextpagenum = $this->PageNo+1;

        if($list_len==&#39;&#39; || preg_match("/[^0-9]/", $list_len))

        {

            $list_len=3;

        }

        $totalpage = ceil($this->TotalResult/$this->PageSize);

        if($totalpage<=1 && $this->TotalResult>0)

        {

            return "共 1 页/".$this->TotalResult." 条记录/r/n";

        }

        if($this->TotalResult == 0)

        {

            return "共 0 页/".$this->TotalResult." 条记录/r/n";

        }

        $maininfo = "{$totalpage}".$this->TotalResult."/r/n";

        $purl = $this->GetCurUrl();

        // 如果开启为静态,则对规则进行替换

        if($cfg_rewrite == &#39;Y&#39;)

        {

            $nowurls = preg_replace("//-/", ".php?", $purl);

            $nowurls = explode("?", $nowurls);

            $purl = $nowurls[0];

        }

        $geturl = "tid=".$this->TypeID."&TotalResult=".$this->TotalResult."&";

        $purl .= &#39;?&#39;.$geturl;

        $optiOnlist= &#39;&#39;;

        //$hidenform = "TypeID."&#39;>/r/n";

        //$hidenform .= "TotalResult."&#39;>/r/n";

        //获得上一页和下一页的链接

        if($this->PageNo != 1)

        {

            $prepage.="上一页/r/n";

            $indexpage="首页/r/n";

        }

        else

        {

            $indexpage="首页/r/n";

        }

        if($this->PageNo!=$totalpage && $totalpage>1)

        {

            $nextpage.="下一页/r/n";

            $endpage="末页/r/n";

        }

        else

        {

            $endpage="末页/r/n";

        }

        //获得数字链接

        $listdd="";

        $total_list = $list_len * 2 + 1;

        if($this->PageNo >= $total_list)

        {

            $j = $this->PageNo-$list_len;

            $total_list = $this->PageNo+$list_len;

            if($total_list>$totalpage)

            {

                $total_list=$totalpage;

            }

        }

        else

        {

            $j=1;

            if($total_list>$totalpage)

            {

                $total_list=$totalpage;

            }

        }

        for($j;$j<=$total_list;$j++)

        {

            if($j==$this->PageNo)

            {

                $listdd.= "$j/r/n";

            }

            else

            {

                $listdd.="".$j."/r/n";

            }

        }

        $plist = &#39;&#39;;

        if(preg_match(&#39;/index/i&#39;, $listitem)) $plist .= $indexpage;

        if(preg_match(&#39;/pre/i&#39;, $listitem)) $plist .= $prepage;

        if(preg_match(&#39;/pageno/i&#39;, $listitem)) $plist .= $listdd;

        if(preg_match(&#39;/next/i&#39;, $listitem)) $plist .= $nextpage;

        if(preg_match(&#39;/end/i&#39;, $listitem)) $plist .= $endpage;

        if(preg_match(&#39;/option/i&#39;, $listitem)) $plist .= $optionlist;

        if(preg_match(&#39;/info/i&#39;, $listitem)) $plist .= $maininfo;

        if($cfg_rewrite == &#39;Y&#39;)

        {

            $plist = str_replace(&#39;.php?tid=&#39;, &#39;-&#39;, $plist);

            $plist = str_replace(&#39;&TotalResult=&#39;, &#39;-&#39;, $plist);

            $plist = preg_replace("/&PageNo=(/d+)/i",&#39;-//1.html&#39;,$plist);

        }

        return $plist;

    }

    /**

     *  获得当前的页面文件的url

     *

     * @access    public

     * @return    string

     */

    function GetCurUrl()

    {

        if(!empty($_SERVER[&#39;REQUEST_URI&#39;]))

        {

            $nowurl = $_SERVER[&#39;REQUEST_URI&#39;];

            $nowurls = explode(&#39;?&#39;, $nowurl);

            $nowurl = $nowurls[0];

        }

        else

        {

            $nowurl = $_SERVER[&#39;PHP_SELF&#39;];

        }

        return $nowurl;

    }

}//End Class

关于如何进行dedecms 列表页支持noflag属性的分析就分享到这里了,希望以上内容可以对大家有一定的帮助,可以学到更多知识。如果觉得文章不错,可以把它分享出去让更多的人看到。


推荐阅读
  • 本文详细介绍了SQL日志收缩的方法,包括截断日志和删除不需要的旧日志记录。通过备份日志和使用DBCC SHRINKFILE命令可以实现日志的收缩。同时,还介绍了截断日志的原理和注意事项,包括不能截断事务日志的活动部分和MinLSN的确定方法。通过本文的方法,可以有效减小逻辑日志的大小,提高数据库的性能。 ... [详细]
  • 本文分享了一个关于在C#中使用异步代码的问题,作者在控制台中运行时代码正常工作,但在Windows窗体中却无法正常工作。作者尝试搜索局域网上的主机,但在窗体中计数器没有减少。文章提供了相关的代码和解决思路。 ... [详细]
  • 一、Hadoop来历Hadoop的思想来源于Google在做搜索引擎的时候出现一个很大的问题就是这么多网页我如何才能以最快的速度来搜索到,由于这个问题Google发明 ... [详细]
  • Monkey《大话移动——Android与iOS应用测试指南》的预购信息发布啦!
    Monkey《大话移动——Android与iOS应用测试指南》的预购信息已经发布,可以在京东和当当网进行预购。感谢几位大牛给出的书评,并呼吁大家的支持。明天京东的链接也将发布。 ... [详细]
  • 本文介绍了lua语言中闭包的特性及其在模式匹配、日期处理、编译和模块化等方面的应用。lua中的闭包是严格遵循词法定界的第一类值,函数可以作为变量自由传递,也可以作为参数传递给其他函数。这些特性使得lua语言具有极大的灵活性,为程序开发带来了便利。 ... [详细]
  • 本文介绍了Python高级网络编程及TCP/IP协议簇的OSI七层模型。首先简单介绍了七层模型的各层及其封装解封装过程。然后讨论了程序开发中涉及到的网络通信内容,主要包括TCP协议、UDP协议和IPV4协议。最后还介绍了socket编程、聊天socket实现、远程执行命令、上传文件、socketserver及其源码分析等相关内容。 ... [详细]
  • GetWindowLong函数
    今天在看一个代码里头写了GetWindowLong(hwnd,0),我当时就有点费解,靠,上网搜索函数原型说明,死活找不到第 ... [详细]
  • 本文介绍了在Python3中如何使用选择文件对话框的格式打开和保存图片的方法。通过使用tkinter库中的filedialog模块的asksaveasfilename和askopenfilename函数,可以方便地选择要打开或保存的图片文件,并进行相关操作。具体的代码示例和操作步骤也被提供。 ... [详细]
  • 本文介绍了使用Java实现大数乘法的分治算法,包括输入数据的处理、普通大数乘法的结果和Karatsuba大数乘法的结果。通过改变long类型可以适应不同范围的大数乘法计算。 ... [详细]
  • PHP设置MySQL字符集的方法及使用mysqli_set_charset函数
    本文介绍了PHP设置MySQL字符集的方法,详细介绍了使用mysqli_set_charset函数来规定与数据库服务器进行数据传送时要使用的字符集。通过示例代码演示了如何设置默认客户端字符集。 ... [详细]
  • Java序列化对象传给PHP的方法及原理解析
    本文介绍了Java序列化对象传给PHP的方法及原理,包括Java对象传递的方式、序列化的方式、PHP中的序列化用法介绍、Java是否能反序列化PHP的数据、Java序列化的原理以及解决Java序列化中的问题。同时还解释了序列化的概念和作用,以及代码执行序列化所需要的权限。最后指出,序列化会将对象实例的所有字段都进行序列化,使得数据能够被表示为实例的序列化数据,但只有能够解释该格式的代码才能够确定数据的内容。 ... [详细]
  • Android中高级面试必知必会,积累总结
    本文介绍了Android中高级面试的必知必会内容,并总结了相关经验。文章指出,如今的Android市场对开发人员的要求更高,需要更专业的人才。同时,文章还给出了针对Android岗位的职责和要求,并提供了简历突出的建议。 ... [详细]
  • 本文介绍了如何使用php限制数据库插入的条数并显示每次插入数据库之间的数据数目,以及避免重复提交的方法。同时还介绍了如何限制某一个数据库用户的并发连接数,以及设置数据库的连接数和连接超时时间的方法。最后提供了一些关于浏览器在线用户数和数据库连接数量比例的参考值。 ... [详细]
  • 给定一个二维平面上的一些点,通过计算曼哈顿距离,求连接所有点的最小总费用。只有任意两点之间有且仅有一条简单路径时,才认为所有点都已连接。给出了几个示例并给出了对应的输出。 ... [详细]
  • 夏侯惇在曹魏集团的地位及其重要性
    本文介绍了夏侯惇在曹魏集团中的地位及其重要性。夏侯惇虽然没有特别显赫的战绩,但是他是曹操最信任的军事将领。通过对夏侯惇生平经历的回顾,可以看出他在曹魏集团的重要地位。从曹魏集团的二号人物到裨将、司马等职位的担任,夏侯惇一直是曹操最亲信的人之一。夏侯惇的历史地位在曹魏集团中不可忽视。 ... [详细]
author-avatar
小小贤
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有