本文整理汇总了PHP中Art::get_db方法的典型用法代码示例。如果您正苦于以下问题:PHP Art::get_db方法的具体用法?PHP Art::get_db怎么用?PHP Art::get_db使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Art
的用法示例。
在下文中一共展示了Art::get_db方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getcoverart
/**
* getCoverArt
* Get a cover art image.
* Takes the cover art id in parameter.
*/
public static function getcoverart($input)
{
self::check_version($input, "1.0.0", true);
$id = self::check_parameter($input, 'id', true);
$size = $input['size'];
$art = null;
if (Subsonic_XML_Data::isArtist($id)) {
$art = new Art(Subsonic_XML_Data::getAmpacheId($id), "artist");
} elseif (Subsonic_XML_Data::isAlbum($id)) {
$art = new Art(Subsonic_XML_Data::getAmpacheId($id), "album");
} elseif (Subsonic_XML_Data::isSong($id)) {
$art = new Art(Subsonic_XML_Data::getAmpacheId($id), "song");
if ($art != null && $art->id == null) {
// in most cases the song doesn't have a picture, but the album where it belongs to has
// if this is the case, we take the album art
$song = new Song(Subsonic_XML_Data::getAmpacheId(Subsonic_XML_Data::getAmpacheId($id)));
$art = new Art(Subsonic_XML_Data::getAmpacheId($song->album), "album");
}
} elseif (Subsonic_XML_Data::isPodcast($id)) {
$art = new Art(Subsonic_XML_Data::getAmpacheId($id), "podcast");
}
header("Access-Control-Allow-Origin: *");
if ($art != null) {
$art->get_db();
if ($size && AmpConfig::get('resize_images')) {
$dim = array();
$dim['width'] = $size;
$dim['height'] = $size;
$thumb = $art->get_thumb($dim);
if ($thumb) {
header('Content-type: ' . $thumb['thumb_mime']);
header('Content-Length: ' . strlen($thumb['thumb']));
echo $thumb['thumb'];
return;
}
}
header('Content-type: ' . $art->raw_mime);
header('Content-Length: ' . strlen($art->raw));
echo $art->raw;
}
}
示例2: get_avatar
/**
* get_avatar
* Get the user avatar
*/
public function get_avatar($local = false)
{
$avatar = array();
$avatar['title'] = T_('User avatar');
$upavatar = new Art($this->id, 'user');
if ($upavatar->get_db()) {
$avatar['url'] = ($local ? AmpConfig::get('local_web_path') : AmpConfig::get('web_path')) . '/image.php?object_type=user&object_id=' . $this->id;
$avatar['url_mini'] = $avatar['url'];
$avatar['url_medium'] = $avatar['url'];
$avatar['url'] .= '&thumb=4';
$avatar['url_mini'] .= '&thumb=5';
$avatar['url_medium'] .= '&thumb=3';
} else {
foreach (Plugin::get_plugins('get_avatar_url') as $plugin_name) {
$plugin = new Plugin($plugin_name);
if ($plugin->load($GLOBALS['user'])) {
$avatar['url'] = $plugin->_plugin->get_avatar_url($this);
if (!empty($avatar['url'])) {
$avatar['url_mini'] = $plugin->_plugin->get_avatar_url($this, 32);
$avatar['url_medium'] = $plugin->_plugin->get_avatar_url($this, 64);
$avatar['title'] .= ' (' . $plugin->_plugin->name . ')';
break;
}
}
}
}
return $avatar;
}
示例3: Art
break;
case 'session':
// If we need to pull the data out of the session
Session::check();
$filename = scrub_in($_REQUEST['image_index']);
$image = Art::get_from_source($_SESSION['form']['images'][$filename], 'album');
$mime = $_SESSION['form']['images'][$filename]['mime'];
$typeManaged = true;
break;
}
}
if (!$typeManaged) {
$item = new $type($_GET['object_id']);
$filename = $item->name ?: $item->title;
$art = new Art($item->id, $type, $kind);
$art->get_db();
$etag = $art->id;
// That means the client has a cached version of the image
$reqheaders = getallheaders();
if (isset($reqheaders['If-Modified-Since']) && isset($reqheaders['If-None-Match'])) {
$ccontrol = $reqheaders['Cache-Control'];
if ($ccontrol != 'no-cache') {
$cetagf = explode('-', $reqheaders['If-None-Match']);
$cetag = $cetagf[0];
// Same image than the cached one? Use the cache.
if ($cetag == $etag) {
header('HTTP/1.1 304 Not Modified');
exit;
}
}
}
示例4: display
/**
* Display an item art.
* @param string $object_type
* @param int $object_id
* @param string $name
* @param int $thumb
* @param string $link
* @param boolean $show_default
* @param string $kind
* @return boolean
*/
public static function display($object_type, $object_id, $name, $thumb, $link = null, $show_default = true, $kind = 'default')
{
if (!self::is_valid_type($object_type)) {
return false;
}
if (!$show_default) {
// Don't show any image if not available
if (!self::has_db($object_id, $object_type, $kind)) {
return false;
}
}
$size = self::get_thumb_size($thumb);
$prettyPhoto = $link == null;
if ($link == null) {
$link = AmpConfig::get('web_path') . "/image.php?object_id=" . $object_id . "&object_type=" . $object_type;
if (AmpConfig::get('use_auth') && AmpConfig::get('require_session')) {
$link .= "&auth=" . session_id();
}
if ($kind != 'default') {
$link .= '&kind=' . $kind;
}
}
echo "<div class=\"item_art\">";
echo "<a href=\"" . $link . "\" title=\"" . $name . "\"";
if ($prettyPhoto) {
echo " rel=\"prettyPhoto\"";
}
echo ">";
$imgurl = AmpConfig::get('web_path') . "/image.php?object_id=" . $object_id . "&object_type=" . $object_type . "&thumb=" . $thumb;
if ($kind != 'default') {
$imgurl .= '&kind=' . $kind;
}
// This to keep browser cache feature but force a refresh in case image just changed
if (Art::has_db($object_id, $object_type)) {
$art = new Art($object_id, $object_type);
if ($art->get_db()) {
$imgurl .= '&fooid=' . $art->id;
}
}
echo "<img src=\"" . $imgurl . "\" alt=\"" . $name . "\" height=\"" . $size['height'] . "\" width=\"" . $size['width'] . "\" />";
if ($size['height'] > 150) {
echo "<div class=\"item_art_play\">";
echo Ajax::text('?page=stream&action=directplay&object_type=' . $object_type . '&object_id=' . $object_id . '\' + getPagePlaySettings() + \'', '<span class="item_art_play_icon" title="' . T_('Play') . '" />', 'directplay_art_' . $object_type . '_' . $object_id);
echo "</div>";
}
if ($prettyPhoto) {
$libitem = new $object_type($object_id);
echo "<div class=\"item_art_actions\">";
if ($GLOBALS['user']->has_access(50) || $GLOBALS['user']->has_access(25) && $GLOBALS['user']->id == $libitem->get_user_owner()) {
echo "<a href=\"javascript:NavigateTo('" . AmpConfig::get('web_path') . "/arts.php?action=find_art&object_type=" . $object_type . "&object_id=" . $object_id . "&burl=' + getCurrentPage());\">";
echo UI::get_icon('edit', T_('Edit/Find Art'));
echo "</a>";
echo "<a href=\"javascript:NavigateTo('" . AmpConfig::get('web_path') . "/arts.php?action=clear_art&object_type=" . $object_type . "&object_id=" . $object_id . "&burl=' + getCurrentPage());\" onclick=\"return confirm('" . T_('Do you really want to reset art?') . "');\">";
echo UI::get_icon('delete', T_('Reset Art'));
echo "</a>";
}
echo "</div>";
}
echo "</a>\n";
echo "</div>";
return true;
}
示例5: library_metadata
//.........这里部分代码省略.........
$litem->format();
Plex_XML_Data::setArtistRoot($r, $litem);
} else {
if (Plex_XML_Data::isAlbum($key)) {
$litem = new Album($id);
$litem->format();
Plex_XML_Data::setAlbumRoot($r, $litem);
} else {
if (Plex_XML_Data::isTVShow($key)) {
$litem = new TVShow($id);
$litem->format();
Plex_XML_Data::setTVShowRoot($r, $litem);
} else {
if (Plex_XML_Data::isTVShowSeason($key)) {
$litem = new TVShow_Season($id);
$litem->format();
Plex_XML_Data::setTVShowSeasonRoot($r, $litem);
}
}
}
}
} elseif ($subact == "thumbs" || $subact == "posters" || $subact == "arts" || $subact == 'backgrounds') {
$kind = Plex_XML_Data::getPhotoKind($subact);
if ($createMode) {
// Upload art
$litem = Plex_XML_Data::createLibraryItem($key);
if ($litem != null) {
$uri = Plex_XML_Data::getMetadataUri($key) . '/' . Plex_XML_Data::getPhotoPlexKind($kind) . '/' . $key;
if (is_a($litem, 'video')) {
$type = 'video';
} else {
$type = get_class($litem);
}
$art = new Art($litem->id, $type, $kind);
$raw = file_get_contents("php://input");
$art->insert($raw);
header('Content-Type: text/html');
echo $uri;
exit;
}
}
Plex_XML_Data::addPhotos($r, $key, $kind);
} elseif ($subact == "thumb" || $subact == "poster" || $subact == "art" || $subact == "background") {
if ($n == 3) {
$kind = Plex_XML_Data::getPhotoKind($subact);
// Ignore art id as we can only have 1 thumb
$art = null;
if (Plex_XML_Data::isArtist($key)) {
$art = new Art($id, "artist", $kind);
} else {
if (Plex_XML_Data::isAlbum($key)) {
$art = new Art($id, "album", $kind);
} else {
if (Plex_XML_Data::isTrack($key)) {
$art = new Art($id, "song", $kind);
} else {
if (Plex_XML_Data::isTVShow($key)) {
$art = new Art($id, "tvshow", $kind);
} else {
if (Plex_XML_Data::isTVShowSeason($key)) {
$art = new Art($id, "tvshow_season", $kind);
} else {
if (Plex_XML_Data::isVideo($key)) {
$art = new Art($id, "video", $kind);
}
}
}
}
}
}
if ($art != null) {
$art->get_db();
ob_clean();
if (!isset($size)) {
self::setHeader($art->raw_mime);
echo $art->raw;
} else {
$dim = array();
$dim['width'] = $size;
$dim['height'] = $size;
$thumb = $art->get_thumb($dim);
self::setHeader($art->thumb_mime);
echo $thumb['thumb'];
}
exit;
}
}
}
}
}
if ($litem != null) {
$catalog_ids = $litem->get_catalogs();
if (count($catalog_ids) > 0) {
$catalog = Catalog::create_from_id($catalog_ids[0]);
Plex_XML_Data::addCatalogIdentity($r, $catalog);
}
}
Plex_XML_Data::setContainerSize($r);
self::apiOutputXml($r->asXML());
}
示例6: dump_album_art
/**
* dump_album_art
*
* This runs through all of the albums and tries to dump the
* art for them into the 'folder.jpg' file in the appropriate dir.
*/
public function dump_album_art($methods = array())
{
// Get all of the albums in this catalog
$albums = $this->get_album_ids();
echo "Starting Dump Album Art...\n";
$i = 0;
// Run through them and get the art!
foreach ($albums as $album_id) {
$album = new Album($album_id);
$art = new Art($album_id, 'album');
if (!$art->get_db()) {
continue;
}
// Get the first song in the album
$songs = $album->get_songs(1);
$song = new Song($songs[0]);
$dir = dirname($song->file);
$extension = Art::extension($art->raw_mime);
// Try the preferred filename, if that fails use folder.???
$preferred_filename = AmpConfig::get('album_art_preferred_filename');
if (!$preferred_filename || strpos($preferred_filename, '%') !== false) {
$preferred_filename = "folder.{$extension}";
}
$file = "{$dir}/{$preferred_filename}";
if ($file_handle = fopen($file, "w")) {
if (fwrite($file_handle, $art->raw)) {
// Also check and see if we should write
// out some metadata
if ($methods['metadata']) {
switch ($methods['metadata']) {
case 'windows':
$meta_file = $dir . '/desktop.ini';
$string = "[.ShellClassInfo]\nIconFile={$file}\nIconIndex=0\nInfoTip={$album->full_name}";
break;
case 'linux':
default:
$meta_file = $dir . '/.directory';
$string = "Name={$album->full_name}\nIcon={$file}";
break;
}
$meta_handle = fopen($meta_file, "w");
fwrite($meta_handle, $string);
fclose($meta_handle);
}
// end metadata
$i++;
if (!($i % 100)) {
echo "Written: {$i}. . .\n";
debug_event('art_write', "{$album->name} Art written to {$file}", '5');
}
} else {
debug_event('art_write', "Unable to open {$file} for writing", 5);
echo "Error: unable to open file for writing [{$file}]\n";
}
}
fclose($file_handle);
}
echo "Album Art Dump Complete\n";
}
示例7: getcoverart
/**
* getCoverArt
* Get a cover art image.
* Takes the cover art id in parameter.
*/
public static function getcoverart($input)
{
self::check_version($input, "1.0.0", true);
$id = self::check_parameter($input, 'id', true);
$size = $input['size'];
$art = null;
if (Subsonic_XML_Data::isArtist($id)) {
$art = new Art(Subsonic_XML_Data::getAmpacheId($id), "artist");
} else {
if (Subsonic_XML_Data::isAlbum($id)) {
$art = new Art(Subsonic_XML_Data::getAmpacheId($id), "album");
} else {
if (Subsonic_XML_Data::isSong($id)) {
$art = new Art(Subsonic_XML_Data::getAmpacheId($id), "song");
}
}
}
if ($art != null) {
$art->get_db();
if ($size) {
$dim = array();
$dim['width'] = $size;
$dim['height'] = $size;
$thumb = $art->get_thumb($dim);
if ($thumb) {
header('Content-type: ' . $thumb['thumb_mime']);
header('Content-Length: ' . strlen($thumb['thumb']));
echo $thumb['thumb'];
return;
}
}
header('Content-type: ' . $art->raw_mime);
header('Content-Length: ' . strlen($art->raw));
echo $art->raw;
}
}
示例8: addArtistThumb
protected static function addArtistThumb(SimpleXMLElement $xml, $artist_id, $attrthumb = 'thumb')
{
$id = self::getArtistId($artist_id);
$art = new Art($artist_id, 'artist');
$thumb = '';
if ($art->get_db()) {
$thumb = self::getMetadataUri($id) . '/thumb/' . $id;
}
$xml->addAttribute($attrthumb, $thumb);
}
示例9: _get_extra_info
/**
* _get_extra_info
* This pulls the extra information from our tables, this is a 3 table join, which is why we don't normally
* do it
*/
private function _get_extra_info()
{
if (parent::is_cached('album_extra', $this->id)) {
return parent::get_from_cache('album_extra', $this->id);
}
$sql = "SELECT " . "COUNT(DISTINCT(`song`.`artist`)) AS `artist_count`, " . "COUNT(`song`.`id`) AS `song_count`, " . "SUM(`song`.`time`) as `total_duration`," . "`song`.`catalog` as `catalog_id`," . "`artist`.`name` AS `artist_name`, " . "`artist`.`prefix` AS `artist_prefix`, " . "`artist`.`id` AS `artist_id` " . "FROM `song` INNER JOIN `artist` " . "ON `artist`.`id`=`song`.`artist` ";
if (AmpConfig::get('catalog_disable')) {
$sql .= "LEFT JOIN `catalog` ON `catalog`.`id` = `song`.`catalog` ";
}
$suite_array = array();
if ($this->allow_group_disks) {
$suite_array = $this->album_suite;
}
if (!count($suite_array)) {
$suite_array[] = $this->id;
}
$idlist = '(' . implode(',', $suite_array) . ')';
$sql .= "WHERE `song`.`album` IN {$idlist} ";
if (AmpConfig::get('catalog_disable')) {
$sql .= "AND `catalog`.`enabled` = '1' ";
}
if (!count($this->album_suite)) {
$sql .= "GROUP BY `song`.`album`";
} else {
$sql .= "GROUP BY `song`.`artist`";
}
$db_results = Dba::read($sql);
$results = Dba::fetch_assoc($db_results);
$art = new Art($this->id, 'album');
$art->get_db();
$results['has_art'] = make_bool($art->raw);
$results['has_thumb'] = make_bool($art->thumb);
if (AmpConfig::get('show_played_times')) {
$results['object_cnt'] = Stats::get_object_count('album', $this->id);
}
parent::add_to_cache('album_extra', $this->id, $results);
return $results;
}
示例10: library_metadata
public static function library_metadata($params)
{
$r = Plex_XML_Data::createLibContainer();
$n = count($params);
if ($n > 0) {
$key = $params[0];
$id = Plex_XML_Data::getAmpacheId($key);
if ($n == 1) {
// Should we check that files still exists here?
$checkFiles = $_REQUEST['checkFiles'];
if (Plex_XML_Data::isArtist($key)) {
$artist = new Artist($id);
$artist->format();
Plex_XML_Data::addArtist($r, $artist);
} elseif (Plex_XML_Data::isAlbum($key)) {
$album = new Album($id);
$album->format();
Plex_XML_Data::addAlbum($r, $album);
} elseif (Plex_XML_Data::isTrack($key)) {
$song = new Song($id);
$song->format();
Plex_XML_Data::addSong($r, $song);
}
} else {
$subact = $params[1];
if ($subact == "children") {
if (Plex_XML_Data::isArtist($key)) {
$artist = new Artist($id);
$artist->format();
Plex_XML_Data::setArtistRoot($r, $artist);
} else {
if (Plex_XML_Data::isAlbum($key)) {
$album = new Album($id);
$album->format();
Plex_XML_Data::setAlbumRoot($r, $album);
}
}
} elseif ($subact == "thumb") {
if ($n == 3) {
// Ignore thumb id as we can only have 1 thumb
$art = null;
if (Plex_XML_Data::isArtist($key)) {
$art = new Art($id, "artist");
} else {
if (Plex_XML_Data::isAlbum($key)) {
$art = new Art($id, "album");
} else {
if (Plex_XML_Data::isTrack($key)) {
$art = new Art($id, "song");
}
}
}
if ($art != null) {
$art->get_db();
if (!isset($size)) {
self::setHeader($art->raw_mime);
echo $art->raw;
} else {
$dim = array();
$dim['width'] = $size;
$dim['height'] = $size;
$thumb = $art->get_thumb($dim);
self::setHeader($art->thumb_mime);
echo $thumb['thumb'];
}
exit;
}
}
}
}
}
Plex_XML_Data::setContainerSize($r);
self::apiOutput($r->asXML());
}