当前位置: 首页>>代码示例>>PHP>>正文


PHP Random::advanced方法代码示例

本文整理汇总了PHP中Random::advanced方法的典型用法代码示例。如果您正苦于以下问题:PHP Random::advanced方法的具体用法?PHP Random::advanced怎么用?PHP Random::advanced使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Random的用法示例。


在下文中一共展示了Random::advanced方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getrandomsongs

 /**
  * getRandomSongs
  * Get random songs matching the given criteria.
  * Takes the optional size, genre, fromYear, toYear and music folder id in parameters.
  */
 public static function getrandomsongs($input)
 {
     self::check_version($input, "1.2.0");
     $size = $input['size'];
     if (!$size) {
         $size = 10;
     }
     $genre = $input['genre'];
     $fromYear = $input['fromYear'];
     $toYear = $input['toYear'];
     $musicFolderId = $input['musicFolderId'];
     $search = array();
     $search['limit'] = $size;
     $search['random'] = $size;
     $search['type'] = "song";
     $i = 0;
     if ($genre) {
         $search['rule_' . $i . '_input'] = $genre;
         $search['rule_' . $i . '_operator'] = 0;
         $search['rule_' . $i . ''] = "tag";
         ++$i;
     }
     if ($fromYear) {
         $search['rule_' . $i . '_input'] = $fromYear;
         $search['rule_' . $i . '_operator'] = 0;
         $search['rule_' . $i . ''] = "year";
         ++$i;
     }
     if ($toYear) {
         $search['rule_' . $i . '_input'] = $toYear;
         $search['rule_' . $i . '_operator'] = 1;
         $search['rule_' . $i . ''] = "year";
         ++$i;
     }
     if ($musicFolderId) {
         if (Subsonic_XML_Data::isArtist($musicFolderId)) {
             $artist = new Artist(Subsonic_XML_Data::getAmpacheId($musicFolderId));
             $finput = $artist->name;
             $operator = 4;
             $ftype = "artist";
         } else {
             if (Subsonic_XML_Data::isAlbum($musicFolderId)) {
                 $album = new Album(Subsonic_XML_Data::getAmpacheId($musicFolderId));
                 $finput = $album->name;
                 $operator = 4;
                 $ftype = "artist";
             } else {
                 $finput = intval($musicFolderId);
                 $operator = 0;
                 $ftype = "catalog";
             }
         }
         $search['rule_' . $i . '_input'] = $finput;
         $search['rule_' . $i . '_operator'] = $operator;
         $search['rule_' . $i . ''] = $ftype;
         ++$i;
     }
     if ($i > 0) {
         $songs = Random::advanced("song", $search);
     } else {
         $songs = Random::get_default($size);
     }
     $r = Subsonic_XML_Data::createSuccessResponse();
     Subsonic_XML_Data::addRandomSongs($r, $songs);
     self::apiOutput($input, $r);
 }
开发者ID:bl00m,项目名称:ampache,代码行数:71,代码来源:subsonic_api.class.php

示例2: Playlist

     break;
 case 'playlist':
     $playlist_id = Random::playlist();
     if (!$playlist_id) {
         $results['rfc3514'] = '0x1';
         break;
     }
     $playlist = new Playlist($playlist_id);
     $items = $playlist->get_items();
     foreach ($items as $item) {
         $GLOBALS['user']->playlist->add_object($item['object_id'], $item['object_type']);
     }
     $results['rightbar'] = UI::ajax_include('rightbar.inc.php');
     break;
 case 'advanced_random':
     $object_ids = Random::advanced('song', $_POST);
     // First add them to the active playlist
     if (is_array($object_ids)) {
         foreach ($object_ids as $object_id) {
             $GLOBALS['user']->playlist->add_object($object_id, 'song');
         }
     }
     $results['rightbar'] = UI::ajax_include('rightbar.inc.php');
     // Now setup the browse and show them below!
     $browse = new Browse();
     $browse->set_type('song');
     $browse->save_objects($object_ids);
     ob_start();
     $browse->show_objects();
     $results['browse'] = ob_get_contents();
     ob_end_clean();
开发者ID:cheese1,项目名称:ampache,代码行数:31,代码来源:random.ajax.php

示例3: switch

 * modify it under the terms of the GNU General Public License v2
 * as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 */
require_once 'lib/init.php';
UI::show_header();
switch ($_REQUEST['action']) {
    case 'get_advanced':
        $object_ids = Random::advanced($_REQUEST['type'], $_POST);
        // We need to add them to the active playlist
        if (is_array($object_ids)) {
            foreach ($object_ids as $object_id) {
                $GLOBALS['user']->playlist->add_object($object_id, 'song');
            }
        }
    case 'advanced':
    default:
        require_once AmpConfig::get('prefix') . '/templates/show_random.inc.php';
        break;
}
// end switch
UI::show_footer();
开发者ID:nioc,项目名称:ampache,代码行数:31,代码来源:random.php


注:本文中的Random::advanced方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。