diff options
Diffstat (limited to 'mod/pages/views')
-rw-r--r-- | mod/pages/views/default/annotation/page.php | 60 | ||||
-rw-r--r-- | mod/pages/views/default/forms/pages/edit.php | 77 | ||||
-rw-r--r-- | mod/pages/views/default/input/write_access.php | 35 | ||||
-rw-r--r-- | mod/pages/views/default/object/page.php | 8 | ||||
-rw-r--r-- | mod/pages/views/default/object/page_top.php | 119 | ||||
-rw-r--r-- | mod/pages/views/default/pages/css.php | 19 | ||||
-rw-r--r-- | mod/pages/views/default/pages/group_module.php | 49 | ||||
-rw-r--r-- | mod/pages/views/default/pages/icon.php | 25 | ||||
-rw-r--r-- | mod/pages/views/default/pages/input/parent.php | 37 | ||||
-rw-r--r-- | mod/pages/views/default/pages/sidebar.php | 14 | ||||
-rw-r--r-- | mod/pages/views/default/pages/sidebar/history.php | 21 | ||||
-rw-r--r-- | mod/pages/views/default/pages/sidebar/navigation.php | 58 | ||||
-rw-r--r-- | mod/pages/views/default/river/object/page/create.php | 13 | ||||
-rw-r--r-- | mod/pages/views/default/river/object/page_top/create.php | 8 | ||||
-rw-r--r-- | mod/pages/views/default/widgets/pages/content.php | 32 | ||||
-rw-r--r-- | mod/pages/views/default/widgets/pages/edit.php | 24 |
16 files changed, 599 insertions, 0 deletions
diff --git a/mod/pages/views/default/annotation/page.php b/mod/pages/views/default/annotation/page.php new file mode 100644 index 000000000..ecb289092 --- /dev/null +++ b/mod/pages/views/default/annotation/page.php @@ -0,0 +1,60 @@ +<?php +/** + * Revision view for history page + * + * @package ElggPages + */ + +$annotation = $vars['annotation']; +$page = get_entity($annotation->entity_guid); + +$icon = elgg_view("pages/icon", array( + 'annotation' => $annotation, + 'size' => 'small', +)); + +$owner_guid = $annotation->owner_guid; +$owner = get_entity($owner_guid); +if (!$owner) { + +} +$owner_link = elgg_view('output/url', array( + 'href' => $owner->getURL(), + 'text' => $owner->name, + 'is_trusted' => true, +)); + +$date = elgg_view_friendly_time($annotation->time_created); + +$title_link = elgg_view('output/url', array( + 'href' => $annotation->getURL(), + 'text' => $page->title, + 'is_trusted' => true, +)); + +$subtitle = elgg_echo('pages:revision:subtitle', array($date, $owner_link)); + +$body = <<< HTML +<h3>$title_link</h3> +<p class="elgg-subtext">$subtitle</p> +HTML; + +if (!elgg_in_context('widgets')) { + $menu = elgg_view_menu('annotation', array( + 'annotation' => $annotation, + 'sort_by' => 'priority', + 'class' => 'elgg-menu-hz float-alt', + )); +} + +$body = <<<HTML +<div class="mbn"> + $menu + <h3>$title_link</h3> + <span class="elgg-subtext"> + $subtitle + </span> +</div> +HTML; + +echo elgg_view_image_block($icon, $body);
\ No newline at end of file diff --git a/mod/pages/views/default/forms/pages/edit.php b/mod/pages/views/default/forms/pages/edit.php new file mode 100644 index 000000000..e14ff19ec --- /dev/null +++ b/mod/pages/views/default/forms/pages/edit.php @@ -0,0 +1,77 @@ +<?php +/** + * Page edit form body + * + * @package ElggPages + */ + +$variables = elgg_get_config('pages'); +$user = elgg_get_logged_in_user_entity(); +$entity = elgg_extract('entity', $vars); +$can_change_access = true; +if ($user && $entity) { + $can_change_access = ($user->isAdmin() || $user->getGUID() == $entity->owner_guid); +} + +foreach ($variables as $name => $type) { + // don't show read / write access inputs for non-owners or admin when editing + if (($type == 'access' || $type == 'write_access') && !$can_change_access) { + continue; + } + + // don't show parent picker input for top or new pages. + if ($name == 'parent_guid' && (!$vars['parent_guid'] || !$vars['guid'])) { + continue; + } + + if ($type == 'parent') { + $input_view = "pages/input/$type"; + } else { + $input_view = "input/$type"; + } + +?> +<div> + <label><?php echo elgg_echo("pages:$name") ?></label> + <?php + if ($type != 'longtext') { + echo '<br />'; + } + + echo elgg_view($input_view, array( + 'name' => $name, + 'value' => $vars[$name], + 'entity' => ($name == 'parent_guid') ? $vars['entity'] : null, + )); + ?> +</div> +<?php +} + +$cats = elgg_view('input/categories', $vars); +if (!empty($cats)) { + echo $cats; +} + + +echo '<div class="elgg-foot">'; +if ($vars['guid']) { + echo elgg_view('input/hidden', array( + 'name' => 'page_guid', + 'value' => $vars['guid'], + )); +} +echo elgg_view('input/hidden', array( + 'name' => 'container_guid', + 'value' => $vars['container_guid'], +)); +if (!$vars['guid']) { + echo elgg_view('input/hidden', array( + 'name' => 'parent_guid', + 'value' => $vars['parent_guid'], + )); +} + +echo elgg_view('input/submit', array('value' => elgg_echo('save'))); + +echo '</div>'; diff --git a/mod/pages/views/default/input/write_access.php b/mod/pages/views/default/input/write_access.php new file mode 100644 index 000000000..69277ca20 --- /dev/null +++ b/mod/pages/views/default/input/write_access.php @@ -0,0 +1,35 @@ +<?php +/** + * Write access + * + * Removes the public option found in input/access + * + * @uses $vars['value'] The current value, if any + * @uses $vars['options_values'] + * @uses $vars['name'] The name of the input field + * @uses $vars['entity'] Optional. The entity for this access control (uses write_access_id) + */ + +$options = get_write_access_array(); +unset($options[ACCESS_PUBLIC]); + +$defaults = array( + 'class' => 'elgg-input-access', + 'disabled' => FALSE, + 'value' => get_default_access(), + 'options_values' => $options, +); + +if (isset($vars['entity'])) { + $defaults['value'] = $vars['entity']->write_access_id; + unset($vars['entity']); +} + +$vars = array_merge($defaults, $vars); + +if ($vars['value'] == ACCESS_DEFAULT) { + $vars['value'] = get_default_access(); +} +$vars['value'] = ($vars['value'] == ACCESS_PUBLIC) ? ACCESS_LOGGED_IN : $vars['value']; + +echo elgg_view('input/dropdown', $vars); diff --git a/mod/pages/views/default/object/page.php b/mod/pages/views/default/object/page.php new file mode 100644 index 000000000..a5e56415d --- /dev/null +++ b/mod/pages/views/default/object/page.php @@ -0,0 +1,8 @@ +<?php +/** + * Page view + * + * @package ElggPages + */ + +echo elgg_view('object/page_top', $vars); diff --git a/mod/pages/views/default/object/page_top.php b/mod/pages/views/default/object/page_top.php new file mode 100644 index 000000000..f35202993 --- /dev/null +++ b/mod/pages/views/default/object/page_top.php @@ -0,0 +1,119 @@ +<?php +/** + * View for page object + * + * @package ElggPages + * + * @uses $vars['entity'] The page object + * @uses $vars['full_view'] Whether to display the full view + * @uses $vars['revision'] This parameter not supported by elgg_view_entity() + */ + + +$full = elgg_extract('full_view', $vars, FALSE); +$page = elgg_extract('entity', $vars, FALSE); +$revision = elgg_extract('revision', $vars, FALSE); + +if (!$page) { + return TRUE; +} + +// pages used to use Public for write access +if ($page->write_access_id == ACCESS_PUBLIC) { + // this works because this metadata is public + $page->write_access_id = ACCESS_LOGGED_IN; +} + + +if ($revision) { + $annotation = $revision; +} else { + $annotation = $page->getAnnotations('page', 1, 0, 'desc'); + if ($annotation) { + $annotation = $annotation[0]; + } +} + +$page_icon = elgg_view('pages/icon', array('annotation' => $annotation, 'size' => 'small')); + +$editor = get_entity($annotation->owner_guid); +$editor_link = elgg_view('output/url', array( + 'href' => "pages/owner/$editor->username", + 'text' => $editor->name, + 'is_trusted' => true, +)); + +$date = elgg_view_friendly_time($annotation->time_created); +$editor_text = elgg_echo('pages:strapline', array($date, $editor_link)); +$categories = elgg_view('output/categories', $vars); + +$comments_count = $page->countComments(); +//only display if there are commments +if ($comments_count != 0 && !$revision) { + $text = elgg_echo("comments") . " ($comments_count)"; + $comments_link = elgg_view('output/url', array( + 'href' => $page->getURL() . '#page-comments', + 'text' => $text, + 'is_trusted' => true, + )); +} else { + $comments_link = ''; +} + +$subtitle = "$editor_text $comments_link $categories"; + +// do not show the metadata and controls in widget view +if (!elgg_in_context('widgets')) { + // If we're looking at a revision, display annotation menu + if ($revision) { + $metadata = elgg_view_menu('annotation', array( + 'annotation' => $annotation, + 'sort_by' => 'priority', + 'class' => 'elgg-menu-hz float-alt', + )); + } else { + // Regular entity menu + $metadata = elgg_view_menu('entity', array( + 'entity' => $vars['entity'], + 'handler' => 'pages', + 'sort_by' => 'priority', + 'class' => 'elgg-menu-hz', + )); + } +} + +if ($full) { + $body = elgg_view('output/longtext', array('value' => $annotation->value)); + + $params = array( + 'entity' => $page, + 'metadata' => $metadata, + 'subtitle' => $subtitle, + ); + $params = $params + $vars; + $summary = elgg_view('object/elements/summary', $params); + + echo elgg_view('object/elements/full', array( + 'entity' => $page, + 'title' => false, + 'icon' => $page_icon, + 'summary' => $summary, + 'body' => $body, + )); + +} else { + // brief view + + $excerpt = elgg_get_excerpt($page->description); + + $params = array( + 'entity' => $page, + 'metadata' => $metadata, + 'subtitle' => $subtitle, + 'content' => $excerpt, + ); + $params = $params + $vars; + $list_body = elgg_view('object/elements/summary', $params); + + echo elgg_view_image_block($page_icon, $list_body); +} diff --git a/mod/pages/views/default/pages/css.php b/mod/pages/views/default/pages/css.php new file mode 100644 index 000000000..24e45cb9d --- /dev/null +++ b/mod/pages/views/default/pages/css.php @@ -0,0 +1,19 @@ +<?php +/** + * Elgg Pages CSS + * + * @package ElggPages + */ +?> + +.pages-nav.treeview ul { + background-color: transparent; +} + +.pages-nav.treeview a.selected { + color: #555555; +} + +.pages-nav.treeview .hover { + color: #0054a7; +}
\ No newline at end of file diff --git a/mod/pages/views/default/pages/group_module.php b/mod/pages/views/default/pages/group_module.php new file mode 100644 index 000000000..0d7df96ac --- /dev/null +++ b/mod/pages/views/default/pages/group_module.php @@ -0,0 +1,49 @@ +<?php +/** + * Group pages + * + * @package ElggPages + */ + + +$group = elgg_get_page_owner_entity(); + +if ($group->pages_enable == "no") { + return true; +} + +$all_link = elgg_view('output/url', array( + 'href' => "pages/group/$group->guid/all", + 'text' => elgg_echo('link:view:all'), + 'is_trusted' => true, +)); + + +elgg_push_context('widgets'); +$options = array( + 'type' => 'object', + 'subtype' => 'page_top', + 'container_guid' => elgg_get_page_owner_guid(), + 'limit' => 6, + 'full_view' => false, + 'pagination' => false, +); +$content = elgg_list_entities($options); +elgg_pop_context(); + +if (!$content) { + $content = '<p>' . elgg_echo('pages:none') . '</p>'; +} + +$new_link = elgg_view('output/url', array( + 'href' => "pages/add/$group->guid", + 'text' => elgg_echo('pages:add'), + 'is_trusted' => true, +)); + +echo elgg_view('groups/profile/module', array( + 'title' => elgg_echo('pages:group'), + 'content' => $content, + 'all_link' => $all_link, + 'add_link' => $new_link, +)); diff --git a/mod/pages/views/default/pages/icon.php b/mod/pages/views/default/pages/icon.php new file mode 100644 index 000000000..cba034ec4 --- /dev/null +++ b/mod/pages/views/default/pages/icon.php @@ -0,0 +1,25 @@ +<?php +/** + * Page icon + * + * Uses a separate icon view due to dependency on annotation + * + * @package ElggPages + * + * @uses $vars['entity'] + * @uses $vars['annotation'] + */ + +$annotation = $vars['annotation']; +$entity = get_entity($annotation->entity_guid); + +// Get size +if (!in_array($vars['size'], array('small', 'medium', 'large', 'tiny', 'master', 'topbar'))) { + $vars['size'] = "medium"; +} + +?> + +<a href="<?php echo $annotation->getURL(); ?>"> + <img alt="<?php echo $entity->title; ?>" src="<?php echo $entity->getIconURL($vars['size']); ?>" /> +</a> diff --git a/mod/pages/views/default/pages/input/parent.php b/mod/pages/views/default/pages/input/parent.php new file mode 100644 index 000000000..c5ee3c3fb --- /dev/null +++ b/mod/pages/views/default/pages/input/parent.php @@ -0,0 +1,37 @@ +<?php +/** + * Parent picker + * + * @uses $vars['value'] The current value, if any + * @uses $vars['options_values'] + * @uses $vars['name'] The name of the input field + * @uses $vars['entity'] Optional. The child entity (uses container_guid) + */ + +elgg_load_library('elgg:pages'); + +if (empty($vars['entity'])) { + $container = elgg_get_page_owner_entity(); +} else { + $container = $vars['entity']->getContainerEntity(); +} + +$pages = pages_get_navigation_tree($container); +$options = array(); + +foreach ($pages as $page) { + $spacing = ""; + for ($i = 0; $i < $page['depth']; $i++) { + $spacing .= "--"; + } + $options[$page['guid']] = "$spacing " . $page['title']; +} + +$defaults = array( + 'class' => 'elgg-pages-input-parent-picker', + 'options_values' => $options, +); + +$vars = array_merge($defaults, $vars); + +echo elgg_view('input/dropdown', $vars); diff --git a/mod/pages/views/default/pages/sidebar.php b/mod/pages/views/default/pages/sidebar.php new file mode 100644 index 000000000..16fc12de0 --- /dev/null +++ b/mod/pages/views/default/pages/sidebar.php @@ -0,0 +1,14 @@ +<?php +/** + * Pages sidebar + */ + +echo elgg_view('page/elements/comments_block', array( + 'subtypes' => array('page', 'page_top'), + 'owner_guid' => elgg_get_page_owner_guid(), +)); + +echo elgg_view('page/elements/tagcloud_block', array( + 'subtypes' => array('page', 'page_top'), + 'owner_guid' => elgg_get_page_owner_guid(), +));
\ No newline at end of file diff --git a/mod/pages/views/default/pages/sidebar/history.php b/mod/pages/views/default/pages/sidebar/history.php new file mode 100644 index 000000000..e0e8ed11a --- /dev/null +++ b/mod/pages/views/default/pages/sidebar/history.php @@ -0,0 +1,21 @@ +<?php +/** + * History of this page + * + * @uses $vars['page'] + */ + +$title = elgg_echo('pages:history'); + +if ($vars['page']) { + $options = array( + 'guid' => $vars['page']->guid, + 'annotation_name' => 'page', + 'limit' => 20, + 'reverse_order_by' => true + ); + elgg_push_context('widgets'); + $content = elgg_list_annotations($options); +} + +echo elgg_view_module('aside', $title, $content);
\ No newline at end of file diff --git a/mod/pages/views/default/pages/sidebar/navigation.php b/mod/pages/views/default/pages/sidebar/navigation.php new file mode 100644 index 000000000..65eb500c8 --- /dev/null +++ b/mod/pages/views/default/pages/sidebar/navigation.php @@ -0,0 +1,58 @@ +<?php +/** + * Navigation menu for a user's or a group's pages + * + * @uses $vars['page'] Page object if manually setting selected item + */ + +// add the jquery treeview files for navigation +elgg_load_js('jquery-treeview'); +elgg_load_css('jquery-treeview'); + + +$selected_page = elgg_extract('page', $vars, false); +if ($selected_page) { + $url = $selected_page->getURL(); +} + +$title = elgg_echo('pages:navigation'); + +pages_register_navigation_tree(elgg_get_page_owner_entity()); + +$content = elgg_view_menu('pages_nav', array('class' => 'pages-nav')); +if (!$content) { + $content = '<p>' . elgg_echo('pages:none') . '</p>'; +} + +echo elgg_view_module('aside', $title, $content); + +?><?php //@todo JS 1.8: no ?> +<script type="text/javascript"> +$(document).ready(function() { + $(".pages-nav").treeview({ + persist: "location", + collapsed: true, + unique: true + }); + +<?php +if ($selected_page) { + // if on a history page, we need to manually select the correct menu item + // code taken from the jquery.treeview library +?> + var current = $(".pages-nav a[href='<?php echo $url; ?>']"); + var items = current.addClass("selected").parents("ul, li").add( current.next() ).show(); + var CLASSES = $.treeview.classes; + items.filter("li") + .swapClass( CLASSES.collapsable, CLASSES.expandable ) + .swapClass( CLASSES.lastCollapsable, CLASSES.lastExpandable ) + .find(">.hitarea") + .swapClass( CLASSES.collapsableHitarea, CLASSES.expandableHitarea ) + .swapClass( CLASSES.lastCollapsableHitarea, CLASSES.lastExpandableHitarea ); +<?php +} +?> + +}); + +</script> diff --git a/mod/pages/views/default/river/object/page/create.php b/mod/pages/views/default/river/object/page/create.php new file mode 100644 index 000000000..4c31def33 --- /dev/null +++ b/mod/pages/views/default/river/object/page/create.php @@ -0,0 +1,13 @@ +<?php +/** + * Page river view. + */ + +$object = $vars['item']->getObjectEntity(); +$excerpt = strip_tags($object->description); +$excerpt = elgg_get_excerpt($excerpt); + +echo elgg_view('river/elements/layout', array( + 'item' => $vars['item'], + 'message' => $excerpt, +));
\ No newline at end of file diff --git a/mod/pages/views/default/river/object/page_top/create.php b/mod/pages/views/default/river/object/page_top/create.php new file mode 100644 index 000000000..b89eed195 --- /dev/null +++ b/mod/pages/views/default/river/object/page_top/create.php @@ -0,0 +1,8 @@ +<?php +/** + * Top page create river view. + * + * @package ElggPages + */ + +echo elgg_view('river/object/page/create', $vars);
\ No newline at end of file diff --git a/mod/pages/views/default/widgets/pages/content.php b/mod/pages/views/default/widgets/pages/content.php new file mode 100644 index 000000000..f63777c09 --- /dev/null +++ b/mod/pages/views/default/widgets/pages/content.php @@ -0,0 +1,32 @@ +<?php +/** + * Elgg pages widget + * + * @package ElggPages + */ + +$num = (int) $vars['entity']->pages_num; + +$options = array( + 'type' => 'object', + 'subtype' => 'page_top', + 'container_guid' => $vars['entity']->owner_guid, + 'limit' => $num, + 'full_view' => FALSE, + 'pagination' => FALSE, +); +$content = elgg_list_entities($options); + +echo $content; + +if ($content) { + $url = "pages/owner/" . elgg_get_page_owner_entity()->username; + $more_link = elgg_view('output/url', array( + 'href' => $url, + 'text' => elgg_echo('pages:more'), + 'is_trusted' => true, + )); + echo "<span class=\"elgg-widget-more\">$more_link</span>"; +} else { + echo elgg_echo('pages:none'); +} diff --git a/mod/pages/views/default/widgets/pages/edit.php b/mod/pages/views/default/widgets/pages/edit.php new file mode 100644 index 000000000..f23514380 --- /dev/null +++ b/mod/pages/views/default/widgets/pages/edit.php @@ -0,0 +1,24 @@ +<?php +/** + * Elgg pages widget edit + * + * @package ElggPages + */ + +// set default value +if (!isset($vars['entity']->pages_num)) { + $vars['entity']->pages_num = 4; +} + +$params = array( + 'name' => 'params[pages_num]', + 'value' => $vars['entity']->pages_num, + 'options' => array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10), +); +$dropdown = elgg_view('input/dropdown', $params); + +?> +<div> + <?php echo elgg_echo('pages:num'); ?>: + <?php echo $dropdown; ?> +</div> |