70 $this->tagRowCallbacks = array();
84 $this->tagRowCallbacks[] = $handler;
89 if(!$this->paginate && count($this->tagRowCallbacks) == 0)
return "";
93 <script type=
"text/javascript">
94 window.addEvent(
'domready',
function()
96 var <?echo $this->
id?> =
new PaginatingList(
'<?echo $this->id ?>',
'<?echo $this->id?>_paginator', {per_page: <?echo $this->pageSize ?>, display_mode:
'<?echo $this->displayMode?>'});
100 $script = ob_get_contents();
107 if (!count($this->items))
109 echo
"<p>{$this->emptyList}</p>";
114 if ($this->CSSclass) $attrs .=
" class='{$this->CSSclass}'";
115 if ($this->styles) $attrs .=
" style='{$this->styles}'";
119 <div style=
"float: right;" class=
"paginator">
120 <ul
id=
"<?echo $this->id?>_paginator"></ul>
125 <<?echo $this->listTag?>
id=
"<?echo $this->id?>"<?echo $attrs?>>
127 foreach($this->items as $item)
132 if ($this->onStartRow)
134 $css = call_user_func($this->onStartRow, $item);
135 if ($css ===
false)
continue;
138 if ($css) $css =
" class='$css'";
140 if($this->writeIdTag)
142 $idTag =
"id='".$this->formatIdTag($item).
"'";
145 $dataAttrs = array();
146 foreach($this->tagRowCallbacks as $cb)
148 $dataAttrs = call_user_func($cb, $item, $dataAttrs);
152 foreach($dataAttrs as $name => $value)
154 $rowAttrs .=
" ".$name.
"='".$value.
"'";
157 echo
"<li {$idTag}{$css}{$rowAttrs}>";
159 if (is_callable($this->format))
161 echo call_user_func($this->format, $item);
163 else echo $item->format($this->format);
167 echo
"</{$this->listTag}>\n";
172 $pk = $item->getPrimaryKey();
173 return "{$pk}_{$item->get($pk)}";
186 $out = ob_get_contents();
228 if (!count($this->items))
230 echo
"<p>{$this->emptyList}</p>";
234 if ($this->page == -1)
237 if (!$this->page) $this->page = 1;
242 $start = ($this->page - 1) * $this->pageSize;
243 if ($start < 0) $start = 0;
246 if ($end > count($this->items)) $end = count($this->items);
251 $end = count($this->items);
255 if ($this->CSSclass) $attrs .=
" class='{$this->CSSclass}'";
256 if ($this->styles) $attrs .=
" style='{$this->styles}'";
261 $prev = $this->page - 1;
262 if ($prev < 1) $prev = 1;
263 $next = $this->page + 1;
264 $total = intval((count($this->items) - 1) / $this->pageSize + 1);
265 if ($next > $total) $next = $total;
267 <div style=
"float: right;" class=
"paginator">
268 <ul
id=
"<?echo $this->id?>_paginator">
269 <li><a href=
"?page=<?echo $prev?>" class=
"paginate"><span><< Prev</span></a></li>
270 <li
class=
"pager"><a href=
"#" class=
"goto-page">Page <?echo $this->page?> of <?echo $total?></a></li>
271 <li><a href=
"?page=<?echo $next?>" class=
"paginate"><span>Next >></span></a></li>
277 <<?echo $this->listTag?>
id=
"<?echo $this->id?>"<?echo $attrs?>>
279 for($i = $start; $i < $end; ++$i)
281 $item = $this->items[$i];
283 if($this->writeIdTag)
285 $idTag =
" id='".$this->formatIdTag($item).
"'";
290 if (is_callable($this->format))
292 echo call_user_func($this->format, $item);
294 else echo $item->format($this->format);
298 echo
"</{$this->listTag}>\n";
304 $pk = $item->getPrimaryKey();
305 return "{$pk}_{$item->get($pk)}";
The PagedList class provides a simple User Interface control to allow pagination of HTML lists of Dat...
ServerPagedList provides the same interface and functionality as PagedList, with the difference that ...
$styles
Specific CSS styles to be applied to the list.
$paginate
Specifies whether list should be paginated.
__construct($items, $id="paged_list", $format=null)
$tagRowCallbacks
Array of callbacks for adding extra attributes to each row.
$writeIdTag
whether to include an id tag for each li item
$writeIdTag
whether to include an id tag for each li item
$format
The formatter used to display the list items (either a format string or a callback function or method...
$pageSize
The number of items per page.
$items
The items to be displayed in the list.
$emptyList
Message to display when the list is empty.
$listTag
The HTML list tag type.
PagedList($items, $id="paged_list", $format=null)
Creates a new PagedList control.
$CSSclass
CSS class(es) to be applied to the list.
addFacetTaggingHandler($handler)
Adds a row tagging handler.
$emptyList
Message to display when the list is empty.
$CSSclass
CSS class(es) to be applied to the list.
$paginate
Specifies whether list should be paginated (false for view only pages)
drawListToString()
Helpful utility function - generates the list HTML in an output buffer and returns the string represe...
$pageSize
The number of items per page.
$listTag
The HTML list tag type.
$onStartRow
Callback for setting the CSS class / visibility of each item in the list.
$styles
Specific CSS styles to be applied to the list.
$id
The HTML id of the list.
$displayMode
CSS display type for visible items.
checkNumeric($p)
Security helper function.