From c1f8c6378f37e2cac408731b07008a345c3ced8f Mon Sep 17 00:00:00 2001 From: icewing Date: Wed, 30 Apr 2008 12:14:22 +0000 Subject: Marcus Povey * First draft file upload git-svn-id: https://code.elgg.org/elgg/trunk@578 36083f99-b078-4883-b0ff-0f9b5a30f544 --- mod/file/start.php | 127 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 127 insertions(+) create mode 100644 mod/file/start.php (limited to 'mod/file/start.php') diff --git a/mod/file/start.php b/mod/file/start.php new file mode 100644 index 000000000..98ee4ff46 --- /dev/null +++ b/mod/file/start.php @@ -0,0 +1,127 @@ +wwwroot . "pg/file/" . $_SESSION['user']->username, array( + menu_item(sprintf(elgg_echo("file:yours"),$_SESSION['user']->name), $CONFIG->wwwroot . "pg/file/" . $_SESSION['user']->username), + menu_item(sprintf(elgg_echo('file:friends'),$_SESSION['user']->name), $CONFIG->wwwroot . "pg/file/". $_SESSION['user']->username . "/friends/"), + menu_item(elgg_echo('file:all'), $CONFIG->wwwroot . "pg/file/". $_SESSION['user']->username . "/world/"), + menu_item(elgg_echo('file:upload'), $CONFIG->wwwroot . "pg/file/". $_SESSION['user']->username . "/new/") + )); + } + else + { + add_menu(elgg_echo('file'), $CONFIG->wwwroot . "pg/file/" . $_SESSION['user']->username . "/", array( + menu_item(elgg_echo('file:all'), $CONFIG->wwwroot . "pg/file/". $_SESSION['user']->username . "/world/"), + )); + } + + // Register a page handler, so we can have nice URLs + register_page_handler('file','file_page_handler'); + + } + + /** + * File page handler + * + * @param array $page Array of page elements, forwarded by the page handling mechanism + */ + function file_page_handler($page) { + + global $CONFIG; + + // The username should be the file we're getting + if (isset($page[0])) { + set_input('username',$page[0]); + } + + if (isset($page[1])) + { + switch($page[1]) + { + case "friends": + include($CONFIG->pluginspath . "file/friends.php"); + break; + case "world": + include($CONFIG->pluginspath . "file/world.php"); + break; + case "new": + include($CONFIG->pluginspath . "file/upload.php"); + break; + } + } + else + { + // Include the standard profile index + include($CONFIG->pluginspath . "file/index.php"); + } + + } + + /** + * Draw an individual file. + * + * @param ElggFile $file + */ + function file_draw_file(ElggFile $file) + { + // Get tags + $tags = $file->getMetaData("tag"); + if (!is_array($tags)) + $tags = array($tags); + + // Draw file + return elgg_view("file/file", array( + "tags" => $tags, + "title" => $file->title, + "description" => $file->description + )); + } + + /** + * Draw a given set of objects. + * + * @param array $objects + */ + function file_draw(array $objects) + { + $body = ""; + + foreach ($objects as $object) + $body .= file_draw_file($object); + + return $body; + } + + function file_draw_footer($limit, $offset) + { + return elgg_view("file/footer", array( + "limit" => $limit, + "offset" => $offset + )); + } + + // Make sure test_init is called on initialisation + register_event_handler('init','system','file_init'); + + // Register an action + register_action("file/upload", false, $CONFIG->pluginspath . "file/actions/upload.php"); +?> \ No newline at end of file -- cgit v1.2.3