aboutsummaryrefslogtreecommitdiff
path: root/mod/file/views
diff options
context:
space:
mode:
Diffstat (limited to 'mod/file/views')
-rw-r--r--mod/file/views/default/embed/file_upload/content.php17
-rw-r--r--mod/file/views/default/file/css.php15
-rw-r--r--mod/file/views/default/file/group_module.php45
-rw-r--r--mod/file/views/default/file/sidebar.php14
-rw-r--r--mod/file/views/default/file/specialcontent/image/default.php20
-rw-r--r--mod/file/views/default/file/typecloud.php50
-rw-r--r--mod/file/views/default/forms/file/upload.php68
-rw-r--r--mod/file/views/default/icon/object/file.php54
-rw-r--r--mod/file/views/default/object/file.php107
-rw-r--r--mod/file/views/default/river/object/file/create.php13
-rw-r--r--mod/file/views/default/widgets/filerepo/content.php33
-rw-r--r--mod/file/views/default/widgets/filerepo/edit.php25
-rw-r--r--mod/file/views/rss/file/enclosure.php16
13 files changed, 477 insertions, 0 deletions
diff --git a/mod/file/views/default/embed/file_upload/content.php b/mod/file/views/default/embed/file_upload/content.php
new file mode 100644
index 000000000..8b630c828
--- /dev/null
+++ b/mod/file/views/default/embed/file_upload/content.php
@@ -0,0 +1,17 @@
+<?php
+/**
+ * Upload a file through the embed interface
+ */
+
+$form_vars = array(
+ 'enctype' => 'multipart/form-data',
+ 'class' => 'elgg-form-embed',
+);
+$body_vars = array('container_guid' => elgg_get_page_owner_guid());
+echo elgg_view_form('file/upload', $form_vars, $body_vars);
+
+// the tab we want to be forwarded to after upload is complete
+echo elgg_view('input/hidden', array(
+ 'name' => 'embed_forward',
+ 'value' => 'file',
+)); \ 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..5476ed7e2
--- /dev/null
+++ b/mod/file/views/default/file/css.php
@@ -0,0 +1,15 @@
+<?php
+/**
+ * File CSS extender
+ *
+ * @package ElggFile
+ */
+?>
+.file-photo {
+ text-align: center;
+ margin-bottom: 15px;
+}
+.file-gallery-item {
+ text-align: center;
+ width: 165px;
+}
diff --git a/mod/file/views/default/file/group_module.php b/mod/file/views/default/file/group_module.php
new file mode 100644
index 000000000..ad6c58dbb
--- /dev/null
+++ b/mod/file/views/default/file/group_module.php
@@ -0,0 +1,45 @@
+<?php
+/**
+ * Group file module
+ */
+
+$group = elgg_get_page_owner_entity();
+
+if ($group->file_enable == "no") {
+ return true;
+}
+
+$all_link = elgg_view('output/url', array(
+ 'href' => "file/group/$group->guid/all",
+ 'text' => elgg_echo('link:view:all'),
+ 'is_trusted' => true,
+));
+
+elgg_push_context('widgets');
+$options = array(
+ 'type' => 'object',
+ 'subtype' => 'file',
+ 'container_guid' => elgg_get_page_owner_guid(),
+ 'limit' => 6,
+ 'full_view' => false,
+ 'pagination' => false,
+);
+$content = elgg_list_entities($options);
+elgg_pop_context();
+
+if (!$content) {
+ $content = '<p>' . elgg_echo('file:none') . '</p>';
+}
+
+$new_link = elgg_view('output/url', array(
+ 'href' => "file/add/$group->guid",
+ 'text' => elgg_echo('file:add'),
+ 'is_trusted' => true,
+));
+
+echo elgg_view('groups/profile/module', array(
+ 'title' => elgg_echo('file:group'),
+ 'content' => $content,
+ 'all_link' => $all_link,
+ 'add_link' => $new_link,
+));
diff --git a/mod/file/views/default/file/sidebar.php b/mod/file/views/default/file/sidebar.php
new file mode 100644
index 000000000..f61b8e64e
--- /dev/null
+++ b/mod/file/views/default/file/sidebar.php
@@ -0,0 +1,14 @@
+<?php
+/**
+ * File sidebar
+ */
+
+echo elgg_view('page/elements/comments_block', array(
+ 'subtypes' => 'file',
+ 'owner_guid' => elgg_get_page_owner_guid(),
+));
+
+echo elgg_view('page/elements/tagcloud_block', array(
+ 'subtypes' => 'file',
+ 'owner_guid' => elgg_get_page_owner_guid(),
+));
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..431ac9f4f
--- /dev/null
+++ b/mod/file/views/default/file/specialcontent/image/default.php
@@ -0,0 +1,20 @@
+<?php
+/**
+ * Display an image
+ *
+ * @uses $vars['entity']
+ */
+
+$file = $vars['entity'];
+
+$image_url = $file->getIconURL('large');
+$image_url = elgg_format_url($image_url);
+$download_url = elgg_get_site_url() . "file/download/{$file->getGUID()}";
+
+if ($vars['full_view']) {
+ echo <<<HTML
+ <div class="file-photo">
+ <a href="$download_url"><img class="elgg-photo" src="$image_url" /></a>
+ </div>
+HTML;
+}
diff --git a/mod/file/views/default/file/typecloud.php b/mod/file/views/default/file/typecloud.php
new file mode 100644
index 000000000..4253bf674
--- /dev/null
+++ b/mod/file/views/default/file/typecloud.php
@@ -0,0 +1,50 @@
+<?php
+/**
+ * Type cloud
+ */
+
+function file_type_cloud_get_url($type, $friends) {
+ $url = elgg_get_site_url() . 'file/search?subtype=file';
+
+ if ($type->tag != "all") {
+ $url .= "&md_type=simpletype&tag=" . urlencode($type->tag);
+ }
+
+ if ($friends) {
+ $url .= "&friends=$friends";
+ }
+
+ if ($type->tag == "image") {
+ $url .= "&list_type=gallery";
+ }
+
+ if (elgg_get_page_owner_guid()) {
+ $url .= "&page_owner=" . elgg_get_page_owner_guid();
+ }
+
+ return $url;
+}
+
+
+$types = elgg_extract('types', $vars, array());
+if (!$types) {
+ return true;
+}
+
+$friends = elgg_extract('friends', $vars, false);
+
+$all = new stdClass;
+$all->tag = "all";
+elgg_register_menu_item('page', array(
+ 'name' => 'file:all',
+ 'text' => elgg_echo('all'),
+ 'href' => file_type_cloud_get_url($all, $friends),
+));
+
+foreach ($types as $type) {
+ elgg_register_menu_item('page', array(
+ 'name' => "file:$type->tag",
+ 'text' => elgg_echo("file:type:$type->tag"),
+ 'href' => file_type_cloud_get_url($type, $friends),
+ ));
+}
diff --git a/mod/file/views/default/forms/file/upload.php b/mod/file/views/default/forms/file/upload.php
new file mode 100644
index 000000000..f637a419e
--- /dev/null
+++ b/mod/file/views/default/forms/file/upload.php
@@ -0,0 +1,68 @@
+<?php
+/**
+ * Elgg file upload/save form
+ *
+ * @package ElggFile
+ */
+
+// once elgg_view stops throwing all sorts of junk into $vars, we can use
+$title = elgg_extract('title', $vars, '');
+$desc = elgg_extract('description', $vars, '');
+$tags = elgg_extract('tags', $vars, '');
+$access_id = elgg_extract('access_id', $vars, ACCESS_DEFAULT);
+$container_guid = elgg_extract('container_guid', $vars);
+if (!$container_guid) {
+ $container_guid = elgg_get_logged_in_user_guid();
+}
+$guid = elgg_extract('guid', $vars, null);
+
+if ($guid) {
+ $file_label = elgg_echo("file:replace");
+ $submit_label = elgg_echo('save');
+} else {
+ $file_label = elgg_echo("file:file");
+ $submit_label = elgg_echo('upload');
+}
+
+?>
+<div>
+ <label><?php echo $file_label; ?></label><br />
+ <?php echo elgg_view('input/file', array('name' => 'upload')); ?>
+</div>
+<div>
+ <label><?php echo elgg_echo('title'); ?></label><br />
+ <?php echo elgg_view('input/text', array('name' => 'title', 'value' => $title)); ?>
+</div>
+<div>
+ <label><?php echo elgg_echo('description'); ?></label>
+ <?php echo elgg_view('input/longtext', array('name' => 'description', 'value' => $desc)); ?>
+</div>
+<div>
+ <label><?php echo elgg_echo('tags'); ?></label>
+ <?php echo elgg_view('input/tags', array('name' => 'tags', 'value' => $tags)); ?>
+</div>
+<?php
+
+$categories = elgg_view('input/categories', $vars);
+if ($categories) {
+ echo $categories;
+}
+
+?>
+<div>
+ <label><?php echo elgg_echo('access'); ?></label><br />
+ <?php echo elgg_view('input/access', array('name' => 'access_id', 'value' => $access_id)); ?>
+</div>
+<div class="elgg-foot">
+<?php
+
+echo elgg_view('input/hidden', array('name' => 'container_guid', 'value' => $container_guid));
+
+if ($guid) {
+ echo elgg_view('input/hidden', array('name' => 'file_guid', 'value' => $guid));
+}
+
+echo elgg_view('input/submit', array('value' => $submit_label));
+
+?>
+</div>
diff --git a/mod/file/views/default/icon/object/file.php b/mod/file/views/default/icon/object/file.php
new file mode 100644
index 000000000..a3190310b
--- /dev/null
+++ b/mod/file/views/default/icon/object/file.php
@@ -0,0 +1,54 @@
+<?php
+/**
+ * File icon view
+ *
+ * @uses $vars['entity'] The entity the icon represents - uses getIconURL() method
+ * @uses $vars['size'] topbar, tiny, small, medium (default), large, master
+ * @uses $vars['href'] Optional override for link
+ * @uses $vars['img_class'] Optional CSS class added to img
+ * @uses $vars['link_class'] Optional CSS class added to link
+ */
+
+$entity = $vars['entity'];
+
+$sizes = array('small', 'medium', 'large', 'tiny', 'master', 'topbar');
+// Get size
+if (!in_array($vars['size'], $sizes)) {
+ $vars['size'] = "medium";
+}
+
+$title = $entity->title;
+$title = htmlspecialchars($title, ENT_QUOTES, 'UTF-8', false);
+
+$url = $entity->getURL();
+if (isset($vars['href'])) {
+ $url = $vars['href'];
+}
+
+$class = '';
+if (isset($vars['img_class'])) {
+ $class = $vars['img_class'];
+}
+if ($entity->thumbnail) {
+ $class = "class=\"elgg-photo $class\"";
+} else if ($class) {
+ $class = "class=\"$class\"";
+}
+
+$img_src = $entity->getIconURL($vars['size']);
+$img_src = elgg_format_url($img_src);
+$img = "<img $class src=\"$img_src\" alt=\"$title\" />";
+
+if ($url) {
+ $params = array(
+ 'href' => $url,
+ 'text' => $img,
+ 'is_trusted' => true,
+ );
+ if (isset($vars['link_class'])) {
+ $params['class'] = $vars['link_class'];
+ }
+ echo elgg_view('output/url', $params);
+} else {
+ echo $img;
+}
diff --git a/mod/file/views/default/object/file.php b/mod/file/views/default/object/file.php
new file mode 100644
index 000000000..64f19c483
--- /dev/null
+++ b/mod/file/views/default/object/file.php
@@ -0,0 +1,107 @@
+<?php
+/**
+ * File renderer.
+ *
+ * @package ElggFile
+ */
+
+$full = elgg_extract('full_view', $vars, FALSE);
+$file = elgg_extract('entity', $vars, FALSE);
+
+if (!$file) {
+ return TRUE;
+}
+
+$owner = $file->getOwnerEntity();
+$container = $file->getContainerEntity();
+$categories = elgg_view('output/categories', $vars);
+$excerpt = elgg_get_excerpt($file->description);
+$mime = $file->mimetype;
+$base_type = substr($mime, 0, strpos($mime,'/'));
+
+$owner_link = elgg_view('output/url', array(
+ 'href' => "file/owner/$owner->username",
+ 'text' => $owner->name,
+ 'is_trusted' => true,
+));
+$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 = $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_menu('entity', array(
+ 'entity' => $vars['entity'],
+ 'handler' => 'file',
+ 'sort_by' => 'priority',
+ 'class' => 'elgg-menu-hz',
+));
+
+$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 && !elgg_in_context('gallery')) {
+
+ $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,
+ );
+ $params = $params + $vars;
+ $summary = elgg_view('object/elements/summary', $params);
+
+ $text = elgg_view('output/longtext', array('value' => $file->description));
+ $body = "$text $extra";
+
+ 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
+
+ $params = array(
+ 'entity' => $file,
+ 'metadata' => $metadata,
+ 'subtitle' => $subtitle,
+ 'content' => $excerpt,
+ );
+ $params = $params + $vars;
+ $list_body = elgg_view('object/elements/summary', $params);
+
+ echo elgg_view_image_block($file_icon, $list_body);
+}
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..e8e6142e0
--- /dev/null
+++ b/mod/file/views/default/river/object/file/create.php
@@ -0,0 +1,13 @@
+<?php
+/**
+ * File river view.
+ */
+
+$object = $vars['item']->getObjectEntity();
+$excerpt = strip_tags($object->description);
+$excerpt = elgg_get_excerpt($excerpt);
+
+echo elgg_view('river/elements/layout', array(
+ 'item' => $vars['item'],
+ 'message' => $excerpt,
+)); \ No newline at end of file
diff --git a/mod/file/views/default/widgets/filerepo/content.php b/mod/file/views/default/widgets/filerepo/content.php
new file mode 100644
index 000000000..f3e152de3
--- /dev/null
+++ b/mod/file/views/default/widgets/filerepo/content.php
@@ -0,0 +1,33 @@
+<?php
+/**
+ * Elgg file widget view
+ *
+ * @package ElggFile
+ */
+
+
+$num = $vars['entity']->num_display;
+
+$options = array(
+ 'type' => 'object',
+ 'subtype' => 'file',
+ 'container_guid' => $vars['entity']->owner_guid,
+ 'limit' => $num,
+ 'full_view' => FALSE,
+ 'pagination' => FALSE,
+);
+$content = elgg_list_entities($options);
+
+echo $content;
+
+if ($content) {
+ $url = "file/owner/" . elgg_get_page_owner_entity()->username;
+ $more_link = elgg_view('output/url', array(
+ 'href' => $url,
+ 'text' => elgg_echo('file:more'),
+ 'is_trusted' => true,
+ ));
+ echo "<span class=\"elgg-widget-more\">$more_link</span>";
+} else {
+ echo elgg_echo('file:none');
+}
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..cab35b6ef
--- /dev/null
+++ b/mod/file/views/default/widgets/filerepo/edit.php
@@ -0,0 +1,25 @@
+<?php
+/**
+ * Elgg file widget edit view
+ *
+ * @package ElggFile
+ */
+
+
+// set default value
+if (!isset($vars['entity']->num_display)) {
+ $vars['entity']->num_display = 4;
+}
+
+$params = array(
+ 'name' => 'params[num_display]',
+ 'value' => $vars['entity']->num_display,
+ 'options' => array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20),
+);
+$dropdown = elgg_view('input/dropdown', $params);
+
+?>
+<div>
+ <?php echo elgg_echo('file:num_files'); ?>:
+ <?php echo $dropdown; ?>
+</div>
diff --git a/mod/file/views/rss/file/enclosure.php b/mod/file/views/rss/file/enclosure.php
new file mode 100644
index 000000000..fb4a899d9
--- /dev/null
+++ b/mod/file/views/rss/file/enclosure.php
@@ -0,0 +1,16 @@
+<?php
+/**
+ * Link to download the file
+ *
+ * @uses $vars['entity']
+ */
+
+if (elgg_instanceof($vars['entity'], 'object', 'file')) {
+ $download_url = elgg_get_site_url() . 'file/download/' . $vars['entity']->getGUID();
+ $size = $vars['entity']->size();
+ $mime_type = $vars['entity']->getMimeType();
+ echo <<<END
+
+ <enclosure url="$download_url" length="$size" type="$mime_type" />";
+END;
+}