From cbb06b10079ee132aae4cbf573aeaa996f390165 Mon Sep 17 00:00:00 2001 From: marcus Date: Thu, 31 Jul 2008 14:56:39 +0000 Subject: Guid tool for import, export and browsing. git-svn-id: https://code.elgg.org/elgg/trunk@1633 36083f99-b078-4883-b0ff-0f9b5a30f544 --- mod/guidtool/export.php | 22 +++++++++ mod/guidtool/format_picker.php | 25 +++++++++++ mod/guidtool/import.php | 4 +- mod/guidtool/index.php | 18 +++++++- mod/guidtool/languages/en.php | 4 ++ mod/guidtool/start.php | 52 ++++++++++++++++++++-- mod/guidtool/view.php | 22 +++++++++ .../views/default/forms/guidtool/export.php | 23 ++++++++++ .../views/default/forms/guidtool/format.php | 40 +++++++++++++++++ mod/guidtool/views/default/guidtool/gallery.php | 26 +++++++++++ mod/guidtool/views/default/guidtool/listing.php | 31 +++++++++++++ mod/guidtool/views/default/guidtool/profile.php | 16 +++++++ .../views/default/object/guidtoolwrapper.php | 21 +++++++++ 13 files changed, 299 insertions(+), 5 deletions(-) create mode 100644 mod/guidtool/export.php create mode 100644 mod/guidtool/format_picker.php create mode 100644 mod/guidtool/view.php create mode 100644 mod/guidtool/views/default/forms/guidtool/export.php create mode 100644 mod/guidtool/views/default/forms/guidtool/format.php create mode 100644 mod/guidtool/views/default/guidtool/gallery.php create mode 100644 mod/guidtool/views/default/guidtool/listing.php create mode 100644 mod/guidtool/views/default/guidtool/profile.php create mode 100644 mod/guidtool/views/default/object/guidtoolwrapper.php (limited to 'mod') diff --git a/mod/guidtool/export.php b/mod/guidtool/export.php new file mode 100644 index 000000000..e1a2b86c6 --- /dev/null +++ b/mod/guidtool/export.php @@ -0,0 +1,22 @@ + $entity_guid)); + + $body = elgg_view_layout('one_column', $body); + + page_draw($title, $body); +?> \ No newline at end of file diff --git a/mod/guidtool/format_picker.php b/mod/guidtool/format_picker.php new file mode 100644 index 000000000..f5e12143d --- /dev/null +++ b/mod/guidtool/format_picker.php @@ -0,0 +1,25 @@ + $formats)); + + $body = elgg_view_layout('one_column', $body); + + page_draw($title, $body); +?> \ No newline at end of file diff --git a/mod/guidtool/import.php b/mod/guidtool/import.php index bab06135f..bfb3f698b 100644 --- a/mod/guidtool/import.php +++ b/mod/guidtool/import.php @@ -10,11 +10,13 @@ */ admin_gatekeeper(); + + $format = get_input('format', 'opendd'); // Render the file upload page $title = elgg_echo("guidtool:import"); $body = elgg_view_title($title); - $body .= elgg_view("forms/guidtool/import"); + $body .= elgg_view("forms/guidtool/import", array('format' => $format, 'forward_url')); $body = elgg_view_layout('one_column', $body); diff --git a/mod/guidtool/index.php b/mod/guidtool/index.php index 9494d8790..cc10f770f 100644 --- a/mod/guidtool/index.php +++ b/mod/guidtool/index.php @@ -19,9 +19,25 @@ $limit = get_input('limit', 10); $offset = get_input('offset'); + $title = elgg_echo("guidtool"); + // Get entities + $entities = get_entities("","","","",$limit, $offset); + $count = get_entities("","","","",$limit, $offset, true); + + $wrapped_entries = array(); + + foreach ($entities as $e) + { + $tmp = new ElggObject(); + $tmp->subtype = 'guidtoolwrapper'; + $tmp->entity = $e; + $wrapped_entries[] = $tmp; + } + + $body = elgg_view_title($title) . elgg_view_entity_list($wrapped_entries, $count, $offset, $limit, false); // Display main admin menu - page_draw(elgg_echo("guidtool"),elgg_view_layout("one_column", $body)); + page_draw($title,elgg_view_layout("one_column", $body)); set_context($context); ?> \ No newline at end of file diff --git a/mod/guidtool/languages/en.php b/mod/guidtool/languages/en.php index e74624605..cb80143e2 100644 --- a/mod/guidtool/languages/en.php +++ b/mod/guidtool/languages/en.php @@ -19,6 +19,10 @@ 'guidtool:browse' => 'Browse GUID', 'guidtool:import' => 'Import', 'guidtool:import:desc' => 'Paste the data you want to import in following window, this must be in "%s" format.', + + 'guidtool:pickformat' => 'Please select the format that you wish to import or export.', + + 'guidbrowser:export' => 'Export', ); add_translation("en",$english); diff --git a/mod/guidtool/start.php b/mod/guidtool/start.php index f658d5abf..f6e461ed3 100644 --- a/mod/guidtool/start.php +++ b/mod/guidtool/start.php @@ -42,8 +42,37 @@ { switch ($page[0]) { - case 'import' : - include($CONFIG->pluginspath . "guidtool/import.php"); + case 'view' : + case 'export': + + if ((isset($page[1]) && (!empty($page[1])))) { + add_submenu_item('GUID:'.$page[1], $CONFIG->url . "pg/guidtool/view/{$page[1]}/"); + add_submenu_item(elgg_echo('guidbrowser:export'), $CONFIG->url . "pg/guidtool/export/{$page[1]}/"); + + set_input('entity_guid', $page[1]); + if ($page[0] == 'view') + include($CONFIG->pluginspath . "guidtool/view.php"); + else + { + if ((isset($page[2]) && (!empty($page[2])))) { + set_input('format', $page[2]); + include($CONFIG->pluginspath . "guidtool/export.php"); + } else { + set_input('forward_url', $CONFIG->url . "pg/guidtool/export/$page[1]/"); + include($CONFIG->pluginspath . "guidtool/format_picker.php"); + } + } + } + else include($CONFIG->pluginspath . "guidtool/index.php"); + break; + case 'import' : + if ((isset($page[1]) && (!empty($page[1])))) { + set_input('format', $page[1]); + include($CONFIG->pluginspath . "guidtool/import.php"); + } else { + set_input('forward_url', $CONFIG->url . "pg/guidtool/import/"); + include($CONFIG->pluginspath . "guidtool/format_picker.php"); + } break; default: include($CONFIG->pluginspath . "guidtool/index.php"); @@ -53,7 +82,24 @@ include($CONFIG->pluginspath . "guidtool/index.php"); } - + /** + * Get a list of import actions + * + */ + function guidtool_get_import_actions() + { + global $CONFIG; + + $return = array(); + + foreach ($CONFIG->actions as $action => $handler) + { + if (strpos($action, "import/")===0) + $return[] = substr($action, 7); + } + + return $return; + } // Initialise log register_elgg_event_handler('init','system','guidtool_init'); diff --git a/mod/guidtool/view.php b/mod/guidtool/view.php new file mode 100644 index 000000000..c9f1f9fc5 --- /dev/null +++ b/mod/guidtool/view.php @@ -0,0 +1,22 @@ + $entity_guid)); + + $body = elgg_view_layout('one_column', $body); + + page_draw($title, $body); +?> \ No newline at end of file diff --git a/mod/guidtool/views/default/forms/guidtool/export.php b/mod/guidtool/views/default/forms/guidtool/export.php new file mode 100644 index 000000000..cb92991a2 --- /dev/null +++ b/mod/guidtool/views/default/forms/guidtool/export.php @@ -0,0 +1,23 @@ + +
+ htmlentities(file_get_contents($CONFIG->url . "export/$format/$entity_guid/")))) ?> +
\ No newline at end of file diff --git a/mod/guidtool/views/default/forms/guidtool/format.php b/mod/guidtool/views/default/forms/guidtool/format.php new file mode 100644 index 000000000..7a3f397d5 --- /dev/null +++ b/mod/guidtool/views/default/forms/guidtool/format.php @@ -0,0 +1,40 @@ + + +
+
+ + " /> +
+
\ No newline at end of file diff --git a/mod/guidtool/views/default/guidtool/gallery.php b/mod/guidtool/views/default/guidtool/gallery.php new file mode 100644 index 000000000..9212df17b --- /dev/null +++ b/mod/guidtool/views/default/guidtool/gallery.php @@ -0,0 +1,26 @@ +entity; + $by = $entity->getOwnerEntity(); + + + + $info .= "

