Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

MDL-28509 repository_youtube Enable selection of sort order

  • Loading branch information...
commit c865e54938eaba0b21050048ac0e7e5b83e11991 1 parent 3df2ab8
authored dongsheng committed
5  repository/youtube/lang/en/repository_youtube.php
@@ -27,3 +27,8 @@
27 27
 $string['search'] = 'Search videos';
28 28
 $string['youtube:view'] = 'Use youtube in file picker';
29 29
 $string['configplugin'] = 'YouTube repository type configuration';
  30
+$string['sortby'] = 'Sort By';
  31
+$string['sortpublished'] = 'Date Published';
  32
+$string['sortrating'] = 'Rating';
  33
+$string['sortrelevance'] = 'Relevance';
  34
+$string['sortviewcount'] = 'View Count';
27  repository/youtube/lib.php
@@ -31,7 +31,7 @@ public function __construct($repositoryid, $context = SYSCONTEXTID, $options = a
31 31
         $this->keyword = optional_param('youtube_keyword', '', PARAM_RAW);
32 32
         $this->start =1;
33 33
         $this->max = 27;
34  
-        $this->sort = 'published';
  34
+        $this->sort = optional_param('youtube_sort', '', PARAM_TEXT);
35 35
         parent::__construct($repositoryid, $context, $options);
36 36
     }
37 37
 
@@ -92,7 +92,30 @@ public function print_login($ajax = true) {
92 92
         $search->id   = 'youtube_search';
93 93
         $search->name = 'youtube_keyword';
94 94
         $search->label = get_string('search', 'repository_youtube').': ';
95  
-        $ret['login'] = array($search);
  95
+        $sort = new stdClass();
  96
+        $sort->type = 'select';
  97
+        $sort->options = array(
  98
+            (object)array(
  99
+                'value' => 'relevance',
  100
+                'label' => get_string('sortrelevance', 'repository_youtube')
  101
+            ),
  102
+            (object)array(
  103
+                'value' => 'published',
  104
+                'label' => get_string('sortpublished', 'repository_youtube')
  105
+            ),
  106
+            (object)array(
  107
+                'value' => 'rating',
  108
+                'label' => get_string('sortrating', 'repository_youtube')
  109
+            ),
  110
+            (object)array(
  111
+                'value' => 'viewCount',
  112
+                'label' => get_string('sortviewcount', 'repository_youtube')
  113
+            )
  114
+        );
  115
+        $sort->id = 'youtube_sort';
  116
+        $sort->name = 'youtube_sort';
  117
+        $sort->label = get_string('sortby', 'repository_youtube').': ';
  118
+        $ret['login'] = array($search, $sort);
96 119
         $ret['login_btn_label'] = get_string('search');
97 120
         $ret['login_btn_action'] = 'search';
98 121
         return $ret;

0 notes on commit c865e54

Please sign in to comment.
Something went wrong with that request. Please try again.