1
0
Fork 0
mirror of https://github.com/Yetangitu/ampache synced 2025-10-04 02:09:23 +02:00

Fix code style

This commit is contained in:
Afterster 2013-11-25 01:56:46 +01:00
parent 3eea65ad1d
commit 3d13df9e0c
9 changed files with 89 additions and 89 deletions

View file

@ -396,7 +396,7 @@ class Album extends database_object
$mbid = $data['mbid'];
$current_id = $this->id;
if ($artist != $this->artist_id AND $artist) {
// Update every song
$songs = $this->get_songs();

View file

@ -20,7 +20,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
require_once Config::get('prefix') . '/modules/plugins/helper.php';
/**
@ -45,9 +45,9 @@ class Plex_Api
header("HTTP/1.0 200 OK", true, 200);
header("Connection: close", true);
header("X-Plex-Protocol: 1.0");
header_remove("x-powered-by");
if (strtolower($f) == "xml") {
header("Cache-Control: no-cache", true);
header("Content-type: text/xml; charset=" . Config::get('site_charset'), true);
@ -58,33 +58,32 @@ class Plex_Api
header("Content-type: " . $f, true);
}
}
public static function apiOutput($string)
{
ob_start('ob_gzhandler');
echo $string;
ob_start('ob_gzhandler');
echo $string;
ob_end_flush();
header("X-Plex-Compressed-Content-Length: " . ob_get_length());
header("X-Plex-Original-Content-Length: " . strlen($string));
}
public static function createError($code)
{
$error = "";
switch ($code)
{
switch ($code) {
case 404:
$error = "Not Found";
break;
}
header("Content-type: text/html", true);
header("HTTP/1.0 ". $code . " " . $error, true, $code);
$html = "<html><head><title>" . $error . "</title></head><body><h1>" . $code . " " . $error . "</h1></body></html>";
self::apiOutput($html);
exit();
}
public static function root()
{
$r = Plex_XML_Data::createContainer();
@ -92,7 +91,7 @@ class Plex_Api
Plex_XML_Data::setContainerSize($r);
self::apiOutput($r->asXML());
}
public static function library($params)
{
$r = Plex_XML_Data::createLibContainer();
@ -100,7 +99,7 @@ class Plex_Api
Plex_XML_Data::setContainerSize($r);
self::apiOutput($r->asXML());
}
public static function system($params)
{
$r = Plex_XML_Data::createSysContainer();
@ -108,37 +107,37 @@ class Plex_Api
Plex_XML_Data::setContainerSize($r);
self::apiOutput($r->asXML());
}
public static function clients($params)
{
$r = Plex_XML_Data::createContainer();
Plex_XML_Data::setContainerSize($r);
self::apiOutput($r->asXML());
}
public static function channels($params)
{
$r = Plex_XML_Data::createContainer();
Plex_XML_Data::setContainerSize($r);
self::apiOutput($r->asXML());
}
public static function photos($params)
{
$r = Plex_XML_Data::createPluginContainer();
Plex_XML_Data::setContainerSize($r);
self::apiOutput($r->asXML());
}
public static function photo($params)
{
if (count($params) == 2) {
if ($params[0] == ':' && $params[1] == 'transcode') {
$width = $_REQUEST['width'];
$height = $_REQUEST['height'];
$url = $_REQUEST['url'];
if ($width && $height && $url) {
$response = PluginHelper::wsGet($url);
if ($response['status'] == 200) {
@ -154,28 +153,28 @@ class Plex_Api
}
}
}
public static function music($params)
{
$r = Plex_XML_Data::createPluginContainer();
Plex_XML_Data::setContainerSize($r);
self::apiOutput($r->asXML());
}
public static function video($params)
{
$r = Plex_XML_Data::createPluginContainer();
Plex_XML_Data::setContainerSize($r);
self::apiOutput($r->asXML());
}
public static function applications($params)
{
$r = Plex_XML_Data::createPluginContainer();
Plex_XML_Data::setContainerSize($r);
self::apiOutput($r->asXML());
}
public static function library_sections($params)
{
$r = Plex_XML_Data::createLibContainer();
@ -199,20 +198,20 @@ class Plex_Api
}
}
}
Plex_XML_Data::setContainerSize($r);
self::apiOutput($r->asXML());
}
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) {
if (Plex_XML_Data::isArtist($key)) {
$artist = new Artist($id);
@ -225,7 +224,7 @@ class Plex_Api
}
} else {
$subact = $params[1];
if($subact == "children") {
if ($subact == "children") {
if (Plex_XML_Data::isArtist($key)) {
$artist = new Artist($id);
$artist->format();
@ -253,7 +252,7 @@ class Plex_Api
if ($art != null) {
$art->get_db();
if (!$size) {
self::setHeader($art->raw_mime);
echo $art->raw;
@ -274,15 +273,15 @@ class Plex_Api
Plex_XML_Data::setContainerSize($r);
self::apiOutput($r->asXML());
}
public static function library_parts($params)
{
$n = count($params);
if ($n == 2) {
$key = $params[0];
$file = $params[1];
$id = Plex_XML_Data::getAmpacheId($key);
$song = new Song($id);
if ($song->id) {

View file

@ -60,12 +60,12 @@ class Plex_XML_Data
{
return $id + Plex_XML_Data::AMPACHEID_TRACK;
}
public static function getMediaId($id)
{
return $id + Plex_XML_Data::AMPACHEID_MEDIA;
}
public static function getPartId($id)
{
return $id + Plex_XML_Data::AMPACHEID_PART;
@ -99,12 +99,12 @@ class Plex_XML_Data
{
return ($id >= Plex_XML_Data::AMPACHEID_TRACK && $id < Plex_XML_Data::AMPACHEID_MEDIA);
}
public static function isMedia($id)
{
return ($id >= Plex_XML_Data::AMPACHEID_MEDIA && $id < Plex_XML_Data::AMPACHEID_PART);
}
public static function isPart($id)
{
return ($id >= Plex_XML_Data::AMPACHEID_PART);
@ -123,7 +123,7 @@ class Plex_XML_Data
$response->addAttribute('status', 'ok');
return $response;
}
public static function createContainer()
{
$response = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><MediaContainer/>');
@ -138,14 +138,14 @@ class Plex_XML_Data
$response->addAttribute('mediaTagVersion', '1365384731');
return $response;
}
public static function createPluginContainer()
{
$response = self::createContainer();
$response->addAttribute('content', 'plugins');
return $response;
}
public static function createSysContainer()
{
$response = self::createContainer();
@ -159,32 +159,32 @@ class Plex_XML_Data
{
$container->addAttribute('size', $container->count());
}
public static function setContainerTitle($container, $title)
{
$container->addAttribute('title1', $title);
}
public static function getResourceUri($resource)
{
return '/resources/' . $resource;
}
public static function getMetadataUri($key)
{
return '/library/metadata/' . $key;
}
public static function getPartUri($key, $type)
{
return '/library/parts/' . $key . '/file.' . $type;
}
public static function uuidFromKey($key)
{
return hash('sha1', $key);
}
public static function setRootContent($xml, $catalogs)
{
$xml->addAttribute('friendlyName', 'Ampache');
@ -199,7 +199,7 @@ class Plex_XML_Data
$xml->addAttribute('transcoderVideo', '0');
$xml->addAttribute('updatedAt', self::getLastUpdate($catalogs));
$xml->addAttribute('version', '0.9.8.10.215-020456b');
$dir = $xml->addChild('Directory');
$dir->addAttribute('count', '1');
$dir->addAttribute('key', 'channels');
@ -237,7 +237,7 @@ class Plex_XML_Data
$dir->addAttribute('key', 'transcode');
$dir->addAttribute('title', 'transcode');
}
public static function getLastUpdate($catalogs)
{
$last_update = 0;
@ -253,12 +253,12 @@ class Plex_XML_Data
$last_update = $catalog->last_clean;
}
}
return $last_update;
}
public static function setSections($xml, $catalogs)
{
{
foreach ($catalogs as $id) {
$catalog = Catalog::create_from_id($id);
$catalog->format();
@ -274,16 +274,16 @@ class Plex_XML_Data
self::setSectionXContent($dir, $catalog, 'title');
//$date = new DateTime("2013-01-01");
//$dir->addAttribute('createdAt', $date->getTimestamp());
$location = $dir->addChild('Location');
$location->addAttribute('id', $id);
$location->addAttribute('path', $catalog->f_full_info);
}
$xml->addAttribute('allowSync', '0');
self::setContainerTitle($xml, 'Plex Library');
}
public static function setLibraryContent($xml)
{
$dir = $xml->addChild('Directory');
@ -295,11 +295,11 @@ class Plex_XML_Data
$dir = $xml->addChild('Directory');
$dir->addAttribute('key', 'onDeck');
$dir->addAttribute('title', 'On Deck Content');
$xml->addAttribute('allowSync', '0');
self::setContainerTitle($xml, 'Plex Library');
}
public static function setSectionContent($xml, $catalog)
{
$dir = $xml->addChild('Directory');
@ -315,7 +315,7 @@ class Plex_XML_Data
$dir = $xml->addChild('Directory');
$dir->addAttribute('key', 'recentlyAdded');
$dir->addAttribute('title', 'Recently Added');
$dir = $xml->addChild('Directory');
$dir->addAttribute('key', 'search?type=8');
$dir->addAttribute('prompt', 'Search for Artists');
@ -331,7 +331,7 @@ class Plex_XML_Data
$dir->addAttribute('prompt', 'Search for Tracks');
$dir->addAttribute('search', '1');
$dir->addAttribute('title', 'Search Tracks...');
$xml->addAttribute('allowSync', '0');
$xml->addAttribute('content', 'secondary');
$xml->addAttribute('nocache', '1');
@ -339,14 +339,14 @@ class Plex_XML_Data
$xml->addAttribute('viewMode', '65592');
self::setSectionXContent($xml, $catalog);
}
public static function setSectionXContent($xml, $catalog, $title = 'title1')
{
$xml->addAttribute('art', self::getResourceUri('artist-fanart.jpg'));
$xml->addAttribute('thumb', self::getResourceUri('artist.png'));
$xml->addAttribute($title, $catalog->name);
}
public static function setSystemContent($xml)
{
$dir = $xml->addChild('Directory');
@ -366,11 +366,11 @@ class Plex_XML_Data
$dir->addAttribute('title', 'Plug-ins');
$dir->addAttribute('name', 'Plug-ins');
}
public static function setSectionAll($xml, $catalog)
{
$artists = Catalog::get_artists(array($catalog->id));
$xml->addAttribute('allowSync', '1');
self::setSectionXContent($xml, $catalog);
$xml->addAttribute('title2', 'All Artists');
@ -379,16 +379,16 @@ class Plex_XML_Data
$xml->addAttribute('viewMode', '65592');
$xml->addAttribute('librarySectionID', $catalog->id);
$xml->addAttribute('librarySectionUUID', self::uuidFromKey($catalog->id));
foreach($artists as $artist) {
foreach ($artists as $artist) {
self::addArtist($xml, $artist);
}
}
public static function setSectionAlbums($xml, $catalog)
{
$albums = $catalog->get_album_ids();
$xml->addAttribute('allowSync', '0');
self::setSectionXContent($xml, $catalog);
$xml->addAttribute('title2', 'By Album');
@ -396,8 +396,8 @@ class Plex_XML_Data
$xml->addAttribute('nocache', '1');
$xml->addAttribute('viewGroup', 'album');
$xml->addAttribute('viewMode', '65592');
foreach($albums as $id) {
foreach ($albums as $id) {
$album = new Album($id);
$album->format();
self::addAlbum($xml, $album);
@ -413,7 +413,7 @@ class Plex_XML_Data
$xdir->addAttribute('addedAt', '');
$xdir->addAttribute('updatedAt', '');
self::addArtistMeta($xdir, $artist);
$tags = Tag::get_top_tags('artist', $artist->id);
foreach ($tags as $tag_id=>$value) {
$tag = new Tag($tag_id);
@ -421,7 +421,7 @@ class Plex_XML_Data
$xgenre->addAttribute('tag', $tag->name);
}
}
public static function addArtistMeta($xml, $artist)
{
$id = self::getArtistId($artist->id);
@ -430,7 +430,7 @@ class Plex_XML_Data
$xml->addAttribute('summary', '');
$xml->addAttribute('thumb', '');
}
public static function addAlbum($xml, $album)
{
$xdir = $xml->addChild('Directory');
@ -444,7 +444,7 @@ class Plex_XML_Data
if ($album->year != 0 && $album->year != 'N/A') {
$xdir->addAttribute('year', $album->year);
}
$tags = Tag::get_top_tags('album', $album->id);
foreach ($tags as $tag_id=>$value) {
$tag = new Tag($tag_id);
@ -452,7 +452,7 @@ class Plex_XML_Data
$xgenre->addAttribute('tag', $tag->name);
}
}
public static function addAlbumMeta($xml, $album)
{
$id = self::getAlbumId($album->id);
@ -475,7 +475,7 @@ class Plex_XML_Data
$xml->addAttribute('addedAt', '');
$xml->addAttribute('updatedAt', '');
}
public static function setArtistRoot($xml, $artist)
{
self::addArtistMeta($xml, $artist);
@ -487,7 +487,7 @@ class Plex_XML_Data
$xml->addAttribute('title2', $artist->name);
$xml->addAttribute('viewGroup', 'album');
$xml->addAttribute('viewMode', '65592');
$allalbums = $artist->get_albums();
foreach ($allalbums as $id) {
$album = new Album($id);
@ -511,7 +511,7 @@ class Plex_XML_Data
}
$xml->addAttribute('viewGroup', 'track');
$xml->addAttribute('viewMode', '65593');
$allsongs = $album->get_songs();
foreach ($allsongs as $id) {
$song = new Song($id);
@ -534,7 +534,7 @@ class Plex_XML_Data
$xdir->addAttribute('type', 'track');
$xdir->addAttribute('addedAt', '');
$xdir->addAttribute('updatedAt', '');
$xmedia = $xdir->addChild('Media');
$mediaid = self::getMediaId($song->id);
$xmedia->addAttribute('id', $mediaid);
@ -544,7 +544,7 @@ class Plex_XML_Data
// Type != Codec != Container, but that's how Ampache works today...
$xmedia->addAttribute('audioCodec', $song->type);
$xmedia->addAttribute('container', $song->type);
$xpart = $xmedia->addChild('Part');
$partid = self::getPartId($song->id);
$xpart->addAttribute('id', $partid);

View file

@ -46,7 +46,7 @@ class Radio extends database_object implements media
public function __construct($id = null)
{
if (!$id) { return false; }
$info = $this->get_info($id, 'live_stream');
// Set the vars

View file

@ -555,7 +555,7 @@ class Song extends database_object implements media
{
foreach ($data as $key=>$value) {
debug_event('song.class.php', $key.'='.$value, '5');
switch ($key) {
case 'artist_name':
// Need to create new artist according the name
@ -895,7 +895,7 @@ class Song extends database_object implements media
// Format the size
$this->f_size = UI::format_bytes($this->size);
$this->f_lyrics = "<a title=\"" . scrub_out($this->title) . "\" href=\"" . Config::get('web_path') . "/song.php?action=show_lyrics&song_id=" . $this->id . "\">" . T_('Show Lyrics') . "</a>";
return true;
@ -1106,12 +1106,13 @@ class Song extends database_object implements media
return array('format' => $target,
'command' => $cmd . ' ' . $args);
}
public function get_lyrics() {
public function get_lyrics()
{
if ($this->lyrics) {
return array('text' => $this->lyrics);
}
foreach (Plugin::get_plugins('get_lyrics') as $plugin_name) {
$plugin = new Plugin($plugin_name);
if ($plugin->load()) {

View file

@ -313,7 +313,7 @@ class Update
$update_string = '- Remove unused live_stream fields and add codec field.<br />';
$version[] = array('version' => '360022', 'description' => $update_string);
$update_string = '- Enable/Disable SubSonic and Plex backend.<br />';
$version[] = array('version' => '360023', 'description' => $update_string);
@ -1717,7 +1717,7 @@ class Update
return true;
}
/**
* update_360023
*
@ -1733,7 +1733,7 @@ class Update
$sql = "INSERT INTO `user_preference` VALUES (-1,?,'0')";
Dba::write($sql, array($id));
$sql = "INSERT INTO `preference` (`name`,`value`,`description`,`level`,`type`,`catagory`) " .
"VALUES ('plex_backend','0','Use Plex backend',25,'boolean','system')";
Dba::write($sql);

View file

@ -42,7 +42,7 @@ switch ($_REQUEST['action']) {
$browse->save_objects($object_ids);
$browse->show_objects($object_ids);
$browse->store();
$results['browse_content'] = ob_get_clean();
break;
case 'create':

View file

@ -74,7 +74,7 @@ function forceIframe()
var jsAjaxShowEditUrl = "<?php echo Config::get('ajax_show_edit_url') ?>";
var jsSaveTitle = "<?php echo T_('Save') ?>";
var jsCancelTitle = "<?php echo T_('Cancel') ?>";
</script>
</head>
<body <?php echo (Config::get('iframes')) ? "onLoad='forceIframe();'" : ""; ?>>

View file

@ -81,7 +81,7 @@ $button_flip_state_id = 'button_flip_state_' . $song->id;
if (Config::get('show_played_times')) {
$songprops[gettext_noop('# Played')] = scrub_out($song->object_cnt);
}
if (Config::get('show_lyrics')) {
$songprops[gettext_noop('Lyrics')] = $song->f_lyrics;
}