diff options
Diffstat (limited to 'mod/file')
79 files changed, 2262 insertions, 0 deletions
diff --git a/mod/file/actions/delete.php b/mod/file/actions/delete.php new file mode 100644 index 000000000..ee6dab91e --- /dev/null +++ b/mod/file/actions/delete.php @@ -0,0 +1,68 @@ +<?php + + /** + * Elgg file delete + * + * @package ElggFile + * @author Curverider Ltd + * @copyright Curverider Ltd 2008-2010 + * @link http://elgg.com/ + */ + + $guid = (int) get_input('file'); + if ($file = get_entity($guid)) { + + if ($file->canEdit()) { + + $container = get_entity($file->container_guid); + + $thumbnail = $file->thumbnail; + $smallthumb = $file->smallthumb; + $largethumb = $file->largethumb; + if ($thumbnail) { + + $delfile = new ElggFile(); + $delfile->owner_guid = $file->owner_guid; + $delfile->setFilename($thumbnail); + $delfile->delete(); + + } + if ($smallthumb) { + + $delfile = new ElggFile(); + $delfile->owner_guid = $file->owner_guid; + $delfile->setFilename($smallthumb); + $delfile->delete(); + + } + if ($largethumb) { + + $delfile = new ElggFile(); + $delfile->owner_guid = $file->owner_guid; + $delfile->setFilename($largethumb); + $delfile->delete(); + + } + + if (!$file->delete()) { + register_error(elgg_echo("file:deletefailed")); + } else { + system_message(elgg_echo("file:deleted")); + } + + } else { + + $container = $_SESSION['user']; + register_error(elgg_echo("file:deletefailed")); + + } + + } else { + + register_error(elgg_echo("file:deletefailed")); + + } + + forward("pg/file/" . $_SESSION['user']->username); + +?>
\ No newline at end of file diff --git a/mod/file/actions/download.php b/mod/file/actions/download.php new file mode 100644 index 000000000..ef5f24964 --- /dev/null +++ b/mod/file/actions/download.php @@ -0,0 +1,40 @@ +<?php + /** + * Elgg file browser download action. + * + * @package ElggFile + * @author Curverider Ltd + * @copyright Curverider Ltd 2008-2010 + * @link http://elgg.com/ + */ + + // Get the guid + $file_guid = get_input("file_guid"); + + // Get the file + $file = get_entity($file_guid); + + if ($file) + { + $mime = $file->getMimeType(); + if (!$mime) $mime = "application/octet-stream"; + + $filename = $file->originalfilename; + + // fix for IE https issue + header("Pragma: public"); + header("Content-type: $mime"); + if (strpos($mime, "image/")!==false) + header("Content-Disposition: inline; filename=\"$filename\""); + else + header("Content-Disposition: attachment; filename=\"$filename\""); + + $contents = $file->grabFile(); + $splitString = str_split($contents, 8192); + foreach($splitString as $chunk) + echo $chunk; + exit; + } + else + register_error(elgg_echo("file:downloadfailed")); +?>
\ No newline at end of file diff --git a/mod/file/actions/save.php b/mod/file/actions/save.php new file mode 100644 index 000000000..038e61d83 --- /dev/null +++ b/mod/file/actions/save.php @@ -0,0 +1,51 @@ +<?php + /** + * Elgg file browser save action + * + * @package ElggFile + * @author Curverider Ltd + * @copyright Curverider Ltd 2008-2010 + * @link http://elgg.com/ + */ + + global $CONFIG; + + // Get variables + $title = get_input("title"); + $desc = get_input("description"); + $tags = get_input("tags"); + $access_id = (int) get_input("access_id"); + + $guid = (int) get_input('file_guid'); + + if (!$file = get_entity($guid)) { + register_error(elgg_echo("file:uploadfailed")); + forward($CONFIG->wwwroot . "pg/file/" . $_SESSION['user']->username); + exit; + } + + $result = false; + + $container_guid = $file->container_guid; + $container = get_entity($container_guid); + + if ($file->canEdit()) { + + $file->access_id = $access_id; + $file->title = $title; + $file->description = $desc; + + // Save tags + $tags = explode(",", $tags); + $file->tags = $tags; + + $result = $file->save(); + } + + if ($result) + system_message(elgg_echo("file:saved")); + else + register_error(elgg_echo("file:uploadfailed")); + + forward($CONFIG->wwwroot . "pg/file/" . $container->username); +?>
\ No newline at end of file diff --git a/mod/file/actions/upload.php b/mod/file/actions/upload.php new file mode 100644 index 000000000..e515c73e0 --- /dev/null +++ b/mod/file/actions/upload.php @@ -0,0 +1,171 @@ +<?php + /** + * Elgg file browser uploader/edit action + * + * @package ElggFile + * @author Curverider Ltd + * @copyright Curverider Ltd 2008-2010 + * @link http://elgg.com/ + */ + + global $CONFIG; + + gatekeeper(); + + // Get variables + $title = get_input("title"); + $desc = get_input("description"); + $access_id = (int) get_input("access_id"); + $container_guid = (int) get_input('container_guid', 0); + if ($container_guid == 0) { + $container_guid = get_loggedin_userid(); + } + $guid = (int) get_input('file_guid'); + $tags = get_input("tags"); + + // check whether this is a new file or an edit + $new_file = true; + if ($guid > 0) { + $new_file = false; + } + + if ($new_file) { + // must have a file if a new file upload + if (empty($_FILES['upload']['name'])) { + // cache information in session + $_SESSION['uploadtitle'] = $title; + $_SESSION['uploaddesc'] = $desc; + $_SESSION['uploadtags'] = $tags; + $_SESSION['uploadaccessid'] = $access_id; + + register_error(elgg_echo('file:nofile')); + forward($_SERVER['HTTP_REFERER']); + } + + $file = new FilePluginFile(); + $file->subtype = "file"; + + // if no title on new upload, grab filename + if (empty($title)) { + $title = $_FILES['upload']['name']; + } + + } else { + // load original file object + $file = get_entity($guid); + if (!$file) { + register_error(elgg_echo('file:cannotload')); + forward($_SERVER['HTTP_REFERER']); + } + + // user must be able to edit file + if (!$file->canEdit()) { + register_error(elgg_echo('file:noaccess')); + forward($_SERVER['HTTP_REFERER']); + } + } + + $file->title = $title; + $file->description = $desc; + $file->access_id = $access_id; + $file->container_guid = $container_guid; + + $tags = explode(",", $tags); + $file->tags = $tags; + + // we have a file upload, so process it + if (isset($_FILES['upload']['name']) && !empty($_FILES['upload']['name'])) { + + $prefix = "file/"; + + // if previous file, delete it + if ($new_file == false) { + $filename = $file->getFilenameOnFilestore(); + if (file_exists($filename)) { + unlink($filename); + } + + // use same filename on the disk - ensures thumbnails are overwritten + $filestorename = $file->getFilename(); + $filestorename = substr($filestorename, strlen($prefix)); + } else { + $filestorename = strtolower(time().$_FILES['upload']['name']); + } + + $file->setFilename($prefix.$filestorename); + $file->setMimeType($_FILES['upload']['type']); + $file->originalfilename = $_FILES['upload']['name']; + $file->simpletype = get_general_file_type($_FILES['upload']['type']); + + $file->open("write"); + $file->write(get_uploaded_file('upload')); + $file->close(); + + $guid = $file->save(); + + // if image, we need to create thumbnails (this should be moved into a function) + if ($guid && $file->simpletype == "image") { + $thumbnail = get_resized_image_from_existing_file($file->getFilenameOnFilestore(),60,60, true); + if ($thumbnail) { + $thumb = new ElggFile(); + $thumb->setMimeType($_FILES['upload']['type']); + + $thumb->setFilename($prefix."thumb".$filestorename); + $thumb->open("write"); + $thumb->write($thumbnail); + $thumb->close(); + + $file->thumbnail = $prefix."thumb".$filestorename; + unset($thumbnail); + } + + $thumbsmall = get_resized_image_from_existing_file($file->getFilenameOnFilestore(),153,153, true); + if ($thumbsmall) { + $thumb->setFilename($prefix."smallthumb".$filestorename); + $thumb->open("write"); + $thumb->write($thumbsmall); + $thumb->close(); + $file->smallthumb = $prefix."smallthumb".$filestorename; + unset($thumbsmall); + } + + $thumblarge = get_resized_image_from_existing_file($file->getFilenameOnFilestore(),600,600, false); + if ($thumblarge) { + $thumb->setFilename($prefix."largethumb".$filestorename); + $thumb->open("write"); + $thumb->write($thumblarge); + $thumb->close(); + $file->largethumb = $prefix."largethumb".$filestorename; + unset($thumblarge); + } + } + } + + // make sure session cache is cleared + unset($_SESSION['uploadtitle']); + unset($_SESSION['uploaddesc']); + unset($_SESSION['uploadtags']); + unset($_SESSION['uploadaccessid']); + + // handle results differently for new files and file updates + if ($new_file) { + if ($guid) { + system_message(elgg_echo("file:saved")); + add_to_river('river/object/file/create', 'create', get_loggedin_userid(), $file->guid); + } else { + // failed to save file object - nothing we can do about this + register_error(elgg_echo("file:uploadfailed")); + } + + $container_user = get_entity($container_guid); + forward($CONFIG->wwwroot . "pg/file/" . $container_user->username); + + } else { + if ($guid) { + system_message(elgg_echo("file:saved")); + } else { + register_error(elgg_echo("file:uploadfailed")); + } + + forward($file->getURL()); + } diff --git a/mod/file/download.php b/mod/file/download.php new file mode 100644 index 000000000..6ef8719b3 --- /dev/null +++ b/mod/file/download.php @@ -0,0 +1,44 @@ +<?php + /** + * Elgg file download. + * + * @package ElggFile + * @author Curverider Ltd + * @copyright Curverider Ltd 2008-2010 + * @link http://elgg.com/ + */ + + require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php"); + + // Get the guid + $file_guid = get_input("file_guid"); + + // Get the file + $file = get_entity($file_guid); + + if ($file) { + $mime = $file->getMimeType(); + if (!$mime) { + $mime = "application/octet-stream"; + } + + $filename = $file->originalfilename; + + // fix for IE https issue + header("Pragma: public"); + + header("Content-type: $mime"); + if (strpos($mime, "image/")!==false) + header("Content-Disposition: inline; filename=\"$filename\""); + else + header("Content-Disposition: attachment; filename=\"$filename\""); + + $contents = $file->grabFile(); + $splitString = str_split($contents, 8192); + foreach($splitString as $chunk) + echo $chunk; + exit; + } else { + register_error(elgg_echo("file:downloadfailed")); + forward(); + }
\ No newline at end of file diff --git a/mod/file/edit.php b/mod/file/edit.php new file mode 100644 index 000000000..9dfc12eea --- /dev/null +++ b/mod/file/edit.php @@ -0,0 +1,41 @@ +<?php +/** + * Elgg file saver + * + * @package ElggFile + * @author Curverider Ltd + * @copyright Curverider Ltd 2008-2010 + * @link http://elgg.com/ + */ + +require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php"); + +gatekeeper(); + +// Render the file upload page + +$file_guid = (int) get_input('file_guid'); +$file = get_entity($file_guid); +if (!$file) { + forward(); +} + +// Set the page owner +$page_owner = page_owner_entity(); +if (!$page_owner) { + $container_guid = $file->container_guid; + if ($container_guid) { + set_page_owner($container_guid); + } +} + +if (!$file->canEdit()) { + forward(); +} + +$title = elgg_echo('file:edit'); +$area2 = elgg_view_title($title); +$area2 .= elgg_view("file/upload", array('entity' => $file)); + +$body = elgg_view_layout('two_column_left_sidebar', '', $area2); +page_draw($title, $body); diff --git a/mod/file/friends.php b/mod/file/friends.php new file mode 100644 index 000000000..0693991d9 --- /dev/null +++ b/mod/file/friends.php @@ -0,0 +1,38 @@ +<?php + /** + * Elgg file browser + * + * @package ElggFile + * @author Curverider Ltd + * @copyright Curverider Ltd 2008-2010 + * @link http://elgg.com/ + */ + + require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php"); + + if (is_callable('group_gatekeeper')) { + group_gatekeeper(); + } + + $owner = page_owner_entity(); + + $title = sprintf(elgg_echo("file:friends"),$owner->name); + + $area2 = elgg_view_title($title); + + set_context('search'); + $content = list_user_friends_objects($owner->guid, 'file', 10, false); + set_context('file'); + $area1 = get_filetype_cloud($owner->guid, true); + + // handle case where friends don't have any files + if (empty($content)) { + $area2 .= elgg_view('page_elements/contentwrapper',array('body' => elgg_echo("file:none"))); + } else { + $area2 .= $content; + } + + $body = elgg_view_layout('two_column_left_sidebar',$area1, $area2); + + page_draw($title, $body); +?>
\ No newline at end of file diff --git a/mod/file/graphics/icons/application.gif b/mod/file/graphics/icons/application.gif Binary files differnew file mode 100644 index 000000000..f78903c0a --- /dev/null +++ b/mod/file/graphics/icons/application.gif diff --git a/mod/file/graphics/icons/application_lrg.gif b/mod/file/graphics/icons/application_lrg.gif Binary files differnew file mode 100644 index 000000000..c6955f749 --- /dev/null +++ b/mod/file/graphics/icons/application_lrg.gif diff --git a/mod/file/graphics/icons/archive.gif b/mod/file/graphics/icons/archive.gif Binary files differnew file mode 100644 index 000000000..044cd042a --- /dev/null +++ b/mod/file/graphics/icons/archive.gif diff --git a/mod/file/graphics/icons/archive_lrg.gif b/mod/file/graphics/icons/archive_lrg.gif Binary files differnew file mode 100644 index 000000000..0d0856cdd --- /dev/null +++ b/mod/file/graphics/icons/archive_lrg.gif diff --git a/mod/file/graphics/icons/excel.gif b/mod/file/graphics/icons/excel.gif Binary files differnew file mode 100644 index 000000000..f74f74fd7 --- /dev/null +++ b/mod/file/graphics/icons/excel.gif diff --git a/mod/file/graphics/icons/excel_lrg.gif b/mod/file/graphics/icons/excel_lrg.gif Binary files differnew file mode 100644 index 000000000..9b53d6dc7 --- /dev/null +++ b/mod/file/graphics/icons/excel_lrg.gif diff --git a/mod/file/graphics/icons/general.gif b/mod/file/graphics/icons/general.gif Binary files differnew file mode 100644 index 000000000..cd5cf467a --- /dev/null +++ b/mod/file/graphics/icons/general.gif diff --git a/mod/file/graphics/icons/general_lrg.gif b/mod/file/graphics/icons/general_lrg.gif Binary files differnew file mode 100644 index 000000000..7c7a3c80a --- /dev/null +++ b/mod/file/graphics/icons/general_lrg.gif diff --git a/mod/file/graphics/icons/music.gif b/mod/file/graphics/icons/music.gif Binary files differnew file mode 100644 index 000000000..c44d7c987 --- /dev/null +++ b/mod/file/graphics/icons/music.gif diff --git a/mod/file/graphics/icons/music_lrg.gif b/mod/file/graphics/icons/music_lrg.gif Binary files differnew file mode 100644 index 000000000..780a252d6 --- /dev/null +++ b/mod/file/graphics/icons/music_lrg.gif diff --git a/mod/file/graphics/icons/openoffice.gif b/mod/file/graphics/icons/openoffice.gif Binary files differnew file mode 100644 index 000000000..3cfdc7196 --- /dev/null +++ b/mod/file/graphics/icons/openoffice.gif diff --git a/mod/file/graphics/icons/openoffice_lrg.gif b/mod/file/graphics/icons/openoffice_lrg.gif Binary files differnew file mode 100644 index 000000000..5cdb13353 --- /dev/null +++ b/mod/file/graphics/icons/openoffice_lrg.gif diff --git a/mod/file/graphics/icons/pages.gif b/mod/file/graphics/icons/pages.gif Binary files differnew file mode 100644 index 000000000..2e4ee761a --- /dev/null +++ b/mod/file/graphics/icons/pages.gif diff --git a/mod/file/graphics/icons/pages_lrg.gif b/mod/file/graphics/icons/pages_lrg.gif Binary files differnew file mode 100644 index 000000000..2e41e4739 --- /dev/null +++ b/mod/file/graphics/icons/pages_lrg.gif diff --git a/mod/file/graphics/icons/pdf.gif b/mod/file/graphics/icons/pdf.gif Binary files differnew file mode 100644 index 000000000..e7854b1e0 --- /dev/null +++ b/mod/file/graphics/icons/pdf.gif diff --git a/mod/file/graphics/icons/pdf_lrg.gif b/mod/file/graphics/icons/pdf_lrg.gif Binary files differnew file mode 100644 index 000000000..5cd62b69c --- /dev/null +++ b/mod/file/graphics/icons/pdf_lrg.gif diff --git a/mod/file/graphics/icons/ppt.gif b/mod/file/graphics/icons/ppt.gif Binary files differnew file mode 100644 index 000000000..44aef679b --- /dev/null +++ b/mod/file/graphics/icons/ppt.gif diff --git a/mod/file/graphics/icons/ppt_lrg.gif b/mod/file/graphics/icons/ppt_lrg.gif Binary files differnew file mode 100644 index 000000000..71965711d --- /dev/null +++ b/mod/file/graphics/icons/ppt_lrg.gif diff --git a/mod/file/graphics/icons/text.gif b/mod/file/graphics/icons/text.gif Binary files differnew file mode 100644 index 000000000..107e7ca37 --- /dev/null +++ b/mod/file/graphics/icons/text.gif diff --git a/mod/file/graphics/icons/text_lrg.gif b/mod/file/graphics/icons/text_lrg.gif Binary files differnew file mode 100644 index 000000000..5f7c95519 --- /dev/null +++ b/mod/file/graphics/icons/text_lrg.gif diff --git a/mod/file/graphics/icons/vcard.gif b/mod/file/graphics/icons/vcard.gif Binary files differnew file mode 100644 index 000000000..f7fdda9c0 --- /dev/null +++ b/mod/file/graphics/icons/vcard.gif diff --git a/mod/file/graphics/icons/vcard_lrg.gif b/mod/file/graphics/icons/vcard_lrg.gif Binary files differnew file mode 100644 index 000000000..6cd4c45e0 --- /dev/null +++ b/mod/file/graphics/icons/vcard_lrg.gif diff --git a/mod/file/graphics/icons/video.gif b/mod/file/graphics/icons/video.gif Binary files differnew file mode 100644 index 000000000..09abfad3b --- /dev/null +++ b/mod/file/graphics/icons/video.gif diff --git a/mod/file/graphics/icons/video_lrg.gif b/mod/file/graphics/icons/video_lrg.gif Binary files differnew file mode 100644 index 000000000..b23dbad91 --- /dev/null +++ b/mod/file/graphics/icons/video_lrg.gif diff --git a/mod/file/graphics/icons/word.gif b/mod/file/graphics/icons/word.gif Binary files differnew file mode 100644 index 000000000..f906c75bd --- /dev/null +++ b/mod/file/graphics/icons/word.gif diff --git a/mod/file/graphics/icons/word_lrg.gif b/mod/file/graphics/icons/word_lrg.gif Binary files differnew file mode 100644 index 000000000..018c8e334 --- /dev/null +++ b/mod/file/graphics/icons/word_lrg.gif diff --git a/mod/file/index.php b/mod/file/index.php new file mode 100644 index 000000000..e76583f0f --- /dev/null +++ b/mod/file/index.php @@ -0,0 +1,43 @@ +<?php + /** + * Elgg file browser + * + * @package ElggFile + * @author Curverider Ltd + * @copyright Curverider Ltd 2008-2010 + * @link http://elgg.com/ + * + * + * TODO: File icons, download & mime types + */ + + require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php"); + + if (is_callable('group_gatekeeper')) { + group_gatekeeper(); + } + + //set the title + if (page_owner() == get_loggedin_userid()) { + $title = elgg_echo('file:yours'); + } else { + $title = sprintf(elgg_echo("file:user"),page_owner_entity()->name); + } + + $area2 = elgg_view_title($title); + + // Get objects + set_context('search'); + $area2 .= elgg_list_entities(array('types' => 'object', 'subtypes' => 'file', 'container_guid' => page_owner(), 'limit' => 10, 'full_view' => FALSE)); + set_context('file'); + $get_filter = get_filetype_cloud(page_owner()); + if ($get_filter) { + $area1 = $get_filter; + } else { + $area2 .= elgg_view('page_elements/contentwrapper',array('body' => elgg_echo("file:none"))); + } + + $body = elgg_view_layout('two_column_left_sidebar', $area1, $area2); + + page_draw($title, $body); +?>
\ No newline at end of file diff --git a/mod/file/languages/en.php b/mod/file/languages/en.php new file mode 100644 index 000000000..ac3795cfb --- /dev/null +++ b/mod/file/languages/en.php @@ -0,0 +1,109 @@ +<?php + /** + * Elgg file plugin language pack + * + * @package ElggFile + * @author Curverider Ltd + * @copyright Curverider Ltd 2008-2010 + * @link http://elgg.com/ + */ + + $english = array( + + /** + * Menu items and titles + */ + + 'file' => "Files", + 'files' => "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:newupload' => 'New file upload', + + '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:created' => "%s uploaded", + 'file:river:item' => "a file", + 'file:river:annotate' => "a comment on this 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 diff --git a/mod/file/manifest.xml b/mod/file/manifest.xml new file mode 100644 index 000000000..f3f44d3bf --- /dev/null +++ b/mod/file/manifest.xml @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="UTF-8"?> +<plugin_manifest> + <field key="author" value="Curverider" /> + <field key="version" value="1.7" /> + <field key="description" value="File browser plugin" /> + <field key="website" value="http://www.elgg.org/" /> + <field key="copyright" value="(C) Curverider 2008-2010" /> + <field key="licence" value="GNU Public License version 2" /> + <field key="elgg_version" value="2010030101" /> +</plugin_manifest> diff --git a/mod/file/search.php b/mod/file/search.php new file mode 100644 index 000000000..ed8846514 --- /dev/null +++ b/mod/file/search.php @@ -0,0 +1,88 @@ +<?php + + /** + * Elgg file search + * + * @package ElggFile + * @author Curverider Ltd + * @copyright Curverider Ltd 2008-2010 + * @link http://elgg.com/ + + */ + + // Load Elgg engine + require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php"); + + + // Get input + $md_type = 'simpletype'; + $tag = get_input('tag'); + $search_viewtype = get_input('search_viewtype'); + + $friends = (int) get_input('friends_guid',0); + if ($friends) { + if ($owner_guid = get_user_friends($user_guid, "", 999999, 0)) { + foreach($owner_guid as $key => $friend) + $owner_guid[$key] = (int) $friend->getGUID(); + } else { + $owner_guid = array(); + } + } else { + $owner_guid = get_input('owner_guid',0); + if (substr_count($owner_guid,',')) { + $owner_guid = explode(",",$owner_guid); + } + } + $page_owner = get_input('page_owner',0); + if ($page_owner) { + set_page_owner($page_owner); + } else { + if ($friends) { + set_page_owner($friends); + } else { + if ($owner_guid > 0 && !is_array($owner_guid)) + set_page_owner($owner_guid); + } + } + + if (is_callable('group_gatekeeper')) group_gatekeeper(); + + if (empty($tag)) { + $title = elgg_echo('file:type:all'); + $area2 = elgg_view_title(elgg_echo('file:type:all')); + } else { + $title = sprintf(elgg_echo('searchtitle'),$tag); + if (is_array($owner_guid)) { + $area2 = elgg_view_title(elgg_echo("file:friends:type:" . $tag)); + } else if (page_owner() && page_owner() != $_SESSION['guid']) { + $area2 = elgg_view_title(sprintf(elgg_echo("file:user:type:" . $tag),page_owner_entity()->name)); + } else{ + $area2 = elgg_view_title(elgg_echo("file:type:" . $tag)); + } + } + if ($friends) { + $area1 = get_filetype_cloud($friends,true); + } else if ($owner_guid) { + $area1 = get_filetype_cloud($owner_guid); + } else { + $area1 = get_filetype_cloud(); + } + + // Set context + set_context('search'); + + $limit = 10; + if ($search_viewtype == "gallery") $limit = 12; + if (!empty($tag)) { + $area2 .= list_entities_from_metadata($md_type, $tag, 'object', 'file', $owner_guid, $limit); + } else { + $area2 .= elgg_list_entities(array('types' => 'object', 'subtypes' => 'file', 'owner_guid' => $owner_guid, 'limit' => $limit)); + } + + set_context("file"); + + $body = elgg_view_layout('two_column_left_sidebar',$area1, $area2); + + page_draw($title, $body); + +?>
\ No newline at end of file diff --git a/mod/file/start.php b/mod/file/start.php new file mode 100644 index 000000000..b6af2fb18 --- /dev/null +++ b/mod/file/start.php @@ -0,0 +1,272 @@ +<?php + /** + * Elgg file browser + * + * @package ElggFile + * @author Curverider Ltd + * @copyright Curverider Ltd 2008-2010 + * @link http://elgg.com/ + */ + + /** + * Override the ElggFile so that + */ + class FilePluginFile extends ElggFile + { + protected function initialise_attributes() + { + parent::initialise_attributes(); + + $this->attributes['subtype'] = "file"; + } + + public function __construct($guid = null) + { + parent::__construct($guid); + } + } + + + /** + * File plugin initialisation functions. + */ + function file_init() + { + global $CONFIG; + + // Set up menu (tools dropdown or other uses as defined by theme) + if (isloggedin()) { + add_menu(elgg_echo('file'), $CONFIG->wwwroot . "pg/file/" . get_loggedin_user()->username); + } else { + add_menu(elgg_echo('file'), $CONFIG->wwwroot . "pg/file/world/world/" ); + } + + // Extend CSS + elgg_extend_view('css', 'file/css'); + + // Extend hover-over and profile menu + elgg_extend_view('profile/menu/links','file/menu'); + + // extend group main page + elgg_extend_view('groups/left_column','file/groupprofile_files'); + + // Register a page handler, so we can have nice URLs + register_page_handler('file','file_page_handler'); + + // Add a new file widget + add_widget_type('filerepo',elgg_echo("file:widget"),elgg_echo("file:widget:description")); + + // 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')); + } + + // Listen to notification events and supply a more useful message + register_plugin_hook('notify:entity:message', 'object', 'file_notify_message'); + + // add the group files tool option + add_group_tool_option('files',elgg_echo('groups:enablefiles'),true); + + // Register entity type + register_entity_type('object','file'); + } + + /** + * Sets up submenus for the file system. Triggered on pagesetup. + * + */ + function file_submenus() { + + global $CONFIG; + + $page_owner = page_owner_entity(); + + // Group submenu option + if ($page_owner instanceof ElggGroup && get_context() == "groups") { + if($page_owner->files_enable != "no"){ + add_submenu_item(sprintf(elgg_echo("file:group"),$page_owner->name), $CONFIG->wwwroot . "pg/file/" . $page_owner->username); + } + } + + // General submenu options + + if (get_context() == "file") { + if ((page_owner() == $_SESSION['guid'] || !page_owner()) && isloggedin()) { + add_submenu_item(sprintf(elgg_echo("file:yours"),$page_owner->name), $CONFIG->wwwroot . "pg/file/" . $page_owner->username); + add_submenu_item(sprintf(elgg_echo('file:yours:friends'),$page_owner->name), $CONFIG->wwwroot . "pg/file/". $page_owner->username . "/friends/"); + } else if (page_owner()) { + add_submenu_item(sprintf(elgg_echo("file:user"),$page_owner->name), $CONFIG->wwwroot . "pg/file/" . $page_owner->username); + if ($page_owner instanceof ElggUser) // This one's for users, not groups + add_submenu_item(sprintf(elgg_echo('file:friends'),$page_owner->name), $CONFIG->wwwroot . "pg/file/". $page_owner->username . "/friends/"); + } + add_submenu_item(elgg_echo('file:all'), $CONFIG->wwwroot . "pg/file/world/world/"); + if (can_write_to_container($_SESSION['guid'], page_owner()) && isloggedin()) + add_submenu_item(elgg_echo('file:upload'), $CONFIG->wwwroot . "pg/file/". $page_owner->username . "/new/"); + } + + } + + /** + * 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 "read": + set_input('guid',$page[2]); + include(dirname(dirname(dirname(__FILE__))) . "/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"); + } + + } + + /** + * 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 = $CONFIG->wwwroot . "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; + } + + /** + * 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; + } + + if (substr_count($mimetype,'text/')) + return "document"; + + if (substr_count($mimetype,'audio/')) + return "audio"; + + if (substr_count($mimetype,'image/')) + return "image"; + + if (substr_count($mimetype,'video/')) + return "video"; + + if (substr_count($mimetype,'opendocument')) + return "document"; + + 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; + } + return elgg_view('file/typecloud',array('owner_guid' => $owner_guid, 'friend_guid' => $friendofguid, 'types' => get_tags(0,10,'simpletype','object','file',$owner_guid))); + + } + + /** + * Populates the ->getUrl() method for file objects + * + * @param ElggEntity $entity File entity + * @return string File URL + */ + function file_url($entity) { + + global $CONFIG; + $title = $entity->title; + $title = friendly_title($title); + return $CONFIG->url . "pg/file/" . $entity->getOwnerEntity()->username . "/read/" . $entity->getGUID() . "/" . $title; + + } + + // Make sure test_init is called on initialisation + register_elgg_event_handler('init','system','file_init'); + register_elgg_event_handler('pagesetup','system','file_submenus'); + + // Register actions + register_action("file/upload", false, $CONFIG->pluginspath . "file/actions/upload.php"); + register_action("file/save", false, $CONFIG->pluginspath . "file/actions/save.php"); + register_action("file/delete", false, $CONFIG->pluginspath. "file/actions/delete.php"); + +?> diff --git a/mod/file/thumbnail.php b/mod/file/thumbnail.php new file mode 100644 index 000000000..a150cce5a --- /dev/null +++ b/mod/file/thumbnail.php @@ -0,0 +1,69 @@ +<?php + +/** + * Elgg file thumbnail + * + * @package ElggFile + * @author Curverider Ltd + * @copyright Curverider Ltd 2008-2010 + * @link http://elgg.com/ + */ + +// Get engine +require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php"); + +// Get file GUID +$file_guid = (int) get_input('file_guid',0); + +// Get file thumbnail size +$size = get_input('size','small'); + +// Get file entity +if ($file = get_entity($file_guid)) { + + if ($file->getSubtype() == "file") { + + $simpletype = $file->simpletype; + if ($simpletype == "image") { + + // Get file thumbnail + switch ($size) { + case "small": + $thumbfile = $file->thumbnail; + break; + case "medium": + $thumbfile = $file->smallthumb; + break; + case "large": + default: + $thumbfile = $file->largethumb; + break; + } + + // Grab the file + if ($thumbfile && !empty($thumbfile)) { + $readfile = new ElggFile(); + $readfile->owner_guid = $file->owner_guid; + $readfile->setFilename($thumbfile); + $mime = $file->getMimeType(); + $contents = $readfile->grabFile(); + + // caching images for 10 days + header("Content-type: $mime"); + header('Expires: ' . date('r',time() + 864000)); + header("Pragma: public", true); + header("Cache-Control: public", true); + header("Content-Length: " . strlen($contents)); + + echo $contents; + exit; + + } + + } + + } + +} + +?>
\ No newline at end of file diff --git a/mod/file/upload.php b/mod/file/upload.php new file mode 100644 index 000000000..d0b503e0c --- /dev/null +++ b/mod/file/upload.php @@ -0,0 +1,27 @@ +<?php + /** + * Elgg file browser uploader + * + * @package ElggFile + * @author Curverider Ltd + * @copyright Curverider Ltd 2008-2010 + * @link http://elgg.com/ + */ + + require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php"); + + gatekeeper(); + if (is_callable('group_gatekeeper')) { + group_gatekeeper(); + } + + // Render the file upload page + + $container_guid = page_owner(); + $area2 = elgg_view_title($title = elgg_echo('file:upload')); + $area2 .= elgg_view("file/upload", array('container_guid' => $container_guid)); + $body = elgg_view_layout('two_column_left_sidebar', '', $area2); + + page_draw(elgg_echo("file:upload"), $body); + +?>
\ No newline at end of file diff --git a/mod/file/views/default/file/css.php b/mod/file/views/default/file/css.php new file mode 100644 index 000000000..64642d9de --- /dev/null +++ b/mod/file/views/default/file/css.php @@ -0,0 +1,224 @@ +<?php + /** + * File CSS extender + * + * @package Elgg File Repository + * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2 + * @author Curverider <info@elgg.com> + * @copyright Curverider Ltd 2008-2010 + * @link http://elgg.org/ + */ +?> + + +p.filerepo_owner { + margin:0; + padding:0; +} +.filerepo_owner_details { + margin:0; + padding:0; + line-height: 1.2em; +} +.filerepo_owner_details small { + color:#666666; +} +.filerepo_owner .usericon { + margin: 3px 5px 5px 0; + float: left; +} + +.filerepo_download a { + font: 12px/100% Arial, Helvetica, sans-serif; + font-weight: bold; + color: white; + background:#4690d6; + border:none; + -webkit-border-radius: 5px; + -moz-border-radius: 5px; + width: auto; + height: 25px; + padding: 3px 6px 3px 6px; + margin:10px 0 10px 0; + cursor: pointer; +} +.filerepo_download a:hover { + background: black; + color:white; + text-decoration: none; +} + +/* FILE REPRO WIDGET VIEW */ +.filerepo_widget_singleitem { + margin:0 0 5px 0; + padding:5px; + min-height:60px; + display:block; + background:white; + -webkit-border-radius: 8px; + -moz-border-radius: 8px; +} +.filerepo_widget_singleitem_more { + margin:0; + padding:5px; + display:block; + background:white; + -webkit-border-radius: 8px; + -moz-border-radius: 8px; +} +.filerepo_listview_icon { + float: left; + margin-right: 10px; +} +.filerepo_timestamp { + color:#666666; + margin:0; +} +.filerepo_listview_desc { + display:none; + padding:0 10px 10px 0; + line-height: 1.2em; +} +.filerepo_listview_desc p { + color:#333333; +} +.filerepo_widget_content { + margin-left: 70px; +} +.filerepo_title { + margin:0; + padding:6px 5px 0 0; + line-height: 1.2em; + color:#666666; + font-weight: bold; +} + +.collapsable_box #filerepo_widget_layout { + margin:0 10px 0 10px; + background: none; +} + +/* widget gallery view */ +#filerepo_widget_layout .filerepo_widget_galleryview { + -webkit-border-radius: 8px; + -moz-border-radius: 8px; + background: white; + margin:0 0 5px 0; +} +.filerepo_widget_galleryview img { + padding:0; + border:1px solid white; + margin:4px; +} +.filerepo_widget_galleryview img:hover { + border:1px solid #333333; +} + +/* SINGLE ITEM VIEW */ +.filerepo_file { + background:white; + margin:10px 10px 0 10px; + -webkit-border-radius: 8px; + -moz-border-radius: 8px; +} +.filerepo_file .filerepo_title_owner_wrapper { + min-height:60px; + +} +.filerepo_title_owner_wrapper .filerepo_title, +.filerepo_title_owner_wrapper .filerepo_owner { + margin-left: 70px !important; +} +.filerepo_file .filerepo_maincontent { + padding:0 20px 0 0; +} +.filerepo_file .filerepo_icon { + width: 70px; + position: absolute; + margin:10px 0 10px 10px; +} +.filerepo_file .filerepo_title { + margin:0; + padding:7px 4px 10px 10px; + line-height: 1.2em; +} +.filerepo_file .filerepo_owner { + padding:0 0 0 10px; +} +.filerepo_file .filerepo_description { + margin:10px 0 0 0; + padding:0 0 0 10px; +} +.filerepo_download, +.filerepo_controls { + padding:0 0 1px 10px; + margin:0 0 10px 0; +} +.filerepo_file .filerepo_description p { + padding:0 0 5px 0; + margin:0; +} +.filerepo_file .filerepo_specialcontent img { + padding:10px; + margin:0 0 0 10px; + -webkit-border-radius: 8px; + -moz-border-radius: 8px; + background: black; +} +/* zaudio player */ +.filerepo_maincontent .filerepo_specialcontent { + margin:0 0 20px 0; +} +.filerepo_tags { + padding:0 0 10px 10px; + margin:0; +} + +/* file repro gallery items */ +.search_gallery .filerepo_controls { + padding:0; +} +.search_gallery .filerepo_title { + font-weight: bold; + line-height: 1.1em; + margin:0 0 10px 0; +} +.filerepo_gallery_item { + margin:0; + padding:0; + text-align:center; + +} +.filerepo_gallery_item p { + margin:0; + padding:0; +} +.filerepo_gallery_item .filerepo_controls { + margin-top:10px; +} +.filerepo_gallery_item .filerepo_controls a { + padding-right:10px; + padding-left:10px; +} +.search_gallery .filerepo_comments { + font-size:90%; +} + +.filerepo_user_gallery_link { + float:right; + margin:5px 5px 5px 50px; +} +.filerepo_user_gallery_link a { + padding:2px 25px 5px 0; + background: transparent url(<?php echo $vars['url']; ?>_graphics/icon_gallery.gif) no-repeat right top; + display:block; +} +.filerepo_user_gallery_link a:hover { + background-position: right -40px; +} + +/* IE6 */ +* html #description_tbl { width:676px !important;} + + + diff --git a/mod/file/views/default/file/groupprofile_files.php b/mod/file/views/default/file/groupprofile_files.php new file mode 100644 index 000000000..778de3301 --- /dev/null +++ b/mod/file/views/default/file/groupprofile_files.php @@ -0,0 +1,74 @@ +<?php + + // Latest forum discussion for the group home page + + //check to make sure this group forum has been activated + if($vars['entity']->files_enable != 'no'){ + +?> + +<script type="text/javascript"> +$(document).ready(function () { + +$('a.show_file_desc').click(function () { + $(this.parentNode).children("[class=filerepo_listview_desc]").slideToggle("fast"); + return false; +}); + +}); /* end document ready function */ +</script> + +<div id="filerepo_widget_layout"> +<h2><?php echo elgg_echo("file:group"); ?></h2> + +<?php + + //the number of files to display + $number = (int) $vars['entity']->num_display; + if (!$number) + $number = 10; + + //get the group's files + $files = elgg_get_entities(array('type' => 'object', + 'subtype' => 'file', + 'container_guid' => $vars['entity']->guid, + 'limit' => $number, + )); + + //if there are some files, go get them + if ($files) { + + //display in list mode + foreach($files as $f){ + + $mime = $f->mimetype; + echo "<div class=\"filerepo_widget_singleitem\">"; + echo "<div class=\"filerepo_listview_icon\"><a href=\"{$f->getURL()}\">" . elgg_view("file/icon", array("mimetype" => $mime, 'thumbnail' => $f->thumbnail, 'file_guid' => $f->guid)) . "</a></div>"; + echo "<div class=\"filerepo_widget_content\">"; + echo "<div class=\"filerepo_listview_title\"><p class=\"filerepo_title\">" . $f->title . "</p></div>"; + echo "<div class=\"filerepo_listview_date\"><p class=\"filerepo_timestamp\"><small>" . friendly_time($f->time_created) . "</small></p></div>"; + $description = $f->description; + if (!empty($description)) echo "<a href=\"javascript:void(0);\" class=\"show_file_desc\">". elgg_echo('more') ."</a><br /><div class=\"filerepo_listview_desc\">" . $description . "</div>"; + echo "</div><div class=\"clearfloat\"></div></div>"; + + } + + + //get a link to the users files + $users_file_url = $vars['url'] . "pg/file/" . page_owner_entity()->username; + + echo "<div class=\"forum_latest\"><a href=\"{$users_file_url}\">" . elgg_echo('file:more') . "</a></div>"; + + } else { + + echo "<div class=\"forum_latest\">" . elgg_echo("file:none") . "</div>"; + + } + +?> +<div class="clearfloat" /></div> +</div> + +<?php + }//end of activate check statement +?>
\ No newline at end of file diff --git a/mod/file/views/default/file/icon.php b/mod/file/views/default/file/icon.php new file mode 100644 index 000000000..f1bb3f8e1 --- /dev/null +++ b/mod/file/views/default/file/icon.php @@ -0,0 +1,65 @@ +<?php + /** + * Elgg file icons. + * Displays an icon, depending on its mime type, for a file. + * Optionally you can specify a size. + * + * @package ElggFile + * @author Curverider Ltd + * @copyright Curverider Ltd 2008-2010 + * @link http://elgg.com/ + */ + + global $CONFIG; + + $mime = $vars['mimetype']; + + // is this request for an image thumbnail + if (isset($vars['thumbnail'])) { + $thumbnail = $vars['thumbnail']; + } else { + $thumbnail = false; + } + + // default size is small for thumbnails + if (isset($vars['size'])) { + $size = $vars['size']; + } else { + $size = 'small'; + } + + // Handle + switch ($mime) + { + case 'image/jpg' : + case 'image/jpeg' : + case 'image/pjpeg' : + case 'image/png' : + case 'image/x-png' : + case 'image/gif' : + case 'image/bmp' : + if ($thumbnail) { + echo "<img src=\"{$vars['url']}mod/file/thumbnail.php?file_guid={$vars['file_guid']}&size={$size}\" border=\"0\" />"; + } else { + if (!empty($mime) && elgg_view_exists("file/icon/{$mime}")) { + echo elgg_view("file/icon/{$mime}", $vars); + } else if (!empty($mime) && elgg_view_exists("file/icon/" . substr($mime,0,strpos($mime,'/')) . "/default")) { + echo elgg_view("file/icon/" . substr($mime,0,strpos($mime,'/')) . "/default", $vars); + } else { + echo "<img src=\"". elgg_view('file/icon/default',$vars) ."\" border=\"0\" />"; + } + } + + break; + default : + if (!empty($mime) && elgg_view_exists("file/icon/{$mime}")) { + echo elgg_view("file/icon/{$mime}", $vars); + } else if (!empty($mime) && elgg_view_exists("file/icon/" . substr($mime,0,strpos($mime,'/')) . "/default")) { + echo elgg_view("file/icon/" . substr($mime,0,strpos($mime,'/')) . "/default", $vars); + } else { + echo "<img src=\"". elgg_view('file/icon/default',$vars) ."\" border=\"0\" />"; + } + break; + } + +?>
\ No newline at end of file diff --git a/mod/file/views/default/file/icon/application/default.php b/mod/file/views/default/file/icon/application/default.php new file mode 100644 index 000000000..eea8cbafe --- /dev/null +++ b/mod/file/views/default/file/icon/application/default.php @@ -0,0 +1,10 @@ +<?php + + if ($vars['size'] == 'large') { + $ext = '_lrg'; + } else { + $ext = ''; + } + echo "<img src=\"{$CONFIG->wwwroot}mod/file/graphics/icons/application{$ext}.gif\" border=\"0\" />"; + +?>
\ No newline at end of file diff --git a/mod/file/views/default/file/icon/application/excel.php b/mod/file/views/default/file/icon/application/excel.php new file mode 100644 index 000000000..ba2460fec --- /dev/null +++ b/mod/file/views/default/file/icon/application/excel.php @@ -0,0 +1,10 @@ +<?php + + if ($vars['size'] == 'large') { + $ext = '_lrg'; + } else { + $ext = ''; + } + echo "<img src=\"{$CONFIG->wwwroot}mod/file/graphics/icons/excel{$ext}.gif\" border=\"0\" />"; + +?>
\ No newline at end of file diff --git a/mod/file/views/default/file/icon/application/msword.php b/mod/file/views/default/file/icon/application/msword.php new file mode 100644 index 000000000..20efb1069 --- /dev/null +++ b/mod/file/views/default/file/icon/application/msword.php @@ -0,0 +1,10 @@ +<?php + + if ($vars['size'] == 'large') { + $ext = '_lrg'; + } else { + $ext = ''; + } + echo "<img src=\"{$CONFIG->wwwroot}mod/file/graphics/icons/word{$ext}.gif\" border=\"0\" />"; + +?>
\ No newline at end of file diff --git a/mod/file/views/default/file/icon/application/pdf.php b/mod/file/views/default/file/icon/application/pdf.php new file mode 100644 index 000000000..6a5a7369c --- /dev/null +++ b/mod/file/views/default/file/icon/application/pdf.php @@ -0,0 +1,10 @@ +<?php + + if ($vars['size'] == 'large') { + $ext = '_lrg'; + } else { + $ext = ''; + } + echo "<img src=\"{$CONFIG->wwwroot}mod/file/graphics/icons/pdf{$ext}.gif\" border=\"0\" />"; + +?>
\ No newline at end of file diff --git a/mod/file/views/default/file/icon/application/powerpoint.php b/mod/file/views/default/file/icon/application/powerpoint.php new file mode 100644 index 000000000..1857d513f --- /dev/null +++ b/mod/file/views/default/file/icon/application/powerpoint.php @@ -0,0 +1,10 @@ +<?php + + if ($vars['size'] == 'large') { + $ext = '_lrg'; + } else { + $ext = ''; + } + echo "<img src=\"{$CONFIG->wwwroot}mod/file/graphics/icons/ppt{$ext}.gif\" border=\"0\" />"; + +?>
\ No newline at end of file diff --git a/mod/file/views/default/file/icon/application/vnd.ms-excel.php b/mod/file/views/default/file/icon/application/vnd.ms-excel.php new file mode 100644 index 000000000..ba2460fec --- /dev/null +++ b/mod/file/views/default/file/icon/application/vnd.ms-excel.php @@ -0,0 +1,10 @@ +<?php + + if ($vars['size'] == 'large') { + $ext = '_lrg'; + } else { + $ext = ''; + } + echo "<img src=\"{$CONFIG->wwwroot}mod/file/graphics/icons/excel{$ext}.gif\" border=\"0\" />"; + +?>
\ No newline at end of file diff --git a/mod/file/views/default/file/icon/application/vnd.ms-powerpoint.php b/mod/file/views/default/file/icon/application/vnd.ms-powerpoint.php new file mode 100644 index 000000000..1857d513f --- /dev/null +++ b/mod/file/views/default/file/icon/application/vnd.ms-powerpoint.php @@ -0,0 +1,10 @@ +<?php + + if ($vars['size'] == 'large') { + $ext = '_lrg'; + } else { + $ext = ''; + } + echo "<img src=\"{$CONFIG->wwwroot}mod/file/graphics/icons/ppt{$ext}.gif\" border=\"0\" />"; + +?>
\ No newline at end of file diff --git a/mod/file/views/default/file/icon/application/vnd.oasis.opendocument.text.php b/mod/file/views/default/file/icon/application/vnd.oasis.opendocument.text.php new file mode 100644 index 000000000..d0bde81df --- /dev/null +++ b/mod/file/views/default/file/icon/application/vnd.oasis.opendocument.text.php @@ -0,0 +1,10 @@ +<?php + + if ($vars['size'] == 'large') { + $ext = '_lrg'; + } else { + $ext = ''; + } + echo "<img src=\"{$CONFIG->wwwroot}mod/file/graphics/icons/openoffice{$ext}.gif\" border=\"0\" />"; + +?>
\ No newline at end of file diff --git a/mod/file/views/default/file/icon/application/x-gzip.php b/mod/file/views/default/file/icon/application/x-gzip.php new file mode 100644 index 000000000..72f839732 --- /dev/null +++ b/mod/file/views/default/file/icon/application/x-gzip.php @@ -0,0 +1,5 @@ +<?php + + echo elgg_view('file/icon/archive',$vars); + +?>
\ No newline at end of file diff --git a/mod/file/views/default/file/icon/application/x-rar-compressed.php b/mod/file/views/default/file/icon/application/x-rar-compressed.php new file mode 100644 index 000000000..72f839732 --- /dev/null +++ b/mod/file/views/default/file/icon/application/x-rar-compressed.php @@ -0,0 +1,5 @@ +<?php + + echo elgg_view('file/icon/archive',$vars); + +?>
\ No newline at end of file diff --git a/mod/file/views/default/file/icon/application/x-stuffit.php b/mod/file/views/default/file/icon/application/x-stuffit.php new file mode 100644 index 000000000..72f839732 --- /dev/null +++ b/mod/file/views/default/file/icon/application/x-stuffit.php @@ -0,0 +1,5 @@ +<?php + + echo elgg_view('file/icon/archive',$vars); + +?>
\ No newline at end of file diff --git a/mod/file/views/default/file/icon/application/zip.php b/mod/file/views/default/file/icon/application/zip.php new file mode 100644 index 000000000..72f839732 --- /dev/null +++ b/mod/file/views/default/file/icon/application/zip.php @@ -0,0 +1,5 @@ +<?php + + echo elgg_view('file/icon/archive',$vars); + +?>
\ No newline at end of file diff --git a/mod/file/views/default/file/icon/archive.php b/mod/file/views/default/file/icon/archive.php new file mode 100644 index 000000000..4fffd9346 --- /dev/null +++ b/mod/file/views/default/file/icon/archive.php @@ -0,0 +1,10 @@ +<?php + + if ($vars['size'] == 'large') { + $ext = '_lrg'; + } else { + $ext = ''; + } + echo "<img src=\"{$CONFIG->wwwroot}mod/file/graphics/icons/archive{$ext}.gif\" border=\"0\" />"; + +?>
\ No newline at end of file diff --git a/mod/file/views/default/file/icon/audio.php b/mod/file/views/default/file/icon/audio.php new file mode 100644 index 000000000..73c55be7b --- /dev/null +++ b/mod/file/views/default/file/icon/audio.php @@ -0,0 +1,10 @@ +<?php + + if ($vars['size'] == 'large') { + $ext = '_lrg'; + } else { + $ext = ''; + } + echo "<img src=\"{$CONFIG->wwwroot}mod/file/graphics/icons/music{$ext}.gif\" border=\"0\" />"; + +?>
\ No newline at end of file diff --git a/mod/file/views/default/file/icon/audio/default.php b/mod/file/views/default/file/icon/audio/default.php new file mode 100644 index 000000000..2bd1498b2 --- /dev/null +++ b/mod/file/views/default/file/icon/audio/default.php @@ -0,0 +1,5 @@ +<?php + + echo elgg_view('file/icon/audio',$vars); + +?>
\ No newline at end of file diff --git a/mod/file/views/default/file/icon/default.php b/mod/file/views/default/file/icon/default.php new file mode 100644 index 000000000..844ee312c --- /dev/null +++ b/mod/file/views/default/file/icon/default.php @@ -0,0 +1,10 @@ +<?php + + if ($vars['size'] == 'large') { + $ext = '_lrg'; + } else { + $ext = ''; + } + echo "{$CONFIG->wwwroot}mod/file/graphics/icons/general{$ext}.gif"; + +?>
\ No newline at end of file diff --git a/mod/file/views/default/file/icon/document.php b/mod/file/views/default/file/icon/document.php new file mode 100644 index 000000000..8823514b8 --- /dev/null +++ b/mod/file/views/default/file/icon/document.php @@ -0,0 +1,10 @@ +<?php + + if ($vars['size'] == 'large') { + $ext = '_lrg'; + } else { + $ext = ''; + } + echo "<img src=\"{$CONFIG->wwwroot}mod/file/graphics/icons/text{$ext}.gif\" border=\"0\" />"; + +?>
\ No newline at end of file diff --git a/mod/file/views/default/file/icon/text/default.php b/mod/file/views/default/file/icon/text/default.php new file mode 100644 index 000000000..bf5da852d --- /dev/null +++ b/mod/file/views/default/file/icon/text/default.php @@ -0,0 +1,5 @@ +<?php + + echo elgg_view('file/icon/document',$vars); + +?>
\ No newline at end of file diff --git a/mod/file/views/default/file/icon/text/directory.php b/mod/file/views/default/file/icon/text/directory.php new file mode 100644 index 000000000..a08e098c6 --- /dev/null +++ b/mod/file/views/default/file/icon/text/directory.php @@ -0,0 +1,10 @@ +<?php + + if ($vars['size'] == 'large') { + $ext = '_lrg'; + } else { + $ext = ''; + } + echo "<img src=\"{$CONFIG->wwwroot}mod/file/graphics/icons/vcard{$ext}.gif\" border=\"0\" />"; + +?>
\ No newline at end of file diff --git a/mod/file/views/default/file/icon/text/v-card.php b/mod/file/views/default/file/icon/text/v-card.php new file mode 100644 index 000000000..5c8ecd855 --- /dev/null +++ b/mod/file/views/default/file/icon/text/v-card.php @@ -0,0 +1,5 @@ +<?php + + echo elgg_view('file/icon/text/directory',$vars); + +?>
\ No newline at end of file diff --git a/mod/file/views/default/file/icon/video.php b/mod/file/views/default/file/icon/video.php new file mode 100644 index 000000000..94617abff --- /dev/null +++ b/mod/file/views/default/file/icon/video.php @@ -0,0 +1,10 @@ +<?php + + if ($vars['size'] == 'large') { + $ext = '_lrg'; + } else { + $ext = ''; + } + echo "<img src=\"{$CONFIG->wwwroot}mod/file/graphics/icons/video{$ext}.gif\" border=\"0\" />"; + +?>
\ No newline at end of file diff --git a/mod/file/views/default/file/icon/video/default.php b/mod/file/views/default/file/icon/video/default.php new file mode 100644 index 000000000..0ff2db791 --- /dev/null +++ b/mod/file/views/default/file/icon/video/default.php @@ -0,0 +1,5 @@ +<?php + + echo elgg_view('file/icon/video',$vars); + +?>
\ No newline at end of file diff --git a/mod/file/views/default/file/menu.php b/mod/file/views/default/file/menu.php new file mode 100644 index 000000000..a9c79a85c --- /dev/null +++ b/mod/file/views/default/file/menu.php @@ -0,0 +1,16 @@ +<?php + + /** + * Elgg hoverover extender for file + * + * @package ElggFile + * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2 + * @copyright Curverider Ltd 2008-2010 + * @link http://elgg.com/ + */ + +?> + + <p class="user_menu_file"> + <a href="<?php echo $vars['url']; ?>pg/file/<?php echo $vars['entity']->username; ?>"><?php echo elgg_echo("file"); ?></a> + </p>
\ No newline at end of file diff --git a/mod/file/views/default/file/specialcontent/audio/mid.php b/mod/file/views/default/file/specialcontent/audio/mid.php new file mode 100644 index 000000000..cf216a3b3 --- /dev/null +++ b/mod/file/views/default/file/specialcontent/audio/mid.php @@ -0,0 +1,4 @@ +<object type="audio/midi" data="<?php echo $vars['url']; ?>mod/file/download.php?file_guid=<?php echo $vars['entity']->getGUID(); ?>" width="200" height="20"> + <param name="autoplay" value="false"> + <param name="autoStart" value="0"> +</object>
\ No newline at end of file diff --git a/mod/file/views/default/file/specialcontent/audio/mp3.php b/mod/file/views/default/file/specialcontent/audio/mp3.php new file mode 100644 index 000000000..83b77c391 --- /dev/null +++ b/mod/file/views/default/file/specialcontent/audio/mp3.php @@ -0,0 +1,4 @@ +<object type="audio/mpeg" data="<?php echo $vars['url']; ?>mod/file/download.php?file_guid=<?php echo $vars['entity']->getGUID(); ?>" width="200" height="20"> + <param name="autoplay" value="false"> + <param name="autoStart" value="0"> +</object>
\ No newline at end of file diff --git a/mod/file/views/default/file/specialcontent/audio/mpeg.php b/mod/file/views/default/file/specialcontent/audio/mpeg.php new file mode 100644 index 000000000..83b77c391 --- /dev/null +++ b/mod/file/views/default/file/specialcontent/audio/mpeg.php @@ -0,0 +1,4 @@ +<object type="audio/mpeg" data="<?php echo $vars['url']; ?>mod/file/download.php?file_guid=<?php echo $vars['entity']->getGUID(); ?>" width="200" height="20"> + <param name="autoplay" value="false"> + <param name="autoStart" value="0"> +</object>
\ No newline at end of file diff --git a/mod/file/views/default/file/specialcontent/audio/x-wav.php b/mod/file/views/default/file/specialcontent/audio/x-wav.php new file mode 100644 index 000000000..21af956c2 --- /dev/null +++ b/mod/file/views/default/file/specialcontent/audio/x-wav.php @@ -0,0 +1,4 @@ +<object type="audio/x-wav" data="<?php echo $vars['url']; ?>mod/file/download.php?file_guid=<?php echo $vars['entity']->getGUID(); ?>" width="200" height="20"> + <param name="autoplay" value="false"> + <param name="autoStart" value="0"> +</object>
\ No newline at end of file diff --git a/mod/file/views/default/file/specialcontent/image/default.php b/mod/file/views/default/file/specialcontent/image/default.php new file mode 100644 index 000000000..b034857c2 --- /dev/null +++ b/mod/file/views/default/file/specialcontent/image/default.php @@ -0,0 +1,9 @@ +<?php + + if ($vars['full'] && $smallthumb = $vars['entity']->smallthumb) { + + echo "<p><a href=\"{$vars['url']}mod/file/download.php?file_guid={$vars['entity']->getGUID()}\"><img src=\"{$vars['url']}mod/file/thumbnail.php?file_guid={$vars['entity']->getGUID()}&size=large\" border=\"0\" /></a></p>"; + + } + +?>
\ No newline at end of file diff --git a/mod/file/views/default/file/typecloud.php b/mod/file/views/default/file/typecloud.php new file mode 100644 index 000000000..b85960849 --- /dev/null +++ b/mod/file/views/default/file/typecloud.php @@ -0,0 +1,70 @@ +<?php + + $types = $vars['types']; + + if (is_array($vars['types']) && sizeof($vars['types'])) { + +?> + + <!-- <div class="filerepo_types"> --> + <!-- <p><b><?php echo elgg_echo('file:types'); ?>:</b> --> + + <div id="canvas_header_submenu"> + <ul> +<?php + + $all = new stdClass; + $all->tag = "all"; + $vars['types'][] = $all; + $vars['types'] = array_reverse($vars['types']); + foreach($vars['types'] as $type) { + + $tag = $type->tag; + if ($tag != "all") { + $label = elgg_echo("file:type:" . $tag); + } else { + $label = elgg_echo('all'); + } + + $url = $vars['url'] . "mod/file/search.php?subtype=file"; + if ($tag != "all") + $url .= "&md_type=simpletype&tag=" . urlencode($tag); + if (isset($vars['friend_guid']) && $vars['friend_guid'] != false) { + $url .= "&friends_guid={$vars['friend_guid']}"; + } else if ($vars['owner_guid'] != "") { + if (is_array($vars['owner_guid'])) { + $owner_guid = implode(",",$vars['owner_guid']); + } else { + $owner_guid = $vars['owner_guid']; + } + $url .= "&owner_guid={$owner_guid}"; + } + if ($tag == "image") + $url .= "&search_viewtype=gallery"; + + $url .= "&page_owner=" . page_owner(); + + $inputtag = get_input('tag'); + if ($inputtag == $tag || (empty($inputtag) && $tag == "all")) { + // $class = "class=\"filerepo_types_current\""; + $class = " class=\"selected\" "; + } else { + $class = ""; + } + + add_submenu_item($label, $url, 'filetypes'); + + //echo "<li {$class} ><a href=\"{$url}\">{$label}</a></li>"; + + } + +?> + <!-- </p> --> + </ul> + </div> + +<?php + + } + +?>
\ No newline at end of file diff --git a/mod/file/views/default/file/upload.php b/mod/file/views/default/file/upload.php new file mode 100644 index 000000000..5a1f5c927 --- /dev/null +++ b/mod/file/views/default/file/upload.php @@ -0,0 +1,134 @@ +<?php + /** + * Elgg file browser uploader + * + * @package ElggFile + * @author Curverider Ltd + * @copyright Curverider Ltd 2008-2010 + * @link http://elgg.com/ + */ + + global $CONFIG; + + if (isset($vars['entity'])) { + $action_type = "update"; + $action = "file/upload"; + $title = $vars['entity']->title; + $description = $vars['entity']->description; + $tags = $vars['entity']->tags; + $access_id = $vars['entity']->access_id; + $container_guid = $vars['entity']->container_guid; + } else { + $action_type = "new"; + $action = "file/upload"; + $title = isset($_SESSION['uploadtitle']) ? $_SESSION['uploadtitle'] : ''; + $description = isset($_SESSION['uploaddesc']) ? $_SESSION['uploaddesc'] : ''; + $tags = isset($_SESSION['uploadtags']) ? $_SESSION['uploadtags'] : ''; + if (defined('ACCESS_DEFAULT')) { + $access_id = ACCESS_DEFAULT; + } else { + $access_id = 0; + } + $access_id = isset($_SESSION['uploadaccessid']) ? $_SESSION['uploadaccessid'] : $access_id; + $container_guid = page_owner_entity()->guid; + } + + // make sure session cache is cleared + unset($_SESSION['uploadtitle']); + unset($_SESSION['uploaddesc']); + unset($_SESSION['uploadtags']); + unset($_SESSION['uploadaccessid']); + + +?> +<div class="contentWrapper"> +<form action="<?php echo $vars['url']; ?>action/<?php echo $action; ?>" enctype="multipart/form-data" method="post"> +<p> + <label> +<?php + echo elgg_view('input/securitytoken'); + if ($action_type == "new") { + echo elgg_echo("file:file"); + } else { + echo elgg_echo("file:replace"); + } +?> +<br /> +<?php + + echo elgg_view("input/file",array('internalname' => 'upload')); + +?> + </label> +</p> +<p> + <label><?php echo elgg_echo("title"); ?><br /> +<?php + + echo elgg_view("input/text", array( + "internalname" => "title", + "value" => $title, + )); + +?> + </label> +</p> +<p class="longtext_editarea"> + <label><?php echo elgg_echo("description"); ?><br /> +<?php + + echo elgg_view("input/longtext",array( + "internalname" => "description", + "value" => $description, + )); +?> + </label> +</p> +<p> + <label><?php echo elgg_echo("tags"); ?><br /> +<?php + + echo elgg_view("input/tags", array( + "internalname" => "tags", + "value" => $tags, + )); + +?> + </label> +</p> +<?php + + $categories = elgg_view('categories',$vars); + if (!empty($categories)) { +?> + + <p> + <?php echo $categories; ?> + </p> + +<?php + } + +?> +<p> + <label> + <?php echo elgg_echo('access'); ?><br /> + <?php echo elgg_view('input/access', array('internalname' => 'access_id','value' => $access_id)); ?> + </label> +</p> + +<p> +<?php + + echo "<input type=\"hidden\" name=\"container_guid\" value=\"{$container_guid}\" />"; + + if (isset($vars['entity'])) { + echo "<input type=\"hidden\" name=\"file_guid\" value=\"{$vars['entity']->getGUID()}\" />"; + } + +?> + <input type="submit" value="<?php echo elgg_echo("save"); ?>" /> +</p> + +</form> +</div> diff --git a/mod/file/views/default/object/file.php b/mod/file/views/default/object/file.php new file mode 100644 index 000000000..9568074b2 --- /dev/null +++ b/mod/file/views/default/object/file.php @@ -0,0 +1,205 @@ +<?php + /** + * Elgg file browser. + * File renderer. + * + * @package ElggFile + * @author Curverider Ltd + * @copyright Curverider Ltd 2008-2010 + * @link http://elgg.com/ + */ + + global $CONFIG; + + $file = $vars['entity']; + + $file_guid = $file->getGUID(); + $tags = $file->tags; + $title = $file->title; + $desc = $file->description; + $owner = $vars['entity']->getOwnerEntity(); + $friendlytime = friendly_time($vars['entity']->time_created); + $mime = $file->mimetype; + + if (!$title) { + $title = elgg_echo('untitled'); + } + + if (get_context() == "search") { // Start search listing version + + if (get_input('search_viewtype') == "gallery") { + echo "<div class=\"filerepo_gallery_item\">"; + if ($vars['entity']->smallthumb) { + echo "<p class=\"filerepo_title\">" . $file->title . "</p>"; + echo "<p><a href=\"{$file->getURL()}\"><img src=\"{$vars['url']}mod/file/thumbnail.php?size=medium&file_guid={$vars['entity']->getGUID()}\" border=\"0\" /></a></p>"; + echo "<p class=\"filerepo_timestamp\"><small><a href=\"{$vars['url']}pg/file/{$owner->username}\">{$owner->username}</a> {$friendlytime}</small></p>"; + + //get the number of comments + $numcomments = elgg_count_comments($vars['entity']); + if ($numcomments) + echo "<p class=\"filerepo_comments\"><a href=\"{$file->getURL()}\">" . sprintf(elgg_echo("comments")) . " (" . $numcomments . ")</a></p>"; + + + //if the user can edit, display edit and delete links + if ($file->canEdit()) { + echo "<div class=\"filerepo_controls\"><p>"; + echo "<a href=\"{$vars['url']}mod/file/edit.php?file_guid={$file->getGUID()}\">" . elgg_echo('edit') . "</a> "; + echo elgg_view('output/confirmlink',array( + + 'href' => $vars['url'] . "action/file/delete?file=" . $file->getGUID(), + 'text' => elgg_echo("delete"), + 'confirm' => elgg_echo("file:delete:confirm"), + 'is_action' => true, + + )); + echo "</p></div>"; + } + + + } else { + echo "<p class=\"filerepo_title\">{$title}</p>"; + echo "<a href=\"{$file->getURL()}\">" . elgg_view("file/icon", array("mimetype" => $mime, 'thumbnail' => $file->thumbnail, 'file_guid' => $file_guid, 'size' => 'large')) . "</a>"; + echo "<p class=\"filerepo_timestamp\"><small><a href=\"{$vars['url']}pg/file/{$owner->username}\">{$owner->name}</a> {$friendlytime}</small></p>"; + //get the number of comments + $numcomments = elgg_count_comments($file); + if ($numcomments) + echo "<p class=\"filerepo_comments\"><a href=\"{$file->getURL()}\">" . sprintf(elgg_echo("comments")) . " (" . $numcomments . ")</a></p>"; + + + } + echo "</div>"; + // echo elgg_view("search/gallery",array('info' => $info, 'icon' => $icon)); + + } else { + + $info = "<p> <a href=\"{$file->getURL()}\">{$title}</a></p>"; + $info .= "<p class=\"owner_timestamp\"><a href=\"{$vars['url']}pg/file/{$owner->username}\">{$owner->name}</a> {$friendlytime}"; + $numcomments = elgg_count_comments($file); + if ($numcomments) + $info .= ", <a href=\"{$file->getURL()}\">" . sprintf(elgg_echo("comments")) . " (" . $numcomments . ")</a>"; + $info .= "</p>"; + + // $icon = elgg_view("profile/icon",array('entity' => $owner, 'size' => 'small')); + $icon = "<a href=\"{$file->getURL()}\">" . elgg_view("file/icon", array("mimetype" => $mime, 'thumbnail' => $file->thumbnail, 'file_guid' => $file_guid, 'size' => 'small')) . "</a>"; + + echo elgg_view_listing($icon, $info); + + } + + } else { // Start main version + +?> + <div class="filerepo_file"> + <div class="filerepo_icon"> + <a href="<?php echo $vars['url']; ?>mod/file/download.php?file_guid=<?php echo $file_guid; ?>"><?php + + echo elgg_view("file/icon", array("mimetype" => $mime, 'thumbnail' => $file->thumbnail, 'file_guid' => $file_guid)); + + ?></a> + </div> + + <div class="filerepo_title_owner_wrapper"> + <?php + //get the user and a link to their gallery + $user_gallery = $vars['url'] . "mod/file/search.php?md_type=simpletype&subtype=file&tag=image&owner_guid=" . $owner->guid . "&search_viewtype=gallery"; + ?> + <div class="filerepo_user_gallery_link"><a href="<?php echo $user_gallery; ?>"><?php echo sprintf(elgg_echo("file:user:gallery"),''); ?></a></div> + <div class="filerepo_title"><h2><a href="<?php echo $vars['url']; ?>mod/file/download.php?file_guid=<?php echo $file_guid; ?>"><?php echo $title; ?></a></h2></div> + <div class="filerepo_owner"> + <?php + + echo elgg_view("profile/icon",array('entity' => $owner, 'size' => 'tiny')); + + ?> + <p class="filerepo_owner_details"><b><a href="<?php echo $vars['url']; ?>pg/file/<?php echo $owner->username; ?>"><?php echo $owner->name; ?></a></b><br /> + <small><?php echo $friendlytime; ?></small></p> + </div> + </div> + + + <div class="filerepo_maincontent"> + + <div class="filerepo_description"><?php echo elgg_view('output/longtext', array('value' => $desc)); ?></div> + <div class="filerepo_tags"> +<?php + + if (!empty($tags)) { + +?> + <div class="object_tag_string"><?php + + echo elgg_view('output/tags',array('value' => $tags)); + + ?></div> +<?php + } + + $categories = elgg_view('categories/view',$vars); + if (!empty($categories)) { +?> + <div class="filerepo_categories"> + <?php + + echo $categories; + + ?> + </div> +<?php + } + +?> + </div> + <?php + if (elgg_view_exists('file/specialcontent/' . $mime)) { + echo "<div class=\"filerepo_specialcontent\">".elgg_view('file/specialcontent/' . $mime, $vars)."</div>"; + } else if (elgg_view_exists("file/specialcontent/" . substr($mime,0,strpos($mime,'/')) . "/default")) { + echo "<div class=\"filerepo_specialcontent\">".elgg_view("file/specialcontent/" . substr($mime,0,strpos($mime,'/')) . "/default", $vars)."</div>"; + } + + ?> + + <div class="filerepo_download"><p><a href="<?php echo $vars['url']; ?>mod/file/download.php?file_guid=<?php echo $file_guid; ?>"><?php echo elgg_echo("file:download"); ?></a></p></div> + +<?php + + if ($file->canEdit()) { +?> + + <div class="filerepo_controls"> + <p> + <a href="<?php echo $vars['url']; ?>mod/file/edit.php?file_guid=<?php echo $file->getGUID(); ?>"><?php echo elgg_echo('edit'); ?></a> + <?php + echo elgg_view('output/confirmlink',array( + + 'href' => $vars['url'] . "action/file/delete?file=" . $file->getGUID(), + 'text' => elgg_echo("delete"), + 'confirm' => elgg_echo("file:delete:confirm"), + 'is_action' => true, + + )); + ?> + </p> + </div> + +<?php + } + +?> + </div> +</div> + +<?php + + if ($vars['full']) { + + echo elgg_view_comments($file); + + } + +?> + +<?php + + } + +?>
\ No newline at end of file diff --git a/mod/file/views/default/river/object/file/create.php b/mod/file/views/default/river/object/file/create.php new file mode 100644 index 000000000..b0e2ca07b --- /dev/null +++ b/mod/file/views/default/river/object/file/create.php @@ -0,0 +1,17 @@ +<?php + + $performed_by = get_entity($vars['item']->subject_guid); + $object = get_entity($vars['item']->object_guid); + $url = $object->getURL(); + $container = get_entity($object->container_guid); + + $url = "<a href=\"{$performed_by->getURL()}\">{$performed_by->name}</a>"; + $string = sprintf(elgg_echo("file:river:created"),$url) . " " . elgg_echo("file:river:item"); + $string .= " <a href=\"" . $object->getURL() . "\">" . $object->title . "</a>"; + if ($container && $container instanceof ElggGroup) { + $string .= ' ' . elgg_echo('groups:river:togroup') . " <a href=\"" . $container->getURL() ."\">". $container->name . "</a>"; + } + + echo $string; + +?>
\ No newline at end of file diff --git a/mod/file/views/default/widgets/filerepo/edit.php b/mod/file/views/default/widgets/filerepo/edit.php new file mode 100644 index 000000000..35d633058 --- /dev/null +++ b/mod/file/views/default/widgets/filerepo/edit.php @@ -0,0 +1,25 @@ +<p> + <?php echo elgg_echo("file:num_files"); ?>: + <select name="params[num_display]"> + <option value="1" <?php if($vars['entity']->num_display == 1) echo "SELECTED"; ?>>1</option> + <option value="2" <?php if($vars['entity']->num_display == 2) echo "SELECTED"; ?>>2</option> + <option value="3" <?php if($vars['entity']->num_display == 3) echo "SELECTED"; ?>>3</option> + <option value="4" <?php if($vars['entity']->num_display == 4) echo "SELECTED"; ?>>4</option> + <option value="5" <?php if($vars['entity']->num_display == 5) echo "SELECTED"; ?>>5</option> + <option value="6" <?php if($vars['entity']->num_display == 6) echo "SELECTED"; ?>>6</option> + <option value="7" <?php if($vars['entity']->num_display == 7) echo "SELECTED"; ?>>7</option> + <option value="8" <?php if($vars['entity']->num_display == 8) echo "SELECTED"; ?>>8</option> + <option value="9" <?php if($vars['entity']->num_display == 9) echo "SELECTED"; ?>>9</option> + <option value="10" <?php if($vars['entity']->num_display == 10) echo "SELECTED"; ?>>10</option> + <option value="15" <?php if($vars['entity']->num_display == 15) echo "SELECTED"; ?>>15</option> + <option value="20" <?php if($vars['entity']->num_display == 20) echo "SELECTED"; ?>>20</option> + </select> +</p> + +<p> + <?php echo elgg_echo("file:gallery_list"); ?>? + <select name="params[gallery_list]"> + <option value="1" <?php if($vars['entity']->gallery_list == 1) echo "SELECTED"; ?>><?php echo elgg_echo("file:list"); ?></option> + <option value="2" <?php if($vars['entity']->gallery_list == 2) echo "SELECTED"; ?>><?php echo elgg_echo("file:gallery"); ?></option> + </select> +</p>
\ No newline at end of file diff --git a/mod/file/views/default/widgets/filerepo/view.php b/mod/file/views/default/widgets/filerepo/view.php new file mode 100644 index 000000000..8113ea45a --- /dev/null +++ b/mod/file/views/default/widgets/filerepo/view.php @@ -0,0 +1,86 @@ +<script type="text/javascript"> +$(document).ready(function () { + +$('a.show_file_desc').click(function () { + $(this.parentNode).children("[class=filerepo_listview_desc]").slideToggle("fast"); + return false; +}); + +}); /* end document ready function */ +</script> + + +<?php + + //the page owner + $owner = $vars['entity']->owner_guid; + + //the number of files to display + $number = (int) $vars['entity']->num_display; + if (!$number) + $number = 1; + + //get the layout view which is set by the user in the edit panel + $get_view = (int) $vars['entity']->gallery_list; + if (!$get_view || $get_view == 1) { + $view = "list"; + }else{ + $view = "gallery"; + } + + //get the user's files + $files = get_user_objects($vars['entity']->owner_guid, "file", $number, 0); + + //if there are some files, go get them + if ($files) { + + echo "<div id=\"filerepo_widget_layout\">"; + + if($view == "gallery"){ + + echo "<div class=\"filerepo_widget_galleryview\">"; + + //display in gallery mode + foreach($files as $f){ + + $mime = $f->mimetype; + echo "<a href=\"{$f->getURL()}\">" . elgg_view("file/icon", array("mimetype" => $mime, 'thumbnail' => $f->thumbnail, 'file_guid' => $f->guid)) . "</a>"; + + } + + echo "</div>"; + + }else{ + + //display in list mode + foreach($files as $f){ + + $mime = $f->mimetype; + echo "<div class=\"filerepo_widget_singleitem\">"; + echo "<div class=\"filerepo_listview_icon\"><a href=\"{$f->getURL()}\">" . elgg_view("file/icon", array("mimetype" => $mime, 'thumbnail' => $f->thumbnail, 'file_guid' => $f->guid)) . "</a></div>"; + echo "<div class=\"filerepo_widget_content\">"; + echo "<div class=\"filerepo_listview_title\"><p class=\"filerepo_title\">" . $f->title . "</p></div>"; + echo "<div class=\"filerepo_listview_date\"><p class=\"filerepo_timestamp\"><small>" . friendly_time($f->time_created) . "</small></p></div>"; + $description = $f->description; + if (!empty($description)) echo "<a href=\"javascript:void(0);\" class=\"show_file_desc\">". elgg_echo('more') ."</a><br /><div class=\"filerepo_listview_desc\">" . $description . "</div>"; + echo "</div><div class=\"clearfloat\"></div></div>"; + + } + + } + + + //get a link to the users files + $users_file_url = $vars['url'] . "pg/file/" . get_user($f->owner_guid)->username; + + echo "<div class=\"filerepo_widget_singleitem_more\"><a href=\"{$users_file_url}\">" . elgg_echo('file:more') . "</a></div>"; + echo "</div>"; + + + } else { + + echo "<div class=\"contentWrapper\">" . elgg_echo("file:none") . "</div>"; + + } + +?>
\ No newline at end of file diff --git a/mod/file/views/rss/object/file.php b/mod/file/views/rss/object/file.php new file mode 100644 index 000000000..fdefb4069 --- /dev/null +++ b/mod/file/views/rss/object/file.php @@ -0,0 +1,30 @@ +<?php + + /** + * Elgg RSS file object view + * + * @package ElggFile + * @subpackage Core + * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2 + * @author Curverider Ltd + * @copyright Curverider Ltd 2008-2010 + * @link http://elgg.org/ + */ + + $title = $vars['entity']->title; + if (empty($title)) { + $title = substr($vars['entity']->description,0,32); + if (strlen($vars['entity']->description) > 32) + $title .= " ..."; + } + +?> + + <item> + <guid isPermaLink='true'><?php echo $vars['entity']->getURL(); ?></guid> + <pubDate><?php echo date("r",$vars['entity']->time_created) ?></pubDate> + <link><?php echo $vars['entity']->getURL(); ?></link> + <title><![CDATA[<?php echo $title; ?>]]></title> + <description><![CDATA[<?php echo (autop($vars['entity']->description)); ?>]]></description> + <enclosure url="<?php echo $vars['url']; ?>mod/file/download.php?file_guid=<?php echo $vars['entity']->getGUID(); ?>" length="<?php echo $vars['entity']->size(); ?>" type="<?php echo $vars['entity']->getMimeType(); ?>" /> + </item> diff --git a/mod/file/world.php b/mod/file/world.php new file mode 100644 index 000000000..8b5e2cb0c --- /dev/null +++ b/mod/file/world.php @@ -0,0 +1,40 @@ +<?php + /** + * Elgg file browser + * + * @package ElggFile + * @author Curverider Ltd + * @copyright Curverider Ltd 2008-2010 - 2009 + * @link http://elgg.com/ + */ + + require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php"); + + $limit = get_input("limit", 10); + $offset = get_input("offset", 0); + $tag = get_input("tag"); + + // Get the current page's owner + $page_owner = page_owner_entity(); + if ($page_owner === false || is_null($page_owner)) { + $page_owner = $_SESSION['user']; + set_page_owner($_SESSION['guid']); + } + + $title = elgg_echo('file:all'); + + // Get objects + $area2 = elgg_view_title($title); + $area1 = get_filetype_cloud(); // the filter + set_context('search'); + if ($tag != "") + $area2 .= list_entities_from_metadata('tags',$tag,'object','file',0,10,false); + else + $area2 .= elgg_list_entities(array('types' => 'object', 'subtypes' => 'file', 'limit' => 10, 'full_view' => FALSE)); + set_context('file'); + + $body = elgg_view_layout('two_column_left_sidebar',$area1, $area2); + + // Finally draw the page + page_draw($title, $body); +?>
\ No newline at end of file |