]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
Fixes #3771. Added missing files for embed support. Added requirement for file in...
authorBrett Profitt <brett.profitt@gmail.com>
Sun, 11 Sep 2011 15:21:36 +0000 (11:21 -0400)
committerBrett Profitt <brett.profitt@gmail.com>
Sun, 11 Sep 2011 15:21:36 +0000 (11:21 -0400)
mod/embed/manifest.xml
mod/file/views/default/embed/file/content.php [new file with mode: 0644]
mod/file/views/default/embed/file_upload/content.php [new file with mode: 0644]

index f61d27c23d32592307a04b2527ad6920fd51f4f4..4acc66e11757ba07cc3cca9e137cf1c79ccdb054 100644 (file)
                <type>elgg_version</type>
                <version>2010030101</version>
        </requires>
+       <requires>
+               <type>plugin</type>
+               <name>files</name>
+       </requires>
        <activate_on_install>true</activate_on_install>
        <admin_interface>advanced</admin_interface>
 </plugin_manifest>
diff --git a/mod/file/views/default/embed/file/content.php b/mod/file/views/default/embed/file/content.php
new file mode 100644 (file)
index 0000000..865a158
--- /dev/null
@@ -0,0 +1,61 @@
+<?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)}\" />" . htmlentities($title, ENT_QUOTES, 'UTF-8');
+
+               $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
new file mode 100644 (file)
index 0000000..13c18f7
--- /dev/null
@@ -0,0 +1,15 @@
+<?php
+/**
+ * Upload a file through the embed interface
+ */
+
+$form_vars = array(
+       'enctype' => 'multipart/form-data',
+       'class' => 'elgg-form',
+);
+$upload_content = 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