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