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