diff options
Diffstat (limited to 'mod/file')
-rw-r--r-- | mod/file/actions/file/delete.php (renamed from mod/file/actions/delete.php) | 0 | ||||
-rw-r--r-- | mod/file/actions/file/download.php (renamed from mod/file/actions/download.php) | 0 | ||||
-rw-r--r-- | mod/file/actions/file/save.php (renamed from mod/file/actions/save.php) | 0 | ||||
-rw-r--r-- | mod/file/actions/file/upload.php (renamed from mod/file/actions/upload.php) | 0 | ||||
-rw-r--r-- | mod/file/edit.php | 33 | ||||
-rw-r--r-- | mod/file/friends.php | 82 | ||||
-rw-r--r-- | mod/file/index.php | 98 | ||||
-rw-r--r-- | mod/file/languages/en.php | 198 | ||||
-rw-r--r-- | mod/file/start.php | 515 | ||||
-rw-r--r-- | mod/file/upload.php | 52 | ||||
-rw-r--r-- | mod/file/views/default/object/file.php | 110 | ||||
-rw-r--r-- | mod/file/world.php | 61 |
12 files changed, 623 insertions, 526 deletions
diff --git a/mod/file/actions/delete.php b/mod/file/actions/file/delete.php index 9357d4955..9357d4955 100644 --- a/mod/file/actions/delete.php +++ b/mod/file/actions/file/delete.php diff --git a/mod/file/actions/download.php b/mod/file/actions/file/download.php index 210735b74..210735b74 100644 --- a/mod/file/actions/download.php +++ b/mod/file/actions/file/download.php diff --git a/mod/file/actions/save.php b/mod/file/actions/file/save.php index 17a9b16fb..17a9b16fb 100644 --- a/mod/file/actions/save.php +++ b/mod/file/actions/file/save.php diff --git a/mod/file/actions/upload.php b/mod/file/actions/file/upload.php index 081b6a312..081b6a312 100644 --- a/mod/file/actions/upload.php +++ b/mod/file/actions/file/upload.php diff --git a/mod/file/edit.php b/mod/file/edit.php index 961332420..da22cacdf 100644 --- a/mod/file/edit.php +++ b/mod/file/edit.php @@ -1,38 +1,37 @@ <?php /** - * Elgg file saver + * Edit a file * * @package ElggFile */ -require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php"); - gatekeeper(); -// Render the file upload page - -$file_guid = (int) get_input('file_guid'); +$file_guid = (int) get_input('guid'); $file = get_entity($file_guid); if (!$file) { forward(); } -// Set the page owner -$page_owner = elgg_get_page_owner(); -if (!$page_owner) { - $container_guid = $file->container_guid; - if ($container_guid) { - set_page_owner($container_guid); - } -} +elgg_push_breadcrumb(elgg_echo('file'), "pg/file/all/"); +elgg_push_breadcrumb($file->title, $file->getURL()); +elgg_push_breadcrumb(elgg_echo('file:edit')); + +elgg_set_page_owner_guid($file->getContainerGUID()); if (!$file->canEdit()) { forward(); } $title = elgg_echo('file:edit'); -$area1 = elgg_view_title($title); -$area1 .= elgg_view("file/upload", array('entity' => $file)); +$content = elgg_view_title($title); +$content .= elgg_view("file/upload", array('entity' => $file)); + +$body = elgg_view_layout('content', array( + 'content' => $content, + 'title' => $title, + 'filter' => '', + 'header' => '', +)); -$body = elgg_view_layout('one_column_with_sidebar', array('content' => $area1)); echo elgg_view_page($title, $body); diff --git a/mod/file/friends.php b/mod/file/friends.php index 6ead3cf40..201f86f62 100644 --- a/mod/file/friends.php +++ b/mod/file/friends.php @@ -1,44 +1,40 @@ <?php - /** - * Elgg file browser - * - * @package ElggFile - */ - - require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php"); - - if (is_callable('group_gatekeeper')) { - group_gatekeeper(); - } - - $owner = elgg_get_page_owner(); - - $title = elgg_echo("file:friends",array($owner->name)); - $area1 = elgg_view('page/elements/content_header', array('context' => "friends", 'type' => 'file')); - elgg_push_context('search'); - // offset is grabbed in list_user_friends_objects - $content = list_user_friends_objects($owner->guid, 'file', 10, false); - elgg_pop_context(); - - $area1 .= get_filetype_cloud($owner->guid, true); - - // handle case where friends don't have any files - if (empty($content)) { - $area2 .= "<p class='margin-top'>".elgg_echo("file:none")."</p>"; - } else { - $area2 .= $content; - } - - //get the latest comments on all files - $comments = get_annotations(0, "object", "file", "generic_comment", "", 0, 4, 0, "desc"); - $area3 = elgg_view('comments/latest', array('comments' => $comments)); - - $content = "<div class='files'>".$area1.$area2."</div>"; - $params = array( - 'content' => $content, - 'sidebar' => $area3 - ); - $body = elgg_view_layout('one_column_with_sidebar', $params); - - echo elgg_view_page($title, $body); -?>
\ No newline at end of file +/** + * Friends Files + * + * @package ElggFile + */ + +elgg_push_breadcrumb(elgg_echo('file'), "pg/file/all/"); +elgg_push_breadcrumb($owner->name, "pg/file/owner/$owner->username"); + + +$owner = elgg_get_page_owner(); + +$title = elgg_echo("file:friends",array($owner->name)); + +elgg_push_context('search'); +// offset is grabbed in list_user_friends_objects +$content = list_user_friends_objects($owner->guid, 'file', 10, false); +elgg_pop_context(); + +$area1 .= get_filetype_cloud($owner->guid, true); + +// handle case where friends don't have any files +if (empty($content)) { + $area2 .= "<p class='margin-top'>".elgg_echo("file:none")."</p>"; +} else { + $area2 .= $content; +} + +//get the latest comments on all files +$comments = get_annotations(0, "object", "file", "generic_comment", "", 0, 4, 0, "desc"); +$area3 = elgg_view('comments/latest', array('comments' => $comments)); + +$body = elgg_view_layout('content', array( + 'filter_context' => 'friends', + 'content' => $content, + 'title' => $title, +)); + +echo elgg_view_page($title, $body); diff --git a/mod/file/index.php b/mod/file/index.php index e0ec1451f..b55f5c835 100644 --- a/mod/file/index.php +++ b/mod/file/index.php @@ -1,51 +1,49 @@ <?php - /** - * Elgg file browser - * - * @package ElggFile - * - * - * TODO: File icons, download & mime types - */ - - require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php"); - - // access check for closed groups - group_gatekeeper(); - - //set the title - if (elgg_get_page_owner_guid() == get_loggedin_userid()) { - $title = elgg_echo('file:yours'); - $area1 = elgg_view('page/elements/content_header', array('context' => "mine", 'type' => 'file')); - } else { - $title = elgg_echo("file:user",array(elgg_get_page_owner()->name)); - $area1 = elgg_view('page/elements/content_header', array('context' => "friends", 'type' => 'file')); - } - - // Get objects - elgg_push_context('search'); - $offset = (int)get_input('offset', 0); - $area2 .= elgg_list_entities(array('types' => 'object', 'subtypes' => 'file', 'container_guid' => elgg_get_page_owner_guid(), 'limit' => 10, 'offset' => $offset, 'full_view' => FALSE)); - elgg_pop_context(); - - $get_filter = get_filetype_cloud(elgg_get_page_owner_guid()); - if ($get_filter) { - $area1 .= $get_filter; - } else { - $area2 .= "<p class='margin-top'>".elgg_echo("file:none")."</p>"; - } - - //get the latest comments on the current users files - $comments = get_annotations(0, "object", "file", "generic_comment", "", 0, 4, 0, "desc",0,0,elgg_get_page_owner_guid()); - $area3 = elgg_view('comments/latest', array('comments' => $comments)); - - $content = "<div class='files'>".$area1.$area2."</div>"; - - $params = array( - 'content' => $content, - 'sidebar' => $area3 - ); - $body = elgg_view_layout('one_column_with_sidebar', $params); - - echo elgg_view_page($title, $body); -?>
\ No newline at end of file +/** + * Elgg file browser + * + * @package ElggFile + */ + +// access check for closed groups +group_gatekeeper(); + +$owner = elgg_get_page_owner(); + +elgg_push_breadcrumb(elgg_echo('file'), "pg/file/all/"); +elgg_push_breadcrumb($owner->name); + + +//set the title +if (elgg_get_page_owner_guid() == get_loggedin_userid()) { + $title = elgg_echo('file:yours'); + $area1 = elgg_view('page/elements/content_header', array('context' => "mine", 'type' => 'file')); +} else { + $title = elgg_echo("file:user",array(elgg_get_page_owner()->name)); + $area1 = elgg_view('page/elements/content_header', array('context' => "friends", 'type' => 'file')); +} + +// Get objects +elgg_push_context('search'); +$offset = (int)get_input('offset', 0); +$content = elgg_list_entities(array('types' => 'object', 'subtypes' => 'file', 'container_guid' => elgg_get_page_owner_guid(), 'limit' => 10, 'offset' => $offset, 'full_view' => FALSE)); +elgg_pop_context(); + +$get_filter = get_filetype_cloud(elgg_get_page_owner_guid()); +if ($get_filter) { + $area1 .= $get_filter; +} else { + $area2 .= "<p class='margin-top'>".elgg_echo("file:none")."</p>"; +} + +//get the latest comments on the current users files +$comments = get_annotations(0, "object", "file", "generic_comment", "", 0, 4, 0, "desc",0,0,elgg_get_page_owner_guid()); +$area3 = elgg_view('comments/latest', array('comments' => $comments)); + +$body = elgg_view_layout('content', array( + 'filter_context' => 'mine', + 'content' => $content, + 'title' => $title, +)); + +echo elgg_view_page($title, $body);
\ No newline at end of file diff --git a/mod/file/languages/en.php b/mod/file/languages/en.php index 1372ae4ce..f06124031 100644 --- a/mod/file/languages/en.php +++ b/mod/file/languages/en.php @@ -1,104 +1,102 @@ <?php +/** + * Elgg file plugin language pack + * + * @package ElggFile + */ + +$english = array( + + /** + * Menu items and titles + */ + 'file' => "Files", + 'files' => "My Files", + 'file:yours' => "Your files", + 'file:yours:friends' => "Your friends' files", + 'file:user' => "%s's files", + 'file:friends' => "%s's friends' files", + 'file:all' => "All site files", + 'file:edit' => "Edit file", + 'file:more' => "More files", + 'file:list' => "list view", + 'file:group' => "Group files", + 'file:gallery' => "gallery view", + 'file:gallery_list' => "Gallery or list view", + 'file:num_files' => "Number of files to display", + 'file:user:gallery'=>'View %s gallery', + 'file:via' => 'via files', + 'file:upload' => "Upload a file", + 'file:replace' => 'Replace file content (leave blank to not change file)', + + 'file:new' => 'Upload a file', + + 'file:file' => "File", + 'file:title' => "Title", + 'file:desc' => "Description", + 'file:tags' => "Tags", + + 'file:types' => "Uploaded file types", + + 'file:type:all' => "All files", + 'file:type:video' => "Videos", + 'file:type:document' => "Documents", + 'file:type:audio' => "Audio", + 'file:type:image' => "Pictures", + 'file:type:general' => "General", + + 'file:user:type:video' => "%s's videos", + 'file:user:type:document' => "%s's documents", + 'file:user:type:audio' => "%s's audio", + 'file:user:type:image' => "%s's pictures", + 'file:user:type:general' => "%s's general files", + + 'file:friends:type:video' => "Your friends' videos", + 'file:friends:type:document' => "Your friends' documents", + 'file:friends:type:audio' => "Your friends' audio", + 'file:friends:type:image' => "Your friends' pictures", + 'file:friends:type:general' => "Your friends' general files", + + 'file:widget' => "File widget", + 'file:widget:description' => "Showcase your latest files", + + 'file:download' => "Download this", + + 'file:delete:confirm' => "Are you sure you want to delete this file?", + + 'file:tagcloud' => "Tag cloud", + + 'file:display:number' => "Number of files to display", + + 'file:river:create' => 'uploaded the file', + + 'item:object:file' => 'Files', + /** - * Elgg file plugin language pack - * - * @package ElggFile + * Embed media + **/ + + 'file:embed' => "Embed media", + 'file:embedall' => "All", + + /** + * Status messages + */ + + 'file:saved' => "Your file was successfully saved.", + 'file:deleted' => "Your file was successfully deleted.", + + /** + * Error messages */ - $english = array( - - /** - * Menu items and titles - */ - - 'file' => "Files", - 'files' => "My Files", - 'file:yours' => "Your files", - 'file:yours:friends' => "Your friends' files", - 'file:user' => "%s's files", - 'file:friends' => "%s's friends' files", - 'file:all' => "All site files", - 'file:edit' => "Edit file", - 'file:more' => "More files", - 'file:list' => "list view", - 'file:group' => "Group files", - 'file:gallery' => "gallery view", - 'file:gallery_list' => "Gallery or list view", - 'file:num_files' => "Number of files to display", - 'file:user:gallery'=>'View %s gallery', - 'file:via' => 'via files', - 'file:upload' => "Upload a file", - 'file:replace' => 'Replace file content (leave blank to not change file)', - - 'file:new' => 'Upload a file', - - 'file:file' => "File", - 'file:title' => "Title", - 'file:desc' => "Description", - 'file:tags' => "Tags", - - 'file:types' => "Uploaded file types", - - 'file:type:all' => "All files", - 'file:type:video' => "Videos", - 'file:type:document' => "Documents", - 'file:type:audio' => "Audio", - 'file:type:image' => "Pictures", - 'file:type:general' => "General", - - 'file:user:type:video' => "%s's videos", - 'file:user:type:document' => "%s's documents", - 'file:user:type:audio' => "%s's audio", - 'file:user:type:image' => "%s's pictures", - 'file:user:type:general' => "%s's general files", - - 'file:friends:type:video' => "Your friends' videos", - 'file:friends:type:document' => "Your friends' documents", - 'file:friends:type:audio' => "Your friends' audio", - 'file:friends:type:image' => "Your friends' pictures", - 'file:friends:type:general' => "Your friends' general files", - - 'file:widget' => "File widget", - 'file:widget:description' => "Showcase your latest files", - - 'file:download' => "Download this", - - 'file:delete:confirm' => "Are you sure you want to delete this file?", - - 'file:tagcloud' => "Tag cloud", - - 'file:display:number' => "Number of files to display", - - 'file:river:create' => 'uploaded the file', - - 'item:object:file' => 'Files', - - /** - * Embed media - **/ - - 'file:embed' => "Embed media", - 'file:embedall' => "All", - - /** - * Status messages - */ - - 'file:saved' => "Your file was successfully saved.", - 'file:deleted' => "Your file was successfully deleted.", - - /** - * Error messages - */ - - 'file:none' => "No files uploaded.", - 'file:uploadfailed' => "Sorry; we could not save your file.", - 'file:downloadfailed' => "Sorry; this file is not available at this time.", - 'file:deletefailed' => "Your file could not be deleted at this time.", - 'file:noaccess' => "You do not have permissions to change this file", - 'file:cannotload' => "There was an error loading the file", - 'file:nofile' => "You must select a file", - ); - - add_translation("en",$english); -?>
\ No newline at end of file + 'file:none' => "No files uploaded.", + 'file:uploadfailed' => "Sorry; we could not save your file.", + 'file:downloadfailed' => "Sorry; this file is not available at this time.", + 'file:deletefailed' => "Your file could not be deleted at this time.", + 'file:noaccess' => "You do not have permissions to change this file", + 'file:cannotload' => "There was an error loading the file", + 'file:nofile' => "You must select a file", +); + +add_translation("en", $english);
\ No newline at end of file diff --git a/mod/file/start.php b/mod/file/start.php index 3376befeb..64533616c 100644 --- a/mod/file/start.php +++ b/mod/file/start.php @@ -1,148 +1,163 @@ <?php - /** - * Elgg file browser - * - * @package ElggFile - */ +/** + * Elgg file browser + * + * @package ElggFile + */ - /** - * Override the ElggFile so that - */ - class FilePluginFile extends ElggFile { - protected function initialise_attributes() { - parent::initialise_attributes(); +/** + * Override the ElggFile so that + */ +class FilePluginFile extends ElggFile { + protected function initialise_attributes() { + parent::initialise_attributes(); - $this->attributes['subtype'] = "file"; - } + $this->attributes['subtype'] = "file"; + } - public function __construct($guid = null) { - parent::__construct($guid); - } + public function __construct($guid = null) { + parent::__construct($guid); } +} - /** - * File plugin initialisation functions. - */ - function file_init() { - global $CONFIG; +/** + * File plugin initialisation functions. + */ +function file_init() { + global $CONFIG; - // Set up menu (tools dropdown) - $item = new ElggMenuItem('file', elgg_echo('file'), 'pg/file'); - elgg_register_menu_item('site', $item); + // Site navigation + $item = new ElggMenuItem('file', elgg_echo('file'), 'pg/file/all'); + elgg_register_menu_item('site', $item); - // Extend CSS - elgg_extend_view('css/screen', 'file/css'); + // Extend CSS + elgg_extend_view('css/screen', 'file/css'); - // extend group main page - elgg_extend_view('groups/tool_latest','file/groupprofile_files'); + // extend group main page + elgg_extend_view('groups/tool_latest', 'file/groupprofile_files'); - // Register a page handler, so we can have nice URLs - register_page_handler('file','file_page_handler'); + // Register a page handler, so we can have nice URLs + register_page_handler('file', 'file_page_handler'); - // Add a new file widget - elgg_register_widget_type('filerepo',elgg_echo("file"),elgg_echo("file:widget:description")); + // Add a new file widget + elgg_register_widget_type('filerepo', elgg_echo("file"), elgg_echo("file:widget:description")); - // Register a URL handler for files - register_entity_url_handler('file_url','object','file'); + // Register a URL handler for files + register_entity_url_handler('file_url', 'object', 'file'); - // Register granular notification for this object type - if (is_callable('register_notification_object')) { - register_notification_object('object', 'file', elgg_echo('file:newupload')); - } + // Register granular notification for this object type + register_notification_object('object', 'file', elgg_echo('file:newupload')); - // Listen to notification events and supply a more useful message - elgg_register_plugin_hook_handler('notify:entity:message', 'object', 'file_notify_message'); + // Listen to notification events and supply a more useful message + elgg_register_plugin_hook_handler('notify:entity:message', 'object', 'file_notify_message'); - // add the group files tool option - add_group_tool_option('file',elgg_echo('groups:enablefiles'),true); + // add the group files tool option + add_group_tool_option('file', elgg_echo('groups:enablefiles'), true); - // Register entity type - register_entity_type('object','file'); + // Register entity type + register_entity_type('object', 'file'); - elgg_register_plugin_hook_handler('register', 'menu:owner_block', 'file_owner_block_menu'); + elgg_register_plugin_hook_handler('register', 'menu:owner_block', 'file_owner_block_menu'); + + // embed support + elgg_register_plugin_hook_handler('embed_get_sections', 'all', 'file_embed_get_sections'); + elgg_register_plugin_hook_handler('embed_get_items', 'file', 'file_embed_get_items'); + elgg_register_plugin_hook_handler('embed_get_upload_sections', 'all', 'file_embed_get_upload_sections'); +} - // embed support - elgg_register_plugin_hook_handler('embed_get_sections', 'all', 'file_embed_get_sections'); - elgg_register_plugin_hook_handler('embed_get_items', 'file', 'file_embed_get_items'); - elgg_register_plugin_hook_handler('embed_get_upload_sections', 'all', 'file_embed_get_upload_sections'); +/** + * Dispatches file pages. + * URLs take the form of + * All files: pg/file/all + * User's files: pg/file/owner/<username> + * Friends' files: pg/file/friends/<username> + * View file: pg/file/view/<guid>/<title> + * New file: pg/file/new/<guid> + * Edit file: pg/file/edit/<guid>/<revision> + * Group files: pg/file/group/<guid>/owner + * + * Title is ignored + * + * @param array $page + * @return NULL + */ +function file_page_handler($page) { + if (!isset($page[0])) { + $page[0] = 'all'; } - /** - * File page handler - * - * @param array $page Array of page elements, forwarded by the page handling mechanism - */ - function file_page_handler($page) { + $file_dir = elgg_get_plugin_path() . 'file'; + + $page_type = $page[0]; + switch ($page_type) { + case 'owner': + set_input('username', $page[1]); + include "$file_dir/index.php"; + break; + case 'friends': + set_input('username', $page[1]); + include "$file_dir/friends.php"; + break; + case 'view': + set_input('guid', $page[1]); + include "$file_dir/view.php"; + break; + case 'new': + set_input('guid', $page[1]); + include "$file_dir/upload.php"; + break; + case 'edit': + set_input('guid', $page[1]); + include "$file_dir/edit.php"; + break; + case 'group': + break; + case 'all': + default: + include "$file_dir/world.php"; + break; + } +} +/** + * Returns a more meaningful message + * + * @param unknown_type $hook + * @param unknown_type $entity_type + * @param unknown_type $returnvalue + * @param unknown_type $params +*/ +function file_notify_message($hook, $entity_type, $returnvalue, $params) { + $entity = $params['entity']; + $to_entity = $params['to_entity']; + $method = $params['method']; + if (($entity instanceof ElggEntity) && ($entity->getSubtype() == 'file')) + { + $descr = $entity->description; + $title = $entity->title; global $CONFIG; - - // The username should be the file we're getting - if (isset($page[0])) { - set_input('username',$page[0]); + $url = elgg_get_site_url() . "pg/view/" . $entity->guid; + if ($method == 'sms') { + $owner = $entity->getOwnerEntity(); + return $owner->name . ' ' . elgg_echo("file:via") . ': ' . $url . ' (' . $title . ')'; } - - if (isset($page[1])) { - switch($page[1]) { - case "read": - set_input('guid',$page[2]); - include(dirname(dirname(dirname(__FILE__))) . "/pages/entities/index.php"); - break; - 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"); + if ($method == 'email') { + $owner = $entity->getOwnerEntity(); + return $owner->name . ' ' . elgg_echo("file:via") . ': ' . $entity->title . "\n\n" . $descr . "\n\n" . $entity->getURL(); } - - } - - /** - * Returns a more meaningful message - * - * @param unknown_type $hook - * @param unknown_type $entity_type - * @param unknown_type $returnvalue - * @param unknown_type $params - */ - function file_notify_message($hook, $entity_type, $returnvalue, $params) { - $entity = $params['entity']; - $to_entity = $params['to_entity']; - $method = $params['method']; - if (($entity instanceof ElggEntity) && ($entity->getSubtype() == 'file')) - { - $descr = $entity->description; - $title = $entity->title; - global $CONFIG; - $url = elgg_get_site_url() . "pg/view/" . $entity->guid; - if ($method == 'sms') { - $owner = $entity->getOwnerEntity(); - return $owner->name . ' ' . elgg_echo("file:via") . ': ' . $url . ' (' . $title . ')'; - } - if ($method == 'email') { - $owner = $entity->getOwnerEntity(); - return $owner->name . ' ' . elgg_echo("file:via") . ': ' . $entity->title . "\n\n" . $descr . "\n\n" . $entity->getURL(); - } - if ($method == 'web') { - $owner = $entity->getOwnerEntity(); - return $owner->name . ' ' . elgg_echo("file:via") . ': ' . $entity->title . "\n\n" . $descr . "\n\n" . $entity->getURL(); - } - } - return null; + if ($method == 'web') { + $owner = $entity->getOwnerEntity(); + return $owner->name . ' ' . elgg_echo("file:via") . ': ' . $entity->title . "\n\n" . $descr . "\n\n" . $entity->getURL(); } + } + return null; +} /** - * Add a menu item to the user ownerblock - */ +* Add a menu item to the user ownerblock +*/ function file_owner_block_menu($hook, $type, $return, $params) { if (elgg_instanceof($params['entity'], 'user')) { $url = "pg/file/owner/{$params['entity']->username}"; @@ -159,164 +174,162 @@ function file_owner_block_menu($hook, $type, $return, $params) { return $return; } - /** - * Returns an overall file type from the mimetype - * - * @param string $mimetype The MIME type - * @return string The overall type - */ - function get_general_file_type($mimetype) { - - switch($mimetype) { - case "application/msword": - return "document"; - break; - case "application/pdf": - return "document"; - break; - } +/** + * Returns an overall file type from the mimetype + * + * @param string $mimetype The MIME type + * @return string The overall type + */ +function get_general_file_type($mimetype) { - if (substr_count($mimetype,'text/')) + switch($mimetype) { + case "application/msword": + return "document"; + break; + case "application/pdf": return "document"; + break; + } - if (substr_count($mimetype,'audio/')) - return "audio"; + if (substr_count($mimetype,'text/')) + return "document"; - if (substr_count($mimetype,'image/')) - return "image"; + if (substr_count($mimetype,'audio/')) + return "audio"; - if (substr_count($mimetype,'video/')) - return "video"; + if (substr_count($mimetype,'image/')) + return "image"; - if (substr_count($mimetype,'opendocument')) - return "document"; + if (substr_count($mimetype,'video/')) + return "video"; - return "general"; - } + if (substr_count($mimetype,'opendocument')) + return "document"; - /** - * Returns a list of filetypes to search specifically on - * - * @param int|array $owner_guid The GUID(s) of the owner(s) of the files - * @param true|false $friends Whether we're looking at the owner or the owner's friends - * @return string The typecloud - */ - function get_filetype_cloud($owner_guid = "", $friends = false) { - - if ($friends) { - if ($friendslist = get_user_friends($user_guid, "", 999999, 0)) { - $friendguids = array(); - foreach($friendslist as $friend) { - $friendguids[] = $friend->getGUID(); - } + return "general"; +} + +/** + * Returns a list of filetypes to search specifically on + * + * @param int|array $owner_guid The GUID(s) of the owner(s) of the files + * @param true|false $friends Whether we're looking at the owner or the owner's friends + * @return string The typecloud + */ +function get_filetype_cloud($owner_guid = "", $friends = false) { + + if ($friends) { + if ($friendslist = get_user_friends($user_guid, "", 999999, 0)) { + $friendguids = array(); + foreach($friendslist as $friend) { + $friendguids[] = $friend->getGUID(); } - $friendofguid = $owner_guid; - $owner_guid = $friendguids; - } else { - $friendofguid = false; } - - elgg_register_tag_metadata_name('simpletype'); - $options = array( - 'type' => 'object', - 'subtype' => 'file', - 'owner_guid' => $owner_guid, - 'threshold' => 0, - 'limit' => 10, - 'tag_names' => array('simpletype') - ); - $types = elgg_get_tags($options); - - return elgg_view('file/typecloud',array('owner_guid' => $owner_guid, 'friend_guid' => $friendofguid, 'types' => $types)); + $friendofguid = $owner_guid; + $owner_guid = $friendguids; + } else { + $friendofguid = false; } - /** - * Register file as an embed type. - * - * @param unknown_type $hook - * @param unknown_type $type - * @param unknown_type $value - * @param unknown_type $params - */ - function file_embed_get_sections($hook, $type, $value, $params) { - $value['file'] = array( - 'name' => elgg_echo('file'), - 'layout' => 'list', - 'icon_size' => 'small', - ); - - return $value; - } + elgg_register_tag_metadata_name('simpletype'); + $options = array( + 'type' => 'object', + 'subtype' => 'file', + 'owner_guid' => $owner_guid, + 'threshold' => 0, + 'limit' => 10, + 'tag_names' => array('simpletype') + ); + $types = elgg_get_tags($options); + + return elgg_view('file/typecloud',array('owner_guid' => $owner_guid, 'friend_guid' => $friendofguid, 'types' => $types)); +} - /** - * Return a list of files for embedding - * - * @param unknown_type $hook - * @param unknown_type $type - * @param unknown_type $value - * @param unknown_type $params - */ - function file_embed_get_items($hook, $type, $value, $params) { - $options = array( - 'owner_guid' => get_loggedin_userid(), - 'type_subtype_pair' => array('object' => 'file'), - 'count' => TRUE - ); +/** + * Register file as an embed type. + * + * @param unknown_type $hook + * @param unknown_type $type + * @param unknown_type $value + * @param unknown_type $params + */ +function file_embed_get_sections($hook, $type, $value, $params) { + $value['file'] = array( + 'name' => elgg_echo('file'), + 'layout' => 'list', + 'icon_size' => 'small', + ); + + return $value; +} - if ($count = elgg_get_entities($options)) { - $value['count'] += $count; +/** + * Return a list of files for embedding + * + * @param unknown_type $hook + * @param unknown_type $type + * @param unknown_type $value + * @param unknown_type $params + */ +function file_embed_get_items($hook, $type, $value, $params) { + $options = array( + 'owner_guid' => get_loggedin_userid(), + 'type_subtype_pair' => array('object' => 'file'), + 'count' => TRUE + ); - unset($options['count']); - $options['offset'] = $params['offset']; - $options['limit'] = $params['limit']; + if ($count = elgg_get_entities($options)) { + $value['count'] += $count; - $items = elgg_get_entities($options); + unset($options['count']); + $options['offset'] = $params['offset']; + $options['limit'] = $params['limit']; - $value['items'] = array_merge($items, $value['items']); - } + $items = elgg_get_entities($options); - return $value; + $value['items'] = array_merge($items, $value['items']); } - /** - * Register file as an embed type. - * - * @param unknown_type $hook - * @param unknown_type $type - * @param unknown_type $value - * @param unknown_type $params - */ - function file_embed_get_upload_sections($hook, $type, $value, $params) { - $value['file'] = array( - 'name' => elgg_echo('file'), - 'view' => 'file/embed_upload' - ); - - return $value; - } + return $value; +} +/** + * Register file as an embed type. + * + * @param unknown_type $hook + * @param unknown_type $type + * @param unknown_type $value + * @param unknown_type $params + */ +function file_embed_get_upload_sections($hook, $type, $value, $params) { + $value['file'] = array( + 'name' => elgg_echo('file'), + 'view' => 'file/embed_upload' + ); - /** - * Populates the ->getUrl() method for file objects - * - * @param ElggEntity $entity File entity - * @return string File URL - */ - function file_url($entity) { - $title = $entity->title; - $title = elgg_get_friendly_title($title); - return "pg/file/" . $entity->getOwnerEntity()->username . "/read/" . $entity->getGUID() . "/" . $title; - } + return $value; +} - // Make sure test_init is called on initialisation - elgg_register_event_handler('init','system','file_init'); - // Register actions - elgg_register_action("file/upload", $CONFIG->pluginspath . "file/actions/upload.php"); - elgg_register_action("file/save", $CONFIG->pluginspath . "file/actions/save.php"); - elgg_register_action("file/delete", $CONFIG->pluginspath. "file/actions/delete.php"); +/** + * Populates the ->getUrl() method for file objects + * + * @param ElggEntity $entity File entity + * @return string File URL + */ +function file_url($entity) { + $title = $entity->title; + $title = elgg_get_friendly_title($title); + return "pg/file/view/" . $entity->getGUID() . "/" . $title; +} + +// Make sure test_init is called on initialisation +elgg_register_event_handler('init','system','file_init'); - // temporary - see #2010 - elgg_register_action("file/download", $CONFIG->pluginspath. "file/actions/download.php"); +// Register actions +elgg_register_action("file/upload", $CONFIG->pluginspath . "file/actions/file/upload.php"); +elgg_register_action("file/save", $CONFIG->pluginspath . "file/actions/file/save.php"); +elgg_register_action("file/delete", $CONFIG->pluginspath. "file/actions/file/delete.php"); -?> +// temporary - see #2010 +elgg_register_action("file/download", $CONFIG->pluginspath. "file/actions/file/download.php"); diff --git a/mod/file/upload.php b/mod/file/upload.php index 2040c7240..0c89e64a5 100644 --- a/mod/file/upload.php +++ b/mod/file/upload.php @@ -1,24 +1,30 @@ <?php - /** - * Elgg file browser uploader - * - * @package ElggFile - */ - - require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php"); - - gatekeeper(); - if (is_callable('group_gatekeeper')) { - group_gatekeeper(); - } - - // Render the file upload page - - $container_guid = elgg_get_page_owner_guid(); - $area1 = elgg_view_title($title = elgg_echo('file:upload')); - $area1 .= elgg_view("file/upload", array('container_guid' => $container_guid)); - $body = elgg_view_layout('one_column_with_sidebar', array('content' => $area1)); - - echo elgg_view_page(elgg_echo("file:upload"), $body); - -?>
\ No newline at end of file +/** + * Upload a new file + * + * @package ElggFile + */ + +elgg_set_page_owner_guid(get_input('guid')); + +gatekeeper(); +group_gatekeeper(); + +elgg_push_breadcrumb(elgg_echo('file'), "pg/file/all/"); +elgg_push_breadcrumb(elgg_echo('file:new')); + +$container_guid = elgg_get_page_owner_guid(); + +$title = elgg_echo('file:upload'); + +$content = elgg_view_title($title); + +$content .= elgg_view("file/upload", array('container_guid' => $container_guid)); +$body = elgg_view_layout('content', array( + 'content' => $content, + 'title' => $title, + 'filter' => '', + 'header' => '', +)); + +echo elgg_view_page($title, $body); diff --git a/mod/file/views/default/object/file.php b/mod/file/views/default/object/file.php index b4754cb18..0f128eed6 100644 --- a/mod/file/views/default/object/file.php +++ b/mod/file/views/default/object/file.php @@ -1,10 +1,108 @@ <?php - /** - * Elgg file browser. - * File renderer. - * - * @package ElggFile - */ +/** + * File renderer. + * + * @package ElggFile + */ + +$full = elgg_get_array_value('full', $vars, FALSE); +$file = elgg_get_array_value('entity', $vars, FALSE); + +if (!$file) { + return TRUE; +} + +$owner = $file->getOwnerEntity(); +$container = $file->getContainerEntity(); +$categories = elgg_view('categories/view', $vars); +$excerpt = elgg_get_excerpt($file->description); +$mime = $file->mimetype; + +$body = autop($file->description); +$owner_icon = elgg_view('profile/icon', array('entity' => $owner, 'size' => 'tiny')); +$owner_link = elgg_view('output/url', array( + 'href' => "pg/file/owner/$owner->username", + 'text' => $owner->name, +)); +$author_text = elgg_echo('blog:author_by_line', array($owner_link)); +if ($file->tags) { + $tags = "<p class=\"elgg-tags\">" . elgg_view('output/tags', array('tags' => $file->tags)) . "</p>"; +} else { + $tags = ""; +} +$date = elgg_view_friendly_time($file->time_created); + +$comments_count = elgg_count_comments($file); +//only display if there are commments +if ($comments_count != 0) { + $text = elgg_echo("comments") . " ($comments_count)"; + $comments_link = elgg_view('output/url', array( + 'href' => $file->getURL() . '#file-comments', + 'text' => $text, + )); +} else { + $comments_link = ''; +} + +$metadata = elgg_view('layout/objects/list/metadata', array( + 'entity' => $file, + 'handler' => 'file', +)); + +$subtitle = "$author_text $date $categories $comments_link"; + +// do not show the metadata and controls in widget view +if (elgg_in_context('widgets')) { + $metadata = ''; +} + +if ($full) { + + $header = elgg_view_title($file->title); + + $params = array( + 'entity' => $file, + 'title' => false, + 'metadata' => $metadata, + 'subtitle' => $subtitle, + 'tags' => $tags, + ); + $list_body = elgg_view('layout/objects/list/body', $params); + + $file_info = elgg_view_image_block($owner_icon, $list_body); + + if (elgg_view_exists('file/specialcontent/' . $mime)) { + $blah = "<div class='filerepo_specialcontent'>".elgg_view('file/specialcontent/' . $mime, $vars)."</div>"; + } else if (elgg_view_exists("file/specialcontent/" . substr($mime,0,strpos($mime,'/')) . "/default")) { + $blah = "<div class='filerepo_specialcontent'>".elgg_view("file/specialcontent/" . substr($mime,0,strpos($mime,'/')) . "/default", $vars)."</div>"; + } + + + echo <<<HTML +$header +$file_info +<div class="file elgg-content"> + $body + $blah +</div> +HTML; + +} else { + // brief view + + $params = array( + 'entity' => $file, + 'metadata' => $metadata, + 'subtitle' => $subtitle, + 'tags' => $tags, + 'content' => $excerpt, + ); + $list_body = elgg_view('layout/objects/list/body', $params); + + echo elgg_view_image_block($owner_icon, $list_body); +} + +return true; global $CONFIG; diff --git a/mod/file/world.php b/mod/file/world.php index 3bacaad00..1b8f5f828 100644 --- a/mod/file/world.php +++ b/mod/file/world.php @@ -1,40 +1,29 @@ <?php - /** - * Elgg file browser - * - * @package ElggFile - */ +/** + * All files + * + * @package ElggFile + */ - require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php"); - - $limit = get_input("limit", 10); - $offset = get_input("offset", 0); - - // Get the current page's owner - $page_owner = elgg_get_page_owner(); - if ($page_owner === false || is_null($page_owner)) { - $page_owner = get_loggedin_user(); - set_page_owner(get_loggedin_userid()); - } - - $title = elgg_echo('file:all'); - - // Get objects - $area1 = elgg_view('page/elements/content_header', array('context' => "everyone", 'type' => 'file')); - $area1 .= get_filetype_cloud(); // the filter - elgg_push_context('search'); - $area2 .= elgg_list_entities(array('types' => 'object', 'subtypes' => 'file', 'limit' => $limit, 'offset' => $offset, 'full_view' => FALSE)); - elgg_pop_context(); +elgg_push_breadcrumb(elgg_echo('file')); - //get the latest comments on all files - $comments = get_annotations(0, "object", "file", "generic_comment", "", 0, 4, 0, "desc"); - $area3 = elgg_view('comments/latest', array('comments' => $comments)); - - $content = "<div class='files'>".$area1.$area2."</div>"; - $params = array( - 'content' => $content, - 'sidebar' => $area3 - ); - $body = elgg_view_layout('one_column_with_sidebar', $params); +$limit = get_input("limit", 10); - echo elgg_view_page($title, $body); +$title = elgg_echo('file:all'); + +elgg_push_context('search'); +$content = elgg_list_entities(array( + 'types' => 'object', + 'subtypes' => 'file', + 'limit' => $limit, + 'full_view' => FALSE +)); +elgg_pop_context(); + +$body = elgg_view_layout('content', array( + 'filter_context' => 'all', + 'content' => $content, + 'title' => $title, +)); + +echo elgg_view_page($title, $body); |