本文整理汇总了PHP中Rating::build_cache方法的典型用法代码示例。如果您正苦于以下问题:PHP Rating::build_cache方法的具体用法?PHP Rating::build_cache怎么用?PHP Rating::build_cache使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rating
的用法示例。
在下文中一共展示了Rating::build_cache方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: T_
<th class="cel_album essential"><?php
echo Ajax::text('?page=browse&action=set_sort&browse_id=' . $browse->id . '&sort=album', T_('Album'), 'sort_song_album' . $browse->id);
?>
</th>
<th class="cel_tags optional"><?php
echo T_('Tags');
?>
</th>
<th class="cel_time optional"><?php
echo Ajax::text('?page=browse&action=set_sort&browse_id=' . $browse->id . '&sort=time', T_('Time'), 'sort_song_time' . $browse->id);
?>
</th>
<?php
if (AmpConfig::get('ratings')) {
++$thcount;
Rating::build_cache('song', $object_ids);
?>
<th class="cel_rating optional"><?php
echo T_('Rating');
?>
</th>
<?php
}
?>
<?php
if (AmpConfig::get('userflags')) {
++$thcount;
Userflag::build_cache('song', $object_ids);
?>
<th class="cel_userflag optional"><?php
echo T_('Fav.');
示例2: T_
<?php
}
?>
<?php
}
?>
<th class="cel_action essential"><?php
echo T_('Actions');
?>
</th>
</tr>
</thead>
<tbody>
<?php
if (AmpConfig::get('ratings')) {
Rating::build_cache('podcast', $object_ids);
}
if (AmpConfig::get('userflags')) {
Userflag::build_cache('podcast', $object_ids);
}
foreach ($object_ids as $podcast_id) {
$libitem = new Podcast($podcast_id);
$libitem->format();
?>
<tr id="podcast_<?php
echo $libitem->id;
?>
" class="<?php
echo UI::flip_class();
?>
">
示例3: T_
}
?>
<?php
}
?>
<th class="cel_action essential"><?php
echo T_('Action');
?>
</th>
</tr>
</thead>
<tbody>
<?php
// Cache the ratings we are going to use
if (AmpConfig::get('ratings')) {
Rating::build_cache('tvshow', $object_ids);
}
if (AmpConfig::get('userflags')) {
Userflag::build_cache('tvshow', $object_ids);
}
/* Foreach through every tv show that has been passed to us */
foreach ($object_ids as $tvshow_id) {
$libitem = new TVShow($tvshow_id);
$libitem->format();
?>
<tr id="tvshow_<?php
echo $libitem->id;
?>
" class="<?php
echo UI::flip_class();
?>
示例4: T_
?>
</th>
<th class="cel_tags optional"><?php
echo T_('Tags');
?>
</th>
<th class="cel_time optional"><?php
echo T_('Time');
?>
</th>
<?php
if (User::is_registered()) {
?>
<?php
if (AmpConfig::get('ratings')) {
Rating::build_cache('song', array_map(create_function('$i', '$i=(array) $i; return $i[\'object_id\'];'), $object_ids));
?>
<th class="cel_rating"><?php
echo T_('Rating');
?>
</th>
<?php
}
?>
<?php
if (AmpConfig::get('userflags')) {
Userflag::build_cache('song', array_map(create_function('$i', '$i=(array) $i; return $i[\'object_id\'];'), $object_ids));
?>
<?php
}
?>
示例5: T_
?>
</th>
<?php
}
?>
<th class="cel_action essential"><?php
echo T_('Action');
?>
</th>
</tr>
</thead>
<tbody>
<?php
// Cache the ratings we are going to use
if (AmpConfig::get('ratings')) {
Rating::build_cache('artist', $object_ids);
}
if (AmpConfig::get('userflags')) {
Userflag::build_cache('artist', $object_ids);
}
/* Foreach through every artist that has been passed to us */
foreach ($object_ids as $artist_id) {
$artist = new Artist($artist_id, $_SESSION['catalog']);
$artist->format();
?>
<tr id="artist_<?php
echo $artist->id;
?>
" class="<?php
echo UI::flip_class();
?>
示例6: T_
echo T_('Fav.');
?>
</th>
<?php
}
?>
<th class="cel_action essential"><?php
echo T_('Actions');
?>
</th>
</tr>
</thead>
<tbody>
<?php
if (AmpConfig::get('ratings')) {
Rating::build_cache('album', $object_ids);
}
if (AmpConfig::get('userflags')) {
Userflag::build_cache('album', $object_ids);
}
/* Foreach through the albums */
foreach ($object_ids as $album_id) {
$album = new Album($album_id);
$album->allow_group_disks = $allow_group_disks;
$album->format();
?>
<tr id="album_<?php
echo $album->id;
?>
" class="<?php
echo UI::flip_class();
示例7: albums
/**
* albums
*
* This echos out a standard albums XML document, it pays attention to the limit
*
* @param array $albums (description here...)
* @return string return xml
*/
public static function albums($albums)
{
if (count($albums) > self::$limit or self::$offset > 0) {
$albums = array_splice($albums, self::$offset, self::$limit);
}
Rating::build_cache('album', $albums);
$string = "";
foreach ($albums as $album_id) {
$album = new Album($album_id);
$album->format();
$rating = new Rating($album_id, 'album');
// Build the Art URL, include session
$art_url = AmpConfig::get('web_path') . '/image.php?object_id=' . $album->id . '&object_type=album&auth=' . scrub_out($_REQUEST['auth']);
$string .= "<album id=\"" . $album->id . "\">\n" . "\t<name><![CDATA[" . $album->name . "]]></name>\n";
// Do a little check for artist stuff
if ($album->artist_count != 1) {
$string .= "\t<artist id=\"0\"><![CDATA[Various]]></artist>\n";
} else {
$string .= "\t<artist id=\"{$album->artist_id}\"><![CDATA[{$album->artist_name}]]></artist>\n";
}
$string .= "\t<year>" . $album->year . "</year>\n" . "\t<tracks>" . $album->song_count . "</tracks>\n" . "\t<disk>" . $album->disk . "</disk>\n" . self::tags_string($album->tags) . "\t<art><![CDATA[{$art_url}]]></art>\n" . "\t<preciserating>" . $rating->get_user_rating() . "</preciserating>\n" . "\t<rating>" . $rating->get_user_rating() . "</rating>\n" . "\t<averagerating>" . $rating->get_average_rating() . "</averagerating>\n" . "\t<mbid>" . $album->mbid . "</mbid>\n" . "</album>\n";
}
// end foreach
$final = self::_header() . $string . self::_footer();
return $final;
}
示例8: T_
<?php
}
?>
<?php
}
?>
<th class="cel_action essential"><?php
echo T_('Actions');
?>
</th>
</tr>
</thead>
<tbody>
<?php
if (AmpConfig::get('ratings')) {
Rating::build_cache('podcast_episode', $object_ids);
}
if (AmpConfig::get('userflags')) {
Userflag::build_cache('podcast_episode', $object_ids);
}
foreach ($object_ids as $episode_id) {
$libitem = new Podcast_Episode($episode_id);
$libitem->format();
?>
<tr id="podcast_episode_<?php
echo $libitem->id;
?>
" class="<?php
echo UI::flip_class();
?>
">
示例9: build_cache
/**
* build_cache
*
* This attempts to reduce queries by asking for everything in the
* browse all at once and storing it in the cache, this can help if the
* db connection is the slow point.
* @param int[] $song_ids
* @return boolean
*/
public static function build_cache($song_ids, $limit_threshold = '')
{
if (!is_array($song_ids) || !count($song_ids)) {
return false;
}
$idlist = '(' . implode(',', $song_ids) . ')';
// Callers might have passed array(false) because they are dumb
if ($idlist == '()') {
return false;
}
// Song data cache
$sql = 'SELECT `song`.`id`, `file`, `catalog`, `album`, ' . '`year`, `artist`, `title`, `bitrate`, `rate`, ' . '`mode`, `size`, `time`, `track`, `played`, ' . '`song`.`enabled`, `update_time`, `tag_map`.`tag_id`, ' . '`mbid`, `addition_time`, `license`, `composer`, `user_upload` ' . 'FROM `song` LEFT JOIN `tag_map` ' . 'ON `tag_map`.`object_id`=`song`.`id` ' . "AND `tag_map`.`object_type`='song' ";
if (AmpConfig::get('catalog_disable')) {
$sql .= "LEFT JOIN `catalog` ON `catalog`.`id` = `song`.`catalog` ";
}
$sql .= "WHERE `song`.`id` IN {$idlist} ";
if (AmpConfig::get('catalog_disable')) {
$sql .= "AND `catalog`.`enabled` = '1' ";
}
$db_results = Dba::read($sql);
$artists = array();
$albums = array();
$tags = array();
while ($row = Dba::fetch_assoc($db_results)) {
if (AmpConfig::get('show_played_times')) {
$row['object_cnt'] = Stats::get_object_count('song', $row['id'], $limit_threshold);
}
parent::add_to_cache('song', $row['id'], $row);
$artists[$row['artist']] = $row['artist'];
$albums[$row['album']] = $row['album'];
if ($row['tag_id']) {
$tags[$row['tag_id']] = $row['tag_id'];
}
}
Artist::build_cache($artists);
Album::build_cache($albums);
Tag::build_cache($tags);
Tag::build_map_cache('song', $song_ids);
Art::build_cache($albums);
// If we're rating this then cache them as well
if (AmpConfig::get('ratings')) {
Rating::build_cache('song', $song_ids);
}
if (AmpConfig::get('userflags')) {
Userflag::build_cache('song', $song_ids);
}
// Build a cache for the song's extended table
$sql = "SELECT * FROM `song_data` WHERE `song_id` IN {$idlist}";
$db_results = Dba::read($sql);
while ($row = Dba::fetch_assoc($db_results)) {
parent::add_to_cache('song_data', $row['song_id'], $row);
}
return true;
}