aboutsummaryrefslogtreecommitdiff
path: root/mod/file
diff options
context:
space:
mode:
authorCash Costello <cash.costello@gmail.com>2011-10-03 19:02:49 -0700
committerCash Costello <cash.costello@gmail.com>2011-10-03 19:02:49 -0700
commitc1ae08ad43ef1eafbd92fc9526c2fdecbe5c5977 (patch)
treeb458316db9f39b2b0f820952d2a05ffd1ad145a0 /mod/file
parente1283016e48e2f785442ee8a0d18cd09376d241c (diff)
parent9d5c00c78c0666a31485d870a1e657d4557b23c4 (diff)
downloadelgg-c1ae08ad43ef1eafbd92fc9526c2fdecbe5c5977.tar.gz
elgg-c1ae08ad43ef1eafbd92fc9526c2fdecbe5c5977.tar.bz2
Merge pull request #70 from cash/embed-menu
Fixes #3852, #3854, #3855 Refs #3567 Embed plugin rewrite
Diffstat (limited to 'mod/file')
-rw-r--r--mod/file/start.php19
-rw-r--r--mod/file/views/default/embed/file/content.php61
-rw-r--r--mod/file/views/default/embed/file_upload/content.php13
-rw-r--r--mod/file/views/default/icon/object/file.php15
4 files changed, 30 insertions, 78 deletions
diff --git a/mod/file/start.php b/mod/file/start.php
index 749d7a519..843ae0794 100644
--- a/mod/file/start.php
+++ b/mod/file/start.php
@@ -61,19 +61,26 @@ function file_init() {
$item = ElggMenuItem::factory(array(
'name' => 'file',
'text' => elgg_echo('file'),
- 'href' => '#',
- 'section' => 'select'
+ 'priority' => 10,
+ 'data' => array(
+ 'options' => array(
+ 'type' => 'object',
+ 'subtype' => 'file',
+ ),
+ ),
));
- elgg_register_menu_item('embed:sections', $item);
+ elgg_register_menu_item('embed', $item);
$item = ElggMenuItem::factory(array(
'name' => 'file_upload',
'text' => elgg_echo('file:upload'),
- 'href' => '#',
- 'section' => 'upload'
+ 'priority' => 100,
+ 'data' => array(
+ 'view' => 'embed/file_upload/content',
+ ),
));
- elgg_register_menu_item('embed:sections', $item);
+ elgg_register_menu_item('embed', $item);
}
/**
diff --git a/mod/file/views/default/embed/file/content.php b/mod/file/views/default/embed/file/content.php
deleted file mode 100644
index eadcd1a6d..000000000
--- a/mod/file/views/default/embed/file/content.php
+++ /dev/null
@@ -1,61 +0,0 @@
-<?php
-/**
- * List files available for upload
- */
-
-$active_section = elgg_extract('active_section', $vars);
-
-$options = array(
- 'owner_guid' => elgg_get_logged_in_user_guid(),
- 'type_subtype_pair' => array('object' => 'file'),
- 'count' => true
-);
-
-$count = elgg_get_entities($options);
-
-if ($count) {
- echo "<div class='embed_modal_$active_section'>";
-
- unset($options['count']);
- $items = elgg_get_entities($options);
-
- foreach ($items as $item) {
-
- // different entity types have different title attribute names.
- $title = isset($item->name) ? $item->name : $item->title;
- // don't let it be too long
- $title = elgg_get_excerpt($title);
-
- $author_text = elgg_echo('byline', array($owner->name));
- $date = elgg_view_friendly_time($item->time_created);
-
- $subtitle = "$author_text $date";
-
- $icon = "<img src=\"{$item->getIconURL($icon_size)}\" />";
-
- $embed_code = elgg_view('output/url', array(
- 'href' => $item->getURL(),
- 'title' => $title,
- 'text' => $icon,
- 'encode_text' => FALSE
- ));
-
- $item_icon = elgg_view_entity_icon($item, $icon_size);
-
- $params = array(
- 'title' => $title,
- 'entity' => $item,
- 'subtitle' => $subtitle,
- 'tags' => FALSE,
- );
- $list_body = elgg_view('object/elements/summary', $params);
-
- // @todo JS 1.8: is this approach better than inline js?
- echo "<div class=\"embed_data\" id=\"embed_{$item->getGUID()}\">" . elgg_view_image_block($item_icon, $list_body) . '</div>';
- echo "<script type=\"text/javascript\">
- $('#embed_{$item->getGUID()}').data('embed_code', " . json_encode($embed_code) . ");
- </script>";
- }
-
- echo '</div>';
-} \ No newline at end of file
diff --git a/mod/file/views/default/embed/file_upload/content.php b/mod/file/views/default/embed/file_upload/content.php
index 13c18f745..4d3db0d97 100644
--- a/mod/file/views/default/embed/file_upload/content.php
+++ b/mod/file/views/default/embed/file_upload/content.php
@@ -5,11 +5,12 @@
$form_vars = array(
'enctype' => 'multipart/form-data',
- 'class' => 'elgg-form',
+ 'class' => 'elgg-form-embed',
);
-$upload_content = elgg_view_form('file/upload', $form_vars);
+echo elgg_view_form('file/upload', $form_vars);
-echo "<div class='mbm'>" . elgg_echo('embed:upload_type') . "$input</div>";
-echo "<div class='embed-upload'>";
-echo $upload_content;
-echo "</div>"; \ No newline at end of file
+// 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/icon/object/file.php b/mod/file/views/default/icon/object/file.php
index 6357d418f..7feba7af3 100644
--- a/mod/file/views/default/icon/object/file.php
+++ b/mod/file/views/default/icon/object/file.php
@@ -2,9 +2,10 @@
/**
* 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['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['link_class'] Optional CSS class added to img
*/
$entity = $vars['entity'];
@@ -32,10 +33,14 @@ $img_src = elgg_format_url($img_src);
$img = "<img $class src=\"$img_src\" alt=\"$title\" />";
if ($url) {
- echo elgg_view('output/url', array(
+ $params = array(
'href' => $url,
'text' => $img,
- ));
+ );
+ if (isset($vars['link_class'])) {
+ $params['class'] = $vars['link_class'];
+ }
+ echo elgg_view('output/url', $params);
} else {
echo $img;
}