diff options
Diffstat (limited to 'mod/file/views/default/object')
| -rw-r--r-- | mod/file/views/default/object/file.php | 262 |
1 files changed, 43 insertions, 219 deletions
diff --git a/mod/file/views/default/object/file.php b/mod/file/views/default/object/file.php index 0f128eed6..64f19c483 100644 --- a/mod/file/views/default/object/file.php +++ b/mod/file/views/default/object/file.php @@ -5,8 +5,8 @@ * @package ElggFile */ -$full = elgg_get_array_value('full', $vars, FALSE); -$file = elgg_get_array_value('entity', $vars, FALSE); +$full = elgg_extract('full_view', $vars, FALSE); +$file = elgg_extract('entity', $vars, FALSE); if (!$file) { return TRUE; @@ -14,79 +14,83 @@ if (!$file) { $owner = $file->getOwnerEntity(); $container = $file->getContainerEntity(); -$categories = elgg_view('categories/view', $vars); +$categories = elgg_view('output/categories', $vars); $excerpt = elgg_get_excerpt($file->description); $mime = $file->mimetype; +$base_type = substr($mime, 0, strpos($mime,'/')); -$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", + 'href' => "file/owner/$owner->username", 'text' => $owner->name, + 'is_trusted' => true, )); -$author_text = elgg_echo('blog:author_by_line', array($owner_link)); -if ($file->tags) { - $tags = "<p class=\"elgg-tags\">" . elgg_view('output/tags', array('tags' => $file->tags)) . "</p>"; -} else { - $tags = ""; -} +$author_text = elgg_echo('byline', array($owner_link)); + +$file_icon = elgg_view_entity_icon($file, 'small'); + $date = elgg_view_friendly_time($file->time_created); -$comments_count = elgg_count_comments($file); +$comments_count = $file->countComments(); //only display if there are commments if ($comments_count != 0) { $text = elgg_echo("comments") . " ($comments_count)"; $comments_link = elgg_view('output/url', array( 'href' => $file->getURL() . '#file-comments', 'text' => $text, + 'is_trusted' => true, )); } else { $comments_link = ''; } -$metadata = elgg_view('layout/objects/list/metadata', array( - 'entity' => $file, +$metadata = elgg_view_menu('entity', array( + 'entity' => $vars['entity'], 'handler' => 'file', + 'sort_by' => 'priority', + 'class' => 'elgg-menu-hz', )); -$subtitle = "$author_text $date $categories $comments_link"; +$subtitle = "$author_text $date $comments_link $categories"; // do not show the metadata and controls in widget view if (elgg_in_context('widgets')) { $metadata = ''; } -if ($full) { +if ($full && !elgg_in_context('gallery')) { - $header = elgg_view_title($file->title); + $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); + } $params = array( 'entity' => $file, 'title' => false, 'metadata' => $metadata, 'subtitle' => $subtitle, - 'tags' => $tags, ); - $list_body = elgg_view('layout/objects/list/body', $params); + $params = $params + $vars; + $summary = elgg_view('object/elements/summary', $params); - $file_info = elgg_view_image_block($owner_icon, $list_body); + $text = elgg_view('output/longtext', array('value' => $file->description)); + $body = "$text $extra"; - if (elgg_view_exists('file/specialcontent/' . $mime)) { - $blah = "<div class='filerepo_specialcontent'>".elgg_view('file/specialcontent/' . $mime, $vars)."</div>"; - } else if (elgg_view_exists("file/specialcontent/" . substr($mime,0,strpos($mime,'/')) . "/default")) { - $blah = "<div class='filerepo_specialcontent'>".elgg_view("file/specialcontent/" . substr($mime,0,strpos($mime,'/')) . "/default", $vars)."</div>"; - } - - - echo <<<HTML -$header -$file_info -<div class="file elgg-content"> - $body - $blah -</div> -HTML; + echo elgg_view('object/elements/full', array( + 'entity' => $file, + 'icon' => $file_icon, + 'summary' => $summary, + 'body' => $body, + )); +} elseif (elgg_in_context('gallery')) { + echo '<div class="file-gallery-item">'; + echo "<h3>" . $file->title . "</h3>"; + echo elgg_view_entity_icon($file, 'medium'); + echo "<p class='subtitle'>$owner_link $date</p>"; + echo '</div>'; } else { // brief view @@ -94,190 +98,10 @@ HTML; 'entity' => $file, 'metadata' => $metadata, 'subtitle' => $subtitle, - 'tags' => $tags, 'content' => $excerpt, ); - $list_body = elgg_view('layout/objects/list/body', $params); + $params = $params + $vars; + $list_body = elgg_view('object/elements/summary', $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 |
