]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
standardized thewire plugin
authorcash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>
Sat, 26 Mar 2011 15:23:08 +0000 (15:23 +0000)
committercash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>
Sat, 26 Mar 2011 15:23:08 +0000 (15:23 +0000)
git-svn-id: http://code.elgg.org/elgg/trunk@8841 36083f99-b078-4883-b0ff-0f9b5a30f544

14 files changed:
mod/thewire/actions/add.php
mod/thewire/actions/delete.php
mod/thewire/classes/ElggWire.php
mod/thewire/languages/en.php
mod/thewire/pages/thewire/everyone.php
mod/thewire/pages/thewire/friends.php
mod/thewire/pages/thewire/owner.php
mod/thewire/pages/thewire/reply.php
mod/thewire/pages/thewire/thread.php
mod/thewire/start.php
mod/thewire/tests/regex.php
mod/thewire/views/default/object/thewire.php
mod/thewire/views/default/thewire/profile_status.php
mod/thewire/views/rss/object/thewire.php

index 33936d5eea4bca2ce160048bfc57ea94adc82872..97b6306780bff77820e0cff19a297419b3097f56 100644 (file)
@@ -1,33 +1,34 @@
-<?php\r
-/**\r
- * Action for adding a wire post\r
- * \r
- */\r
-\r
-// Get input data\r
-$body = get_input('body', '', false); // don't filter since we strip and filter escapes some characters\r
-$access_id = ACCESS_PUBLIC;\r
-$method = 'site';\r
-$parent_guid = (int) get_input('parent_guid');\r
-\r
-// make sure the post isn't blank\r
-if (empty($body)) {\r
-       register_error(elgg_echo("thewire:blank"));\r
-       forward(REFERER);\r
-}\r
-\r
-$guid = thewire_save_post($body, get_loggedin_userid(), $access_id, $parent_guid, $method);\r
-if (!$guid) {\r
-       register_error(elgg_echo("thewire:error"));\r
-       forward(REFERER);\r
-}\r
-\r
-// Send response to original poster if not already registered to receive notification\r
-if ($parent_guid) {\r
-       thewire_send_response_notification($guid, $parent_guid, $user);\r
-       $parent = get_entity($parent_guid);\r
-       forward("thewire/thread/$parent->wire_thread");\r
-}\r
-\r
-system_message(elgg_echo("thewire:posted"));\r
-forward(REFERER);\r
+<?php
+/**
+ * Action for adding a wire post
+ * 
+ */
+
+// don't filter since we strip and filter escapes some characters
+$body = get_input('body', '', false);
+
+$access_id = ACCESS_PUBLIC;
+$method = 'site';
+$parent_guid = (int) get_input('parent_guid');
+
+// make sure the post isn't blank
+if (empty($body)) {
+       register_error(elgg_echo("thewire:blank"));
+       forward(REFERER);
+}
+
+$guid = thewire_save_post($body, get_loggedin_userid(), $access_id, $parent_guid, $method);
+if (!$guid) {
+       register_error(elgg_echo("thewire:error"));
+       forward(REFERER);
+}
+
+// Send response to original poster if not already registered to receive notification
+if ($parent_guid) {
+       thewire_send_response_notification($guid, $parent_guid, $user);
+       $parent = get_entity($parent_guid);
+       forward("thewire/thread/$parent->wire_thread");
+}
+
+system_message(elgg_echo("thewire:posted"));
+forward(REFERER);
index 9d629325a179200f4347e9ab302ecb57226f06ff..58502a7e78e0464e3c1b5248b90130acc61606c9 100644 (file)
@@ -1,39 +1,39 @@
-<?php\r
-/**\r
- * Action for deleting a wire post\r
- * \r
- */\r
-\r
-// Get input data\r
-$guid = (int) get_input('guid');\r
-\r
-// Make sure we actually have permission to edit\r
-$thewire = get_entity($guid);\r
-if ($thewire->getSubtype() == "thewire" && $thewire->canEdit()) {\r
-\r
-       // unset reply metadata on children\r
-       $children = elgg_get_entities_from_relationship(array(\r
-               'relationship' => 'parent',\r
-               'relationship_guid' => $post_guid,\r
-               'inverse_relationship' => true,\r
-       ));\r
-       if ($children) {\r
-               foreach ($children as $child) {\r
-                       $child->reply = false;\r
-               }\r
-       }\r
-\r
-       // Get owning user\r
-       $owner = get_entity($thewire->getOwner());\r
-\r
-       // Delete it\r
-       $rowsaffected = $thewire->delete();\r
-       if ($rowsaffected > 0) {\r
-               // Success message\r
-               system_message(elgg_echo("thewire:deleted"));\r
-       } else {\r
-               register_error(elgg_echo("thewire:notdeleted"));\r
-       }\r
-\r
-       forward("thewire/owner/" . $owner->username);\r
-}\r
+<?php
+/**
+ * Action for deleting a wire post
+ * 
+ */
+
+// Get input data
+$guid = (int) get_input('guid');
+
+// Make sure we actually have permission to edit
+$thewire = get_entity($guid);
+if ($thewire->getSubtype() == "thewire" && $thewire->canEdit()) {
+
+       // unset reply metadata on children
+       $children = elgg_get_entities_from_relationship(array(
+               'relationship' => 'parent',
+               'relationship_guid' => $post_guid,
+               'inverse_relationship' => true,
+       ));
+       if ($children) {
+               foreach ($children as $child) {
+                       $child->reply = false;
+               }
+       }
+
+       // Get owning user
+       $owner = get_entity($thewire->getOwner());
+
+       // Delete it
+       $rowsaffected = $thewire->delete();
+       if ($rowsaffected > 0) {
+               // Success message
+               system_message(elgg_echo("thewire:deleted"));
+       } else {
+               register_error(elgg_echo("thewire:notdeleted"));
+       }
+
+       forward("thewire/owner/" . $owner->username);
+}
index d864cc259d2c65ca74702b8c8fede00570ab0f7f..3242dd5cbb83646483c481951b1b400e12a84bc6 100644 (file)
@@ -5,7 +5,9 @@
 class ElggWire extends ElggObject {
 
        /**
-        * Set subtype to thewire.
+        * Set subtype to thewire
+        * 
+        * @return void
         */
        protected function initializeAttributes() {
                parent::initializeAttributes();
index 4143a40cb28aa53b194c843c3c0a0604d902b4ac..0896ecf14aeeaea35b6d6cfa9b06481426d14a38 100644 (file)
@@ -39,8 +39,8 @@ $english = array(
         */
        'thewire:posted' => "Your message was successfully posted to the wire.",
        'thewire:deleted' => "The wire post was successfully deleted.",
-       'thewire:blank' => "Sorry; you need to actually put something in the textbox before we can save it.",
-       'thewire:notfound' => "Sorry; we could not find the specified wire post.",
+       'thewire:blank' => "Sorry, you need to enter come text before we can post this.",
+       'thewire:notfound' => "Sorry, we could not find the specified wire post.",
        'thewire:notdeleted' => "Sorry. We could not delete this wire post.",
 
 );
index 6ccff11fd0f8d885871f190b5e42d2e62a6050ab..e3d38ace54a9eaaee5a8b2053f2a62ebd86b42f3 100644 (file)
@@ -1,30 +1,30 @@
-<?php\r
-/**\r
- * All wire posts\r
- * \r
- */\r
-\r
-elgg_push_breadcrumb(elgg_echo('thewire'));\r
-\r
-$title = elgg_echo('thewire:everyone');\r
-\r
-if (elgg_is_logged_in()) {\r
-       $content .= elgg_view_form('thewire/add');\r
-       $content .= elgg_view('input/urlshortener');\r
-}\r
-\r
-$content .= elgg_list_entities(array(\r
-       'type' => 'object',\r
-       'subtype' => 'thewire',\r
-       'limit' => 15,\r
-));\r
-\r
-$body = elgg_view_layout('content', array(\r
-       'filter_context' => 'all',\r
-       'content' => $content,\r
-       'title' => $title,\r
-       'buttons' => false,\r
-       'sidebar' => elgg_view('thewire/sidebar'),\r
-));\r
-\r
-echo elgg_view_page($title, $body);\r
+<?php
+/**
+ * All wire posts
+ * 
+ */
+
+elgg_push_breadcrumb(elgg_echo('thewire'));
+
+$title = elgg_echo('thewire:everyone');
+
+if (elgg_is_logged_in()) {
+       $content .= elgg_view_form('thewire/add');
+       $content .= elgg_view('input/urlshortener');
+}
+
+$content .= elgg_list_entities(array(
+       'type' => 'object',
+       'subtype' => 'thewire',
+       'limit' => 15,
+));
+
+$body = elgg_view_layout('content', array(
+       'filter_context' => 'all',
+       'content' => $content,
+       'title' => $title,
+       'buttons' => false,
+       'sidebar' => elgg_view('thewire/sidebar'),
+));
+
+echo elgg_view_page($title, $body);
index 6e8642544fa8f12d672eeb334ad711de2fbd4d50..ab452aa550308f688d69ee15c8e67d98ffdb356c 100644 (file)
@@ -1,23 +1,23 @@
-<?php\r
-/**\r
- * Wire posts of your friends\r
- */\r
-\r
-$owner = elgg_get_page_owner_entity();\r
-\r
-$title = elgg_echo('thewire:friends');\r
-\r
-elgg_push_breadcrumb(elgg_echo('thewire'), "thewire/all");\r
-elgg_push_breadcrumb($owner->name, "thewire/owner/$owner->username");\r
-elgg_push_breadcrumb(elgg_echo('friends'));\r
-\r
-$content = list_user_friends_objects($owner->guid, 'thewire', 15, false);\r
-\r
-$body = elgg_view_layout('content', array(\r
-       'filter_context' => 'friends',\r
-       'content' => $content,\r
-       'title' => $title,\r
-       'buttons' => false,\r
-));\r
-\r
-echo elgg_view_page($title, $body);\r
+<?php
+/**
+ * Wire posts of your friends
+ */
+
+$owner = elgg_get_page_owner_entity();
+
+$title = elgg_echo('thewire:friends');
+
+elgg_push_breadcrumb(elgg_echo('thewire'), "thewire/all");
+elgg_push_breadcrumb($owner->name, "thewire/owner/$owner->username");
+elgg_push_breadcrumb(elgg_echo('friends'));
+
+$content = list_user_friends_objects($owner->guid, 'thewire', 15, false);
+
+$body = elgg_view_layout('content', array(
+       'filter_context' => 'friends',
+       'content' => $content,
+       'title' => $title,
+       'buttons' => false,
+));
+
+echo elgg_view_page($title, $body);
index e52b445ab27c670552d52b2bd3329eb89e30165f..d61307990e5f172787776ab0653b3a1c4f010553 100644 (file)
@@ -1,34 +1,34 @@
-<?php\r
-/**\r
- * User's wire posts\r
- * \r
- */\r
-\r
-$owner = elgg_get_page_owner_entity();\r
-\r
-$title = elgg_echo('thewire:user', array($owner->name));\r
-\r
-elgg_push_breadcrumb(elgg_echo('thewire'), "thewire/all");\r
-elgg_push_breadcrumb($owner->name);\r
-\r
-if (get_loggedin_userid() == $owner->guid) {\r
-       $content = elgg_view_form('thewire/add');\r
-       $content .= elgg_view('input/urlshortener');\r
-}\r
-\r
-$content .= elgg_list_entities(array(\r
-       'type' => 'object',\r
-       'subtype' => 'thewire',\r
-       'owner_guid' => $owner->guid,\r
-       'limit' => 15,\r
-));\r
-\r
-$body = elgg_view_layout('content', array(\r
-       'filter_context' => 'mine',\r
-       'content' => $content,\r
-       'title' => $title,\r
-       'buttons' => false,\r
-       'sidebar' => elgg_view('thewire/sidebar'),\r
-));\r
-\r
-echo elgg_view_page($title, $body);\r
+<?php
+/**
+ * User's wire posts
+ * 
+ */
+
+$owner = elgg_get_page_owner_entity();
+
+$title = elgg_echo('thewire:user', array($owner->name));
+
+elgg_push_breadcrumb(elgg_echo('thewire'), "thewire/all");
+elgg_push_breadcrumb($owner->name);
+
+if (get_loggedin_userid() == $owner->guid) {
+       $content = elgg_view_form('thewire/add');
+       $content .= elgg_view('input/urlshortener');
+}
+
+$content .= elgg_list_entities(array(
+       'type' => 'object',
+       'subtype' => 'thewire',
+       'owner_guid' => $owner->guid,
+       'limit' => 15,
+));
+
+$body = elgg_view_layout('content', array(
+       'filter_context' => 'mine',
+       'content' => $content,
+       'title' => $title,
+       'buttons' => false,
+       'sidebar' => elgg_view('thewire/sidebar'),
+));
+
+echo elgg_view_page($title, $body);
index c29f81669bd5afe60dec6616699da271d51d8984..826d513b6ed15506e9d4c51104d58d5dfed85e21 100644 (file)
@@ -1,28 +1,28 @@
-<?php\r
-/**\r
- * Reply page\r
- * \r
- */\r
-\r
-gatekeeper();\r
-\r
-$post = get_entity(get_input('guid'));\r
-\r
-$title = elgg_echo('thewire:reply');\r
-\r
-elgg_push_breadcrumb(elgg_echo('thewire'), 'thewire/all');\r
-elgg_push_breadcrumb($title);\r
-\r
-$content = elgg_view('thewire/reply', array('post' => $post));\r
-$content .= elgg_view_form('thewire/add', array(), array('post' => $post));\r
-$content .= elgg_view('input/urlshortener');\r
-\r
-\r
-$body = elgg_view_layout('content', array(\r
-       'filter' => false,\r
-       'content' => $content,\r
-       'title' => $title,\r
-       'buttons' => false,\r
-));\r
-\r
-echo elgg_view_page($title, $body);\r
+<?php
+/**
+ * Reply page
+ * 
+ */
+
+gatekeeper();
+
+$post = get_entity(get_input('guid'));
+
+$title = elgg_echo('thewire:reply');
+
+elgg_push_breadcrumb(elgg_echo('thewire'), 'thewire/all');
+elgg_push_breadcrumb($title);
+
+$content = elgg_view('thewire/reply', array('post' => $post));
+$content .= elgg_view_form('thewire/add', array(), array('post' => $post));
+$content .= elgg_view('input/urlshortener');
+
+
+$body = elgg_view_layout('content', array(
+       'filter' => false,
+       'content' => $content,
+       'title' => $title,
+       'buttons' => false,
+));
+
+echo elgg_view_page($title, $body);
index 8b6ee4bd07970b73bd45ffff9ed915da056a9511..5c32a84000f9355155219ff6c7298a27ea30582f 100644 (file)
@@ -1,28 +1,28 @@
-<?php\r
-/**\r
- * View conversation thread\r
- */\r
-\r
-$thread_id = get_input('thread_id');\r
-\r
-$title = elgg_echo('thewire:thread');\r
-\r
-elgg_push_breadcrumb(elgg_echo('thewire'), 'thewire/all');\r
-elgg_push_breadcrumb($title);\r
-\r
-$content = elgg_list_entities_from_metadata(array(\r
-       "metadata_name" => "wire_thread",\r
-       "metadata_value" => $thread_id,\r
-       "type" => "object",\r
-       "subtype" => "thewire",\r
-       "limit" => 20,\r
-));\r
-\r
-$body = elgg_view_layout('content', array(\r
-       'filter' => false,\r
-       'content' => $content,\r
-       'title' => $title,\r
-       'buttons' => false,\r
-));\r
-\r
-echo elgg_view_page($title, $body);\r
+<?php
+/**
+ * View conversation thread
+ */
+
+$thread_id = get_input('thread_id');
+
+$title = elgg_echo('thewire:thread');
+
+elgg_push_breadcrumb(elgg_echo('thewire'), 'thewire/all');
+elgg_push_breadcrumb($title);
+
+$content = elgg_list_entities_from_metadata(array(
+       "metadata_name" => "wire_thread",
+       "metadata_value" => $thread_id,
+       "type" => "object",
+       "subtype" => "thewire",
+       "limit" => 20,
+));
+
+$body = elgg_view_layout('content', array(
+       'filter' => false,
+       'content' => $content,
+       'title' => $title,
+       'buttons' => false,
+));
+
+echo elgg_view_page($title, $body);
index d10efb6ba395d2511e7085cfe260d15c10bdd46c..0c35b0231a385cf1ec9ac5c0d0b74cd1283fa308 100644 (file)
-<?php\r
-/**\r
- * Elgg wire plugin\r
- * \r
- * Forked from Curverider's version\r
- * \r
- * JHU/APL Contributors:\r
- * Cash Costello\r
- * Clark Updike\r
- * John Norton\r
- * Max Thomas\r
- * Nathan Koterba\r
- */\r
-\r
-register_elgg_event_handler('init', 'system', 'thewire_init');\r
-\r
-function thewire_init() {\r
-       global $CONFIG;\r
-\r
-       if (!update_subtype('object', 'thewire', 'ElggWire')) {\r
-               add_subtype('object', 'thewire', 'ElggWire');\r
-       }\r
-       \r
-       elgg_register_js('elgg.thewire', 'mod/thewire/js/thewire.js', 'footer');\r
-\r
-       // add a site navigation item\r
-       $item = new ElggMenuItem('thewire', elgg_echo('thewire'), 'thewire/all');\r
-       elgg_register_menu_item('site', $item);\r
-\r
-       // owner block menu\r
-       elgg_register_plugin_hook_handler('register', 'menu:owner_block', 'thewire_owner_block_menu');\r
-\r
-       // remove edit and access and add thread, reply, view previous\r
-       elgg_register_plugin_hook_handler('register', 'menu:entity', 'thewire_setup_entity_menu_items');\r
-       \r
-       // Extend system CSS with our own styles, which are defined in the thewire/css view\r
-       elgg_extend_view('css', 'thewire/css');\r
-\r
-       //extend views\r
-       elgg_extend_view('activity/thewire', 'thewire/activity_view');\r
-       elgg_extend_view('profile/status', 'thewire/profile_status');\r
-       elgg_extend_view('js/initialise_elgg', 'thewire/js/textcounter');\r
-\r
-       // Register a page handler, so we can have nice URLs\r
-       elgg_register_page_handler('thewire', 'thewire_page_handler');\r
-\r
-       // Register a URL handler for thewire posts\r
-       elgg_register_entity_url_handler('object', 'thewire', 'thewire_url');\r
-\r
-       // Your thewire widget\r
-       add_widget_type('thewire', elgg_echo('thewire'), elgg_echo("thewire:widget:desc"));\r
-\r
-       // Register entity type\r
-       elgg_register_entity_type('object', 'thewire');\r
-\r
-       // Register granular notification for this type\r
-       register_notification_object('object', 'thewire', elgg_echo('thewire:notify:subject'));\r
-\r
-       // Listen to notification events and supply a more useful message\r
-       register_plugin_hook('notify:entity:message', 'object', 'thewire_notify_message');\r
-\r
-       // Register actions\r
-       $action_base = $CONFIG->pluginspath . 'thewire/actions';\r
-       register_action("thewire/add", false, "$action_base/add.php");\r
-       register_action("thewire/delete", false, "$action_base/delete.php");\r
-\r
-       register_plugin_hook('unit_test', 'system', 'thewire_test');\r
-}\r
-\r
-/**\r
- * The wire page handler\r
- *\r
- * Supports:\r
- * thewire/all                  View site wire posts\r
- * thewire/owner/<username>     View this user's wire posts\r
- * thewire/following/<username> View the posts of those this user follows\r
- * thewire/reply/<guid>         Reply to a post\r
- * thewire/view/<guid>          View a conversation thread\r
- * thewire/tag/<tag>            View wire posts tagged with <tag>\r
- *\r
- * @param array $page From the page_handler function\r
- * @return true|false Depending on success\r
- */\r
-function thewire_page_handler($page) {\r
-\r
-       $base_dir = elgg_get_plugins_path() . 'thewire/pages/thewire';\r
-\r
-       // if just /thewire go to global view in the else statement\r
-       if (isset($page[0]) && $page[0]) {\r
-\r
-               switch ($page[0]) {\r
-                       case "all":\r
-                               include "$base_dir/everyone.php";\r
-                               break;\r
-\r
-                       case "friends":\r
-                               include "$base_dir/friends.php";\r
-                               break;\r
-\r
-                       case "owner":\r
-                               include "$base_dir/owner.php";\r
-                               break;\r
-\r
-                       case "thread":\r
-                               if (isset($page[1])) {\r
-                                       set_input('thread_id', $page[1]);\r
-                               }\r
-                               include "$base_dir/thread.php";\r
-                               break;\r
-                       case "reply":\r
-                               if (isset($page[1])) {\r
-                                       set_input('guid', $page[1]);\r
-                               }\r
-                               include "$base_dir/reply.php";\r
-                               break;\r
-                       case "tag":\r
-                               if (isset($page[1])) {\r
-                                       set_input('tag', $page[1]);\r
-                               }\r
-                               include "$base_dir/tag.php";\r
-                               break;\r
-                       case "previous":\r
-                               if (isset($page[1])) {\r
-                                       set_input('guid', $page[1]);\r
-                               }\r
-                               include "$base_dir/previous.php";\r
-                               break;\r
-               }\r
-       } else {\r
-               include "$base_dir/everyone.php";\r
-       }\r
-\r
-       return true;\r
-}\r
-\r
-/**\r
- * Override the url for a wire post to return the thread\r
- * \r
- * @param $thewirepost - wire post object\r
- */\r
-function thewire_url($thewirepost) {\r
-       global $CONFIG;\r
-       return $CONFIG->url . "thewire/view/" . $thewirepost->guid;\r
-}\r
-\r
-/**\r
- * Returns the notification body\r
- *\r
- * @param string $hook\r
- * @param string $entity_type\r
- * @param string $returnvalue\r
- * @param array  $params\r
- * @return $string\r
- */\r
-function thewire_notify_message($hook, $entity_type, $returnvalue, $params) {\r
-       global $CONFIG;\r
-       \r
-       $entity = $params['entity'];\r
-       if (($entity instanceof ElggEntity) && ($entity->getSubtype() == 'thewire')) {\r
-               $descr = $entity->description;\r
-               $owner = $entity->getOwnerEntity();\r
-               if ($entity->reply) {\r
-                       // have to do this because of poor design of Elgg notification system\r
-                       $parent_post = get_entity(get_input('parent_guid'));\r
-                       if ($parent_post) {\r
-                               $parent_owner = $parent_post->getOwnerEntity();\r
-                       }\r
-                       $body = sprintf(elgg_echo('thewire:notify:reply'), $owner->name, $parent_owner->name);\r
-               } else {\r
-                       $body = sprintf(elgg_echo('thewire:notify:post'), $owner->name);\r
-               }\r
-               $body .= "\n\n" . $descr . "\n\n";\r
-               $body .= elgg_echo('thewire') . ": {$CONFIG->url}thewire";\r
-               return $body;\r
-       }\r
-       return $returnvalue;\r
-}\r
-\r
-/**\r
- * Get an array of hashtags from a text string\r
- * \r
- * @param string $text\r
- * @return array\r
- */\r
-function thewire_get_hashtags($text) {\r
-       // beginning of text or white space followed by hashtag\r
-       // hashtag must begin with # and contain at least one character not digit, space, or punctuation\r
-       $matches = array();\r
-       preg_match_all('/(^|[^\w])#(\w*[^\s\d!-\/:-@]+\w*)/', $text, $matches);\r
-       return $matches[2];\r
-}\r
-\r
-/**\r
- * Replace urls, hash tags, and @'s by links\r
- * \r
- * @param $text\r
- * @return string\r
- */\r
-function thewire_filter($text) {\r
-       global $CONFIG;\r
-\r
-       $text = ' ' . $text;\r
-\r
-       // email addresses\r
-       $text = preg_replace(\r
-                               '/(^|[^\w])([\w\-\.]+)@(([0-9a-z-]+\.)+[0-9a-z]{2,})/i',\r
-                               '$1<a href="mailto:$2@$3">$2@$3</a>',\r
-                               $text);\r
-\r
-       // links\r
-       $text = parse_urls($text);\r
-\r
-       // usernames\r
-       $text = preg_replace(\r
-                               '/(^|[^\w])@([\w]+)/',\r
-                               '$1<a href="' . $CONFIG->wwwroot . 'thewire/owner/$2">@$2</a>',\r
-                               $text);\r
-\r
-       // hashtags\r
-       $text = preg_replace(\r
-                               '/(^|[^\w])#(\w*[^\s\d!-\/:-@]+\w*)/',\r
-                               '$1<a href="' . $CONFIG->wwwroot . 'thewire/tag/$2">#$2</a>',\r
-                               $text);\r
-\r
-       $text = trim($text);\r
-\r
-       return $text;\r
-}\r
-\r
-/**\r
- * Create a new wire post.\r
- *\r
- * @param string $text        The post text\r
- * @param int    $userid      The user's guid\r
- * @param int    $access_id   Public/private etc\r
- * @param int    $parent_guid Parent post guid (if any)\r
- * @param string $method      The method (default: 'site')\r
- * @return guid or false if failure\r
- */\r
-function thewire_save_post($text, $userid, $access_id, $parent_guid = 0, $method = "site") {\r
-       $post = new ElggObject();\r
-\r
-       $post->subtype = "thewire";\r
-       $post->owner_guid = $userid;\r
-       $post->access_id = $access_id;\r
-\r
-       // only 200 characters allowed\r
-       $text = elgg_substr($text, 0, 200);\r
-\r
-       // no html tags allowed so we escape\r
-       $post->description = htmlspecialchars($text, ENT_NOQUOTES, 'UTF-8');\r
-\r
-       $post->method = $method; //method: site, email, api, ...\r
-\r
-       $tags = thewire_get_hashtags($text);\r
-       if ($tags) {\r
-               $post->tags = $tags;\r
-       }\r
-\r
-       // must do this before saving so notifications pick up that this is a reply\r
-       if ($parent_guid) {\r
-               $post->reply = true;\r
-       }\r
-\r
-       $guid = $post->save();\r
-\r
-       // set thread guid\r
-       if ($parent_guid) {\r
-               $post->addRelationship($parent_guid, 'parent');\r
-               \r
-               // name conversation threads by guid of first post (works even if first post deleted)\r
-               $parent_post = get_entity($parent_guid);\r
-               $post->wire_thread = $parent_post->wire_thread;\r
-       } else {\r
-               // first post in this thread\r
-               $post->wire_thread = $guid;\r
-       }\r
-\r
-       if ($guid) {\r
-               add_to_river('river/object/thewire/create', 'create', $post->owner_guid, $post->guid);\r
-       }\r
-       \r
-       return $guid;\r
-}\r
-\r
-/**\r
- * Send notification to poster of parent post if not notified already\r
- *\r
- * @param int      $guid\r
- * @param int      $parent_guid\r
- * @param ElggUser $user\r
- */\r
-function thewire_send_response_notification($guid, $parent_guid, $user) {\r
-       $parent_owner = get_entity($parent_guid)->getOwnerEntity();\r
-       $user = get_loggedin_user();\r
-\r
-       // check to make sure user is not responding to self\r
-       if ($parent_owner->guid != $user->guid) {\r
-               // check if parent owner has notification for this user\r
-               $send_response = true;\r
-               global $NOTIFICATION_HANDLERS;\r
-               foreach ($NOTIFICATION_HANDLERS as $method => $foo) {\r
-                       if (check_entity_relationship($parent_owner->guid, 'notify' . $method, $user->guid)) {\r
-                               $send_response = false;\r
-                       }\r
-               }\r
-\r
-               // create the notification message\r
-               if ($send_response) {\r
-                       // grab same notification message that goes to everyone else\r
-                       $params = array(\r
-                               'entity' => get_entity($guid),\r
-                               'method' => "email",\r
-                       );\r
-                       $msg = thewire_notify_message("", "", "", $params);\r
-\r
-                       notify_user(\r
-                                       $parent_owner->guid,\r
-                                       $user->guid,\r
-                                       elgg_echo('thewire:notify:subject'),\r
-                                       $msg);\r
-               }\r
-       }\r
-}\r
-\r
-/**\r
- * Get the latest wire guid - used for ajax update\r
- * @return guid\r
- */\r
-function thewire_latest_guid() {\r
-       $post = elgg_get_entities(array(\r
-               'type' => 'object',\r
-               'subtype' => 'thewire',\r
-               'limit' => 1,\r
-       ));\r
-       if ($post) {\r
-               return $post[0]->guid;\r
-       } else {\r
-               return 0;\r
-       }\r
-}\r
-\r
-/**\r
- * Get the parent of a wire post\r
- * \r
- * @param ElggObject $post\r
- * @return ElggObject or null \r
- */\r
-function thewire_get_parent($post_guid) {\r
-       $parents = elgg_get_entities_from_relationship(array(\r
-               'relationship' => 'parent',\r
-               'relationship_guid' => $post_guid,\r
-       ));\r
-       if ($parents) {\r
-               return $parents[0];\r
-       }\r
-       return null;\r
-}\r
-\r
-/**\r
- * Sets up the entity menu for thewire\r
- *\r
- * Adds reply, thread, and view previous links. Removes edit and access.\r
- *\r
- * @param string $hook\r
- * @param string $type\r
- * @param array $value\r
- * @param array $params\r
- * @return array\r
- */\r
-function thewire_setup_entity_menu_items($hook, $type, $value, $params) {\r
-       $handler = elgg_extract('handler', $params, false);\r
-       if ($handler != 'thewire') {\r
-               return $value;\r
-       }\r
-\r
-       foreach ($value as $index => $item) {\r
-               $name = $item->getName();\r
-               if ($name == 'access' || $name == 'edit') {\r
-                       unset($value[$index]);\r
-               }\r
-       }\r
-\r
-       $entity = $params['entity'];\r
-\r
-       if (elgg_is_logged_in()) {\r
-               $options = array(\r
-                       'name' => 'reply',\r
-                       'text' => elgg_echo('thewire:reply'),\r
-                       'href' => "thewire/reply/$entity->guid",\r
-                       'priority' => 150,\r
-               );\r
-               $value[] = ElggMenuItem::factory($options);\r
-       }\r
-\r
-       if ($entity->reply) {\r
-               $options = array(\r
-                       'name' => 'previous',\r
-                       'text' => elgg_echo('thewire:previous'),\r
-                       'href' => "thewire/previous/$entity->guid",\r
-                       'priority' => 160,\r
-               );\r
-               $value[] = ElggMenuItem::factory($options);\r
-       }\r
-\r
-       $options = array(\r
-               'name' => 'thread',\r
-               'text' => elgg_echo('thewire:thread'),\r
-               'href' => "thewire/thread/$entity->wire_thread",\r
-               'priority' => 170,\r
-       );\r
-       $value[] = ElggMenuItem::factory($options);\r
-\r
-       return $value;\r
-}\r
-\r
-/**\r
- * Add a menu item to an ownerblock\r
- */\r
-function thewire_owner_block_menu($hook, $type, $return, $params) {\r
-       if (elgg_instanceof($params['entity'], 'user')) {\r
-               $url = "thewire/owner/{$params['entity']->username}";\r
-               $item = new ElggMenuItem('thewire', elgg_echo('item:object:thewire'), $url);\r
-               $return[] = $item;\r
-       }\r
-\r
-       return $return;\r
-}\r
-\r
-/**\r
- * Runs unit tests for the wire\r
- */\r
-function thewire_test($hook, $type, $value, $params) {\r
-       global $CONFIG;\r
-       $value[] = $CONFIG->pluginspath . 'thewire/tests/regex.php';\r
-       return $value;\r
-}\r
+<?php
+/**
+ * Elgg wire plugin
+ * 
+ * Forked from Curverider's version
+ * 
+ * JHU/APL Contributors:
+ * Cash Costello
+ * Clark Updike
+ * John Norton
+ * Max Thomas
+ * Nathan Koterba
+ */
+
+register_elgg_event_handler('init', 'system', 'thewire_init');
+
+/**
+ * The Wire initialization
+ */
+function thewire_init() {
+       global $CONFIG;
+
+       if (!update_subtype('object', 'thewire', 'ElggWire')) {
+               add_subtype('object', 'thewire', 'ElggWire');
+       }
+       
+       elgg_register_js('elgg.thewire', 'mod/thewire/js/thewire.js', 'footer');
+
+       // add a site navigation item
+       $item = new ElggMenuItem('thewire', elgg_echo('thewire'), 'thewire/all');
+       elgg_register_menu_item('site', $item);
+
+       // owner block menu
+       elgg_register_plugin_hook_handler('register', 'menu:owner_block', 'thewire_owner_block_menu');
+
+       // remove edit and access and add thread, reply, view previous
+       elgg_register_plugin_hook_handler('register', 'menu:entity', 'thewire_setup_entity_menu_items');
+       
+       // Extend system CSS with our own styles, which are defined in the thewire/css view
+       elgg_extend_view('css', 'thewire/css');
+
+       //extend views
+       elgg_extend_view('activity/thewire', 'thewire/activity_view');
+       elgg_extend_view('profile/status', 'thewire/profile_status');
+       elgg_extend_view('js/initialise_elgg', 'thewire/js/textcounter');
+
+       // Register a page handler, so we can have nice URLs
+       elgg_register_page_handler('thewire', 'thewire_page_handler');
+
+       // Register a URL handler for thewire posts
+       elgg_register_entity_url_handler('object', 'thewire', 'thewire_url');
+
+       // Your thewire widget
+       add_widget_type('thewire', elgg_echo('thewire'), elgg_echo("thewire:widget:desc"));
+
+       // Register entity type
+       elgg_register_entity_type('object', 'thewire');
+
+       // Register granular notification for this type
+       register_notification_object('object', 'thewire', elgg_echo('thewire:notify:subject'));
+
+       // Listen to notification events and supply a more useful message
+       register_plugin_hook('notify:entity:message', 'object', 'thewire_notify_message');
+
+       // Register actions
+       $action_base = $CONFIG->pluginspath . 'thewire/actions';
+       register_action("thewire/add", false, "$action_base/add.php");
+       register_action("thewire/delete", false, "$action_base/delete.php");
+
+       register_plugin_hook('unit_test', 'system', 'thewire_test');
+}
+
+/**
+ * The wire page handler
+ *
+ * Supports:
+ * thewire/all                  View site wire posts
+ * thewire/owner/<username>     View this user's wire posts
+ * thewire/following/<username> View the posts of those this user follows
+ * thewire/reply/<guid>         Reply to a post
+ * thewire/view/<guid>          View a conversation thread
+ * thewire/tag/<tag>            View wire posts tagged with <tag>
+ *
+ * @param array $page From the page_handler function
+ * @return true|false Depending on success
+ */
+function thewire_page_handler($page) {
+
+       $base_dir = elgg_get_plugins_path() . 'thewire/pages/thewire';
+
+       // if just /thewire go to global view in the else statement
+       if (isset($page[0]) && $page[0]) {
+
+               switch ($page[0]) {
+                       case "all":
+                               include "$base_dir/everyone.php";
+                               break;
+
+                       case "friends":
+                               include "$base_dir/friends.php";
+                               break;
+
+                       case "owner":
+                               include "$base_dir/owner.php";
+                               break;
+
+                       case "thread":
+                               if (isset($page[1])) {
+                                       set_input('thread_id', $page[1]);
+                               }
+                               include "$base_dir/thread.php";
+                               break;
+                       case "reply":
+                               if (isset($page[1])) {
+                                       set_input('guid', $page[1]);
+                               }
+                               include "$base_dir/reply.php";
+                               break;
+                       case "tag":
+                               if (isset($page[1])) {
+                                       set_input('tag', $page[1]);
+                               }
+                               include "$base_dir/tag.php";
+                               break;
+                       case "previous":
+                               if (isset($page[1])) {
+                                       set_input('guid', $page[1]);
+                               }
+                               include "$base_dir/previous.php";
+                               break;
+               }
+       } else {
+               include "$base_dir/everyone.php";
+       }
+
+       return true;
+}
+
+/**
+ * Override the url for a wire post to return the thread
+ * 
+ * @param ElggObject $thewirepost Wire post object
+ */
+function thewire_url($thewirepost) {
+       global $CONFIG;
+       return $CONFIG->url . "thewire/view/" . $thewirepost->guid;
+}
+
+/**
+ * Returns the notification body
+ *
+ * @return $string
+ */
+function thewire_notify_message($hook, $entity_type, $returnvalue, $params) {
+       global $CONFIG;
+       
+       $entity = $params['entity'];
+       if (($entity instanceof ElggEntity) && ($entity->getSubtype() == 'thewire')) {
+               $descr = $entity->description;
+               $owner = $entity->getOwnerEntity();
+               if ($entity->reply) {
+                       // have to do this because of poor design of Elgg notification system
+                       $parent_post = get_entity(get_input('parent_guid'));
+                       if ($parent_post) {
+                               $parent_owner = $parent_post->getOwnerEntity();
+                       }
+                       $body = sprintf(elgg_echo('thewire:notify:reply'), $owner->name, $parent_owner->name);
+               } else {
+                       $body = sprintf(elgg_echo('thewire:notify:post'), $owner->name);
+               }
+               $body .= "\n\n" . $descr . "\n\n";
+               $body .= elgg_echo('thewire') . ": {$CONFIG->url}thewire";
+               return $body;
+       }
+       return $returnvalue;
+}
+
+/**
+ * Get an array of hashtags from a text string
+ * 
+ * @param string $text The text of a post
+ * @return array
+ */
+function thewire_get_hashtags($text) {
+       // beginning of text or white space followed by hashtag
+       // hashtag must begin with # and contain at least one character not digit, space, or punctuation
+       $matches = array();
+       preg_match_all('/(^|[^\w])#(\w*[^\s\d!-\/:-@]+\w*)/', $text, $matches);
+       return $matches[2];
+}
+
+/**
+ * Replace urls, hash tags, and @'s by links
+ * 
+ * @param string $text The text of a post
+ * @return string
+ */
+function thewire_filter($text) {
+       global $CONFIG;
+
+       $text = ' ' . $text;
+
+       // email addresses
+       $text = preg_replace(
+                               '/(^|[^\w])([\w\-\.]+)@(([0-9a-z-]+\.)+[0-9a-z]{2,})/i',
+                               '$1<a href="mailto:$2@$3">$2@$3</a>',
+                               $text);
+
+       // links
+       $text = parse_urls($text);
+
+       // usernames
+       $text = preg_replace(
+                               '/(^|[^\w])@([\w]+)/',
+                               '$1<a href="' . $CONFIG->wwwroot . 'thewire/owner/$2">@$2</a>',
+                               $text);
+
+       // hashtags
+       $text = preg_replace(
+                               '/(^|[^\w])#(\w*[^\s\d!-\/:-@]+\w*)/',
+                               '$1<a href="' . $CONFIG->wwwroot . 'thewire/tag/$2">#$2</a>',
+                               $text);
+
+       $text = trim($text);
+
+       return $text;
+}
+
+/**
+ * Create a new wire post.
+ *
+ * @param string $text        The post text
+ * @param int    $userid      The user's guid
+ * @param int    $access_id   Public/private etc
+ * @param int    $parent_guid Parent post guid (if any)
+ * @param string $method      The method (default: 'site')
+ * @return guid or false if failure
+ */
+function thewire_save_post($text, $userid, $access_id, $parent_guid = 0, $method = "site") {
+       $post = new ElggObject();
+
+       $post->subtype = "thewire";
+       $post->owner_guid = $userid;
+       $post->access_id = $access_id;
+
+       // only 200 characters allowed
+       $text = elgg_substr($text, 0, 200);
+
+       // no html tags allowed so we escape
+       $post->description = htmlspecialchars($text, ENT_NOQUOTES, 'UTF-8');
+
+       $post->method = $method; //method: site, email, api, ...
+
+       $tags = thewire_get_hashtags($text);
+       if ($tags) {
+               $post->tags = $tags;
+       }
+
+       // must do this before saving so notifications pick up that this is a reply
+       if ($parent_guid) {
+               $post->reply = true;
+       }
+
+       $guid = $post->save();
+
+       // set thread guid
+       if ($parent_guid) {
+               $post->addRelationship($parent_guid, 'parent');
+               
+               // name conversation threads by guid of first post (works even if first post deleted)
+               $parent_post = get_entity($parent_guid);
+               $post->wire_thread = $parent_post->wire_thread;
+       } else {
+               // first post in this thread
+               $post->wire_thread = $guid;
+       }
+
+       if ($guid) {
+               add_to_river('river/object/thewire/create', 'create', $post->owner_guid, $post->guid);
+       }
+       
+       return $guid;
+}
+
+/**
+ * Send notification to poster of parent post if not notified already
+ *
+ * @param int      $guid        The guid of the reply wire post
+ * @param int      $parent_guid The guid of the original wire post
+ * @param ElggUser $user        The user who posted the reply
+ * @return void
+ */
+function thewire_send_response_notification($guid, $parent_guid, $user) {
+       $parent_owner = get_entity($parent_guid)->getOwnerEntity();
+       $user = get_loggedin_user();
+
+       // check to make sure user is not responding to self
+       if ($parent_owner->guid != $user->guid) {
+               // check if parent owner has notification for this user
+               $send_response = true;
+               global $NOTIFICATION_HANDLERS;
+               foreach ($NOTIFICATION_HANDLERS as $method => $foo) {
+                       if (check_entity_relationship($parent_owner->guid, 'notify' . $method, $user->guid)) {
+                               $send_response = false;
+                       }
+               }
+
+               // create the notification message
+               if ($send_response) {
+                       // grab same notification message that goes to everyone else
+                       $params = array(
+                               'entity' => get_entity($guid),
+                               'method' => "email",
+                       );
+                       $msg = thewire_notify_message("", "", "", $params);
+
+                       notify_user(
+                                       $parent_owner->guid,
+                                       $user->guid,
+                                       elgg_echo('thewire:notify:subject'),
+                                       $msg);
+               }
+       }
+}
+
+/**
+ * Get the latest wire guid - used for ajax update
+ * 
+ * @return guid
+ */
+function thewire_latest_guid() {
+       $post = elgg_get_entities(array(
+               'type' => 'object',
+               'subtype' => 'thewire',
+               'limit' => 1,
+       ));
+       if ($post) {
+               return $post[0]->guid;
+       } else {
+               return 0;
+       }
+}
+
+/**
+ * Get the parent of a wire post
+ * 
+ * @param int $post_guid The guid of the reply
+ * @return ElggObject or null 
+ */
+function thewire_get_parent($post_guid) {
+       $parents = elgg_get_entities_from_relationship(array(
+               'relationship' => 'parent',
+               'relationship_guid' => $post_guid,
+       ));
+       if ($parents) {
+               return $parents[0];
+       }
+       return null;
+}
+
+/**
+ * Sets up the entity menu for thewire
+ *
+ * Adds reply, thread, and view previous links. Removes edit and access.
+ *
+ * @param string $hook   Hook name
+ * @param string $type   Hook type
+ * @param array  $value  Array of menu items
+ * @param array  $params Array with the entity
+ * @return array
+ */
+function thewire_setup_entity_menu_items($hook, $type, $value, $params) {
+       $handler = elgg_extract('handler', $params, false);
+       if ($handler != 'thewire') {
+               return $value;
+       }
+
+       foreach ($value as $index => $item) {
+               $name = $item->getName();
+               if ($name == 'access' || $name == 'edit') {
+                       unset($value[$index]);
+               }
+       }
+
+       $entity = $params['entity'];
+
+       if (elgg_is_logged_in()) {
+               $options = array(
+                       'name' => 'reply',
+                       'text' => elgg_echo('thewire:reply'),
+                       'href' => "thewire/reply/$entity->guid",
+                       'priority' => 150,
+               );
+               $value[] = ElggMenuItem::factory($options);
+       }
+
+       if ($entity->reply) {
+               $options = array(
+                       'name' => 'previous',
+                       'text' => elgg_echo('thewire:previous'),
+                       'href' => "thewire/previous/$entity->guid",
+                       'priority' => 160,
+               );
+               $value[] = ElggMenuItem::factory($options);
+       }
+
+       $options = array(
+               'name' => 'thread',
+               'text' => elgg_echo('thewire:thread'),
+               'href' => "thewire/thread/$entity->wire_thread",
+               'priority' => 170,
+       );
+       $value[] = ElggMenuItem::factory($options);
+
+       return $value;
+}
+
+/**
+ * Add a menu item to an ownerblock
+ *
+ * @return array
+ */
+function thewire_owner_block_menu($hook, $type, $return, $params) {
+       if (elgg_instanceof($params['entity'], 'user')) {
+               $url = "thewire/owner/{$params['entity']->username}";
+               $item = new ElggMenuItem('thewire', elgg_echo('item:object:thewire'), $url);
+               $return[] = $item;
+       }
+
+       return $return;
+}
+
+/**
+ * Runs unit tests for the wire
+ *
+ * @return array
+ */
+function thewire_test($hook, $type, $value, $params) {
+       global $CONFIG;
+       $value[] = $CONFIG->pluginspath . 'thewire/tests/regex.php';
+       return $value;
+}
index a1a432a207a3e24446f1c1eb1ab5af889b50feca..f5487a422c283f89bc1ac132540d54cae50db8ea 100644 (file)
@@ -38,22 +38,46 @@ class TheWireRegexTest extends ElggCoreUnitTest {
                parent::__destruct();
        }
 
+       /**
+        * Get the link for a user's wire page
+        *
+        * @param string $username Username
+        * @return string
+        */
        protected function getUserWireLink($username) {
                $url = "thewire/owner/$username";
                $url = elgg_normalize_url($url);
                return "<a href=\"$url\">@$username</a>";
        }
 
+       /**
+        * Get the link for a hashtag page
+        *
+        * @param string $tag Tag string
+        * @return string
+        */
        protected function getHashtagLink($tag) {
                $url = "thewire/tag/$tag";
                $url = elgg_normalize_url($url);
                return "<a href=\"$url\">#$tag</a>";
        }
 
+       /**
+        * Get a link for an email address mailto
+        *
+        * @param string $address Email address
+        * @return string
+        */
        protected function getEmailLink($address) {
                return "<a href=\"mailto:$address\">$address</a>";
        }
 
+       /**
+        * Get the html for a link
+        *
+        * @param string $address URL
+        * @return string
+        */
        protected function getLink($address) {
                return parse_urls($address);
        }
index 9ffde3eeb2bd3e307146dba2c1a31f0b2c978696..ace290589311bf1913095c9246144c32371427e7 100644 (file)
@@ -30,10 +30,10 @@ $author_text = elgg_echo('byline', array($owner_link));
 $date = elgg_view_friendly_time($post->time_created);
 
 $metadata = elgg_view_menu('entity', array(
-        'entity' => $post,
-        'handler' => 'thewire',
-        'sort_by' => 'priority',
-        'class' => 'elgg-menu-hz',
+       'entity' => $post,
+       'handler' => 'thewire',
+       'sort_by' => 'priority',
+       'class' => 'elgg-menu-hz',
 ));
 
 $subtitle = "$author_text $date";
index 7b04cba506a09effa85cc4ff3d1d112e3c292d05..6ab47bccbe1a678e073e5d79b92296729c474386 100644 (file)
@@ -23,7 +23,7 @@ if ($latest_wire && count($latest_wire) > 0) {
 
        $button = '';
        if ($owner == elgg_get_logged_in_user_guid()) {
-       $url_to_wire = "thewire/owner/" . $vars['entity']->username;
+               $url_to_wire = "thewire/owner/" . $vars['entity']->username;
                $button = elgg_view('output/url', array(
                        'text' => elgg_echo('thewire:update'),
                        'href' => $url_to_wire,
index fbbb670b7bf19dbc9ee3d1466ffab509ad4b4931..8229f46f1a5bd47e016542d3834090efe5024586 100644 (file)
@@ -11,38 +11,37 @@ if ($owner) {
        $title = elgg_echo('thewire:by', array($owner->name));
 } else {
        $subtitle = strip_tags($vars['entity']->description);
-       $title = substr($subtitle,0,32);
-       if (strlen($subtitle) > 32) {
-               $title .= " ...";
-       }
+       $title = elgg_get_excerpt($subtitle, 32);
 }
 
 ?>
 
 <item>
 <guid isPermaLink='false'><?php echo $vars['entity']->getGUID(); ?></guid>
-<pubDate><?php echo date("r",$vars['entity']->time_created) ?></pubDate>
+<pubDate><?php echo date("r", $vars['entity']->time_created) ?></pubDate>
 <link><?php echo htmlspecialchars($vars['entity']->getURL()); ?></link>
 <title><![CDATA[<?php echo $title; ?>]]></title>
 <description><![CDATA[<?php echo (autop($vars['entity']->description)); ?>]]></description>
 <?php
-               $owner = $vars['entity']->getOwnerEntity();
-               if ($owner) {
-?>
-<dc:creator><?php echo $owner->name; ?></dc:creator>
-<?php
-               }
+$owner = $vars['entity']->getOwnerEntity();
+if ($owner) {
+       ?>
+       <dc:creator><?php echo $owner->name; ?></dc:creator>
+       <?php
+}
 ?>
 <?php
-               if (
-                       ($vars['entity'] instanceof Locatable) &&
-                       ($vars['entity']->getLongitude()) &&
-                       ($vars['entity']->getLatitude())
-               ) {
-                       ?>
-                       <georss:point><?php echo $vars['entity']->getLatitude(); ?> <?php echo $vars['entity']->getLongitude(); ?></georss:point>
-                       <?php
-               }
+if (
+       ($vars['entity'] instanceof Locatable) &&
+       ($vars['entity']->getLongitude()) &&
+       ($vars['entity']->getLatitude())
+) {
+       ?>
+       <georss:point>
+               <?php echo $vars['entity']->getLatitude(); ?> <?php echo $vars['entity']->getLongitude(); ?>
+       </georss:point>
+       <?php
+}
 ?>
 <?php echo elgg_view('extensions/item'); ?>
 </item>