]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
Added first loosely coupled upload support to embed.
authorbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>
Fri, 4 Jun 2010 22:18:31 +0000 (22:18 +0000)
committerbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>
Fri, 4 Jun 2010 22:18:31 +0000 (22:18 +0000)
git-svn-id: http://code.elgg.org/elgg/trunk@6360 36083f99-b078-4883-b0ff-0f9b5a30f544

mod/embed/start.php
mod/embed/views/default/embed/embed.php
mod/embed/views/default/embed/upload/content.php [new file with mode: 0644]

index eb6f6d4a6e1045c95c02cfaf3efbf54e23ead5c5..a3b8113713641d118de767aa2ebdc05ddc489d99 100644 (file)
@@ -49,12 +49,15 @@ function embed_page_handler($page) {
                        // @todo trigger for all right now. If we categorize these later we can trigger
                        // for certain categories.
                        $sections = trigger_plugin_hook('embed_get_sections', 'all', NULL, array());
+                       $upload_sections = trigger_plugin_hook('embed_get_upload_sections', 'all', NULL, array());
                        asort($sections, SORT_LOCALE_STRING);
+                       asort($upload_sections, SORT_LOCALE_STRING);
                        $active_section = get_input('active_section', NULL);
 
                        echo elgg_view('embed/embed', array(
                                'sections' => $sections,
-                               'active_section' => $active_section
+                               'active_section' => $active_section,
+                               'upload_sections' => $upload_sections
                        ));
 
                        break;
index 4a14543d3651792e99f9d8034275ad41756bfa20..70241609bba7334116c6db5e3fc282debaadebe0 100644 (file)
@@ -9,8 +9,9 @@
  * @uses string $vars['active_section'] Currently selected section_id
  */
 
-$sections = (isset($vars['sections'])) ? $vars['sections'] : array();
-$active_section = (isset($vars['active_section'])) ? $vars['active_section'] : array_shift(array_keys($sections));
+$sections = elgg_get_array_value('sections', $vars, array());
+$active_section = elgg_get_array_value('active_section', $vars, array_shift(array_keys($sections)));
+$upload_sections = elgg_get_array_value('upload_sections', $vars, array());
 
 if (!$sections) {
        $content = elgg_echo('embed:no_sections');
@@ -38,11 +39,21 @@ if (!$sections) {
                $tabs[] = $tab;
        }
 
+       // make sure upload is always the last tab
+       if ($upload_sections) {
+               $tabs[] = array(
+                       'title' => elgg_echo('embed:upload'),
+                       'url' => '#',
+                       'url_class' => 'embed_section',
+                       'url_js' => 'id="upload"',
+               );
+       }
+
        $tabs_html = elgg_view('navigation/tabs', array('tabs' => $tabs));
        $content .= $tabs_html;
 
        // build the items and layout.
-       if (array_key_exists($active_section, $sections)) {
+       if ($section != 'upload' || array_key_exists($active_section, $sections)) {
                $section_info = $sections[$active_section];
                $layout = isset($section_info['layout']) ? $section_info['layout'] : 'list';
 
@@ -51,7 +62,8 @@ if (!$sections) {
                        //'subtype'     => $subtype,
                        'offset' => $offset,
                        'limit' => $limit,
-                       'section' => $active_section
+                       'section' => $active_section,
+                       'upload_sections' => $upload_sections
                );
 
                // allow full override for this section
@@ -99,7 +111,6 @@ if (!$sections) {
        } else {
                $content .= elgg_echo('embed:invalid_section');
        }
-
 }
 echo $content;
 ?>
diff --git a/mod/embed/views/default/embed/upload/content.php b/mod/embed/views/default/embed/upload/content.php
new file mode 100644 (file)
index 0000000..089e417
--- /dev/null
@@ -0,0 +1,47 @@
+<?php
+/**
+ * Special upload form for
+ */
+$upload_sections = elgg_get_array_value('upload_sections', $vars, array());
+$active_section = get_input('active_upload_section', array_shift(array_keys($upload_sections)));
+
+$options = array();
+
+if ($upload_sections) {
+       foreach ($upload_sections as $id => $info) {
+               $options[$id] = $info['name'];
+       }
+
+       $input = elgg_view('input/pulldown', array(
+               'name' => 'download_section',
+               'options_values' => $options,
+               'internalid' => 'embed_upload',
+               'value' => $active_section
+       ));
+
+       echo "<p>$input</p>";
+
+       if (!$upload_content = elgg_view($upload_sections[$active_section]['view'])) {
+               $upload_content = elgg_echo('embed:no_upload_content');
+       }
+
+       echo $upload_content;
+
+?>
+       <script type="text/javascript">
+       $(document).ready(function() {
+
+               // change for pulldown
+               $('#embed_upload').change(function() {
+                       var upload_section = $(this).val();
+                       var url = '<?php echo $vars['url']; ?>pg/embed/embed?active_section=upload&active_upload_section=' + upload_section;
+                       $('#facebox .body .content').load(url);
+               });
+
+       });
+       </script>
+<?php
+
+} else {
+       echo elgg_echo('embed:no_upload_sections');
+}