]> git.mjollnir.org Git - moodle.git/commitdiff
"MDL-19180, clean up repository url download plugin, and make it support non-js file...
authordongsheng <dongsheng>
Wed, 24 Jun 2009 03:38:13 +0000 (03:38 +0000)
committerdongsheng <dongsheng>
Wed, 24 Jun 2009 03:38:13 +0000 (03:38 +0000)
repository/url/repository.class.php

index 666974cef15fb42a984f26c1a7874380d6e09685..dd315bffa5f9d9c86053bf01378828ade973924f 100755 (executable)
 class repository_url extends repository {
 
     /**
-     *
-     * @global object $SESSION
-     * @global string $action
-     * @global object $CFG
      * @param int $repositoryid
      * @param object $context
      * @param array $options
      */
     public function __construct($repositoryid, $context = SITEID, $options = array()){
-        global $SESSION, $action, $CFG;
+        global $CFG;
         parent::__construct($repositoryid, $context, $options);
         if (!empty($options['client_id'])) {
+            // will be used to construct download form
             $this->client_id = $options['client_id'];
         }
         $this->file_url = optional_param('download_from', '', PARAM_RAW);
@@ -37,7 +34,6 @@ class repository_url extends repository {
     }
 
     public function check_login() {
-        global $action;
         if (!empty($this->file_url)) {
             return true;
         } else {
@@ -45,32 +41,47 @@ class repository_url extends repository {
         }
     }
     /**
-     *
-     * @global object $SESSION
-     * @param boolean $ajax
      * @return mixed
      */
-    public function print_login($ajax = true) {
-        $url = new stdclass;
-        $url->label = get_string('url', 'repository_url').': ';
-        $url->id   = 'fileurl-'.$this->client_id;
-        $url->type = 'text';
-        $url->name = 'fileiii';
+    public function print_login() {
+        $strdownload = get_string('download', 'repository');
+        $strname     = get_string('rename', 'repository_url');
+        $strurl      = get_string('url', 'repository_url');
+        if ($this->options['ajax']) {
+            $url = new stdclass;
+            $url->label = $strurl.': ';
+            $url->id   = 'fileurl-'.$this->client_id;
+            $url->type = 'text';
+            $url->name = 'file';
+
+            $title = new stdclass;
+            $title->label = $strname.': ';
+            $title->id    = 'newname-'.$this->client_id;
+            $title->type = 'text';
+            $title->name = 'title';
 
-        $title = new stdclass;
-        $title->label = get_string('rename', 'repository_url').': ';
-        $title->id    = 'newname-'.$this->client_id;
-        $title->type = 'text';
-        $title->name = 'file';
+            $ret['login'] = array($url, $title);
+            $ret['login_btn_label'] = get_string('download', 'repository_url');
+            $ret['login_btn_action'] = 'download';
+            return $ret;
+        } else {
+            echo <<<EOD
+<table>
+<tr>
+<td>{$strurl}: </td><td><input name="file" type="text" /></td>
+</tr>
+<tr>
+<td>{$strname}: </td><td><input name="title" type="text" /></td>
+</tr>
+</table>
+<input type="hidden" name="action" value="download" />
+<input type="submit" value="{$strdownload}" />
+EOD;
 
-        $ret['login'] = array($url, $title);
-        $ret['login_btn_label'] = get_string('download', 'repository_url');
-        $ret['login_btn_action'] = 'download';
-        return $ret;
+        }
     }
 
     /**
-     *
      * @param mixed $path
      * @param string $search
      * @return array