杰奇自定义分页代码,教程及案例

在杰奇仿站的时候,分页区域的修改是不可避免的问题,但是基本上一开始完全就搞不懂修改分页的位置在哪里,而确实杰奇没有给出自定义的地方,相关的位置也是完全加密的。不过好不容易找到目录再解密之后,试了几下倒也是知道了修改的办法,难度不是很大就看能不能理解。

通常情况下,分页区域的代码是如下这样,感觉非常乱:

<div class="pages"><div class="pagelink" id="pagelink"><a href="http://127.0.0.110/modules/article/articlefilter.php?order=lastupdate&page=1" rel="external nofollow"  rel="external nofollow"  class="first">1</a><a href="http://127.0.0.110/modules/article/articlefilter.php?order=lastupdate&page=1" rel="external nofollow"  rel="external nofollow"  class="pgroup">&lt;&lt;</a><strong>1</strong><a href="http://127.0.0.110/modules/article/articlefilter.php?order=lastupdate&page=2" rel="external nofollow"  rel="external nofollow"  rel="external nofollow"  rel="external nofollow" >2</a><a href="http://127.0.0.110/modules/article/articlefilter.php?order=lastupdate&page=2" rel="external nofollow"  rel="external nofollow"  rel="external nofollow"  rel="external nofollow"  class="next">&gt;</a><a href="http://127.0.0.110/modules/article/articlefilter.php?order=lastupdate&page=2" rel="external nofollow"  rel="external nofollow"  rel="external nofollow"  rel="external nofollow"  class="ngroup">&gt;&gt;</a><a href="http://127.0.0.110/modules/article/articlefilter.php?order=lastupdate&page=2" rel="external nofollow"  rel="external nofollow"  rel="external nofollow"  rel="external nofollow"  class="last">2</a><kbd><input name="page" type="text" size="3" onkeydown="if(event.keyCode==13){window.location.href='http://127.0.0.110/modules/article/articlefilter.php?order=lastupdate&page='+this.parentNode.getElementsByTagName('input')[0].value; return false;}" title="输入页码,按回车快速跳转" /></kbd></div></div>

文件位置在/lib/html/page.php,这是加密的。
解密工具在这里:点击进入

解密之后,定义样式的关键代码如下:

public function pageurl($page)
{
    if (strpos($this->linkurl, "<{\$" . $this->pagevar) === false) {
        $url = $this->linkurl . $page;
    }
    else {
        $url = str_replace(array("<{\$" . $this->pagevar . "|subdirectory}>", "<{\$" . $this->pagevar . "}>"), array(jieqi_getsubdir($page), $page), $this->linkurl);
    }

    if ($this->useajax == 1) {
        $url = "javascript:Ajax.Update('" . urldecode($url) . "'," . $this->ajax_parm . ");";
    }

    return $url;
}

public function pagelink($page, $char, $class = "")
{
    $link_url = $this->pageurl($page);

    if (empty($class)) {
        return "<a href=\"" . $link_url . "\">" . $char . "</a>";
    }
    else {
        return "<a href=\"" . $link_url . "\" class=\"" . $class . "\">" . $char . "</a>";
    }
}

public function first_page($link = 1, $char = "")
{
    if ($char == "") {
        $char = "1";
    }

    if ($link == 1) {
        return $this->pagelink(1, $char, "first");
    }
    else {
        return 1;
    }
}

public function total_page($link = 1, $char = "")
{
    if ($char == "") {
        $char = $this->totalpages;
    }

    if ($link == 1) {
        return $this->pagelink($this->totalpages, $char, "last");
    }
    else {
        return $this->totalpages;
    }
}

public function pre_page($char = "")
{
    if ($char == "") {
        $char = "&lt;";
    }

    if (1 < $this->current) {
        return $this->pagelink($this->current - 1, $char, "prev");
    }
    else {
        return "";
    }
}

public function next_page($char = "")
{
    if ($char == "") {
        $char = "&gt;";
    }

    if ($this->current < $this->totalpages) {
        return $this->pagelink($this->current + 1, $char, "next");
    }
    else {
        return "";
    }
}

