Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

MDL-28509 repository_youtube Enable selection of sort order

  • Loading branch information...
commit 88bf951aa753ff789872c062fe4fa14fb7e39973 1 parent 84553f6
Mark Johnson authored
View
5 repository/youtube/lang/en/repository_youtube.php
@@ -27,3 +27,8 @@
$string['search'] = 'Search videos';
$string['youtube:view'] = 'Use youtube in file picker';
$string['configplugin'] = 'YouTube repository type configuration';
+$string['sortby'] = 'Sort By';
+$string['sortpublished'] = 'Date Published';
+$string['sortrating'] = 'Rating';
+$string['sortrelevance'] = 'Relevance';
+$string['sortviewcount'] = 'View Count';
View
27 repository/youtube/lib.php
@@ -31,7 +31,7 @@ public function __construct($repositoryid, $context = SYSCONTEXTID, $options = a
$this->keyword = optional_param('youtube_keyword', '', PARAM_RAW);
$this->start =1;
$this->max = 27;
- $this->sort = 'published';
+ $this->sort = optional_param('youtube_sort', '', PARAM_TEXT);
parent::__construct($repositoryid, $context, $options);
}
@@ -92,7 +92,30 @@ public function print_login($ajax = true) {
$search->id = 'youtube_search';
$search->name = 'youtube_keyword';
$search->label = get_string('search', 'repository_youtube').': ';
- $ret['login'] = array($search);
+ $sort = new stdClass();
+ $sort->type = 'select';
+ $sort->options = array(
+ (object)array(
+ 'value' => 'relevance',
+ 'label' => get_string('sortrelevance', 'repository_youtube')
+ ),
+ (object)array(
+ 'value' => 'published',
+ 'label' => get_string('sortpublished', 'repository_youtube')
+ ),
+ (object)array(
+ 'value' => 'rating',
+ 'label' => get_string('sortrating', 'repository_youtube')
+ ),
+ (object)array(
+ 'value' => 'viewCount',
+ 'label' => get_string('sortviewcount', 'repository_youtube')
+ )
+ );
+ $sort->id = 'youtube_sort';
+ $sort->name = 'youtube_sort';
+ $sort->label = get_string('sortby', 'repository_youtube').': ';
+ $ret['login'] = array($search, $sort);
$ret['login_btn_label'] = get_string('search');
$ret['login_btn_action'] = 'search';
return $ret;
Please sign in to comment.
Something went wrong with that request. Please try again.