aboutsummaryrefslogtreecommitdiff
path: root/views/default/page
diff options
context:
space:
mode:
Diffstat (limited to 'views/default/page')
-rw-r--r--views/default/page/components/gallery.php75
-rw-r--r--views/default/page/components/image_block.php52
-rw-r--r--views/default/page/components/list.php75
-rw-r--r--views/default/page/components/module.php52
-rw-r--r--views/default/page/components/widget.php67
-rw-r--r--views/default/page/elements/owner_block.php2
6 files changed, 322 insertions, 1 deletions
diff --git a/views/default/page/components/gallery.php b/views/default/page/components/gallery.php
new file mode 100644
index 000000000..f57cc99ba
--- /dev/null
+++ b/views/default/page/components/gallery.php
@@ -0,0 +1,75 @@
+<?php
+/**
+ * Gallery view
+ *
+ * @uses $vars['items']
+ *
+ * @todo not complete - number of columns
+ */
+
+$items = $vars['items'];
+if (!is_array($items) && sizeof($items) == 0) {
+ return true;
+}
+
+elgg_push_context('gallery');
+
+$offset = $vars['offset'];
+$limit = $vars['limit'];
+$count = $vars['count'];
+$pagination = elgg_extract('pagination', $vars, true);
+$full_view = elgg_extract('full_view', $vars, false);
+$offset_key = elgg_extract('offset_key', $vars, 'offset');
+$position = elgg_extract('position', $vars, 'after');
+
+$num_columns = 4;
+
+
+if ($pagination && $count) {
+ $nav .= elgg_view('navigation/pagination', array(
+ 'offset' => $offset,
+ 'count' => $count,
+ 'limit' => $limit,
+ 'offset_key' => $offset_key,
+ ));
+}
+
+if ($position == 'before' || $position == 'both') {
+ echo $nav;
+}
+
+?>
+<table class="elgg-gallery">
+<?php
+
+$col = 0;
+foreach ($items as $item) {
+ if ($col == 0) {
+ echo '<tr>';
+ }
+ $col++;
+
+ echo '<td>';
+ echo elgg_view_list_item($item, $full_view, $vars);
+ echo "</td>";
+
+ if ($col == $num_columns) {
+ echo '</tr>';
+ $col = 0;
+ }
+}
+
+if ($col > 0) {
+ echo '</tr>';
+}
+
+?>
+
+</table>
+
+<?php
+if ($position == 'after' || $position == 'both') {
+ echo $nav;
+}
+
+elgg_pop_context();
diff --git a/views/default/page/components/image_block.php b/views/default/page/components/image_block.php
new file mode 100644
index 000000000..a7f480aef
--- /dev/null
+++ b/views/default/page/components/image_block.php
@@ -0,0 +1,52 @@
+<?php
+/**
+ * Elgg image block pattern
+ *
+ * Common pattern where there is an image, icon, media object to the left
+ * and a descriptive block of text to the right.
+ *
+ * ---------------------------------------------------------------
+ * | | | alt |
+ * | image | body | image |
+ * | block | block | block |
+ * | | | (optional)|
+ * ---------------------------------------------------------------
+ *
+ * @uses $vars['body'] HTML content of the body block
+ * @uses $vars['image'] HTML content of the image block
+ * @uses $vars['image_alt'] HTML content of the alternate image block
+ * @uses $vars['class'] Optional additional class for media element
+ * @uses $vars['id'] Optional id for the media element
+ */
+
+$body = elgg_extract('body', $vars, '');
+$image = elgg_extract('image', $vars, '');
+$alt_image = elgg_extract('image_alt', $vars, '');
+
+$class = 'elgg-image-block';
+$additional_class = elgg_extract('class', $vars, '');
+if ($additional_class) {
+ $class = "$class $additional_class";
+}
+
+$id = '';
+if (isset($vars['id'])) {
+ $id = "id=\"{$vars['id']}\"";
+}
+
+
+$body = "<div class=\"elgg-body\">$body</div>";
+
+if ($image) {
+ $image = "<div class=\"elgg-image\">$image</div>";
+}
+
+if ($alt_image) {
+ $alt_image = "<div class=\"elgg-image-alt\">$alt_image</div>";
+}
+
+echo <<<HTML
+<div class="$class clearfix" $id>
+ $image$alt_image$body
+</div>
+HTML;
diff --git a/views/default/page/components/list.php b/views/default/page/components/list.php
new file mode 100644
index 000000000..374922ecd
--- /dev/null
+++ b/views/default/page/components/list.php
@@ -0,0 +1,75 @@
+<?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 = $vars['offset'];
+$limit = $vars['limit'];
+$count = $vars['count'];
+$base_url = $vars['base_url'];
+$pagination = elgg_extract('pagination', $vars, true);
+$full_view = elgg_extract('full_view', $vars, false);
+$offset_key = elgg_extract('offset_key', $vars, 'offset');
+$position = elgg_extract('position', $vars, 'after');
+
+$list_class = 'elgg-list';
+if (isset($vars['list_class'])) {
+ $list_class = "{$vars['list_class']} $list_class";
+}
+
+$item_class = 'elgg-list-item';
+if (isset($vars['item_class'])) {
+ $item_class = "{$vars['item_class']} $item_class";
+}
+
+$html = "";
+$nav = "";
+
+if ($pagination && $count) {
+ $nav .= elgg_view('navigation/pagination', array(
+ 'baseurl' => $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, $full_view, $vars);
+ $html .= '</li>';
+ }
+ $html .= '</ul>';
+}
+
+if ($position == 'before' || $position == 'both') {
+ $html = $nav . $html;
+}
+
+if ($position == 'after' || $position == 'both') {
+ $html .= $nav;
+}
+
+echo $html;
diff --git a/views/default/page/components/module.php b/views/default/page/components/module.php
new file mode 100644
index 000000000..f7b9da59c
--- /dev/null
+++ b/views/default/page/components/module.php
@@ -0,0 +1,52 @@
+<?php
+/**
+ * Elgg module element
+ *
+ * @uses $vars['title'] Title text
+ * @uses $vars['header'] HTML content of the header
+ * @uses $vars['body'] HTML content of the body
+ * @uses $vars['footer'] HTML content of the footer
+ * @uses $vars['class'] Optional additional class for module
+ * @uses $vars['id'] Optional id for module
+ * @uses $vars['show_inner'] Optional flag to leave out inner div (default: false)
+ */
+
+$title = elgg_extract('title', $vars, '');
+$header = elgg_extract('header', $vars, '');
+$body = elgg_extract('body', $vars, '');
+$footer = elgg_extract('footer', $vars, '');
+$show_inner = elgg_extract('show_inner', $vars, false);
+
+$class = 'elgg-module';
+$additional_class = elgg_extract('class', $vars, '');
+if ($additional_class) {
+ $class = "$class $additional_class";
+}
+
+$id = '';
+if (isset($vars['id'])) {
+ $id = "id=\"{$vars['id']}\"";
+}
+
+if (isset($vars['header'])) {
+ if ($vars['header']) {
+ $header = "<div class=\"elgg-head\">$header</div>";
+ }
+} else {
+ $header = "<div class=\"elgg-head\"><h3>$title</h3></div>";
+}
+
+$body = "<div class=\"elgg-body\">$body</div>";
+
+if (isset($vars['footer'])) {
+ if ($vars['footer']) {
+ $footer = "<div class=\"elgg-foot\">$footer</div>";
+ }
+}
+
+$contents = $header . $body . $footer;
+if ($show_inner) {
+ $contents = "<div class=\"elgg-inner\">$contents</div>";
+}
+
+echo "<div class=\"$class\" $id>$contents</div>";
diff --git a/views/default/page/components/widget.php b/views/default/page/components/widget.php
new file mode 100644
index 000000000..d5e2c4ca2
--- /dev/null
+++ b/views/default/page/components/widget.php
@@ -0,0 +1,67 @@
+<?php
+/**
+ * Widget object
+ *
+ * @uses $vars['entity'] ElggWidget
+ * @uses $vars['show_access'] Show the access control in edit area? (true)
+ */
+
+$widget = $vars['entity'];
+if (!elgg_instanceof($widget, 'object', 'widget')) {
+ return true;
+}
+
+$show_access = elgg_extract('show_access', $vars, true);
+
+// @todo catch for disabled plugins
+$widget_types = elgg_get_widget_types('all');
+
+$handler = $widget->handler;
+
+$title = $widget->getTitle();
+
+$edit_area = '';
+$can_edit = $widget->canEdit();
+if ($can_edit) {
+ $edit_area = elgg_view('layout/objects/widget/settings', array(
+ 'widget' => $widget,
+ 'show_access' => $show_access,
+ ));
+}
+$controls = elgg_view('layout/objects/widget/controls', array(
+ 'widget' => $widget,
+ 'show_edit' => $edit_area != '',
+));
+
+
+if (elgg_view_exists("widgets/$handler/content")) {
+ $content = elgg_view("widgets/$handler/content", $vars);
+} else {
+ elgg_deprecated_notice("widgets use content as the display view", 1.8);
+ $content = elgg_view("widgets/$handler/view", $vars);
+}
+
+
+$widget_id = "elgg-widget-$widget->guid";
+$widget_instance = "elgg-widget-instance-$handler";
+$widget_class = "elgg-module elgg-module-widget";
+if ($can_edit) {
+ $widget_class .= " elgg-state-draggable $widget_instance";
+} else {
+ $widget_class .= " elgg-state-fixed $widget_instance";
+}
+
+echo <<<HTML
+<div class="$widget_class" id="$widget_id">
+ <div class="elgg-head">
+ <h3>$title</h3>
+ $controls
+ </div>
+ <div class="elgg-body">
+ $edit_area
+ <div class="elgg-widget-content">
+ $content
+ </div>
+ </div>
+</div>
+HTML;
diff --git a/views/default/page/elements/owner_block.php b/views/default/page/elements/owner_block.php
index 8cfa2d683..2f9fc8603 100644
--- a/views/default/page/elements/owner_block.php
+++ b/views/default/page/elements/owner_block.php
@@ -25,7 +25,7 @@ if ($owner instanceof ElggGroup ||
$body .= elgg_view('page/elements/owner_block/extend', $vars);
//@todo elgg-module-owner-block?
- echo elgg_view('layout/objects/module', array(
+ echo elgg_view('page/components/module', array(
'header' => $header,
'body' => $body,
'class' => 'elgg-owner-block',