public function num_bar()
{
    $pagelinks = &$this->pagelinks;
    $mid = floor($pagelinks / 2);
    $last = $pagelinks - 1;
    $current = &$this->current;
    $totalpage = &$this->totalpages;
    $linkurl = &$this->linkurl;
    $minpage = (($current - $mid) < 1 ? 1 : $current - $mid);
    $maxpage = $minpage + $last;

    if ($totalpage < $maxpage) {
        $maxpage = &$totalpage;
        $minpage = $maxpage - $last;
        $minpage = ($minpage < 1 ? 1 : $minpage);
    }

    $linkbar = "";

    for ($i = $minpage; $i <= $maxpage; $i++) {
        $char = $i;

        if ($i == $current) {
            $linkchar = "<strong>" . $char . "</strong>";
        }
        else {
            $linkchar = $this->pagelink($i, $char);
        }

        $linkbar .= $linkchar;
    }

    return $linkbar;
}

public function pre_group($char = "")
{
    $current = &$this->current;
    $linkurl = &$this->linkurl;
    $pagelinks = &$this->pagelinks;
    $mid = floor($pagelinks / 2);
    $minpage = (($current - $mid) < 1 ? 1 : $current - $mid);
    $char = ($char == "" ? "&lt;&lt;" : $char);
    $pgpage = ($pagelinks < $minpage ? $minpage - $mid : 1);
    return $this->pagelink($pgpage, $char, "pgroup");
}

public function next_group($char = "")
{
    $current = &$this->current;
    $linkurl = &$this->linkurl;
    $totalpage = &$this->totalpages;
    $pagelinks = &$this->pagelinks;
    $mid = floor($pagelinks / 2);
    $last = $pagelinks;
    $minpage = (($current - $mid) < 1 ? 1 : $current - $mid);
    $maxpage = $minpage + $last;

    if ($totalpage < $maxpage) {
        $maxpage = &$totalpage;
        $minpage = $maxpage - $last;
        $minpage = ($minpage < 1 ? 1 : $minpage);
    }

    $char = ($char == "" ? "&gt;&gt;" : $char);
    $ngpage = (($maxpage + $last) < $totalpage ? $maxpage + $mid : $totalpage);
    return $this->pagelink($ngpage, $char, "ngroup");
}

public function jump_js()
{
    if ($this->useajax == 1) {
        $linkurl = urldecode($this->linkurl);
    }
    else {
        $linkurl = $this->linkurl;
    }

    $pos = strpos($linkurl, "<{\$" . $this->pagevar);

    if ($pos === false) {
        $urlcode = "'" . $linkurl . "'+this.parentNode.getElementsByTagName('input')[0].value";
    }
    else {
        $urlcode = "'" . $linkurl . "'.replace('<{\$" . $this->pagevar . "|subdirectory}>', '/' + Math.floor(this.parentNode.getElementsByTagName('input')[0].value / 1000)).replace('<{\$" . $this->pagevar . "}>', this.parentNode.getElementsByTagName('input')[0].value)";
    }

    if ($this->useajax == 1) {
        $js = "Ajax.Update(" . $urlcode . "," . $this->ajax_parm . ");";
    }
    else {
        $js = "window.location.href=" . $urlcode . " rel="external nofollow" ;";
    }

    return $js;
}

public function more_js()
{
    if ($this->current < $this->totalpages) {
        $page = $this->current + 1;

        if (strpos($this->linkurl, "<{\$" . $this->pagevar) === false) {
            $url = $this->linkurl . $page;
        }
        else {
            $url = str_replace(array("<{\$" . $this->pagevar . "|subdirectory}>", "<{\$" . $this->pagevar . "}>"), array(jieqi_getsubdir($page), $page), $this->linkurl);
        }

        $js = "Ajax.Request('" . urldecode($url) . "',{onLoading:function(){},onComplete:function(){var c = document.getElementById('" . $this->pagecontents . "') ? document.getElementById('" . $this->pagecontents . "').innerHTML : null; document.getElementsByTagName('body')[0].innerHTML = this.response.match(/<body[^>]*>([\s\S]*)<\/body>/i)[1]; if(typeof c == 'string') document.getElementById('" . $this->pagecontents . "').innerHTML = c + document.getElementById('" . $this->pagecontents . "').innerHTML;}});";
    }
    else {
        $js = "this.parentNode.innerHTML = '';";
    }

    return $js;
}

