$this->sess_account = 'flickr_public_'.$this->id.'_account';
$this->sess_tag = 'flickr_public_'.$this->id.'_tag';
$this->sess_text = 'flickr_public_'.$this->id.'_text';
- $this->sess_license = 'flickr_public_'.$this->id.'_license';
if (!empty($account) or !empty($fulltext) or !empty($tag) or !empty($license)) {
$SESSION->{$this->sess_tag} = $tag;
$SESSION->{$this->sess_text} = $fulltext;
$SESSION->{$this->sess_account} = $account;
- $SESSION->{$this->sess_license} = $license;
}
}
$email_field->type = 'text';
$email_field->name = 'flickr_account';
- $license = new stdclass;
- $license->label = get_string('license', 'repository_flickr_public').': ';
- $license->id = 'flickr_license_type';
- $license->type = 'radio';
- $license->name = 'flickr_license';
- // all -> all licenses
- // cc -> creative commons
- // ccc -> reeative commons commercial
- $license->value = implode('|', array('all', 1, 2, 3, 4, 5, 6));
- $license->value_label = implode('|', array(
- get_string('all', 'repository_flickr_public'),
- get_string('by-nc-sa', 'repository_flickr_public'),
- get_string('by-nc', 'repository_flickr_public'),
- get_string('by-nc-nd', 'repository_flickr_public'),
- get_string('by', 'repository_flickr_public'),
- get_string('by-sa', 'repository_flickr_public'),
- get_string('by-nd', 'repository_flickr_public')
- ));
-
- $ret['login'] = array($fulltext, $tag, $email_field, $license);
+ $commercial = new stdclass;
+ $commercial->label = get_string('commercialuse', 'repository_flickr_public').': ';
+ $commercial->id = 'flickr_commercial_id';
+ $commercial->type = 'radio';
+ $commercial->name = 'flickr_commercial';
+ $commercial->value = implode('|', array('yes', 'no'));
+ $commercial->value_label = implode('|', array(
+ get_string('yes'),
+ get_string('no')
+ ));
+
+ $modification = new stdclass;
+ $modification->label = get_string('modification', 'repository_flickr_public').': ';
+ $modification->id = 'flickr_modification_id';
+ $modification->type = 'radio';
+ $modification->name = 'flickr_modification';
+ $modification->value = implode('|', array('yes', 'sharealike', 'no'));
+ $modification->value_label = implode('|', array(
+ get_string('yes'),
+ get_string('sharealike', 'repository_flickr_public'),
+ get_string('no')
+ ));
+
+ $ret['login'] = array($fulltext, $tag, $email_field, $commercial, $modification);
$ret['login_btn_label'] = get_string('search');
$ret['login_btn_action'] = 'search';
return $ret;
echo '<tr><td><label>'.get_string('username', 'repository_flickr_public').'</label></td>';
echo '<td><input type="text" name="flickr_account" /></td></tr>';
- echo '<tr><td><label>'.get_string('license', 'repository_flickr_public').'</label></td>';
+ echo '<tr><td><label>'.get_string('commercialuse', 'repository_flickr_public').'</label></td>';
echo '<td>';
- echo '<input type="radio" name="flickr_license" value="all" /> '.get_string('all', 'repository_flickr_public');
+ echo '<input type="radio" name="flickr_commercial" value="yes" /> '.get_string('yes');
echo '<br />';
- echo '<input type="radio" name="flickr_license" value="1" /> '.get_string('by-nc-sa', 'repository_flickr_public');
+ echo '<input type="radio" name="flickr_commercial" value="no" /> '.get_string('no');
echo '<br />';
- echo '<input type="radio" name="flickr_license" value="2" /> '.get_string('by-nc', 'repository_flickr_public');
- echo '<br />';
- echo '<input type="radio" name="flickr_license" value="3" /> '.get_string('by-nc-nd', 'repository_flickr_public');
+ echo '</td></tr>';
+
+ echo '<tr><td><label>'.get_string('modification', 'repository_flickr_public').'</label></td>';
+ echo '<td>';
+ echo '<input type="radio" name="flickr_modification" value="yes" /> '.get_string('yes');
echo '<br />';
- echo '<input type="radio" name="flickr_license" value="4" /> '.get_string('by', 'repository_flickr_public');
+ echo '<input type="radio" name="flickr_modification" value="sharealike" /> '.get_string('sharealike', 'repository_flickr_public');
echo '<br />';
- echo '<input type="radio" name="flickr_license" value="5" /> '.get_string('by-sa', 'repository_flickr_public');
+ echo '<input type="radio" name="flickr_modification" value="no" /> '.get_string('no');
echo '<br />';
- echo '<input type="radio" name="flickr_license" value="6" /> '.get_string('by-nd', 'repository_flickr_public');
echo '</td></tr>';
echo '</table>';
} else {
$page = 1;
}
- if (!empty($SESSION->{$this->sess_tag}) or !empty($SESSION->{$this->sess_text})
- or !empty($SESSION->{$this->sess_account}) or !empty($this->nsid))
- {
- if ( empty($SESSION->{$this->sess_license}) or $SESSION->{$this->sess_license}=='all') {
- $photos = $this->flickr->photos_search(array(
- 'tags'=>$SESSION->{$this->sess_tag},
- 'page'=>$page,
- 'per_page'=>24,
- 'user_id'=>$this->nsid,
- 'text'=>$SESSION->{$this->sess_text}
- )
- );
- } else {
- $photos = $this->flickr->photos_search(array(
- 'tags'=>$SESSION->{$this->sess_tag},
- 'page'=>$page,
- 'per_page'=>24,
- 'user_id'=>$this->nsid,
- 'license'=>$SESSION->{$this->sess_license},
- 'text'=>$SESSION->{$this->sess_text}
- )
- );
- }
+ // including all licenses by default
+ $licenses = array(1=>1, 2, 3, 4, 5, 6, 7);
+
+ $commercial = optional_param('flickr_commercial', '', PARAM_RAW);
+ $modification = optional_param('flickr_modification', '', PARAM_RAW);
+
+ if ($commercial == 'yes') {
+ // including
+ // 4: Attribution License
+ // 5: Attribution ShareAlike
+ // 6: Attribution NoDerives
+ // 7: unknown license
+ unset($licenses[1], $licenses[2], $licenses[3]);
+ }
+ if ($modification == 'yes') {
+ // including
+ // 1: Attribution NonCommercial ShareAlike
+ // 2: Attribution NonCommercial
+ // 4: Attribution License
+ // 5: Attribution ShareAlike
+ // 7: unknown license
+ unset($licenses[3], $licenses[6]);
+ }
+ if ($modification == 'sharealike') {
+ // including
+ // 1: Attribution NonCommercial ShareAlike
+ // 5: Attribution ShareAlike
+ unset($licenses[2], $licenses[3], $licenses[4], $licenses[6], $licenses[7]);
+ }
+
+ $licenses = implode(',', $licenses);
+
+ if (!empty($SESSION->{$this->sess_tag}) // use tag to search
+ or !empty($SESSION->{$this->sess_text}) // use keyword to search
+ or !empty($this->nsid)/*use pre-defined accound*/) {
+ $photos = $this->flickr->photos_search(array(
+ 'tags'=>$SESSION->{$this->sess_tag},
+ 'page'=>$page,
+ 'per_page'=>24,
+ 'user_id'=>$this->nsid,
+ 'license'=>$licenses,
+ 'text'=>$SESSION->{$this->sess_text}
+ )
+ );
}
$ret = array();
$ret['total'] = $photos['total'];