]> git.mjollnir.org Git - moodle.git/commitdiff
"MDL-16911, 1. allow double/single quotes to be showed in title 2. allow change youtu...
authordongsheng <dongsheng>
Wed, 29 Apr 2009 06:02:26 +0000 (06:02 +0000)
committerdongsheng <dongsheng>
Wed, 29 Apr 2009 06:02:26 +0000 (06:02 +0000)
repository/repository.js
repository/ws.php
repository/youtube/repository.class.php

index 7a426aa5539f0ce494aee7bc6e0e1c3f8ba04927..34dbe99665d3db15755bd8695a41b91f5d3e2d21 100644 (file)
@@ -15,6 +15,8 @@
 var repository_listing = {};
 var cached_client_id = {};
 var file_extensions = {};
+/* when selected a file, filename will be cached in this varible */
+var new_filename = '';
 // repository_client has static functions
 var repository_client = (function(){
     // private static field
@@ -493,12 +495,14 @@ repository_client.select_file = function(oldname, url, icon, client_id, repo_id)
     var html = '<div class="fp-rename-form">';
     html += '<p><img src="'+icon+'" /></p>';
     html += '<p><label for="newname-'+client_id+'">'+fp_lang.saveas+'</label>';
-    html += '<input type="text" id="newname-'+client_id+'" value="'+oldname+'" /></p>';
+    html += '<input type="text" id="newname-'+client_id+'" value="" /></p>';
     html += '<p><input type="hidden" id="fileurl-'+client_id+'" value="'+url+'" />';
     html += '<input type="button" onclick="repository_client.download(\''+client_id+'\', \''+repo_id+'\')" value="'+fp_lang.downbtn+'" />';
     html += '<input type="button" onclick="repository_client.viewfiles(\''+client_id+'\')" value="'+fp_lang.cancel+'" /></p>';
     html += '</div>';
     panel.get('element').innerHTML += html;
+    /* to deal with double quote, single quote, we need to use javascript change value */
+    document.getElementById('newname-'+client_id).value = oldname;
     var tree = document.getElementById('treediv-'+client_id);
     if(tree){
         tree.style.display = 'none';
@@ -695,7 +699,7 @@ repository_client.view_as_icons = function(client_id, data) {
         } else {
             var el_title = new YAHOO.util.Element(title.id);
             var file = new YAHOO.util.Element(link.id);
-            el_title.title = file.title = list[k].title;
+            el_title.filename = file.filename = list[k].title;
             el_title.value = file.value = list[k].source;
             el_title.icon = file.icon  = list[k].thumbnail;
             if(fp.fs.repo_id) {
@@ -705,12 +709,12 @@ repository_client.view_as_icons = function(client_id, data) {
             }
             file.on('contentReady', function() {
                 this.on('click', function() {
-                    repository_client.select_file(this.title, this.value, this.icon, client_id, this.repo_id);
+                    repository_client.select_file(this.filename, this.value, this.icon, client_id, this.repo_id);
                 });
             });
             el_title.on('contentReady', function() {
                 this.on('click', function() {
-                    repository_client.select_file(this.title, this.value, this.icon, client_id, this.repo_id);
+                    repository_client.select_file(this.filename, this.value, this.icon, client_id, this.repo_id);
                 });
             });
         }
@@ -820,6 +824,7 @@ repository_client.logout = function(client_id, repo_id) {
 repository_client.download = function(client_id, repo_id) {
     var fp = repository_client.fp[client_id];
     var title = document.getElementById('newname-'+client_id).value;
+    new_filename = title;
     var file = document.getElementById('fileurl-'+client_id).value;
     repository_client.loading(client_id, 'download', title);
     var params = [];
@@ -854,7 +859,11 @@ repository_client.end = function(client_id, obj) {
     if(fp.env=='filepicker') {
         fp.target.value = obj['id'];
     }else if(fp.env=='editor'){
-        fp.target.value = obj['url'];
+        if (obj['type'] == 'link') {
+            fp.target.value = obj['url']+'#'+new_filename;
+        } else {
+            fp.target.value = obj['url'];
+        }
         fp.target.onchange();
     }
     fp.formcallback(obj);
index 58ca4ed1656d7030ef0c3be6324e585beab6c4cd..ba0e64ac55b51711cbf27727c95fb34885373406 100644 (file)
@@ -187,7 +187,17 @@ EOD;
                     $itemid = (int)substr(hexdec(uniqid()), 0, 9)+rand(1,100);
                 }
                 if (preg_match('#(https?://([-\w\.]+)+(:\d+)?(/([\w/_\.]*(\?\S+)?)?)?)#', $path)) {
-                    echo json_encode(array('client_id'=>$client_id, 'url'=>$path, 'id'=>$path, 'file'=>$path));
+                    echo json_encode(array(
+                                /* File picker need to know this is a link
+                                 * in order to attach title to url
+                                 */
+                                'type'=>'link',
+                                'client_id'=>$client_id,
+                                'url'=>$path,
+                                'id'=>$path,
+                                'file'=>$path
+                                )
+                            );
                 } else {
                     $info = repository::move_to_filepool($path, $title, $itemid);
                     $info['client_id'] = $client_id;
index a11b4becf88bfaf5466415759562774266223930..6b49b2da638beb9fba9a42fa1d2061756e8ce4e7 100644 (file)
@@ -11,7 +11,7 @@ class repository_youtube extends repository {
     public function __construct($repositoryid, $context = SITEID, $options = array()) {
         $options['keyword'] = optional_param('youtube_keyword', '', PARAM_RAW);
         $options['start'] =1;
-        $options['max'] = 25;
+        $options['max'] = 27;
         $options['sort'] = 'relevance';
         parent::__construct($repositoryid, $context, $options);
     }
@@ -49,7 +49,7 @@ class repository_youtube extends repository {
                 'thumbnail_height'=>120,
                 'size'=>'',
                 'date'=>'',
-                'source'=>$source.'#'.$title
+                'source'=>$source
             );
         } 
         return $list;