url}pg/guidtool/view/{$entity->guid}/\">" . get_class($entity) . "

"; + + $info .= "
"; + if ($by) $info .= elgg_echo('by') . " getURL()."\">{$by->name} "; + $info .= " " . friendly_time($entity->time_created )."
"; + + echo elgg_view_listing($icon, $info); +?> \ No newline at end of file diff --git a/mod/guidtool/views/default/guidtool/listing.php b/mod/guidtool/views/default/guidtool/listing.php new file mode 100644 index 000000000..21d93b64a --- /dev/null +++ b/mod/guidtool/views/default/guidtool/listing.php @@ -0,0 +1,31 @@ +entity; + $by = $entity->getOwnerEntity(); + + $icon = elgg_view( + 'graphics/icon', array( + 'entity' => $vars['entity'], + 'size' => 'small', + ) + ); + + $info .= "

url}pg/guidtool/view/{$entity->guid}/\">" . get_class($entity) . "

"; + + $info .= "
"; + if ($by) $info .= elgg_echo('by') . " getURL()."\">{$by->name} "; + $info .= " " . friendly_time($entity->time_created )."
"; + + echo elgg_view_listing($icon, $info); +?> \ No newline at end of file diff --git a/mod/guidtool/views/default/guidtool/profile.php b/mod/guidtool/views/default/guidtool/profile.php new file mode 100644 index 000000000..d32141b11 --- /dev/null +++ b/mod/guidtool/views/default/guidtool/profile.php @@ -0,0 +1,16 @@ + get_entity($entity_guid))); +?> \ No newline at end of file diff --git a/mod/guidtool/views/default/object/guidtoolwrapper.php b/mod/guidtool/views/default/object/guidtoolwrapper.php new file mode 100644 index 000000000..d83f7fb30 --- /dev/null +++ b/mod/guidtool/views/default/object/guidtoolwrapper.php @@ -0,0 +1,21 @@ + \ No newline at end of file -- cgit v1.2.3