-
Notifications
You must be signed in to change notification settings - Fork 2
/
Sorter.php
98 lines (85 loc) · 2.98 KB
/
Sorter.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<?php
//Sorter Class @0-0B1D2525
class clsSorter
{
var $OrderDirection;
var $OrderColumn;
var $IsOn;
var $IsAsc;
var $TargetName;
var $SorterName;
var $FileName;
function clsSorter($ComponentName, $SorterName, $FileName)
{
$this->TargetName = $ComponentName;
$this->SorterName = $SorterName;
$this->FileName = $FileName;
$this->OrderColumn = CCGetParam($this->TargetName . "Order", "");
$this->OrderDirection = CCGetParam($this->TargetName . "Dir", "");
$this->IsOn = ($this->OrderColumn == $this->SorterName);
$this->IsAsc = (!strlen($this->OrderDirection) || $this->OrderDirection == "asc");
}
function Show()
{
global $Tpl;
$QueryString = CCGetQueryString("QueryString", Array($this->TargetName . "Page", "ccsForm"));
$SorterBlock = "Sorter " . $this->SorterName;
$AscOnPath = $SorterBlock . "/Asc_On";
$AscOffPath = $SorterBlock . "/Asc_Off";
$DescOnPath = $SorterBlock . "/Desc_On";
$DescOffPath = $SorterBlock . "/Desc_Off";
$QueryString = CCAddParam($QueryString, $this->TargetName . "Order", $this->SorterName);
$AscOnExist = $Tpl->BlockExists($AscOnPath);
$AscOffExist = $Tpl->BlockExists($AscOffPath);
$DescOnExist = $Tpl->BlockExists($DescOnPath);
$DescOffExist = $Tpl->BlockExists($DescOffPath);
if($this->IsOn)
{
if($this->IsAsc)
{
$this->OrderDirection = "desc";
if($AscOnExist) $Tpl->Parse($AscOnPath, false);
if($AscOffExist) $Tpl->SetVar($AscOffPath, "");
if($DescOnExist) $Tpl->SetVar($DescOnPath, "");
if($DescOffExist)
{
$Tpl->SetVar("Desc_URL", $this->FileName . "?" . CCAddParam($QueryString, $this->TargetName . "Dir", "desc"));
$Tpl->Parse($DescOffPath, false);
}
}
Else
{
$this->OrderDirection = "asc";
if($AscOnExist) $Tpl->SetVar($AscOnPath, "");
if($AscOffExist)
{
$Tpl->SetVar("Asc_URL", $this->FileName . "?" . CCAddParam($QueryString, $this->TargetName . "Dir", "asc"));
$Tpl->Parse($AscOffPath, false);
}
if($DescOnExist) $Tpl->Parse($DescOnPath, false);
if($DescOffExist) $Tpl->SetVar($DescOffPath, "");
}
}
else
{
$this->OrderDirection = "asc";
if($AscOnExist) $Tpl->SetVar($AscOnPath, "");
if($AscOffExist)
{
$Tpl->SetVar("Asc_URL", $this->FileName . "?" . CCAddParam($QueryString, $this->TargetName . "Dir", "asc"));
$Tpl->Parse($AscOffPath, false);
}
if($DescOnExist) $Tpl->SetVar($DescOnPath, "");
if($DescOffExist)
{
$Tpl->SetVar("Desc_URL", $this->FileName . "?" . CCAddParam($QueryString, $this->TargetName . "Dir", "desc"));
$Tpl->Parse($DescOffPath, false);
}
}
$QueryString = CCAddParam($QueryString, $this->TargetName . "Dir", $this->OrderDirection);
$Tpl->SetVar("Sort_URL", $this->FileName . "?" . $QueryString);
$Tpl->Parse($SorterBlock, false);
}
}
//End Sorter Class
?>