From ea7898979c69c2af5e211f6fb2cfd042bd7251d9 Mon Sep 17 00:00:00 2001 From: dongsheng Date: Wed, 29 Apr 2009 06:02:26 +0000 Subject: [PATCH] "MDL-16911, 1. allow double/single quotes to be showed in title 2. allow change youtube video name" --- repository/repository.js | 19 ++++++++++++++----- repository/ws.php | 12 +++++++++++- repository/youtube/repository.class.php | 4 ++-- 3 files changed, 27 insertions(+), 8 deletions(-) diff --git a/repository/repository.js b/repository/repository.js index 7a426aa553..34dbe99665 100644 --- a/repository/repository.js +++ b/repository/repository.js @@ -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 = '
'; html += '

'; html += '

'; - html += '

'; + html += '

'; html += '

'; html += ''; html += '

'; html += '
'; 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); diff --git a/repository/ws.php b/repository/ws.php index 58ca4ed165..ba0e64ac55 100644 --- a/repository/ws.php +++ b/repository/ws.php @@ -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; diff --git a/repository/youtube/repository.class.php b/repository/youtube/repository.class.php index a11b4becf8..6b49b2da63 100644 --- a/repository/youtube/repository.class.php +++ b/repository/youtube/repository.class.php @@ -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; -- 2.39.5