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

本文阅读 2 分钟
广告

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

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

<div class="pages"><div class="pagelink" id="pagelink"><a href="http://127.0.0.110/modules/article/articlefilter.php?order=lastupdate&page=1" class="first">1</a><a href="http://127.0.0.110/modules/article/articlefilter.php?order=lastupdate&page=1" class="pgroup">&lt;&lt;</a><strong>1</strong><a href="http://127.0.0.110/modules/article/articlefilter.php?order=lastupdate&page=2">2</a><a href="http://127.0.0.110/modules/article/articlefilter.php?order=lastupdate&page=2" class="next">&gt;</a><a href="http://127.0.0.110/modules/article/articlefilter.php?order=lastupdate&page=2" class="ngroup">&gt;&gt;</a><a href="http://127.0.0.110/modules/article/articlefilter.php?order=lastupdate&page=2" 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 . ";";
    }

    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。
比如我之前的分页显示是这样:
1.png
我修改了标签和class,自定义样式之后,是这样:
2.png

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

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

本文来自投稿,不代表本站立场,如若转载,请注明出处:https://www.ruletree.club/archives/359/
另类科幻短篇,《弑神》
« 上一篇 11-18
吐槽一下,百度相关的东西
下一篇 » 11-21
广告

发表评论

V注册会员 L评论等级
R4 条回复
  1. 谎言Lv.1 说道:
    2019-05-21     Win 7 /    Chrome

    我想改变分页的地址。比如sort_1 改成xuanhuan/1.htm.
    付费解决谢谢

    1. 不暇VLv.6 说道:
      2019-05-21     Android /    Chrome

      @谎言

      这个通过伪静态和路径格式修改就可以,你加博客交流群吧。

  2. AndLv.1 说道:
    2018-05-16     Win 7 /    Chrome

    请问博主,怎么实现内容页面的分页啊

    1. 不暇VLv.6 说道:
      2018-05-17     Win 7 /    Chrome

      @And

      我暂时也没有找到好办法

没有更多评论了

作者信息

热门文章

标签TAG

热评文章