Completed
Push — master ( 989e4a...36050a )
by
unknown
02:26
created

DLpaginateReversed   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 33
rs 10
c 0
b 0
f 0
wmc 7
lcom 1
cbo 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A renderItemTPL() 0 5 1
B get_pagenum_link() 0 15 6
1
<?php
2
3
/**
4
 * Class DLpaginate
5
 */
6
class DLpaginateReversed extends DLpaginate
7
{
8
    /**
9
     * @param $tpl
10
     * @param $num
11
     * @return mixed
12
     */
13
    protected function renderItemTPL($tpl, $num)
14
    {
15
        $_num = $this->total_pages + 1 - $num;
16
        return str_replace(array('[+num+]', '[+link+]'), array($_num, $this->get_pagenum_link($_num)), $tpl);
17
    }
18
19
    /**
20
     * @param $id
21
     * @return mixed|string
22
     */
23
    public function get_pagenum_link($id)
24
    {
25
        $flag = (strpos($this->target, '?') === false);
26
        $value = $this->getPageQuery($id);
27
        if ($flag && !empty($this->urlF)) {
28
            $out = str_replace($this->urlF, $value, $this->target);
29
        } else {
30
            $out = $this->target;
31
            if ($id > 0 && $id < $this->total_pages) {
32
                $out .= ($flag ? "?" : "&") . $this->parameterName . "=" . $value;
33
            }
34
        }
35
36
        return $out;
37
    }
38
}
39