]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-16414 - make the handling of the download portfolio plugin nicer
authormjollnir_ <mjollnir_>
Tue, 16 Sep 2008 14:23:41 +0000 (14:23 +0000)
committermjollnir_ <mjollnir_>
Tue, 16 Sep 2008 14:23:41 +0000 (14:23 +0000)
lang/en_utf8/portfolio_download.php
portfolio/type/download/file.php [new file with mode: 0644]
portfolio/type/download/lib.php

index f2a3b9864b5e0172c0c31e425e20abd142318556..c36e35ef51d2d80f47fa032fc918c1dad8eaa3b3 100644 (file)
@@ -2,5 +2,6 @@
 
 $string['downloadfile'] = 'Download your portfolio export file';
 $string['pluginname'] = 'File download';
+$string['downloading'] = 'Downloading ...';
 
 ?>
diff --git a/portfolio/type/download/file.php b/portfolio/type/download/file.php
new file mode 100644 (file)
index 0000000..b734b43
--- /dev/null
@@ -0,0 +1,30 @@
+<?php
+
+require_once(dirname(dirname(dirname(dirname(__FILE__)))) . '/config.php');
+require_once($CFG->libdir . '/portfoliolib.php');
+require_js(array(
+    'yui_yahoo',
+    'yui_dom',
+));
+$id = required_param('id', PARAM_INT);
+
+$exporter = portfolio_exporter::rewaken_object($id);
+$exporter->verify_rewaken();
+
+$exporter->print_header(get_string('downloading', 'portfolio_download'), false);
+$returnurl = $exporter->get('caller')->get_return_url();
+notify('<a href="' . $returnurl . '">' . get_string('returntowhereyouwere', 'portfolio') . '</a><br />');
+
+echo '<div id="redirect">
+    <form action="' . $exporter->get('instance')->get_base_file_url() . '" method="post" id="redirectform">
+      <input type="submit" value="' . get_string('downloadfile', 'portfolio_download') . '" />
+    </form>
+    <script language="javascript">
+        f = YAHOO.util.Dom.get("redirectform");
+        YAHOO.util.Dom.addClass(f.parentNode, "hide");
+        f.submit();
+    </script>';
+
+print_footer();
+
+?>
index d5a93862620b11508565198089d5823a8117bd4b..d7d3ba33fcaa7f5709c5c58fc4550bb3410490c1 100644 (file)
@@ -1,7 +1,6 @@
 <?php
 
 require_once($CFG->libdir . '/portfoliolib.php');
-require_once($CFG->libdir . '/packer/zip_packer.php');
 
 class portfolio_plugin_download extends portfolio_plugin_pull_base {
 
@@ -30,10 +29,19 @@ class portfolio_plugin_download extends portfolio_plugin_pull_base {
         }
     }
 
+    public function steal_control($stage) {
+        if ($stage == PORTFOLIO_STAGE_FINISHED) {
+            global $CFG;
+            return $CFG->wwwroot . '/portfolio/type/download/file.php?id=' . $this->get('exporter')->get('id');
+        }
+    }
+
+    /*
     public function get_extra_finish_options() {
         global $CFG;
         return array($this->get_base_file_url() => get_string('downloadfile', 'portfolio_download'));
     }
+    */
 
     public function send_package() {}