本文整理汇总了PHP中Random::get_default方法的典型用法代码示例。如果您正苦于以下问题:PHP Random::get_default方法的具体用法?PHP Random::get_default怎么用?PHP Random::get_default使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Random
的用法示例。
在下文中一共展示了Random::get_default方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
/**
* Sub-Ajax page, requires AJAX_INCLUDE
*/
if (!defined('AJAX_INCLUDE')) {
exit;
}
$results = array();
switch ($_REQUEST['action']) {
case 'song':
$songs = Random::get_default();
if (!count($songs)) {
$results['rfc3514'] = '0x1';
break;
}
foreach ($songs as $song_id) {
$GLOBALS['user']->playlist->add_object($song_id, 'song');
}
$results['rightbar'] = UI::ajax_include('rightbar.inc.php');
break;
case 'album':
$album_id = Album::get_random();
if (!$album_id) {
$results['rfc3514'] = '0x1';
break;
}
示例2: 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);
}