1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14:
15:
16: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
17:
18: 19: 20: 21: 22: 23:
24: class cGuiObjectPager extends cGuiFoldingRow {
25:
26: public $_pagerLink;
27: public $_parameterToAdd;
28:
29: 30: 31:
32: public function __construct($uuid, $items, $itemsperpage, $currentpage, $link, $parameterToAdd, $id = '') {
33: if ((int) $currentpage == 0) {
34: $currentpage = 1;
35: }
36:
37: if ($id == '') {
38: parent::__construct($uuid, i18n("Paging"));
39: } else {
40: parent::__construct($uuid, i18n("Paging"), $id);
41: }
42:
43: if (!is_object($link)) {
44: throw new cException('Parameter link is not an object');
45: return false;
46: }
47: $this->_cPager = new cPager($items, $itemsperpage, $currentpage);
48: $this->_pagerLink = $link;
49: $this->_parameterToAdd = $parameterToAdd;
50: }
51:
52: public function render($bContentOnly = false) {
53:
54: if ($this->_cPager->getMaxPages() == 1) {
55: $this->_headerRow->setStyle("display:none");
56: $this->_contentRow->setStyle("display:none");
57: }
58:
59: $items = $this->_cPager->getPagesInRange();
60: $link = $this->_pagerLink;
61:
62: $output = '';
63:
64: if (!$this->_cPager->isFirstPage()) {
65: $img = new cHTMLImage("images/paging/first.gif");
66:
67: $link->setAlt(i18n("First page"));
68: $link->setContent($img);
69: $link->setCustom($this->_parameterToAdd, 1);
70: $output .= $link->render();
71: $output .= " ";
72:
73: $img = new cHTMLImage("images/paging/previous.gif");
74: $link->setAlt(i18n("Previous page"));
75: $link->setContent($img);
76:
77: $link->setCustom($this->_parameterToAdd, $this->_cPager->getCurrentPage() - 1);
78:
79: $output .= $link->render();
80: $output .= " ";
81: } else {
82: $output .= '<img src="images/spacer.gif" alt="" width="8"> ';
83: $output .= '<img src="images/spacer.gif" alt="" width="8">';
84: }
85:
86: foreach ($items as $key => $item) {
87: $link->setContent($key);
88: $link->setAlt(sprintf(i18n("Page %s"), $key));
89: $link->setCustom($this->_parameterToAdd, $key);
90:
91: switch ($item) {
92: case "|": $output .= "...";
93: break;
94: case "current": $output .= '<span class="cpager_currentitem">' . $key . "</span>";
95: break;
96: default: $output .= $link->render();
97: }
98:
99: $output .= " ";
100: }
101:
102: if (!$this->_cPager->isLastPage()) {
103: $img = new cHTMLImage("images/paging/next.gif");
104: $link->setAlt(i18n("Next page"));
105: $link->setContent($img);
106: $link->setCustom($this->_parameterToAdd, $this->_cPager->getCurrentPage() + 1);
107:
108: $output .= $link->render();
109: $output .= " ";
110:
111: $img = new cHTMLImage("images/paging/last.gif");
112:
113: $link->setCustom($this->_parameterToAdd, $this->_cPager->getMaxPages());
114: $link->setAlt(i18n("Last page"));
115: $link->setContent($img);
116:
117: $output .= $link->render();
118: $output .= " ";
119: } else {
120: $output .= '<img src="images/spacer.gif" alt="" width="8"> ';
121: $output .= '<img src="images/spacer.gif" alt="" width="8">';
122: }
123:
124: $this->_contentData->setAlignment("center");
125: $this->_contentData->setClass("foldingrow_content");
126:
127:
128: if ($this->_cPager->getMaxPages() == 1) {
129: $output = '';
130: }
131:
132: $this->_contentData->setContent($output);
133:
134: if ($bContentOnly) {
135: return $output;
136: } else {
137: return parent::render();
138: }
139: }
140:
141: }
142: