From fe04f54b34210e6771fa06d8e4ca2849749c8477 Mon Sep 17 00:00:00 2001 From: marcus Date: Wed, 9 Jul 2008 18:04:00 +0000 Subject: Closes #81: OpenDD aggregator http://trac.elgg.org/elgg/ticket/81 git-svn-id: https://code.elgg.org/elgg/trunk@1377 36083f99-b078-4883-b0ff-0f9b5a30f544 --- mod/opendd/actions/opendd/feed/delete.php | 42 ++++++++ mod/opendd/actions/opendd/feed/subscribe.php | 58 +++++++++++ mod/opendd/edit.php | 19 ++++ mod/opendd/feeds.php | 25 +++++ mod/opendd/graphics/defaultlarge.jpg | Bin 0 -> 4231 bytes mod/opendd/graphics/defaultmedium.jpg | Bin 0 -> 1807 bytes mod/opendd/graphics/defaultsmall.jpg | Bin 0 -> 990 bytes mod/opendd/graphics/defaulttiny.jpg | Bin 0 -> 640 bytes mod/opendd/index.php | 76 ++++++++++++++ mod/opendd/languages/en.php | 52 +++++++++ mod/opendd/manage.php | 27 +++++ mod/opendd/manifest.xml | 9 ++ mod/opendd/start.php | 116 +++++++++++++++++++++ mod/opendd/viewfeed.php | 75 +++++++++++++ .../views/default/forms/opendd/subscribe.php | 37 +++++++ mod/opendd/views/default/object/oddentity.php | 25 +++++ mod/opendd/views/default/object/oddfeed.php | 21 ++++ mod/opendd/views/default/object/oddmetadata.php | 30 ++++++ .../views/default/object/oddrelationship.php | 25 +++++ mod/opendd/views/default/opendd/css.php | 3 + mod/opendd/views/default/opendd/gallery.php | 25 +++++ mod/opendd/views/default/opendd/icon.php | 36 +++++++ mod/opendd/views/default/opendd/link_logo.php | 22 ++++ mod/opendd/views/default/opendd/links.php | 3 + mod/opendd/views/default/opendd/listing.php | 26 +++++ mod/opendd/views/default/opendd/metatags.php | 16 +++ mod/opendd/views/default/opendd/profile.php | 109 +++++++++++++++++++ 27 files changed, 877 insertions(+) create mode 100644 mod/opendd/actions/opendd/feed/delete.php create mode 100644 mod/opendd/actions/opendd/feed/subscribe.php create mode 100644 mod/opendd/edit.php create mode 100644 mod/opendd/feeds.php create mode 100644 mod/opendd/graphics/defaultlarge.jpg create mode 100644 mod/opendd/graphics/defaultmedium.jpg create mode 100644 mod/opendd/graphics/defaultsmall.jpg create mode 100644 mod/opendd/graphics/defaulttiny.jpg create mode 100644 mod/opendd/index.php create mode 100644 mod/opendd/languages/en.php create mode 100644 mod/opendd/manage.php create mode 100644 mod/opendd/manifest.xml create mode 100644 mod/opendd/start.php create mode 100644 mod/opendd/viewfeed.php create mode 100644 mod/opendd/views/default/forms/opendd/subscribe.php create mode 100644 mod/opendd/views/default/object/oddentity.php create mode 100644 mod/opendd/views/default/object/oddfeed.php create mode 100644 mod/opendd/views/default/object/oddmetadata.php create mode 100644 mod/opendd/views/default/object/oddrelationship.php create mode 100644 mod/opendd/views/default/opendd/css.php create mode 100644 mod/opendd/views/default/opendd/gallery.php create mode 100644 mod/opendd/views/default/opendd/icon.php create mode 100644 mod/opendd/views/default/opendd/link_logo.php create mode 100644 mod/opendd/views/default/opendd/links.php create mode 100644 mod/opendd/views/default/opendd/listing.php create mode 100644 mod/opendd/views/default/opendd/metatags.php create mode 100644 mod/opendd/views/default/opendd/profile.php (limited to 'mod/opendd') diff --git a/mod/opendd/actions/opendd/feed/delete.php b/mod/opendd/actions/opendd/feed/delete.php new file mode 100644 index 000000000..2826174bf --- /dev/null +++ b/mod/opendd/actions/opendd/feed/delete.php @@ -0,0 +1,42 @@ +delete()) { + system_message(elgg_echo("opendd:deleted")); + $returnurl = $CONFIG->url . "mod/opendd/"; + } + else + system_message(elgg_echo("opendd:notdeleted")); + + } + else + system_message(elgg_echo("opendd:notobject")); + + + + $returnurl = $CONFIG->url . "mod/opendd/"; + forward($returnurl); + exit; +?> \ No newline at end of file diff --git a/mod/opendd/actions/opendd/feed/subscribe.php b/mod/opendd/actions/opendd/feed/subscribe.php new file mode 100644 index 000000000..654e6aef3 --- /dev/null +++ b/mod/opendd/actions/opendd/feed/subscribe.php @@ -0,0 +1,58 @@ +opendd as $shortname => $valuetype) { + $input[$shortname] = get_input($shortname); + if ($valuetype == 'tags') + $input[$shortname] = string_to_tag_array($input[$shortname]); + } + + $feed_guid = get_input('feed_guid'); + $feed = NULL; + if ($feed_guid) + $feed = get_entity($feed_guid); + else + { + $feed = new ElggObject(); + $feed->subtype = 'oddfeed'; + } + + if (!($feed instanceof ElggObject)) + { + system_message(elgg_echo("opendd:notobject")); + + forward($_SERVER['HTTP_REFERER']); + exit; + } + + // Assume we can edit or this is a new group + if (sizeof($input) > 0) + { + foreach($input as $shortname => $value) { + $feed->$shortname = $value; + } + } + + + if ($feed->save()) + system_message(elgg_echo("opendd:feedok")); + else + system_message(elgg_echo("opendd:feednotok")); + + forward($_SERVER['HTTP_REFERER']); + exit; +?> \ No newline at end of file diff --git a/mod/opendd/edit.php b/mod/opendd/edit.php new file mode 100644 index 000000000..f1b060a6c --- /dev/null +++ b/mod/opendd/edit.php @@ -0,0 +1,19 @@ + get_entity(get_input('feed_guid')))); + + $body = elgg_view_layout('one_column',$form); + + page_draw(elgg_echo("opendd:edit"), $body); +?> \ No newline at end of file diff --git a/mod/opendd/feeds.php b/mod/opendd/feeds.php new file mode 100644 index 000000000..69b35aa7e --- /dev/null +++ b/mod/opendd/feeds.php @@ -0,0 +1,25 @@ + \ No newline at end of file diff --git a/mod/opendd/graphics/defaultlarge.jpg b/mod/opendd/graphics/defaultlarge.jpg new file mode 100644 index 000000000..04d7b7bef Binary files /dev/null and b/mod/opendd/graphics/defaultlarge.jpg differ diff --git a/mod/opendd/graphics/defaultmedium.jpg b/mod/opendd/graphics/defaultmedium.jpg new file mode 100644 index 000000000..e3475850f Binary files /dev/null and b/mod/opendd/graphics/defaultmedium.jpg differ diff --git a/mod/opendd/graphics/defaultsmall.jpg b/mod/opendd/graphics/defaultsmall.jpg new file mode 100644 index 000000000..1be985956 Binary files /dev/null and b/mod/opendd/graphics/defaultsmall.jpg differ diff --git a/mod/opendd/graphics/defaulttiny.jpg b/mod/opendd/graphics/defaulttiny.jpg new file mode 100644 index 000000000..c384ccf3a Binary files /dev/null and b/mod/opendd/graphics/defaulttiny.jpg differ diff --git a/mod/opendd/index.php b/mod/opendd/index.php new file mode 100644 index 000000000..83b6b0368 --- /dev/null +++ b/mod/opendd/index.php @@ -0,0 +1,76 @@ += $offset) && ($cnt < $offset + $limit)) + { + $tmp = new ElggObject(); + $tmp->subtype = strtolower(get_class($obj)); + + $attr = $obj->getAttributes(); + foreach ($attr as $k => $v) + { + $key = 'opendd:' . $k; + $tmp->$key = $v; + } + + $key = 'opendd:body'; + $tmp->$key = $obj->getBody(); + + $objects[] = $tmp; + } + + $cnt++; + } + + $context = get_context(); + set_context('search'); + $body .= elgg_view_entity_list($objects, $cnt, $offset, $limit, false); + set_context($context); + + // Add logo link + $body .= elgg_view('opendd/link_logo', array('feed_url' => $CONFIG->url . "pg/opendd/". page_owner_entity()->username ."/activity/opendd")); + + // Turn off rss view & default odd view + global $autofeed; $autofeed = false; + + // Point to my activity in odd + extend_view('metatags', 'opendd/metatags'); + + $body = elgg_view_layout('one_column',$body); + + // Finally draw the page + page_draw(sprintf(elgg_echo("opendd:your"),page_owner_entity()->name), $body); + } +?> \ No newline at end of file diff --git a/mod/opendd/languages/en.php b/mod/opendd/languages/en.php new file mode 100644 index 000000000..08f764728 --- /dev/null +++ b/mod/opendd/languages/en.php @@ -0,0 +1,52 @@ + "OpenDD", + 'opendd:your' => "Your activity", + 'opendd:feeds' => "Your subscriptions", + 'opendd:manage' => "Manage subscriptions", + 'opendd:edit' => "Edit subscription", + + 'opendd:feedurl' => "Feed URL", + + 'opendd:notobject' => "Entity is not an object, this should not have happened.", + 'opendd:feednotok' => "Unable to edit your OpenDD feeds.", + 'opendd:feedok' => "Successfully subscribed to feed.", + + 'opendd:deleted' => "Feed subscription deleted.", + 'opendd:notdeleted' => "Feed subscription not deleted.", + + 'opendd:noopenddfound' => "No OpenDD elements found in stream.", + + 'opendd:metadata:uuid' => "UUID of metadata", + 'opendd:metadata:entityuuid' => "Referring to UUID", + 'opendd:metadata:owneruuid' => "Owner", + 'opendd:metadata:key' => "Key", + 'opendd:metadata:value' => "Value", + + 'opendd:entity:uuid' => "Universal Identifier", + 'opendd:entity:class' => "Class", + 'opendd:entity:subclass' => "Subclass", + + 'opendd:published' => "Published", + + 'opendd:nodata' => "There was a problem getting the feed, response: %s", + + ); + + add_translation("en",$english); +?> \ No newline at end of file diff --git a/mod/opendd/manage.php b/mod/opendd/manage.php new file mode 100644 index 000000000..22c5ace3f --- /dev/null +++ b/mod/opendd/manage.php @@ -0,0 +1,27 @@ + \ No newline at end of file diff --git a/mod/opendd/manifest.xml b/mod/opendd/manifest.xml new file mode 100644 index 000000000..9b3923f51 --- /dev/null +++ b/mod/opendd/manifest.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/mod/opendd/start.php b/mod/opendd/start.php new file mode 100644 index 000000000..88891ba11 --- /dev/null +++ b/mod/opendd/start.php @@ -0,0 +1,116 @@ +wwwroot . "pg/opendd/{$_SESSION['user']->username}",array( + menu_item(elgg_echo('opendd:your'), $CONFIG->wwwroot."pg/opendd/{$_SESSION['user']->username}"), + menu_item(elgg_echo('opendd:feeds'), $CONFIG->wwwroot."pg/opendd/{$_SESSION['user']->username}/feeds/"), + menu_item(elgg_echo('opendd:manage'), $CONFIG->wwwroot . "pg/opendd/{$_SESSION['user']->username}/manage/"), + ),'opendd'); + } + + // Register a page handler, so we can have nice URLs + register_page_handler('opendd','opendd_page_handler'); + + // Register opendd url + register_entity_url_handler('opendd_url','object','oddfeed'); + + // Actions + register_action("opendd/feed/subscribe",false, $CONFIG->pluginspath . "opendd/actions/opendd/feed/subscribe.php"); + register_action("opendd/feed/delete",false, $CONFIG->pluginspath . "opendd/actions/opendd/feed/delete.php"); + + // Extend some views + extend_view('css','opendd/css'); + + + // Subscribe fields + $CONFIG->opendd = array( + 'feedurl' => 'text', + ); + + } + + /** + * Group page handler + * + * @param array $page Array of page elements, forwarded by the page handling mechanism + */ + function opendd_page_handler($page) + { + global $CONFIG; + + if (isset($page[0])) + set_input('username',$page[0]); + + if (isset($page[1])) + { + // See what context we're using + switch($page[1]) + { + case "view" : + if (isset($page[2])) + { + set_input('feed_guid', $page[2]); + include($CONFIG->pluginspath . "opendd/viewfeed.php"); + } + break; + case "manage": + include($CONFIG->pluginspath . "opendd/manage.php"); + break; + case "feeds" : + include($CONFIG->pluginspath . "opendd/feeds.php"); + break; + case "activity" : + if (isset($page[2])) + { + switch ($page[2]) + { + case 'opendd' : + default : + set_input('view', 'odd'); + include($CONFIG->pluginspath . "opendd/index.php"); + } + } + break; + default: + include($CONFIG->pluginspath . "opendd/index.php"); + } + } + else + include($CONFIG->pluginspath . "opendd/index.php"); + } + + /** + * Register a url to handle opendd feeds. + * + * @param ElggEntity $feed The feed object. + * @return string + */ + function opendd_url($feed) + { + global $CONFIG; + return $CONFIG->wwwroot . "pg/opendd/" . $feed->getOwnerEntity()->username . "/view/{$feed->guid}"; + } + + + // Make sure the groups initialisation function is called on initialisation + register_elgg_event_handler('init','system','opendd_init'); +?> \ No newline at end of file diff --git a/mod/opendd/viewfeed.php b/mod/opendd/viewfeed.php new file mode 100644 index 000000000..a581c834e --- /dev/null +++ b/mod/opendd/viewfeed.php @@ -0,0 +1,75 @@ + $entity)); + + $ctx = stream_context_create(array( + 'http' => array( + 'timeout' => 1 + ) + ) + ); + + $data = file_get_contents($entity->feedurl);//, 0, $ctx); + + if ($data) + { + $opendd = ODD_Import($data); + + if ($opendd) + { + $objects = array(); + + $cnt = 0; + foreach ($opendd as $obj) + { + if (($cnt >= $offset) && ($cnt < $offset + $limit)) + { + $tmp = new ElggObject(); + $tmp->subtype = strtolower(get_class($obj)); + + $attr = $obj->getAttributes(); + foreach ($attr as $k => $v) + { + $key = 'opendd:' . $k; + $tmp->$key = $v; + } + + $key = 'opendd:body'; + $tmp->$key = $obj->getBody(); + + $objects[] = $tmp; + } + + $cnt++; + } + + $context = get_context(); + set_context('search'); + $body .= elgg_view_entity_list($objects, $cnt, $offset, $limit, false); + set_context($context); + + } + else + $body .= elgg_echo('opendd:noopenddfound'); + } + else + $body .= sprintf(elgg_echo('opendd:nodata'), $http_response_header[0]); + + // Finally draw the page + page_draw($vars['entity']->feedurl,elgg_view_layout('one_column', $body)); +?> \ No newline at end of file diff --git a/mod/opendd/views/default/forms/opendd/subscribe.php b/mod/opendd/views/default/forms/opendd/subscribe.php new file mode 100644 index 000000000..16f0e808b --- /dev/null +++ b/mod/opendd/views/default/forms/opendd/subscribe.php @@ -0,0 +1,37 @@ + +
+opendd) && sizeof($vars['config']->opendd) > 0) + foreach($vars['config']->opendd as $shortname => $valtype) { + +?> + +

+ +

+ + + + + " /> +
\ No newline at end of file diff --git a/mod/opendd/views/default/object/oddentity.php b/mod/opendd/views/default/object/oddentity.php new file mode 100644 index 000000000..43cba4a2f --- /dev/null +++ b/mod/opendd/views/default/object/oddentity.php @@ -0,0 +1,25 @@ + +
+
+

: get('opendd:published'); ?>

+
+
+

: get('opendd:uuid'); ?>

+
+
+

: get('opendd:class'); ?>

+

: get('opendd:subclass'); ?>

+
+
\ No newline at end of file diff --git a/mod/opendd/views/default/object/oddfeed.php b/mod/opendd/views/default/object/oddfeed.php new file mode 100644 index 000000000..265a78257 --- /dev/null +++ b/mod/opendd/views/default/object/oddfeed.php @@ -0,0 +1,21 @@ + \ No newline at end of file diff --git a/mod/opendd/views/default/object/oddmetadata.php b/mod/opendd/views/default/object/oddmetadata.php new file mode 100644 index 000000000..cc63a09ec --- /dev/null +++ b/mod/opendd/views/default/object/oddmetadata.php @@ -0,0 +1,30 @@ + +
+
+

: get('opendd:published'); ?>

+
+
+

: get('opendd:uuid'); ?>

+
+
+

: get('opendd:entity_uuid'); ?>

+
+
+

: get('opendd:owner_uuid'); ?>

+
+
+

get('opendd:name'); ?> : get('opendd:body'); ?>

+
+
\ No newline at end of file diff --git a/mod/opendd/views/default/object/oddrelationship.php b/mod/opendd/views/default/object/oddrelationship.php new file mode 100644 index 000000000..beb7847d4 --- /dev/null +++ b/mod/opendd/views/default/object/oddrelationship.php @@ -0,0 +1,25 @@ + +
+
+

: get('opendd:published'); ?>

+
+
+

+ get('opendd:uuid1'); ?> + get('opendd:type'); ?> + get('opendd:uuid2'); ?> +

+
+
\ No newline at end of file diff --git a/mod/opendd/views/default/opendd/css.php b/mod/opendd/views/default/opendd/css.php new file mode 100644 index 000000000..15c5adc7f --- /dev/null +++ b/mod/opendd/views/default/opendd/css.php @@ -0,0 +1,3 @@ + \ No newline at end of file diff --git a/mod/opendd/views/default/opendd/gallery.php b/mod/opendd/views/default/opendd/gallery.php new file mode 100644 index 000000000..008c1c6bd --- /dev/null +++ b/mod/opendd/views/default/opendd/gallery.php @@ -0,0 +1,25 @@ + $vars['entity'], + 'size' => 'large', + ) + ); + + $info .= "

getUrl() . "\">" . $vars['entity']->feedurl . "

"; + + // num users, last activity, owner etc + + + echo elgg_view('search/gallery_listing',array('icon' => $icon, 'info' => $info)); +?> \ No newline at end of file diff --git a/mod/opendd/views/default/opendd/icon.php b/mod/opendd/views/default/opendd/icon.php new file mode 100644 index 000000000..bb8614ea7 --- /dev/null +++ b/mod/opendd/views/default/opendd/icon.php @@ -0,0 +1,36 @@ +icontime) { + $icontime = "{$icontime}"; + } else { + $icontime = "default"; + } + + +?> + +
+ /> +
\ No newline at end of file diff --git a/mod/opendd/views/default/opendd/link_logo.php b/mod/opendd/views/default/opendd/link_logo.php new file mode 100644 index 000000000..1d1a81049 --- /dev/null +++ b/mod/opendd/views/default/opendd/link_logo.php @@ -0,0 +1,22 @@ + +
+ +" border="0" /> + +
\ No newline at end of file diff --git a/mod/opendd/views/default/opendd/links.php b/mod/opendd/views/default/opendd/links.php new file mode 100644 index 000000000..15c5adc7f --- /dev/null +++ b/mod/opendd/views/default/opendd/links.php @@ -0,0 +1,3 @@ + \ No newline at end of file diff --git a/mod/opendd/views/default/opendd/listing.php b/mod/opendd/views/default/opendd/listing.php new file mode 100644 index 000000000..748edc20c --- /dev/null +++ b/mod/opendd/views/default/opendd/listing.php @@ -0,0 +1,26 @@ + $vars['entity'], + 'size' => 'small', + ) + ); + + $info .= "

getUrl() . "\">" . $vars['entity']->feedurl . "

"; + + // num users, last activity, owner etc + + echo elgg_view_listing($icon, $info); + +?> \ No newline at end of file diff --git a/mod/opendd/views/default/opendd/metatags.php b/mod/opendd/views/default/opendd/metatags.php new file mode 100644 index 000000000..6cc130fc6 --- /dev/null +++ b/mod/opendd/views/default/opendd/metatags.php @@ -0,0 +1,16 @@ + +username}/activity/opendd" ?>" /> \ No newline at end of file diff --git a/mod/opendd/views/default/opendd/profile.php b/mod/opendd/views/default/opendd/profile.php new file mode 100644 index 000000000..ce4dc9e0f --- /dev/null +++ b/mod/opendd/views/default/opendd/profile.php @@ -0,0 +1,109 @@ + + + + + + + + +
+ +
+
+ + $vars['entity'], + //'align' => "left", + 'size' => $iconsize, + ) + ); + + // display relevant links + echo elgg_view("opendd/links", array("entity" => $vars['entity'])); + ?> + +
+
+ +
+
+ + feedurl. "\">" . $vars['entity']->feedurl . "
"; + + ?> + + opendd) && sizeof($vars['config']->opendd) > 0) + { + + foreach($vars['config']->opendd as $shortname => $valtype) { + if ($shortname != "title") { + $value = $vars['entity']->$shortname; + + if (!empty($value)) { + + //This function controls the alternating class + $even_odd = ( 'odd' != $even_odd ) ? 'odd' : 'even'; + } + + echo "

"; + echo ""; + echo elgg_echo("opendd:{$shortname}"); + echo ": "; + + echo elgg_view("output/{$valtype}",array('value' => $vars['entity']->$shortname)); + + echo "

"; + } + } + } + } + + + ?> + +
+
+ +
+ +

+ +canEdit()) + { + +?> + + +   + + + +

+
-- cgit v1.2.3