From: dongsheng Date: Wed, 24 Jun 2009 05:49:52 +0000 (+0000) Subject: "MDL-18830, improve flickr_public plugin license searching, easier to use " X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=16e9dccdd1ce1c8e2d0a6aa4b992512052a35024;p=moodle.git "MDL-18830, improve flickr_public plugin license searching, easier to use " --- diff --git a/lang/en_utf8/repository_flickr_public.php b/lang/en_utf8/repository_flickr_public.php index 34d2b992fc..d21747db94 100644 --- a/lang/en_utf8/repository_flickr_public.php +++ b/lang/en_utf8/repository_flickr_public.php @@ -10,12 +10,14 @@ $string['by-nc-nd'] = 'Attribution-NonCommercial-NoDerivs License'; $string['by'] = 'Attribution License'; $string['by-sa'] = 'Attribution-ShareAlike License'; $string['by-nd'] = 'Attribution-NoDerivs License'; +$string['commercialuse'] = 'Allow commercial uses of your work?'; $string['creativecommonscommercial'] = 'Only creative commons commercial'; $string['emailaddress'] = 'Email address'; $string['fulltext'] = 'Full text'; $string['information'] = '
Get Flickr API Key for your Moodle site.
'; $string['invalidemail'] = 'Invalid email address for flickr'; $string['license'] = 'License'; +$string['modification'] = 'Allow modifications of your work?'; $string['notitle'] = 'notitle'; $string['nullphotolist'] = 'There are no photos in this account'; $string['tag'] = 'Tag'; @@ -23,5 +25,6 @@ $string['remember'] = 'Remember me'; $string['repositoryname'] = 'Flickr public'; $string['repositorydesc'] = 'Repository on flickr.com'; $string['secret'] = 'Secret'; +$string['sharealike'] = 'Yes, as long as others share alike'; $string['username'] = 'Flickr account email'; diff --git a/repository/flickr_public/repository.class.php b/repository/flickr_public/repository.class.php index 84a27117a5..8aeb95d05c 100644 --- a/repository/flickr_public/repository.class.php +++ b/repository/flickr_public/repository.class.php @@ -86,13 +86,11 @@ class repository_flickr_public extends repository { $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; } } @@ -130,26 +128,30 @@ class repository_flickr_public extends repository { $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; @@ -162,21 +164,22 @@ class repository_flickr_public extends repository { echo ''; echo ''; - echo ''; + echo ''; echo ''; - echo ' '.get_string('all', 'repository_flickr_public'); + echo ' '.get_string('yes'); echo '
'; - echo ' '.get_string('by-nc-sa', 'repository_flickr_public'); + echo ' '.get_string('no'); echo '
'; - echo ' '.get_string('by-nc', 'repository_flickr_public'); - echo '
'; - echo ' '.get_string('by-nc-nd', 'repository_flickr_public'); + echo ''; + + echo ''; + echo ''; + echo ' '.get_string('yes'); echo '
'; - echo ' '.get_string('by', 'repository_flickr_public'); + echo ' '.get_string('sharealike', 'repository_flickr_public'); echo '
'; - echo ' '.get_string('by-sa', 'repository_flickr_public'); + echo ' '.get_string('no'); echo '
'; - echo ' '.get_string('by-nd', 'repository_flickr_public'); echo ''; echo ''; @@ -222,29 +225,50 @@ class repository_flickr_public extends repository { } 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'];