elgg_push_breadcrumb($title);
$content = elgg_view_entity($file, true);
-//$content .= elgg_view_comments($file);
+$content .= elgg_view_comments($file);
$body = elgg_view_layout('content', array(
'content' => $content,
<?php
- /**
- * File CSS extender
- *
- * @package Elgg File Repository
- */
+/**
+ * File CSS extender
+ *
+ * @package ElggFile
+ */
?>
+.file-image {
+ text-align: center;
+}
+.file-image img {
+ padding: 10px;
+ -webkit-border-radius: 6px;
+ -moz-border-radius: 6px;
+ background: #333333;
+}
+
+
.files .entity-listing .entity-listing-info {
width:453px;
}
<?php
- /**
- * Elgg file icons.
- * Displays an icon, depending on its mime type, for a file.
- * Optionally you can specify a size.
- *
- * @package ElggFile
- */
+/**
+ * Elgg file icons.
+ * Displays an icon, depending on its mime type, for a file.
+ * Optionally you can specify a size.
+ *
+ * @package ElggFile
+ *
+ * @uses $vars['size']
+ * @uses $vars['mimetype']
+ * @uses $vars['thumbnail']
+ * @uses $vars['file_guid']
+ */
- global $CONFIG;
-
- $mime = $vars['mimetype'];
-
- // is this request for an image thumbnail
- if (isset($vars['thumbnail'])) {
- $thumbnail = $vars['thumbnail'];
- } else {
- $thumbnail = false;
- }
+$mime = $vars['mimetype'];
+$simple_type = get_general_file_type($mime);
+
+// is this request for an image thumbnail
+$thumbnail = elgg_get_array_value('thumbnail', $vars, false);
- // default size is small for thumbnails
- if (isset($vars['size'])) {
- $size = $vars['size'];
+// default size is small for thumbnails
+$size = elgg_get_array_value('size', $vars, 'small');
+
+if ($simple_type == 'image' && $thumbnail) {
+ $icon = "<img src=\"" . elgg_get_site_url() . "mod/file/thumbnail.php?file_guid={$vars['file_guid']}&size={$size}\" />";
+} else {
+ $base_type = substr($mime, 0, strpos($mime, '/'));
+ if ($mime && elgg_view_exists("file/icon/$mime")) {
+ $icon = elgg_view("file/icon/{$mime}", $vars);
+ } else if ($mime && elgg_view_exists("file/icon/$base_type/default")) {
+ $icon = elgg_view("file/icon/$base_type/default", $vars);
} 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=\"".elgg_get_site_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;
+ $icon = elgg_view('file/icon/default', $vars);
}
+}
-?>
\ No newline at end of file
+echo $icon;
<?php
+/**
+ * Default application icon
+ */
- if ($vars['size'] == 'large') {
- $ext = '_lrg';
- } else {
- $ext = '';
- }
- echo "<img src=\"".elgg_get_site_url()."mod/file/graphics/icons/application{$ext}.gif\" border=\"0\" />";
+$vars['type'] = 'application';
-?>
\ No newline at end of file
+echo elgg_view('file/icon/default', $vars);
\ No newline at end of file
<?php
+/**
+ * Excel icon
+ */
- if ($vars['size'] == 'large') {
- $ext = '_lrg';
- } else {
- $ext = '';
- }
- echo "<img src=\"".elgg_get_site_url()."mod/file/graphics/icons/excel{$ext}.gif\" border=\"0\" />";
+$vars['type'] = 'excel';
-?>
\ No newline at end of file
+echo elgg_view('file/icon/default', $vars);
\ No newline at end of file
<?php
+/**
+ * Word icon
+ */
- if ($vars['size'] == 'large') {
- $ext = '_lrg';
- } else {
- $ext = '';
- }
- echo "<img src=\"".elgg_get_site_url()."mod/file/graphics/icons/word{$ext}.gif\" border=\"0\" />";
+$vars['type'] = 'word';
-?>
\ No newline at end of file
+echo elgg_view('file/icon/default', $vars);
\ No newline at end of file
<?php
+/**
+ * PDF icon
+ */
- if ($vars['size'] == 'large') {
- $ext = '_lrg';
- } else {
- $ext = '';
- }
- echo "<img src=\"".elgg_get_site_url()."mod/file/graphics/icons/pdf{$ext}.gif\" border=\"0\" />";
+$vars['type'] = 'pdf';
-?>
\ No newline at end of file
+echo elgg_view('file/icon/default', $vars);
\ No newline at end of file
<?php
+/**
+ * Powerpoint icon
+ */
- if ($vars['size'] == 'large') {
- $ext = '_lrg';
- } else {
- $ext = '';
- }
- echo "<img src=\"".elgg_get_site_url()."mod/file/graphics/icons/ppt{$ext}.gif\" border=\"0\" />";
+$vars['type'] = 'ppt';
-?>
\ No newline at end of file
+echo elgg_view('file/icon/default', $vars);
\ No newline at end of file
<?php
+/**
+ * Excel icon
+ */
- if ($vars['size'] == 'large') {
- $ext = '_lrg';
- } else {
- $ext = '';
- }
- echo "<img src=\"".elgg_get_site_url()."mod/file/graphics/icons/excel{$ext}.gif\" border=\"0\" />";
-
-?>
\ No newline at end of file
+echo elgg_view('file/icon/application/excel', $vars);
\ No newline at end of file
<?php
+/**
+ * Powerpoint icon
+ */
- if ($vars['size'] == 'large') {
- $ext = '_lrg';
- } else {
- $ext = '';
- }
- echo "<img src=\"".elgg_get_site_url()."mod/file/graphics/icons/ppt{$ext}.gif\" border=\"0\" />";
-
-?>
\ No newline at end of file
+echo elgg_view('file/icon/application/powerpoint', $vars);
\ No newline at end of file
<?php
+/**
+ * Open Office icon
+ */
- if ($vars['size'] == 'large') {
- $ext = '_lrg';
- } else {
- $ext = '';
- }
- echo "<img src=\"".elgg_get_site_url()."mod/file/graphics/icons/openoffice{$ext}.gif\" border=\"0\" />";
+$vars['type'] = 'openoffice';
-?>
\ No newline at end of file
+echo elgg_view('file/icon/default', $vars);
\ No newline at end of file
<?php
+/**
+ * GZip icon
+ */
- echo elgg_view('file/icon/archive',$vars);
-
-?>
\ No newline at end of file
+echo elgg_view('file/icon/archive', $vars);
<?php
+/**
+ * Rar icon
+ */
- echo elgg_view('file/icon/archive',$vars);
-
-?>
\ No newline at end of file
+echo elgg_view('file/icon/archive', $vars);
<?php
+/**
+ * Stuffit icon
+ */
- echo elgg_view('file/icon/archive',$vars);
-
-?>
\ No newline at end of file
+echo elgg_view('file/icon/archive', $vars);
<?php
+/**
+ * Zip icon
+ */
- echo elgg_view('file/icon/archive',$vars);
-
-?>
\ No newline at end of file
+echo elgg_view('file/icon/archive', $vars);
<?php
+/**
+ * Archive icon
+ */
- if ($vars['size'] == 'large') {
- $ext = '_lrg';
- } else {
- $ext = '';
- }
- echo "<img src=\"".elgg_get_site_url()."mod/file/graphics/icons/archive{$ext}.gif\" border=\"0\" />";
+$vars['type'] = 'archive';
-?>
\ No newline at end of file
+echo elgg_view('file/icon/default', $vars);
<?php
+/**
+ * Audio icon
+ */
- if ($vars['size'] == 'large') {
- $ext = '_lrg';
- } else {
- $ext = '';
- }
- echo "<img src=\"".elgg_get_site_url()."mod/file/graphics/icons/music{$ext}.gif\" border=\"0\" />";
+$vars['type'] = 'music';
-?>
\ No newline at end of file
+echo elgg_view('file/icon/default', $vars);
<?php
+/**
+ * Audio default icon
+ */
- echo elgg_view('file/icon/audio',$vars);
-
-?>
\ No newline at end of file
+echo elgg_view('file/icon/audio', $vars);
<?php
+/**
+ * Default file icon
+ */
- if ($vars['size'] == 'large') {
- $ext = '_lrg';
- } else {
- $ext = '';
- }
- echo elgg_get_site_url()."mod/file/graphics/icons/general{$ext}.gif";
+$type = elgg_get_array_value('type', $vars, 'general');
-?>
\ No newline at end of file
+$size = elgg_get_array_value('size', $vars, '');
+if ($size == 'large') {
+ $ext = '_lrg';
+} else {
+ $ext = '';
+}
+
+$src = elgg_get_site_url() . "mod/file/graphics/icons/{$type}{$ext}.gif";
+echo "<img src=\"$src\" />";
<?php
+/**
+ * Document icon
+ */
- if ($vars['size'] == 'large') {
- $ext = '_lrg';
- } else {
- $ext = '';
- }
- echo "<img src=\"".elgg_get_site_url()."mod/file/graphics/icons/text{$ext}.gif\" border=\"0\" />";
+$vars['type'] = 'text';
-?>
\ No newline at end of file
+echo elgg_view('file/icon/default', $vars);
\ No newline at end of file
<?php
+/**
+ * Document default icon
+ */
- echo elgg_view('file/icon/document',$vars);
-
-?>
\ No newline at end of file
+echo elgg_view('file/icon/document', $vars);
<?php
+/**
+ * Directory default icon
+ */
- if ($vars['size'] == 'large') {
- $ext = '_lrg';
- } else {
- $ext = '';
- }
- echo "<img src=\"".elgg_get_site_url()."mod/file/graphics/icons/vcard{$ext}.gif\" border=\"0\" />";
+$vars['type'] = 'vcard';
-?>
\ No newline at end of file
+echo elgg_view('file/icon/default', $vars);
\ No newline at end of file
<?php
+/**
+ * V-card icon
+ */
- echo elgg_view('file/icon/text/directory',$vars);
-
-?>
\ No newline at end of file
+echo elgg_view('file/icon/text/directory', $vars);
<?php
+/**
+ * Video icon
+ */
- if ($vars['size'] == 'large') {
- $ext = '_lrg';
- } else {
- $ext = '';
- }
- echo "<img src=\"".elgg_get_site_url()."mod/file/graphics/icons/video{$ext}.gif\" border=\"0\" />";
+$vars['type'] = 'video';
-?>
\ No newline at end of file
+echo elgg_view('file/icon/default', $vars);
\ No newline at end of file
<?php
+/**
+ * Video default icon
+ */
- echo elgg_view('file/icon/video',$vars);
-
-?>
\ No newline at end of file
+echo elgg_view('file/icon/video', $vars);
+++ /dev/null
-<object type="audio/midi" data="<?php echo elgg_get_site_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
+++ /dev/null
-<object type="audio/mpeg" data="<?php echo elgg_get_site_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
+++ /dev/null
-<object type="audio/mpeg" data="<?php echo elgg_get_site_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
+++ /dev/null
-<object type="audio/x-wav" data="<?php echo elgg_get_site_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
<?php
+/**
+ * Display an image
+ */
- if ($vars['full'] && $smallthumb = $vars['entity']->smallthumb) {
-
- echo "<p><a href=\"".elgg_get_site_url()."mod/file/download.php?file_guid={$vars['entity']->getGUID()}\"><img src=\"".elgg_get_site_url()."mod/file/thumbnail.php?file_guid={$vars['entity']->getGUID()}&size=large\" border=\"0\" /></a></p>";
-
- }
-
-?>
\ No newline at end of file
+if ($vars['full'] && $smallthumb = $vars['entity']->smallthumb) {
+ echo "<p class=\"file-image\"><a href=\"".elgg_get_site_url()."mod/file/download.php?file_guid={$vars['entity']->getGUID()}\"><img src=\"".elgg_get_site_url()."mod/file/thumbnail.php?file_guid={$vars['entity']->getGUID()}&size=large\" /></a></p>";
+}
$categories = elgg_view('categories/view', $vars);
$excerpt = elgg_get_excerpt($file->description);
$mime = $file->mimetype;
+$base_type = substr($mime, 0, strpos($mime,'/'));
+
+$body = elgg_view('output/longtext', array('value' => $file->description));
-$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));
+
+$file_icon = elgg_view('file/icon', array(
+ 'mimetype' => $mime,
+ 'thumbnail' => $file->thumbnail,
+ 'file_guid' => $file->guid,
+ 'size' => 'small'
+));
+
if ($file->tags) {
$tags = "<p class=\"elgg-tags\">" . elgg_view('output/tags', array('tags' => $file->tags)) . "</p>";
} else {
if ($full) {
+ $extra = '';
+ if (elgg_view_exists("file/specialcontent/$mime")) {
+ $extra = elgg_view("file/specialcontent/$mime", $vars);
+ } else if (elgg_view_exists("file/specialcontent/$base_type/default")) {
+ $extra = elgg_view("file/specialcontent/$base_type/default", $vars);
+ }
+
+ $download = elgg_view('output/url', array(
+ 'href' => "mod/file/download.php?file_guid=$file->guid",
+ 'text' => elgg_echo("file:download"),
+ 'class' => 'elgg-action-button',
+ ));
+
$header = elgg_view_title($file->title);
$params = array(
);
$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>";
- }
-
+ $file_info = elgg_view_image_block($file_icon, $list_body);
echo <<<HTML
$header
$file_info
<div class="file elgg-content">
$body
- $blah
+ $extra
+ <p>$download</p>
</div>
HTML;
);
$list_body = elgg_view('layout/objects/list/body', $params);
- echo elgg_view_image_block($owner_icon, $list_body);
+ echo elgg_view_image_block($file_icon, $list_body);
}
-
-return true;
-
- global $CONFIG;
-
- $file = $vars['entity'];
-
- $file_guid = $file->getGUID();
- $tags = $file->tags;
- $title = $file->title;
- $desc = $file->description;
- $owner = $vars['entity']->getOwnerEntity();
- $friendlytime = elgg_view_friendly_time($vars['entity']->time_created);
- $mime = $file->mimetype;
-
- if (!$title) {
- $title = elgg_echo('untitled');
- }
-
- if (elgg_get_context() == "search") { // Start search listing version
-
- if (get_input('listtype') == "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=\"".elgg_get_site_url()."mod/file/thumbnail.php?size=medium&file_guid={$vars['entity']->getGUID()}\" border=\"0\" /></a></p>";
- echo "<p class='filerepo_timestamp'><small><a href=\"".elgg_get_site_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()}\">" . 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=\"".elgg_get_site_url()."mod/file/edit.php?file_guid={$file->getGUID()}\">" . elgg_echo('edit') . "</a> ";
- echo elgg_view('output/confirmlink',array(
-
- 'href' => "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=\"".elgg_get_site_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()}\">" . elgg_echo("comments") . " (" . $numcomments . ")</a></p>";
-
- }
- echo "</div>";
-
- } else {
-
- $info = "<p class='entity-title'> <a href=\"{$file->getURL()}\">{$title}</a></p>";
- $info .= "<p class='entity-subtext'><a href=\"".elgg_get_site_url()."pg/file/{$owner->username}\">{$owner->name}</a> {$friendlytime}";
- $numcomments = elgg_count_comments($file);
- if ($numcomments)
- $info .= ", <a href=\"{$file->getURL()}\">" . elgg_echo("comments") . " (" . $numcomments . ")</a>";
- $info .= "</p>";
- $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 elgg_get_site_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 = elgg_get_site_url() . "mod/file/search.php?md_type=simpletype&subtype=file&tag=image&owner_guid=" . $owner->guid . "&listtype=gallery";
- ?>
- <div class="filerepo_user_gallery_link"><a href="<?php echo $user_gallery; ?>"><?php echo elgg_echo("file:user:gallery",array('')); ?></a></div>
- <div class="filerepo_title"><h2><a href="<?php echo elgg_get_site_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 elgg_get_site_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>
-<?php
-
- if (!empty($tags)) {
-?>
- <p class="tags"><?php echo elgg_view('output/tags',array('value' => $tags)); ?></p>
-<?php
- }
-
- $categories = elgg_view('categories/view',$vars);
- if (!empty($categories)) {
-?>
- <p class="categories"><?php echo $categories; ?></p>
-<?php
- }
-
-?>
- <?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 class="elgg-action-button small" href="<?php echo elgg_get_site_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 elgg_get_site_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' => "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