*/
public function search($search_text) {
global $SESSION;
+ $ret = array();
if (!empty($this->flickr_account)) {
$people = $this->flickr->people_findByEmail($this->flickr_account);
$this->nsid = $people['nsid'];
}
if (empty($this->nsid)) {
$this->nsid = null;
+ // user specify a flickr account, but it is not valid
+ if (!empty($this->flickr_account) or !empty($SESSION->{$this->sess_account})) {
+ $ret['e'] = get_string('invalidemail', 'repository_flickr_public');
+ return $ret;
+ }
}
$is_paging = optional_param('search_paging', '', PARAM_RAW);
if (!empty($is_paging)) {
)
);
}
- $ret = array();
$ret['total'] = $photos['total'];
$ret['perpage'] = $photos['perpage'];
if (empty($photos)) {
$format = 'jpg';
}
$format = '.'.$format;
- // append extensions to the files
if (substr($p['title'], strlen($p['title'])-strlen($format)) != $format) {
+ // append author id
+ $p['title'] .= '-'.$p['owner'];
+ // append file extension
$p['title'] .= $format;
}
$ret['list'][] = array('title'=>$p['title'], 'source'=>$p['id'],
$c = new curl;
$c->download(array(array('url'=>$url, 'file'=>$fp)));
+ $watermark = get_config('flickr_public', 'watermark');
+ if (!empty($watermark)) {
+ // process watermark
+ }
return $path;
}
$api_key = '';
}
$strrequired = get_string('required');
+
+ $mform->addElement('checkbox', 'watermark', get_string('watermark', 'repository_flickr_public'));
+
$mform->addElement('text', 'api_key', get_string('apikey', 'repository_flickr_public'), array('value'=>$api_key,'size' => '40'));
$mform->addRule('api_key', $strrequired, 'required', null, 'client');
+
+
$mform->addElement('static', null, '', get_string('information','repository_flickr_public'));
}
* @return <type>
*/
public static function get_type_option_names() {
- return array('api_key');
+ return array('api_key', 'watermark');
}
/**
* Show the search screen, if required
* @return null
*/
- public function print_search() {
+ public function print_search($client_id) {
$str = '';
$str .= '<input type="hidden" name="repo_id" value="'.$this->id.'" />';
$str .= '<input type="hidden" name="ctx_id" value="'.$this->context->id.'" />';
$lang['download'] = get_string('downloadsucc', 'repository');
$lang['date'] = get_string('date', 'repository').': ';
$lang['error'] = get_string('error', 'repository');
+ $lang['emptylist'] = get_string('emptylist', 'repository');
$lang['filenotnull'] = get_string('filenotnull', 'repository');
$lang['federatedsearch'] = get_string('federatedsearch', 'repository');
$lang['help'] = get_string('help');
global $CFG, $USER;
$ret = array();
$ret['dynload'] = true;
+ $ret['nosearch'] = true;
$list = array();
// list draft files
$gauth = new google_authsub(false, $googletoken); // will throw exception if fails
google_picasa::set_sesskey($gauth->get_sessiontoken(), $USER->id);
}
+ $this->check_login();
}
public function check_login() {
.fp-grid p{margin:0;padding:0;background: #FFFFCC}
.fp-grid .label{height:48px;text-align:center}
.fp-grid span{color:gray}
+.fp-error {padding: 2em 0; margin: 3em 5px;text-align:center;background: #FFBBBB}
+/* file picker search dialog */
+div.bd{text-align:left}
/* TODO: Fix IE6 somehow
.yui-skin-sam .yui-panel .hd{}
-*/
\ No newline at end of file
+*/
repo.viewbar.set('disabled', false);
var panel = new YAHOO.util.Element('panel-'+data.client_id);
if(data && data.e) {
- panel.get('element').innerHTML = data.e;
+ panel.get('element').innerHTML = '<div class="fp-error">'+data.e+'</div>';
return;
}
// save data
field_id = ' id="'+login[k].id+'"';
}
if (login[k].label) {
- str += '<td align="right"><label'+label_id+'>'+login[k].label+'</label> </td>';
+ str += '<td align="right" valign="top"><label'+label_id+'>'+login[k].label+'</label> </td>';
} else {
str += '<td></td>';
}
}
count++;
}
+ if (list.length == 0) {
+ panel.innerHTML = '<div class="fp-error">'+fp_lang.emptylist+'</div>';
+ }
container.appendChild(panel);
repository_client.print_footer(client_id);
}
var fp = repository_client.fp[data.client_id];
if(el) {
el.innerHTML = '';
- } else {
- var el = document.createElement('DIV');
- el.id = 'fp-search-dlg';
+ el.parentNode.removeChild(el);
}
- var div1 = document.createElement('DIV');
- div1.className = 'hd';
- div1.innerHTML = fp_lang.searching+"\"" + repository_listing[data.client_id][fp.fs.repo_id].name + '"';
- var div2 = document.createElement('DIV');
- div2.className = 'bd';
+ var el = document.createElement('DIV');
+ el.id = 'fp-search-dlg';
+ var dlg_title = document.createElement('DIV');
+ dlg_title.className = 'hd';
+ dlg_title.innerHTML = fp_lang.searching+"\"" + repository_listing[data.client_id][fp.fs.repo_id].name + '"';
+ var dlg_body = document.createElement('DIV');
+ dlg_body.className = 'bd';
var sform = document.createElement('FORM');
sform.method = 'POST';
sform.id = "fp-search-form";
sform.action = moodle_cfg.wwwroot+'/repository/ws.php?action=search';
sform.innerHTML = data['form'];
- div2.appendChild(sform);
- el.appendChild(div1);
- el.appendChild(div2);
+ dlg_body.appendChild(sform);
+ el.appendChild(dlg_title);
+ el.appendChild(dlg_body);
document.body.appendChild(el);
var dlg_handler = function() {
var client_id=dlg_handler.client_id;
handler: dlg_handler,
isDefault:true
},
- {text:fp_lang.cancel,handler:function(){this.cancel()}}
+ {text:fp_lang.cancel,handler:function(){this.destroy()}}
]
});
dlg.render();
require_once('../config.php');
require_once('../lib/filelib.php');
require_once('lib.php');
+ require_login();
/// Parameters
$page = optional_param('page', '', PARAM_RAW); // page
// If Moodle is working on HTTPS mode, then we are not allowed to access
// parent window, in this case, we need to alert user to refresh the repository
// manually.
+ $strhttpsbug = get_string('cannotaccessparentwin', 'repository');
+ $strrefreshnonjs = get_string('refreshnonjsfilepicker', 'repository');
$js =<<<EOD
<html><head>
<script type="text/javascript">
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.");
+ alert("{$strhttpsbug }");
}
</script>
<body>
<noscript>
-Close this window and refresh file picker.
+{$strrefreshnonjs}
</noscript>
</body>
</html>
echo json_encode($logout);
break;
case 'searchform':
- $search_form['form'] = $repo->print_search();
+ $search_form['form'] = $repo->print_search($client_id);
$search_form['client_id'] = $client_id;
echo json_encode($search_form);
break;