From 55b4bb1d9e9581e98580f858d39bf728588900fe Mon Sep 17 00:00:00 2001 From: dongsheng Date: Wed, 27 Aug 2008 06:23:01 +0000 Subject: [PATCH] MDL-13766, fix lang strings and small bugs --- lang/en_utf8/repository.php | 2 ++ repository/boxnet/boxlibphp5.php | 4 ++-- repository/lib.php | 10 ++++++---- repository/ws.php | 6 ++++-- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/lang/en_utf8/repository.php b/lang/en_utf8/repository.php index b44065b7c6..e974d7a227 100644 --- a/lang/en_utf8/repository.php +++ b/lang/en_utf8/repository.php @@ -15,6 +15,7 @@ $string['downloadsucc'] = 'The file has been downloaded successfully'; $string['error'] = 'An unknown error occurred!'; $string['filename'] = 'Filename'; $string['filesaved'] = 'The file has been saved'; +$string['getfile'] = 'Select this file'; $string['instance'] = 'instance'; $string['invalidrepositoryid'] = 'Invalid repository ID'; $string['invalidplugin'] = 'Invalid repository plug-in'; @@ -32,6 +33,7 @@ $string['plugin'] = 'Repository plug-ins'; $string['repository'] = 'Repository'; $string['repositories'] = 'Repositories'; $string['save'] = 'Save'; +$string['saveas'] = 'Save As'; $string['saved'] = 'Saved'; $string['saving'] = 'Saving'; $string['settings'] = 'Settings'; diff --git a/repository/boxnet/boxlibphp5.php b/repository/boxnet/boxlibphp5.php index 1b485e8ac6..a4312d6d74 100755 --- a/repository/boxnet/boxlibphp5.php +++ b/repository/boxnet/boxlibphp5.php @@ -20,7 +20,7 @@ class boxclient { public $auth_token = ''; - private $_box_api_url = 'http://www.box.net/api/1.0/rest'; + private $_box_api_url = 'http://box.net/api/1.0/rest'; private $_box_api_upload_url = 'http://upload.box.net/api/1.0/upload'; private $_error_code = ''; private $_error_msg = ''; @@ -144,7 +144,7 @@ class boxclient { } catch (Exception $e){ } $ret = array(); - $o = simplexml_load_string($xml); + $o = simplexml_load_string(trim($xml)); if($o->status == 'listing_ok') { $tree = $o->tree->folder; $this->buildtree($tree, $ret); diff --git a/repository/lib.php b/repository/lib.php index fa472afb13..f9399b84e3 100644 --- a/repository/lib.php +++ b/repository/lib.php @@ -530,16 +530,18 @@ function repository_static_function($plugin, $function) { * @param string file path in download folder * @param string file name * @param int itemid to identify a file in filepool + * @param string file area + * @param string filepath in file area * @return array information of file in file pool */ -function move_to_filepool($path, $name, $itemid) { +function move_to_filepool($path, $name, $itemid, $filearea = 'user_draft', $filepath = '/') { global $DB, $CFG, $USER; $context = get_context_instance(CONTEXT_USER, $USER->id); $entry = new object(); - $entry->filearea = 'user_draft'; + $entry->filearea = $filearea; $entry->contextid = $context->id; $entry->filename = $name; - $entry->filepath = '/'; + $entry->filepath = $filepath; $entry->timecreated = time(); $entry->timemodified = time(); if(is_numeric($itemid)) { @@ -572,7 +574,7 @@ function get_repository_client($context){ $stradd = get_string('add', 'repository'); $strback = get_string('back', 'repository'); $strclose = get_string('close', 'repository'); - $strdownbtn = get_string('download', 'repository'); + $strdownbtn = get_string('getfile', 'repository'); $strdownload = get_string('downloadsucc', 'repository'); $strdate = get_string('date', 'repository').': '; $strerror = get_string('error', 'repository'); diff --git a/repository/ws.php b/repository/ws.php index ad71f65227..37edbe255e 100644 --- a/repository/ws.php +++ b/repository/ws.php @@ -7,7 +7,7 @@ require_once('../lib/filelib.php'); require_once('lib.php'); // set one hour here $CFG->repository_cache_expire = 60*60; -// page +// page or path $p = optional_param('p', '', PARAM_INT); // opened in editor or moodleform $env = optional_param('env', 'form', PARAM_ALPHA); @@ -24,6 +24,8 @@ $repo_id = optional_param('repo_id', 1, PARAM_INT); // what will happen if user use a fake ctx_id? // Think about using $SESSION save it $ctx_id = optional_param('ctx_id', SITEID, PARAM_INT); +$filearea = optional_param('filearea', 'user_draft', PARAM_RAW); +$filepath = optional_param('filepath', '/', PARAM_RAW); $userid = $USER->id; if(!$repository = repository_instance($repo_id)) @@ -71,7 +73,7 @@ if ($action == 'list' || $action == 'search') { $path = $repo->get_file($file, $title); $itemid = (int)substr(hexdec(uniqid()), 0, 9)+rand(1,100); try { - $info = move_to_filepool($path, $title, $itemid); + $info = move_to_filepool($path, $title, $itemid, $filearea, $filepath); if($env == 'form'){ echo json_encode($info['id']); } elseif($env == 'editor') { -- 2.39.5