Skip to content

Commit

Permalink
"MDL-13766, support iframe repository"
Browse files Browse the repository at this point in the history
  • Loading branch information
dongsheng committed Nov 3, 2008
1 parent 18729a5 commit 1e08b5c
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
6 changes: 6 additions & 0 deletions repository/javascript.php
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,10 @@ function _client() {
var trans = YAHOO.util.Connect.asyncRequest('POST',
'$CFG->httpswwwroot/repository/ws.php?action=list', callback, _client.postdata(params));
}
_client.viewiframe = function() {
var panel = new YAHOO.util.Element('panel-$suffix');
panel.get('element').innerHTML = "<iframe frameborder=\"0\" width=\"98%\" height=\"400px\" src=\""+_client.ds.iframe+"\" />";
}
_client.viewlist = function() {
_client.viewmode = 0;
var panel = new YAHOO.util.Element('panel-$suffix');
Expand Down Expand Up @@ -916,6 +920,8 @@ function _client() {
_client.ds = ret;
if(!_client.ds) {
return;
}else if(_client.ds.iframe) {
_client.viewiframe();
}else if(_client.ds && _client.ds.login) {
_client.print_login();
} else if(_client.ds.list) {
Expand Down
24 changes: 22 additions & 2 deletions repository/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -705,8 +705,10 @@ final public static function create($type, $userid, $context, $params, $readonly
$id = $DB->insert_record('repository_instances', $record);
$options = array();
$configs = call_user_func($classname . '::get_instance_option_names');
foreach ($configs as $config) {
$options[$config] = $params[$config];
if (!empty($configs)) {
foreach ($configs as $config) {
$options[$config] = $params[$config];
}
}

if (!empty($id)) {
Expand Down Expand Up @@ -1254,6 +1256,24 @@ function repository_move_to_filepool($path, $name, $itemid, $filearea = 'user_dr
}
}

function repository_download_btn($repo_id, $ctx_id, $sesskey, $title, $src, $returnurl = '') {
global $CFG;
if (empty($returnurl)) {
$returnurl = get_referer();
}
$str = '<form action="'.$CFG->httpswwwroot.'/repository/ws.php">';
$str .= ' <input type="hidden" name="sesskey" value="'.$sesskey.'" />';
$str .= ' <input type="hidden" name="ctx_id" value="'.$ctx_id.'" />';
$str .= ' <input type="hidden" name="repo_id" value="'.$repo_id.'" />';
$str .= ' <input type="hidden" name="file" value="'.$src.'" />';
$str .= ' <input type="hidden" name="action" value="download" />';
$str .= ' <input type="hidden" name="returnurl" value="'.$returnurl.'" />';
$str .= ' <input type="text" name="title" value="'.$title.'" />';
$str .= ' <input type="submit" value="Select it!" />';
$str .= '</form>';
return $str;
}

/**
* Save file to local filesystem pool
* @param string $elname name of element
Expand Down

0 comments on commit 1e08b5c

Please sign in to comment.