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