Пример #1
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);
 }
Пример #2
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);
     }
 }