这些代码分别定义了分页样式里面全部的标签和class,而且也是可删除的,但是我并不建议删除这些定义,直接修改它设置的标签或者calss即可,但是页面上的实际显示是由以下的代码定义。

switch ($this->pagestyle) {
        case 3:
            $html_template = "<div><a class=\"pagemore\" href=\"javascript:;\" onclick=\"" . $this->more_js() . "\">" . LANG_PAGE_MORE . "</a></div>";
            break;

        case 2:
            $html_template = "<div class=\"pagelink\" id=\"pagelink\"><a href=\"{?\$jieqi_page_previousurl?}\" class=\"prev\">{?\$jieqi_page_previouslang?}</a><em id=\"pagestats\"><kbd><input name=\"" . $this->pagevar . "\" type=\"text\" size=\"3\" value=\"{?\$jieqi_page_current?}\" onkeydown=\"if(event.keyCode==13){{?\$jieqi_page_jumpjs?} return false;}\" onfocus=\"if(this.value==this.getAttribute('dftval'))this.value='';\" onblur=\"if(this.value=='')this.value=this.getAttribute('dftval');\" dftval=\"{?\$jieqi_page_current?}\" /></kbd>/{?\$jieqi_page_totalpages?}<a href=\"javascript:;\" onclick=\"{?\$jieqi_page_jumpjs?}\">{?\$jieqi_page_submitlang?}</a></em><a href=\"{?\$jieqi_page_nexturl?}\" class=\"next\">{?\$jieqi_page_nextlang?}</a></div>";
            break;

        case 1:
        default:
            $html_template = "<div class=\"pagelink\" id=\"pagelink\">{?\$jieqi_page_firsthtm?}{?\$jieqi_page_gprevioushtm?}{?\$jieqi_page_previoushtm?}{?\$jieqi_page_numshtm?}{?\$jieqi_page_nexthtm?}{?\$jieqi_page_gnexthtm?}{?\$jieqi_page_lasthtm?}<kbd><input name=\"" . $this->pagevar . "\" type=\"text\" size=\"3\" onkeydown=\"if(event.keyCode==13){{?\$jieqi_page_jumpjs?} return false;}\" title=\"{?\$jieqi_page_titlelang?}\" /></kbd></div>";
            break;
        }

这里的代码就相当明显了,删除相应的地方,页面上就不会显示,或者也可以修改整个区块css。
比如我之前的分页显示是这样:
杰奇自定义分页代码,教程及案例
我修改了标签和class,自定义样式之后,是这样:
杰奇自定义分页代码,教程及案例

杰奇每个版本的这个文件都有所不同,而且1.7的话我的解密工具用不了,但是网上有开源版,找到这个文件覆盖就好了。

规则之树版权所有,转载注明来源

本文由网友投稿或「聚码源码网」整理自网络,如转载请注明出处:https://www.jumaniu.com/14066/

本站发布的内容若侵犯到您的权益,请邮件联系 zhangqy2022#yeah.net 删除,我们将及时处理!

从您进入本站开始,已表示您已同意接受本站【免责声明】中的一切条款!

本站大部分下载资源收集于网络,不保证其完整性以及安全性,请下载后自行研究。

本站资源仅供学习和交流使用,版权归原作者所有,请在下载后24小时之内自觉删除。

若作商业用途,请购买正版,由于未及时购买和付费发生的侵权行为,使用者自行承担,概与本站无关。

常见问题
  • 本站所有资源解压密码为:www.jumaniu.com 或 www.tdji.cn
查看详情

相关文章

评论
暂无评论