diff options
Diffstat (limited to 'mod')
26 files changed, 426 insertions, 459 deletions
diff --git a/mod/pages/actions/pages/edit.php b/mod/pages/actions/pages/edit.php index 4487c67a3..e8e7a254a 100644 --- a/mod/pages/actions/pages/edit.php +++ b/mod/pages/actions/pages/edit.php @@ -1,110 +1,79 @@ <?php /** - * Edit a page + * Create or edit a page * * @package ElggPages */ -// Load configuration -global $CONFIG; - -elgg_set_context('pages'); - -//boolean to select correct add to river. It will be new or edit -$which_river = 'new'; - -// Get group fields +$variables = elgg_get_config('pages'); $input = array(); -foreach($CONFIG->pages as $shortname => $valuetype) { - $input[$shortname] = get_input($shortname); - if ($shortname == 'title') { - $input[$shortname] = strip_tags($input[$shortname]); +foreach ($variables as $name => $type) { + $input[$name] = get_input($name); + if ($name == 'title') { + $input[$name] = strip_tags($input[$name]); + } + if ($type == 'tags') { + $input[$name] = string_to_tag_array($input[$name]); } - if ($valuetype == 'tags') - $input[$shortname] = string_to_tag_array($input[$shortname]); } -// Get parent -$parent_guid = (int)get_input('parent_guid', 0); +// Get guids +$page_guid = (int)get_input('page_guid'); +$container_guid = (int)get_input('container_guid'); +$parent_guid = (int)get_input('parent_guid'); -// New or old? -$page = NULL; -$pages_guid = (int)get_input('pages_guid'); +elgg_make_sticky_form('page'); -if ($pages_guid) { - $page = get_entity($pages_guid); - if (!$page->canEdit()) { - $page = NULL; // if we can't edit it, go no further. - } +if (!$input['title']) { + register_error(elgg_echo('pages:error:no_title')); + forward(REFERER); +} - //select river boolean to edit - $which_river = 'edit'; +if ($page_guid) { + $page = get_entity($page_guid); + if (!$page || !$page->canEdit()) { + register_error(elgg_echo('pages:error:no_save')); + forward(REFERER); + } + $new_page = false; } else { $page = new ElggObject(); - if (!$parent_guid) { - $page->subtype = 'page_top'; - } else { + if ($parent_guid) { $page->subtype = 'page'; + } else { + $page->subtype = 'page_top'; } - - // New instance, so set container_guid - $container_guid = get_input('container_guid', get_loggedin_userid()); - $page->container_guid = $container_guid; - - // cache data in session in case data from form does not validate - $_SESSION['page_description'] = $input['description']; - $_SESSION['page_tags'] = get_input('tags'); - $_SESSION['page_read_access'] = (int)get_input('access_id'); - $_SESSION['page_write_access'] = (int)get_input('write_access_id'); + $new_page = true; } -// Have we got it? Can we edit it? -if ($page instanceof ElggObject) { - // Save fields - note we always save latest description as both description and annotation - if (sizeof($input) > 0) { - foreach($input as $shortname => $value) { - $page->$shortname = $value; - } +if (sizeof($input) > 0) { + foreach ($input as $name => $value) { + $page->$name = $value; } +} - if (!$page->title) { - register_error(elgg_echo("pages:notitle")); +// need to add check to make sure user can write to container +$page->container_guid = $container_guid; - forward(REFERER); - } - - $page->access_id = (int)get_input('access_id', ACCESS_PRIVATE); - $page->write_access_id = (int)get_input('write_access_id', ACCESS_PRIVATE); +if ($parent_guid) { $page->parent_guid = $parent_guid; - $page->owner_guid = ($page->owner_guid ? $page->owner_guid : get_loggedin_userid()); - - if ($page->save()) { +} - // Now save description as an annotation - $page->annotate('page', $page->description, $page->access_id); +if ($page->save()) { - // clear cache - unset($_SESSION['page_description']); - unset($_SESSION['page_tags']); - unset($_SESSION['page_read_access']); - unset($_SESSION['page_write_access']); + elgg_clear_sticky_form('page'); - system_message(elgg_echo("pages:saved")); + // Now save description as an annotation + $page->annotate('page', $page->description, $page->access_id); - //add to river - if ($which_river == 'new') { - add_to_river('river/object/page/create','create',get_loggedin_userid(),$page->guid); - } + system_message(elgg_echo('pages:saved')); - // Forward to the user's profile - forward($page->getUrl()); - } else { - register_error(elgg_echo('pages:notsaved')); + if ($new_page) { + add_to_river('river/object/page/create', 'create', get_loggedin_userid(), $page->guid); } + forward($page->getURL()); } else { - register_error(elgg_echo("pages:noaccess")); + register_error(elgg_echo('pages:error:no_save')); + forward(REFERER); } - -// Forward to the user's profile -forward($page->getUrl());
\ No newline at end of file diff --git a/mod/pages/edit.php b/mod/pages/edit.php index 23b6cc168..8e530084b 100644 --- a/mod/pages/edit.php +++ b/mod/pages/edit.php @@ -26,7 +26,8 @@ elgg_push_breadcrumb(elgg_echo('edit')); $title = elgg_echo("pages:edit"); if ($page->canEdit()) { - $content = elgg_view("forms/pages/edit", array('entity' => $page)); + $vars = pages_prepare_form_vars($page); + $content = elgg_view_form('pages/edit', array(), $vars); } else { $content = elgg_echo("pages:noaccess"); } diff --git a/mod/pages/friends.php b/mod/pages/friends.php index fd2e01833..1f047701e 100644 --- a/mod/pages/friends.php +++ b/mod/pages/friends.php @@ -1,6 +1,6 @@ <?php /** - * Elgg Pages list + * List a user's friends' pages * * @package ElggPages */ diff --git a/mod/pages/history.php b/mod/pages/history.php index 7a13ae484..cb8a52ee2 100644 --- a/mod/pages/history.php +++ b/mod/pages/history.php @@ -1,6 +1,6 @@ <?php /** - * Elgg Pages + * History of revisions of a page * * @package ElggPages */ @@ -19,6 +19,7 @@ if (!$container) { elgg_set_page_owner_guid($container->getGUID()); +elgg_push_breadcrumb($container->name, $container->getURL()); elgg_push_breadcrumb($page->title, $page->getURL()); elgg_push_breadcrumb(elgg_echo('pages:history')); diff --git a/mod/pages/index.php b/mod/pages/index.php index 2da53ed7b..b257b14b4 100644 --- a/mod/pages/index.php +++ b/mod/pages/index.php @@ -1,6 +1,6 @@ <?php /** - * Elgg Pages list + * List a user's or group's pages * * @package ElggPages */ @@ -32,6 +32,7 @@ $params = array( 'filter_context' => 'mine', 'content' => $content, 'title' => $title, + 'sidebar' => elgg_view('pages/sidebar/navigation'), ); if (elgg_instanceof($owner, 'group')) { diff --git a/mod/pages/languages/en.php b/mod/pages/languages/en.php index eab972343..1cb879edc 100644 --- a/mod/pages/languages/en.php +++ b/mod/pages/languages/en.php @@ -22,10 +22,11 @@ $english = array( 'pages:edit' => "Edit this page", 'pages:delete' => "Delete this page", - 'pages:history' => "Page history", + 'pages:history' => "History", 'pages:view' => "View page", + 'pages:revision' => "Revision", - 'pages:navigation' => "Page navigation", + 'pages:navigation' => "Navigation", 'pages:via' => "via pages", 'item:object:page_top' => 'Top-level pages', 'item:object:page' => 'Pages', @@ -74,7 +75,7 @@ $english = array( /** * History */ - 'pages:revision' => 'Revision created %s by %s', + 'pages:revision:subtitle' => 'Revision created %s by %s', /** * Widget diff --git a/mod/pages/lib/pages.php b/mod/pages/lib/pages.php index 943383fd7..e3ed3c822 100644 --- a/mod/pages/lib/pages.php +++ b/mod/pages/lib/pages.php @@ -6,10 +6,10 @@ /** * Prepare the add/edit form variables * - * @param ElggOobject $page + * @param ElggObject $page * @return array */ -function pages_prepare_form_vars($page = null) { +function pages_prepare_form_vars($page = null, $parent_guid = 0) { // input names => defaults $values = array( @@ -21,11 +21,12 @@ function pages_prepare_form_vars($page = null) { 'container_guid' => elgg_get_page_owner_guid(), 'guid' => null, 'entity' => $page, + 'parent_guid' => $parent_guid, ); if ($page) { foreach (array_keys($values) as $field) { - $values[$field] = $file->$field; + $values[$field] = $page->$field; } } @@ -39,3 +40,67 @@ function pages_prepare_form_vars($page = null) { return $values; } + +/** + * Register the navigation menu + * + * @param ElggEntity $container Container entity for the pages + */ +function pages_register_navigation_tree($container) { + if (!$container) { + return; + } + + $top_pages = elgg_get_entities(array( + 'type' => 'object', + 'subtype' => 'page_top', + 'container_guid' => $container->getGUID, + )); + + foreach ($top_pages as $page) { + elgg_register_menu_item('pages_nav', array( + 'name' => $page->getGUID(), + 'title' => $page->title, + 'url' => $page->getURL(), + )); + + $stack = array(); + array_push($stack, $page); + while (count($stack) > 0) { + $parent = array_pop($stack); + $children = elgg_get_entities_from_metadata(array( + 'type' => 'object', + 'subtype' => 'page', + 'metadata_name' => 'parent_guid', + 'metadata_value' => $parent->getGUID(), + )); + + foreach ($children as $child) { + elgg_register_menu_item('pages_nav', array( + 'name' => $child->getGUID(), + 'title' => $child->title, + 'url' => $child->getURL(), + 'parent_name' => $parent->getGUID(), + )); + array_push($stack, $child); + } + } + } +} + +/** + * Return the correct sidebar for a given entity + * + * @param ElggObject $entity + */ +function pages_get_entity_sidebar(ElggObject $entity, $fulltree = 0) { + $body = ""; + + $children = elgg_get_entities_from_metadata(array('metadata_names' => 'parent_guid', 'metadata_values' => $entity->guid, 'limit' => 9999)); + $body .= elgg_view('pages/sidebar/sidebarthis', array('entity' => $entity, + 'children' => $children, + 'fulltree' => $fulltree)); + //$body = elgg_view('pages/sidebar/wrapper', array('body' => $body)); + + return $body; +} diff --git a/mod/pages/new.php b/mod/pages/new.php index 8a51d9f03..31b0c7951 100644 --- a/mod/pages/new.php +++ b/mod/pages/new.php @@ -7,24 +7,26 @@ gatekeeper(); -$container_guid = get_input('guid'); - +$container_guid = (int) get_input('guid'); $container = get_entity($container_guid); if (!$container) { } +$parent_page = null; $page_owner = $container; if (elgg_instanceof($container, 'object')) { + $parent_page = $container; $page_owner = $container->getContainerEntity(); } -elgg_set_page_owner_guid($page_owner->getGUID); +elgg_set_page_owner_guid($page_owner->getGUID()); $title = elgg_echo('pages:add'); elgg_push_breadcrumb($title); -$content = elgg_view("forms/pages/edit"); +$vars = pages_prepare_form_vars(null, $parent_page->getGUID()); +$content = elgg_view_form('pages/edit', array(), $vars); $body = elgg_view_layout('content', array( 'filter' => '', diff --git a/mod/pages/revision.php b/mod/pages/revision.php new file mode 100644 index 000000000..e301e26df --- /dev/null +++ b/mod/pages/revision.php @@ -0,0 +1,49 @@ +<?php +/** + * View a revision of page + * + * @package ElggPages + */ + +$id = get_input('id'); +$annotation = get_annotation($id); +if (!$annotation) { + forward(); +} + +$page = get_entity($annotation->entity_guid); +if (!$page) { + +} + +elgg_set_page_owner_guid($page->getContainerGUID()); + +group_gatekeeper(); + +$container = elgg_get_page_owner(); +if (!$container) { +} + +$title = $page->title . ": " . elgg_echo('pages:revision'); + +elgg_push_breadcrumb($container->name, $container->getURL()); +elgg_push_breadcrumb($page->title, $page->getURL()); +elgg_push_breadcrumb(elgg_echo('pages:revision')); + +$content = elgg_view('object/page_top', array( + 'entity' => $page, + 'revision' => $annotation, + 'full' => true, +)); + +$sidebar = elgg_view('pages/sidebar/tree', array('page' => $page)); + +$body = elgg_view_layout('content', array( + 'filter' => '', + 'buttons' => '', + 'content' => $content, + 'title' => $title, + 'sidebar' => $sidebar, +)); + +echo elgg_view_page($title, $body); diff --git a/mod/pages/start.php b/mod/pages/start.php index 16b73cce6..5872e6b11 100644 --- a/mod/pages/start.php +++ b/mod/pages/start.php @@ -26,6 +26,7 @@ function pages_init() { // Register a url handler register_entity_url_handler('pages_url', 'object', 'page_top'); register_entity_url_handler('pages_url', 'object', 'page'); + register_extender_url_handler('pages_revision_url', 'annotation', 'page'); // Register some actions $action_base = elgg_get_plugin_path() . 'pages/actions/pages'; @@ -76,14 +77,15 @@ function pages_init() { /** * Dispatcher for pages. * URLs take the form of - * All pages: pg/pages/all - * User's pages: pg/pages/owner/<username> - * Friends' pages: pg/pages/friends/<username> - * View page: pg/pages/view/<guid>/<title> - * New page: pg/pages/add/<guid> (container: user, group, parent) - * Edit page: pg/pages/edit/<guid> - * History of page: pg/pages/history/<guid> - * Group pages: pg/pages/group/<guid>/owner + * All pages: pg/pages/all + * User's pages: pg/pages/owner/<username> + * Friends' pages: pg/pages/friends/<username> + * View page: pg/pages/view/<guid>/<title> + * New page: pg/pages/add/<guid> (container: user, group, parent) + * Edit page: pg/pages/edit/<guid> + * History of page: pg/pages/history/<guid> + * Revision of page: pg/pages/revision/<id> + * Group pages: pg/pages/group/<guid>/owner * * Title is ignored * @@ -132,6 +134,10 @@ function pages_page_handler($page) { set_input('guid', $page[1]); include "$base_dir/history.php"; break; + case 'revision': + set_input('id', $page[1]); + include "$base_dir/revision.php"; + break; case 'all': default: include "$base_dir/world.php"; @@ -153,6 +159,16 @@ function pages_url($entity) { } /** + * Override the page annotation url + * + * @param ElggAnnotation $annotation + * @return string + */ +function pages_revision_url($annotation) { + return "pg/pages/revision/$annotation->id"; +} + +/** * Add a menu item to the user ownerblock */ function pages_owner_block_menu($hook, $type, $return, $params) { @@ -242,24 +258,6 @@ function pages_get_path($guid) { } /** - * Return the correct sidebar for a given entity - * - * @param ElggObject $entity - */ -function pages_get_entity_sidebar(ElggObject $entity, $fulltree = 0) -{ - $body = ""; - - $children = elgg_get_entities_from_metadata(array('metadata_names' => 'parent_guid', 'metadata_values' => $entity->guid, 'limit' => 9999)); - $body .= elgg_view('pages/sidebar/sidebarthis', array('entity' => $entity, - 'children' => $children, - 'fulltree' => $fulltree)); - //$body = elgg_view('pages/sidebar/wrapper', array('body' => $body)); - - return $body; -} - -/** * Extend permissions checking to extend can-edit for write users. * * @param unknown_type $hook diff --git a/mod/pages/views/default/annotation/icon.php b/mod/pages/views/default/annotation/icon.php deleted file mode 100644 index 42d32b021..000000000 --- a/mod/pages/views/default/annotation/icon.php +++ /dev/null @@ -1,26 +0,0 @@ -<?php -/** - * @todo What is this doing here? - * - * @package ElggPages - */ - -$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"; - -// Get any align and js -if (!empty($vars['align'])) { - $align = " align=\"{$vars['align']}\" "; -} else { - $align = ""; -} - -?> - -<div class="groupicon"> -<a href="<?php echo $entity->getURL() . "?rev=" . $annotation->id; ?>"><img src="<?php echo $entity->getIcon($vars['size']); ?>" border="0" <?php echo $align; ?> <?php echo $vars['js']; ?> /></a> -</div> diff --git a/mod/pages/views/default/annotation/page.php b/mod/pages/views/default/annotation/page.php index 53f38831f..87d32e23b 100644 --- a/mod/pages/views/default/annotation/page.php +++ b/mod/pages/views/default/annotation/page.php @@ -1,34 +1,40 @@ <?php /** - * Default page listing? + * Revision view for history page * * @package ElggPages */ $annotation = $vars['annotation']; -$entity = get_entity($annotation->entity_guid); +$page = get_entity($annotation->entity_guid); -$icon = elgg_view( - "annotation/icon", array( - 'annotation' => $vars['annotation'], - 'size' => 'small', - ) -); +$icon = elgg_view("pages/icon", array( + 'annotation' => $annotation, + 'size' => 'small', +)); $owner_guid = $annotation->owner_guid; $owner = get_entity($owner_guid); +if (!$owner) { -$rev = elgg_echo('pages:revision', - array(elgg_view_friendly_time($annotation->time_created)), - "<a href=\"" . $owner->getURL() . "\">" . $owner->name ."</a>" -); +} +$owner_link = elgg_view('output/url', array( + 'href' => $owner->getURL(), + 'text' => $owner->name, +)); -$link = $entity->getURL() . "?rev=" . $annotation->id; +$date = elgg_view_friendly_time($annotation->time_created); -$info = <<< END +$title_link = elgg_view('output/url', array( + 'href' => $annotation->getURL(), + 'text' => $page->title, +)); -<div><a href="$link">{$entity->title}</a></div> -<div>$rev</div> -END; +$subtitle = elgg_echo('pages:revision:subtitle', array($date, $owner_link)); -echo elgg_view_listing($icon, $info); +$body = <<< HTML +<h3>$title_link</h3> +<p class="elgg-subtitle">$subtitle</p> +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 index 94e969a57..e4188a29b 100644 --- a/mod/pages/views/default/forms/pages/edit.php +++ b/mod/pages/views/default/forms/pages/edit.php @@ -5,92 +5,44 @@ * @package ElggPages */ -$parent_guid = get_input('parent_guid'); -$container_guid = get_input('container_guid'); -if (!$container_guid) { - $container_guid = elgg_get_page_owner_guid(); -} - -$new_page = false; -if (!$vars['entity']) { - $new_page = true; - - // bootstrap the access permissions in the entity array so we can use defaults - if (defined('ACCESS_DEFAULT')) { - $vars['entity']->access_id = ACCESS_DEFAULT; - $vars['entity']->write_access_id = ACCESS_DEFAULT; - } else { - $vars['entity']->access_id = 0; - $vars['entity']->write_access_id = 0; - } - - // pull in sticky values from session - if (isset($_SESSION['page_description'])) { - $vars['entity']->description = $_SESSION['page_description']; - $vars['entity']->tags = $_SESSION['page_tags']; - $vars['entity']->access_id = $_SESSION['page_read_access']; - $vars['entity']->write_access_id = $_SESSION['page_write_access']; - - // clear them - unset($_SESSION['page_description']); - unset($_SESSION['page_tags']); - unset($_SESSION['page_read_access']); - unset($_SESSION['page_write_access']); - } -} -?> -<div class="contentWrapper"> -<form action="<?php echo elgg_get_site_url(); ?>action/pages/edit" method="post"> -<?php -echo elgg_view('input/securitytoken'); -if (is_array($vars['config']->pages) && sizeof($vars['config']->pages) > 0) { - foreach($vars['config']->pages as $shortname => $valtype) { +$variables = elgg_get_config('pages'); +foreach ($variables as $name => $type) { ?> - <p> - <label> - <?php echo elgg_echo("pages:{$shortname}") ?><br /> - <?php echo elgg_view("input/{$valtype}",array( - 'internalname' => $shortname, - 'value' => $vars['entity']->$shortname - )); ?> - </label> + <label><?php echo elgg_echo("pages:$name") ?></label><br /> + <?php echo elgg_view("input/$type", array( + 'internalname' => $name, + 'value' => $vars[$name], + )); + ?> </p> - <?php - - } } $cats = elgg_view('categories', $vars); if (!empty($cats)) { -?> -<p> - <?php - echo $cats; - ?> -</p> -<?php + echo "<p>$cats</p>"; +} - } -?> -<p> -<?php -if (!$new_page) { - ?><input type="hidden" name="pages_guid" value="<?php echo $vars['entity']->getGUID(); ?>" /><?php +echo '<p>'; +if ($vars['guid']) { + echo elgg_view('input/hidden', array( + 'internalname' => 'page_guid', + 'value' => $vars['guid'], + )); } - -if ($container_guid) { - ?><input type="hidden" name="container_guid" value="<?php echo $container_guid; ?>" /><?php +echo elgg_view('input/hidden', array( + 'internalname' => 'container_guid', + 'value' => $vars['container_guid'], +)); +if ($vars['parent_guid']) { + echo elgg_view('input/hidden', array( + 'internalname' => 'parent_guid', + 'value' => $vars['parent_guid'], + )); } -?> - <input type="hidden" name="parent_guid" value="<?php if (!$new_page) echo $vars['entity']->parent_guid; else echo $parent_guid; ?>" /> - <input type="hidden" name="owner_guid" value="<?php if (!$new_page) echo $vars['entity']->owner_guid; else echo elgg_get_page_owner_guid(); ?>" /> -<?php - echo elgg_view('input/submit', array('value' => elgg_echo('save'))); -?> -</p> -</form> -</div>
\ No newline at end of file +echo elgg_view('input/submit', array('value' => elgg_echo('save'))); + +echo '</p>'; diff --git a/mod/pages/views/default/object/page.php b/mod/pages/views/default/object/page.php index dbca0755b..a5e56415d 100644 --- a/mod/pages/views/default/object/page.php +++ b/mod/pages/views/default/object/page.php @@ -5,12 +5,4 @@ * @package ElggPages */ -if ($vars['full']) { - echo elgg_view("pages/pageprofile", $vars); -} else { - if (get_input('listtype') == "gallery") { - echo elgg_view('pages/pagegallery', $vars); - } else { - echo elgg_view("pages/pagelisting", $vars); - } -}
\ No newline at end of file +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 index d1a9ef7e8..9770dce23 100644 --- a/mod/pages/views/default/object/page_top.php +++ b/mod/pages/views/default/object/page_top.php @@ -3,30 +3,45 @@ * View for page object * * @package ElggPages + * + * @uses $vars['entity'] The page object + * @uses $vars['full'] Whether to display the full view + * @uses $vars['revision'] This parameter not supported by elgg_view_entity() */ $full = elgg_get_array_value('full', $vars, FALSE); $page = elgg_get_array_value('entity', $vars, FALSE); +$revision = elgg_get_array_value('revision', $vars, FALSE); if (!$page) { return TRUE; } -$owner = $page->getOwnerEntity(); -$owner_icon = elgg_view('profile/icon', array('entity' => $owner, 'size' => 'tiny')); -$owner_link = elgg_view('output/url', array( - 'href' => "pg/pages/owner/$owner->username", - 'text' => $owner->name, +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' => "pg/pages/owner/$editor->username", + 'text' => $editor->name, )); -$author_text = elgg_echo('blog:author_by_line', array($owner_link)); + +$date = elgg_view_friendly_time($annotation->time_created); +$editor_text = elgg_echo('pages:strapline', array($date, $editor_link)); $tags = elgg_view('output/tags', array('tags' => $page->tags)); -$date = elgg_view_friendly_time($page->time_created); -$excerpt = elgg_get_excerpt($page->description); $comments_count = elgg_count_comments($page); //only display if there are commments -if ($comments_count != 0) { +if ($comments_count != 0 && !$revision) { $text = elgg_echo("comments") . " ($comments_count)"; $comments_link = elgg_view('output/url', array( 'href' => $page->getURL() . '#page-comments', @@ -36,20 +51,26 @@ if ($comments_count != 0) { $comments_link = ''; } +$history_link = elgg_view('output/url', array( + 'href' => "pg/pages/history/$page->guid", + 'text' => elgg_echo('pages:history'), +)); + $metadata = elgg_view('layout/objects/list/metadata', array( 'entity' => $page, 'handler' => 'pages', + 'links' => array($history_link), )); -$subtitle = "$author_text $date $categories $comments_link"; +$subtitle = "$editor_text $categories $comments_link"; // do not show the metadata and controls in widget view -if (elgg_in_context('widgets')) { +if (elgg_in_context('widgets') || $revision) { $metadata = ''; } if ($full) { - $body = elgg_view('output/longtext', array('value' => $page->description)); + $body = elgg_view('output/longtext', array('value' => $annotation->value)); $params = array( 'entity' => $page, @@ -60,7 +81,7 @@ if ($full) { ); $list_body = elgg_view('layout/objects/list/body', $params); - $info = elgg_view_image_block($owner_icon, $list_body); + $info = elgg_view_image_block($page_icon, $list_body); echo <<<HTML $info @@ -70,6 +91,8 @@ HTML; } else { // brief view + $excerpt = elgg_get_excerpt($page->description); + $params = array( 'entity' => $page, 'metadata' => $metadata, @@ -79,5 +102,5 @@ HTML; ); $list_body = elgg_view('layout/objects/list/body', $params); - echo elgg_view_image_block($owner_icon, $list_body); + 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 index 48991b904..245c39b47 100644 --- a/mod/pages/views/default/pages/css.php +++ b/mod/pages/views/default/pages/css.php @@ -6,6 +6,11 @@ */ ?> +.pages-nav .elgg-child-menu { + display: none; + margin-left: 15px; +} + .treeview, .treeview ul { padding: 0; margin: 0; 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..2e6b7f6ec --- /dev/null +++ b/mod/pages/views/default/pages/group_module.php @@ -0,0 +1,51 @@ +<?php +/** + * Group pages + * + * @package ElggPages + */ + + +$group = elgg_get_page_owner(); + +if ($group->pages_enable == "no") { + return true; +} + +$all_link = elgg_view('output/url', array( + 'href' => "pg/pages/group/$group->guid/owner", + 'text' => elgg_echo('link:view:all'), +)); + +$header = "<span class=\"group-widget-viewall\">$all_link</span>"; +$header .= '<h3>' . elgg_echo('pages:group') . '</h3>'; + + +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' => "pg/pages/add/$group->guid", + 'text' => elgg_echo('pages:add'), +)); +$content .= "<span class='elgg-widget-more'>$new_link</span>"; + + +$params = array( + 'header' => $header, + 'body' => $content, +); +echo elgg_view('layout/objects/module', $params); diff --git a/mod/pages/views/default/pages/groupprofile_pages.php b/mod/pages/views/default/pages/groupprofile_pages.php deleted file mode 100644 index 8069cdd8b..000000000 --- a/mod/pages/views/default/pages/groupprofile_pages.php +++ /dev/null @@ -1,28 +0,0 @@ -<?php -/** - * Page icon override medium - * - * @package ElggPages - */ - -//check to make sure this group forum has been activated -if ($vars['entity']->pages_enable != 'no') { -?> - -<div id="group_pages_widget"> -<h2><?php echo elgg_echo("pages:groupprofile"); ?></h2> -<?php - - $objects = elgg_list_entities(array('types' => 'object', 'subtypes' => 'page_top', 'container_guid' => elgg_get_page_owner_guid(), 'limit' => 5, 'full_view' => FALSE)); - - if($objects) - echo $objects; - else - echo "<div class=\"forum_latest\">" . elgg_echo("pages:nogroup") . "</div>"; - -?> -<br class="clearfloat" /> -</div> - -<?php - } diff --git a/mod/pages/views/default/pages/icon.php b/mod/pages/views/default/pages/icon.php new file mode 100644 index 000000000..fd084bca7 --- /dev/null +++ b/mod/pages/views/default/pages/icon.php @@ -0,0 +1,27 @@ +<?php +/** + * Page icon + * + * @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"; +} + +if (!empty($vars['align'])) { + $align = " align=\"{$vars['align']}\" "; +} else { + $align = ""; +} + +?> + +<a href="<?php echo $annotation->getURL(); ?>"><img src="<?php echo $entity->getIcon($vars['size']); ?>" <?php echo $align; ?> /></a> diff --git a/mod/pages/views/default/pages/pagegallery.php b/mod/pages/views/default/pages/pagegallery.php deleted file mode 100644 index 0dadb63c2..000000000 --- a/mod/pages/views/default/pages/pagegallery.php +++ /dev/null @@ -1,31 +0,0 @@ -<?php -/** - * Elgg Pages gallery listing. - * - * @package ElggPages - */ - -$icon = elgg_view( - "graphics/icon", array( - 'entity' => $vars['entity'], - 'size' => 'medium', - ) -); - -$info = "<div><p><b><a href=\"" . $vars['entity']->getUrl() . "\">" . $vars['entity']->title . "</a></b></p></div>"; - -$latest = $vars['entity']->getAnnotations('page', 1, 0, 'desc'); -if ($latest) { - $latest = $latest[0]; - - $time_updated = $latest->time_created; - $owner_guid = $latest->owner_guid; - $owner = get_entity($owner_guid); - - - $info .= "<br /><div>". - strip_tags(substr($latest->value, 0, 100)) - . "</div>"; -} - -echo elgg_view_listing($icon, $info);
\ No newline at end of file diff --git a/mod/pages/views/default/pages/pagelisting.php b/mod/pages/views/default/pages/pagelisting.php deleted file mode 100644 index b5034313f..000000000 --- a/mod/pages/views/default/pages/pagelisting.php +++ /dev/null @@ -1,32 +0,0 @@ -<?php -/** - * Elgg Pages flat listing - * - * @package ElggPages - */ - -$icon = elgg_view( - "graphics/icon", array( - 'entity' => $vars['entity'], - 'size' => 'small', - ) - ); - -$info .= "<p><b><a href=\"" . $vars['entity']->getUrl() . "\">" . $vars['entity']->title . "</a></b></p>"; - -$latest = $vars['entity']->getAnnotations('page', 1, 0, 'desc'); -if ($latest) { - $latest = $latest[0]; - - $time_updated = $latest->time_created; - $owner_guid = $latest->owner_guid; - $owner = get_entity($owner_guid); - - - $info .= "<p class=\"owner_timestamp\">" . elgg_echo("pages:strapline", - array(elgg_view_friendly_time($time_updated), - "<a href=\"" . $owner->getURL() . "\">" . $owner->name ."</a>" - )) . "</p>"; -} - -echo elgg_view_listing($icon, $info); diff --git a/mod/pages/views/default/pages/pageprofile.php b/mod/pages/views/default/pages/pageprofile.php deleted file mode 100644 index f8399556a..000000000 --- a/mod/pages/views/default/pages/pageprofile.php +++ /dev/null @@ -1,74 +0,0 @@ -<?php -/** - * Elgg Pages profile - * - * @package ElggPages - */ - -// Output body -$entity = $vars['entity']; - -$rev = (int)get_input('rev'); - -if ($rev) { - $latest = get_annotation($rev); -} else { - $latest = $entity->getAnnotations('page', 1, 0, 'desc'); - if ($latest) $latest = $latest[0]; -} -?> -<div class="contentWrapper"> - <div id="pages_page"> - - <?php - if ($entity) { - echo elgg_view('output/longtext', array('value' => /*$entity->description*/ $latest->value)); - - $tags = $vars['entity']->tags; - if (!empty($tags)) { - - ?> - <!-- display tags --> - <p class="tags"> - <?php - - echo elgg_view('output/tags', array('tags' => $tags)); - - ?> - </p> - - <?php - - } - $cats = elgg_view('categories/view',$vars); - if (!empty($cats)) { - - ?> - <p class="categories"> - <?php echo $cats; ?> - </p> - <?php - - } - } - - // last edit & by whome - ?> - - <p class="strapline"> - <?php - - $time_updated = $latest->time_created; - $owner_guid = $latest->owner_guid; - $owner = get_entity($owner_guid); - - echo elgg_echo("pages:strapline", - array(elgg_view_friendly_time($time_updated), - "<a href=\"" . $owner->getURL() . "\">" . $owner->name ."</a>" - )); - - ?> - </p> - </div> - -</div> 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..ddd931dab --- /dev/null +++ b/mod/pages/views/default/pages/sidebar/navigation.php @@ -0,0 +1,16 @@ +<?php +/** + * Navigation menu for a user's or a group's pages + */ + +$title = elgg_echo('pages:navigation'); + +pages_register_navigation_tree(elgg_get_page_owner()); + +$content = elgg_view_menu('pages_nav', array('class' => 'pages-nav')); + +echo elgg_view('layout/objects/module', array( + 'title' => $title, + 'body' => $content, + 'class' => 'elgg-aside-module', +)); diff --git a/mod/pages/views/default/widgets/pages/content.php b/mod/pages/views/default/widgets/pages/content.php index f42a1a85f..63a2d8e7e 100644 --- a/mod/pages/views/default/widgets/pages/content.php +++ b/mod/pages/views/default/widgets/pages/content.php @@ -1,27 +1,31 @@ -<style type="text/css"> -#pages_widget .pagination { - display:none; -} -</style> <?php - /** - * Elgg pages widget edit + * Elgg pages widget * * @package ElggPages */ -$num_display = (int) $vars['entity']->pages_num; +$num = (int) $vars['entity']->pages_num; -if (!$num_display) { - $num_display = 4; -} +$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); -$pages = elgg_list_entities(array('types' => 'object', 'subtypes' => 'page_top', 'container_guid' => elgg_get_page_owner_guid(), 'limit' => $num_display, 'full_view' => FALSE)); +echo $content; -if ($pages) { - $pagesurl = elgg_get_site_url() . "pg/pages/owned/" . elgg_get_page_owner()->username; - $pages .= "<div class=\"pages_widget_singleitem_more\"><a href=\"{$pagesurl}\">" . elgg_echo('pages:more') . "</a></div>"; +if ($content) { + $url = "pg/pages/owner/" . elgg_get_page_owner()->username; + $more_link = elgg_view('output/url', array( + 'href' => $url, + 'text' => elgg_echo('pages:more'), + )); + echo "<span class=\"elgg-widget-more\">$more_link</span>"; +} else { + echo elgg_echo('pages:none'); } - -echo "<div id=\"pages_widget\">" . $pages . "</div>";
\ No newline at end of file diff --git a/mod/pages/views/default/widgets/pages/edit.php b/mod/pages/views/default/widgets/pages/edit.php index 4ddfec428..7e76e69d5 100644 --- a/mod/pages/views/default/widgets/pages/edit.php +++ b/mod/pages/views/default/widgets/pages/edit.php @@ -5,24 +5,20 @@ * @package ElggPages */ +// set default value if (!isset($vars['entity']->pages_num)) { $vars['entity']->pages_num = 4; } -?> -<p> -<?php echo elgg_echo("pages:num"); ?>: -<select name="params[pages_num]"> - -<?php -for ($i=1; $i<=10; $i++) { - $selected = ''; - if ($vars['entity']->pages_num == $i) { - $selected = "selected='selected'"; - } +$params = array( + 'internalname' => 'params[pages_num]', + 'value' => $vars['entity']->pages_num, + 'options' => array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10), +); +$dropdown = elgg_view('input/pulldown', $params); - echo " <option value='{$i}' $selected >{$i}</option>\n"; -} ?> -</select> +<p> + <?php echo elgg_echo('pages:num'); ?>: + <?php echo $dropdown; ?> </p> diff --git a/mod/pages/world.php b/mod/pages/world.php index e3b158c1e..2a7ea4be9 100644 --- a/mod/pages/world.php +++ b/mod/pages/world.php @@ -1,6 +1,6 @@ <?php /** - * All pages + * List all pages * * @package ElggPages */ @@ -10,7 +10,6 @@ $title = elgg_echo('pages:all'); elgg_pop_breadcrumb(); elgg_push_breadcrumb(elgg_echo('pages')); -// Get objects $content = elgg_list_entities(array( 'types' => 'object', 'subtypes' => 'page_top', |