示例#1
0
 /**
  * display_home
  * This display the module in home page
  */
 public function display_home()
 {
     if (AmpConfig::get('userflags')) {
         $userflags = Userflag::get_latest(null, -1, $this->maxitems);
         $i = 0;
         echo '<div class="home_plugin"><table class="tabledata">';
         foreach ($userflags as $userflag) {
             $item = new $userflag['type']($userflag['id']);
             $item->format();
             $user = new User($userflag['user']);
             $user->format();
             if ($item->id) {
                 echo '<tr class="' . ($i % 2 == 0 ? 'even' : 'odd') . '"><td>';
                 echo '<div>';
                 echo '<div style="float: left;">';
                 echo '<span style="font-weight: bold;">' . $item->f_link . '</span> ';
                 echo '<span style="margin-right: 10px;">';
                 if (AmpConfig::get('directplay')) {
                     echo Ajax::button('?page=stream&action=directplay&object_type=' . $userflag['type'] . '&object_id=' . $userflag['id'], 'play', T_('Play'), 'play_' . $userflag['type'] . '_' . $userflag['id']);
                     if (Stream_Playlist::check_autoplay_append()) {
                         echo Ajax::button('?page=stream&action=directplay&object_type=' . $userflag['type'] . '&object_id=' . $userflag['id'] . '&append=true', 'play_add', T_('Play last'), 'addplay_' . $userflag['type'] . '_' . $userflag['id']);
                     }
                 }
                 echo Ajax::button('?action=basket&type=' . $userflag['type'] . '&id=' . $userflag['id'], 'add', T_('Add to temporary playlist'), 'play_full_' . $userflag['id']);
                 echo '</span>';
                 echo '</div>';
                 echo '<div style="float: right; opacity: 0.5;">' . T_('recommended by') . ' ' . $user->f_link . '</div>';
                 echo '</div><br />';
                 echo '<div style="margin-left: 30px;">';
                 echo '<div style="float: left; margin-right: 20px;">';
                 $thumb = UI::is_grid_view('album') ? 2 : 11;
                 $item->display_art($thumb);
                 echo '</div>';
                 echo '<div style="white-space: normal;">' . $item->get_description() . '</div>';
                 echo '</div>';
                 echo '</td></tr>';
                 $i++;
             }
         }
         echo '</table></div>';
     }
 }
示例#2
0
 public static function stats($input)
 {
     $type = $input['type'];
     $offset = $input['offset'];
     $limit = $input['limit'];
     if ($type == "newest") {
         $albums = Stats::get_newest("album", $limit, $offset);
     } else {
         if ($type == "highest") {
             $albums = Rating::get_highest("album", $limit, $offset);
         } else {
             if ($type == "frequent") {
                 $albums = Stats::get_top("album", $limit, '', $offset);
             } else {
                 if ($type == "recent") {
                     $albums = Stats::get_recent("album", $limit, $offset);
                 } else {
                     if ($type == "flagged") {
                         $albums = Userflag::get_latest('album');
                     } else {
                         if (!$limit) {
                             $limit = AmpConfig::get('popular_threshold');
                         }
                         $albums = Album::get_random($limit);
                     }
                 }
             }
         }
     }
     ob_end_clean();
     echo XML_Data::albums($albums);
 }
示例#3
0
 /**
  * getStarred
  * Get starred songs, albums and artists.
  * Takes no parameter.
  * Not supported.
  */
 public static function getstarred($input, $elementName = "starred")
 {
     self::check_version($input, "1.7.0");
     $r = Subsonic_XML_Data::createSuccessResponse();
     Subsonic_XML_Data::addStarred($r, Userflag::get_latest('artist', null, 99999), Userflag::get_latest('album', null, 99999), Userflag::get_latest('song', null, 99999), $elementName);
     self::apiOutput($input, $r);
 }
示例#4
0
 /**
  * This get library stats.
  * @param array $input
  */
 public static function stats($input)
 {
     $type = $input['type'];
     $offset = $input['offset'];
     $limit = $input['limit'];
     $username = $input['username'];
     $albums = null;
     if ($type == "newest") {
         $albums = Stats::get_newest("album", $limit, $offset);
     } else {
         if ($type == "highest") {
             $albums = Rating::get_highest("album", $limit, $offset);
         } else {
             if ($type == "frequent") {
                 $albums = Stats::get_top("album", $limit, '', $offset);
             } else {
                 if ($type == "recent") {
                     if (!empty($username)) {
                         $user = User::get_from_username($username);
                         if ($user !== null) {
                             $albums = $user->get_recently_played($limit, 'album');
                         } else {
                             debug_event('api', 'User `' . $username . '` cannot be found.', 1);
                         }
                     } else {
                         $albums = Stats::get_recent("album", $limit, $offset);
                     }
                 } else {
                     if ($type == "flagged") {
                         $albums = Userflag::get_latest('album');
                     } else {
                         if (!$limit) {
                             $limit = AmpConfig::get('popular_threshold');
                         }
                         $albums = Album::get_random($limit);
                     }
                 }
             }
         }
     }
     if ($albums !== null) {
         ob_end_clean();
         echo XML_Data::albums($albums);
     }
 }