"MDL-13766, support iframe repository"

This commit is contained in:
dongsheng 2008-11-03 04:44:53 +00:00
parent 18729a5138
commit 1e08b5cf79
2 changed files with 28 additions and 2 deletions

View file

@ -705,8 +705,10 @@ abstract class repository {
$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)) {
@ -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