diff options
author | Sem <sembrestels@riseup.net> | 2012-07-20 06:38:08 +0200 |
---|---|---|
committer | Sem <sembrestels@riseup.net> | 2012-07-20 06:38:08 +0200 |
commit | 0ef4f3dd1637687d3ece88e2a6208d5e17a96ce1 (patch) | |
tree | 7473af8e01b87ef5134928bd44587a62023b7070 /views_override/default | |
parent | 4caa18176ab7b25896596276ee5a3d724a5915fd (diff) | |
download | elgg-0ef4f3dd1637687d3ece88e2a6208d5e17a96ce1.tar.gz elgg-0ef4f3dd1637687d3ece88e2a6208d5e17a96ce1.tar.bz2 |
Moved plugin to root folder.
Diffstat (limited to 'views_override/default')
-rw-r--r-- | views_override/default/page/components/list.php | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/views_override/default/page/components/list.php b/views_override/default/page/components/list.php new file mode 100644 index 000000000..b34c454a6 --- /dev/null +++ b/views_override/default/page/components/list.php @@ -0,0 +1,86 @@ +<?php +/** + * View a list of items + * + * @package Elgg + * + * @uses $vars['items'] Array of ElggEntity or ElggAnnotation objects + * @uses $vars['offset'] Index of the first list item in complete list + * @uses $vars['limit'] Number of items per page + * @uses $vars['count'] Number of items in the complete list + * @uses $vars['base_url'] Base URL of list (optional) + * @uses $vars['pagination'] Show pagination? (default: true) + * @uses $vars['position'] Position of the pagination: before, after, or both + * @uses $vars['full_view'] Show the full view of the items (default: false) + * @uses $vars['list_class'] Additional CSS class for the <ul> element + * @uses $vars['item_class'] Additional CSS class for the <li> elements + */ + +$items = $vars['items']; +$offset = elgg_extract('offset', $vars); +$limit = elgg_extract('limit', $vars); +$count = elgg_extract('count', $vars); +$base_url = elgg_extract('base_url', $vars, ''); +$pagination = elgg_extract('pagination', $vars, true); +$offset_key = elgg_extract('offset_key', $vars, 'offset'); +$position = elgg_extract('position', $vars, 'after'); + +// remove non-object items for anyone who's not the subject +if(is_array($items) && ($items[0] instanceof ElggRiverItem)){ + foreach($items as $key => $item){ + if($item->type != 'object' && $item->subject_guid != elgg_get_logged_in_user_guid()){ + unset($items[$key]); + } + } +} + +// reset key values +$items = array_merge(array(), $items); + +$list_class = 'elgg-list'; +if (isset($vars['list_class'])) { + $list_class = "$list_class {$vars['list_class']}"; +} + +$item_class = 'elgg-item'; +if (isset($vars['item_class'])) { + $item_class = "$item_class {$vars['item_class']}"; +} + +$html = ""; +$nav = ""; + +if ($pagination && $count) { + $nav .= elgg_view('navigation/pagination', array( + 'base_url' => $base_url, + 'offset' => $offset, + 'count' => $count, + 'limit' => $limit, + 'offset_key' => $offset_key, + )); +} + +if (is_array($items) && count($items) > 0) { + $html .= "<ul class=\"$list_class\">"; + foreach ($items as $item) { + if (elgg_instanceof($item)) { + $id = "elgg-{$item->getType()}-{$item->getGUID()}"; + } else { + $id = "item-{$item->getType()}-{$item->id}"; + } + $html .= "<li id=\"$id\" class=\"$item_class\">"; + $html .= elgg_view_list_item($item, $vars); + $html .= '</li>'; + } + $html .= '</ul>'; +} + +if ($position == 'before' || $position == 'both') { + $html = $nav . $html; +} + +if ($position == 'after' || $position == 'both') { + $html .= $nav; +} + +echo $html; |