echo '<input type="submit" value="Upload" />';
echo '</form>';
} else {
- foreach ($list['path'] as $p) {
- echo '<form method="post" style="display:inline">';
- echo '<input type="hidden" name="p" value="'.$p['path'].'"';
- echo '<input type="hidden" name="action" value="list"';
- echo '<input type="submit" value="'.$p['name'].'" />';
- echo '</form>';
- echo ' <strong>/</strong> ';
+ if (!empty($list['path'])) {
+ foreach ($list['path'] as $p) {
+ echo '<form method="post" style="display:inline">';
+ echo '<input type="hidden" name="p" value="'.$p['path'].'"';
+ echo '<input type="hidden" name="action" value="list"';
+ echo '<input type="submit" value="'.$p['name'].'" />';
+ echo '</form>';
+ echo ' <strong>/</strong> ';
+ }
}
echo '<table>';
foreach ($list['list'] as $item) {
* @param <type> $ajax
* @return <type>
*/
- public function print_login($ajax = true) {
- if ($ajax) {
+ public function print_login() {
+ if ($this->options['ajax']) {
$ret = array();
$popup_btn = new stdclass;
$popup_btn->type = 'popup';
$popup_btn->url = $this->flickr->auth();
$ret['login'] = array($popup_btn);
return $ret;
+ } else {
+ echo '<a target="_blank" href="'.$this->flickr->auth().'">Login</a>';
}
}
$contextid = $context->id;
$fs = get_file_storage();
if ($file = $fs->get_file($contextid, 'user_draft', $itemid, '/', $title)) {
- $file->delete();
- echo 200;
+ if($result = $file->delete()) {
+ echo 200;
+ } else {
+ echo '';
+ }
} else {
echo '';
}
// parent window, in this case, we need to alert user to refresh the repository
// manually.
$js =<<<EOD
-<html><head><script type="text/javascript">
+<html><head>
+<script type="text/javascript">
if(window.opener){
window.opener.repository_callback($repo_id);
window.close();
} else {
alert("If parent window is on HTTPS, then we are not allowed to access window.opener object, so we cannot refresh the repository for you automatically, but we already got your session, just go back to file picker and select the repository again, it should work now.");
}
-</script><body></body></html>
+</script>
+<body>
+<noscript>
+Close this window and refresh file picker.
+</noscript>
+</body>
+</html>
EOD;
echo $js;
die;
$itemid = (int)substr(hexdec(uniqid()), 0, 9)+rand(1,100);
}
if (preg_match('#(https?://([-\w\.]+)+(:\d+)?(/([\w/_\.]*(\?\S+)?)?)?)#', $filepath)) {
+ // youtube plugin return a url instead a file path
$url = $filepath;
echo json_encode(array(
/* File picker need to know this is a link
)
);
} else if (is_array($filepath)) {
+ // file api don't have real file path, so we need more file api specific info for "local" plugin
$fileinfo = $filepath;
$info = array();
$info['client_id'] = $client_id;