示例#1
0
 public function output()
 {
     if (!empty($this->search)) {
         foreach ($this->search as $key => $current) {
             $popularity = Helper::floatToBars($current['popularity']);
             if ($current['type'] == 'track') {
                 $subtitle = "{$popularity} {$current['album']} by {$current['artist']}";
             } elseif ($current['type'] == 'album') {
                 $subtitle = "{$popularity} Album by {$current['artist']}";
             } else {
                 $subtitle = "{$popularity} " . ucfirst($current['type']);
             }
             if ($current['type'] == 'track') {
                 $valid = 'yes';
                 $arg = "play track \"{$current['href']}\"";
                 $autocomplete = '';
             } else {
                 $valid = 'no';
                 $arg = '';
                 $autocomplete = "{$current['href']} ⟩ {$this->query} ⟩";
             }
             $currentResult['title'] = $current['title'];
             $currentResult['subtitle'] = $subtitle;
             $currentResult['uid'] = "bs-spotify-{$this->query}-{$current['type']}-{$current['title']}";
             $currentResult['valid'] = $valid;
             $currentResult['arg'] = $arg;
             $currentResult['autocomplete'] = $autocomplete;
             $currentResult['icon'] = "include/images/{$current['type']}.png";
             $results[] = $currentResult;
         }
     }
     /* Give the option to continue searching in Spotify because even I know my limits. */
     $results[] = array('title' => "Search for {$this->query}", 'subtitle' => "Continue this search in Spotify…", 'uid' => "bs-spotify-{$this->query}-more", 'arg' => "activate (open location \"spotify:search:{$this->query}\")", 'icon' => 'include/images/search.png');
     return $results;
 }
示例#2
0
 public function output()
 {
     $results = array();
     if (!empty($this->raw)) {
         foreach ($this->raw as $key => $current) {
             $currentResult = array();
             if ($current['type'] == 'track') {
                 $currentResult['title'] = "{$current['number']}. {$current['title']}";
                 $currentResult['subtitle'] = Helper::floatToBars($current['popularity'], 12);
                 $currentResult['arg'] = "play track \"{$current['href']}\" in context \"{$this->currentURI}\"";
                 $currentResult['valid'] = "yes";
                 $currentResult['icon'] = "include/images/track.png";
             } else {
                 $currentResult['title'] = $current['title'];
                 $currentResult['subtitle'] = "Browse this {$current['type']}";
                 $currentResult['valid'] = "no";
                 $currentResult['autocomplete'] = "{$this->currentURI} ⟩ {$current['href']} ⟩ {$this->query} ⟩{$this->search}⟩";
                 $currentResult['icon'] = "include/images/album.png";
             }
             $results[] = $currentResult;
         }
     }
     $scope['title'] = $this->title;
     $scope['subtitle'] = "Browse this {$this->type} in Spotify";
     $scope['arg'] = "activate (open location \"{$this->currentURI}\")";
     $scope['icon'] = "include/images/{$this->type}.png";
     if ($this->search == null) {
         array_unshift($results, $scope);
     } else {
         array_push($results, $scope);
     }
     return $results;
 }