summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarl 'vollmerk' Vollmer <vollmer@ampache.org>2008-08-31 15:57:33 +0000
committerKarl 'vollmerk' Vollmer <vollmer@ampache.org>2008-08-31 15:57:33 +0000
commitc2e9b311e92f4b1e952f752c5177a92c5704c345 (patch)
treeae697620203e077aec8c182829e529e2f0d809f7
parent4b309a5f02490bb1a62ebcd61aed8935671d1cd8 (diff)
downloadampache-c2e9b311e92f4b1e952f752c5177a92c5704c345.tar.gz
ampache-c2e9b311e92f4b1e952f752c5177a92c5704c345.tar.bz2
ampache-c2e9b311e92f4b1e952f752c5177a92c5704c345.zip
remove lib/album.lib.php and move its two functions into album class, corrected some old php4 ish code in localplay controllers, removed redundent link from sidebar (modules)
-rw-r--r--image.php2
-rw-r--r--lib/album.lib.php139
-rw-r--r--lib/class/album.class.php99
-rw-r--r--lib/class/catalog.class.php2
-rw-r--r--lib/init.php1
-rw-r--r--logout.php2
-rw-r--r--modules/localplay/httpq.controller.php28
-rw-r--r--modules/localplay/mpd.controller.php27
-rw-r--r--server/index.ajax.php2
-rw-r--r--templates/show_album_art.inc.php2
-rw-r--r--templates/sidebar_modules.inc.php1
11 files changed, 133 insertions, 172 deletions
diff --git a/image.php b/image.php
index 8fffeac1..077133b8 100644
--- a/image.php
+++ b/image.php
@@ -67,7 +67,7 @@ switch ($_REQUEST['type']) {
case 'session':
vauth::check_session();
$key = scrub_in($_REQUEST['image_index']);
- $image = get_image_from_source($_SESSION['form']['images'][$key]);
+ $image = Album::get_image_from_source($_SESSION['form']['images'][$key]);
$mime = $_SESSION['form']['images'][$key]['mime'];
$data = explode("/",$mime);
$extension = $data['1'];
diff --git a/lib/album.lib.php b/lib/album.lib.php
deleted file mode 100644
index 2bdd55b8..00000000
--- a/lib/album.lib.php
+++ /dev/null
@@ -1,139 +0,0 @@
-<?php
-/*
-Copyright (c) 2001 - 2007 Ampache.org
-All Rights Reserved
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License v2
-as published by the Free Software Foundation.
-
-This program is distributed int he hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANT ABILITY 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.
-
- This library handles album related functions.... wooo!
-*/
-
-/*!
- @function get_albums
- @discussion pass a sql statement, and it gets full album info and returns
- an array of the goods.. can be set to format them as well
-*/
-function get_albums($sql, $action=0) {
-
- $db_results = mysql_query($sql, dbh());
- while ($r = mysql_fetch_array($db_results)) {
- $album = new Album($r[0]);
- $album->format_album();
- $albums[] = $album;
- }
-
- return $albums;
-
-
-} // get_albums
-
-/**
- * get_image_from_source
- * This gets an image for the album art from a source as
- * defined in the passed array. Because we don't know where
- * its comming from we are a passed an array that can look like
- * ['url'] = URL *** OPTIONAL ***
- * ['file'] = FILENAME *** OPTIONAL ***
- * ['raw'] = Actual Image data, already captured
- */
-function get_image_from_source($data) {
-
- // Already have the data, this often comes from id3tags
- if (isset($data['raw'])) {
- return $data['raw'];
- }
-
- // If it came from the database
- if (isset($data['db'])) {
- // Repull it
- $album_id = Dba::escape($data['db']);
- $sql = "SELECT * FROM `album_data` WHERE `album_id`='$album_id'";
- $db_results = Dba::query($sql);
- $row = Dba::fetch_assoc($db_results);
- return $row['art'];
- } // came from the db
-
- // Check to see if it's a URL
- if (isset($data['url'])) {
- $snoopy = new Snoopy();
- $snoopy->fetch($data['url']);
- return $snoopy->results;
- }
-
- // Check to see if it's a FILE
- if (isset($data['file'])) {
- $handle = fopen($data['file'],'rb');
- $image_data = fread($handle,filesize($data['file']));
- fclose($handle);
- return $image_data;
- }
-
- // Check to see if it is embedded in id3 of a song
- if (isset($data['song'])) {
- // If we find a good one, stop looking
- $getID3 = new getID3();
- $id3 = $getID3->analyze($data['song']);
-
- if ($id3['format_name'] == "WMA") {
- return $id3['asf']['extended_content_description_object']['content_descriptors']['13']['data'];
- }
- elseif (isset($id3['id3v2']['APIC'])) {
- // Foreach incase they have more then one
- foreach ($id3['id3v2']['APIC'] as $image) {
- return $image['data'];
- }
- }
- } // if data song
-
- return false;
-
-} // get_image_from_source
-
-/**
- * get_random_albums
- * This returns a random number of albums from the catalogs
- * this is used by the index to return some 'potential' albums to play
- */
-function get_random_albums($count=6) {
-
- $sql = 'SELECT `id` FROM `album` ORDER BY RAND() LIMIT ' . ($count*2);
- $db_results = Dba::query($sql);
-
- $in_sql = '`album_id` IN (';
-
- while ($row = Dba::fetch_assoc($db_results)) {
- $in_sql .= "'" . $row['id'] . "',";
- $total++;
- }
-
- if ($total < $count) { return false; }
-
- $in_sql = rtrim($in_sql,',') . ')';
-
- $sql = "SELECT `album_id`,ISNULL(`art`) AS `no_art` FROM `album_data` WHERE $in_sql";
- $db_results = Dba::query($sql);
- $results = array();
-
- while ($row = Dba::fetch_assoc($db_results)) {
- $results[$row['album_id']] = $row['no_art'];
- } // end for
-
- asort($results);
- $albums = array_keys($results);
- $results = array_slice($albums,0,$count);
-
- return $results;
-} // get_random_albums
-
-?>
diff --git a/lib/class/album.class.php b/lib/class/album.class.php
index 6180b6c7..049331ff 100644
--- a/lib/class/album.class.php
+++ b/lib/class/album.class.php
@@ -822,6 +822,105 @@ class Album extends database_object {
} // save_resized_art
+ /**
+ * get_random_albums
+ * This returns a random number of albums from the catalogs
+ * this is used by the index to return some 'potential' albums to play
+ */
+ public static function get_random_albums($count=6) {
+
+ $sql = 'SELECT `id` FROM `album` ORDER BY RAND() LIMIT ' . ($count*2);
+ $db_results = Dba::query($sql);
+
+ $in_sql = '`album_id` IN (';
+
+ while ($row = Dba::fetch_assoc($db_results)) {
+ $in_sql .= "'" . $row['id'] . "',";
+ $total++;
+ }
+
+ if ($total < $count) { return false; }
+
+ $in_sql = rtrim($in_sql,',') . ')';
+
+ $sql = "SELECT `album_id`,ISNULL(`art`) AS `no_art` FROM `album_data` WHERE $in_sql";
+ $db_results = Dba::query($sql);
+ $results = array();
+
+ while ($row = Dba::fetch_assoc($db_results)) {
+ $results[$row['album_id']] = $row['no_art'];
+ } // end for
+
+ asort($results);
+ $albums = array_keys($results);
+ $results = array_slice($albums,0,$count);
+
+ return $results;
+
+ } // get_random_albums
+
+ /**
+ * get_image_from_source
+ * This gets an image for the album art from a source as
+ * defined in the passed array. Because we don't know where
+ * its comming from we are a passed an array that can look like
+ * ['url'] = URL *** OPTIONAL ***
+ * ['file'] = FILENAME *** OPTIONAL ***
+ * ['raw'] = Actual Image data, already captured
+ */
+ public static function get_image_from_source($data) {
+
+ // Already have the data, this often comes from id3tags
+ if (isset($data['raw'])) {
+ return $data['raw'];
+ }
+
+ // If it came from the database
+ if (isset($data['db'])) {
+ // Repull it
+ $album_id = Dba::escape($data['db']);
+ $sql = "SELECT * FROM `album_data` WHERE `album_id`='$album_id'";
+ $db_results = Dba::query($sql);
+ $row = Dba::fetch_assoc($db_results);
+ return $row['art'];
+ } // came from the db
+
+ // Check to see if it's a URL
+ if (isset($data['url'])) {
+ $snoopy = new Snoopy();
+ $snoopy->fetch($data['url']);
+ return $snoopy->results;
+ }
+
+ // Check to see if it's a FILE
+ if (isset($data['file'])) {
+ $handle = fopen($data['file'],'rb');
+ $image_data = fread($handle,filesize($data['file']));
+ fclose($handle);
+ return $image_data;
+ }
+
+ // Check to see if it is embedded in id3 of a song
+ if (isset($data['song'])) {
+ // If we find a good one, stop looking
+ $getID3 = new getID3();
+ $id3 = $getID3->analyze($data['song']);
+
+ if ($id3['format_name'] == "WMA") {
+ return $id3['asf']['extended_content_description_object']['content_descriptors']['13']['data'];
+ }
+ elseif (isset($id3['id3v2']['APIC'])) {
+ // Foreach incase they have more then one
+ foreach ($id3['id3v2']['APIC'] as $image) {
+ return $image['data'];
+ }
+ }
+ } // if data song
+
+ return false;
+
+ } // get_image_from_source
+
} //end of album class
?>
diff --git a/lib/class/catalog.class.php b/lib/class/catalog.class.php
index ee51e9e5..153153e1 100644
--- a/lib/class/catalog.class.php
+++ b/lib/class/catalog.class.php
@@ -640,7 +640,7 @@ class Catalog {
if (count($results)) {
// Pull the string representation from the source
- $image = get_image_from_source($results['0']);
+ $image = Album::get_image_from_source($results['0']);
if (strlen($image) > '5') {
$album->insert_art($image,$results['0']['mime']);
}
diff --git a/lib/init.php b/lib/init.php
index 1ee9e4f9..d855be1d 100644
--- a/lib/init.php
+++ b/lib/init.php
@@ -121,7 +121,6 @@ $results['mysql_db'] = $results['database_name'];
define('INIT_LOADED','1');
// Library and module includes we can't do with the autoloader
-require_once $prefix . '/lib/album.lib.php';
require_once $prefix . '/lib/search.php';
require_once $prefix . '/lib/preferences.php';
require_once $prefix . '/lib/rss.php';
diff --git a/logout.php b/logout.php
index 17058d91..d78cdc36 100644
--- a/logout.php
+++ b/logout.php
@@ -1,7 +1,7 @@
<?php
/*
- Copyright (c) 2001 - 2007 Ampache.org
+ Copyright (c) Ampache.org
All rights reserved.
This program is free software; you can redistribute it and/or
diff --git a/modules/localplay/httpq.controller.php b/modules/localplay/httpq.controller.php
index fe279b5b..dd26fa6c 100644
--- a/modules/localplay/httpq.controller.php
+++ b/modules/localplay/httpq.controller.php
@@ -312,7 +312,7 @@ class AmpacheHttpq extends localplay_controller {
* clear_playlist
* This deletes the entire Httpq playlist... nuff said
*/
- function clear_playlist() {
+ public function clear_playlist() {
if (is_null($this->_httpq->clear())) { return false; }
@@ -358,7 +358,7 @@ class AmpacheHttpq extends localplay_controller {
* skip
* This tells HttpQ to skip to the specified song
*/
- function skip($song) {
+ public function skip($song) {
if (is_null($this->_httpq->skip($song))) { return false; }
return true;
@@ -368,7 +368,7 @@ class AmpacheHttpq extends localplay_controller {
/**
* This tells Httpq to increase the volume by WinAmps default amount
*/
- function volume_up() {
+ public function volume_up() {
if (is_null($this->_httpq->volume_up())) { return false; }
return true;
@@ -378,7 +378,7 @@ class AmpacheHttpq extends localplay_controller {
/**
* This tells HttpQ to decrease the volume by Winamps default amount
*/
- function volume_down() {
+ public function volume_down() {
if (is_null($this->_httpq->volume_down())) { return false; }
return true;
@@ -387,9 +387,9 @@ class AmpacheHttpq extends localplay_controller {
/**
* next
- * This just tells MPD to skip to the next song
+ * This just tells HttpQ to skip to the next song
*/
- function next() {
+ public function next() {
if (is_null($this->_httpq->next())) { return false; }
@@ -399,9 +399,9 @@ class AmpacheHttpq extends localplay_controller {
/**
* prev
- * This just tells MPD to skip to the prev song
+ * This just tells HttpQ to skip to the prev song
*/
- function prev() {
+ public function prev() {
if (is_null($this->_httpq->prev())) { return false; }
@@ -411,9 +411,9 @@ class AmpacheHttpq extends localplay_controller {
/**
* pause
- * This tells MPD to pause the current song
+ * This tells HttpQ to pause the current song
*/
- function pause() {
+ public function pause() {
if (is_null($this->_httpq->pause())) { return false; }
return true;
@@ -425,7 +425,7 @@ class AmpacheHttpq extends localplay_controller {
* This tells HttpQ to set the volume to the specified amount this
* is 0-100
*/
- function volume($volume) {
+ public function volume($volume) {
if (is_null($this->_httpq->set_volume($volume))) { return false; }
return true;
@@ -477,6 +477,7 @@ class AmpacheHttpq extends localplay_controller {
$data['raw'] = $entry;
$url_data = $this->parse_url($entry);
+
switch ($url_data['primary_key']) {
case 'song':
$song = new Song($url_data['song']);
@@ -489,6 +490,10 @@ class AmpacheHttpq extends localplay_controller {
$data['name'] = _('Democratic') . ' - ' . $democratic->name;
$data['link'] = '';
break;
+ case 'random':
+ $data['name'] = _('Random') . ' - ' . scrub_out(ucfirst($url_data['type']));
+ $data['link'] = '';
+ break;
default:
/* If we don't know it, look up by filename */
@@ -509,7 +514,6 @@ class AmpacheHttpq extends localplay_controller {
break;
} // end switch on primary key type
-
$data['track'] = $key+1;
$results[] = $data;
diff --git a/modules/localplay/mpd.controller.php b/modules/localplay/mpd.controller.php
index cc7a564c..08b790b1 100644
--- a/modules/localplay/mpd.controller.php
+++ b/modules/localplay/mpd.controller.php
@@ -313,7 +313,7 @@ class AmpacheMpd extends localplay_controller {
* clear_playlist
* This deletes the entire MPD playlist... nuff said
*/
- function clear_playlist() {
+ public function clear_playlist() {
if (is_null($this->_mpd->PLClear())) { return false; }
@@ -326,7 +326,7 @@ class AmpacheMpd extends localplay_controller {
* This just tells MPD to start playing, it does not
* take any arguments
*/
- function play() {
+ public function play() {
if (is_null($this->_mpd->Play())) { return false; }
return true;
@@ -338,7 +338,7 @@ class AmpacheMpd extends localplay_controller {
* This just tells MPD to stop playing, it does not take
* any arguments
*/
- function stop() {
+ public function stop() {
if (is_null($this->_mpd->Stop())) { return false; }
return true;
@@ -349,7 +349,7 @@ class AmpacheMpd extends localplay_controller {
* skip
* This tells MPD to skip to the specified song
*/
- function skip($song) {
+ public function skip($song) {
if (is_null($this->_mpd->SkipTo($song))) { return false; }
return true;
@@ -359,7 +359,7 @@ class AmpacheMpd extends localplay_controller {
/**
* This tells MPD to increase the volume by 5
*/
- function volume_up() {
+ public function volume_up() {
if (is_null($this->_mpd->AdjustVolume('5'))) { return false; }
return true;
@@ -369,7 +369,7 @@ class AmpacheMpd extends localplay_controller {
/**
* This tells MPD to decrese the volume by 5
*/
- function volume_down() {
+ public function volume_down() {
if (is_null($this->_mpd->AdjustVolume('-5'))) { return false; }
return true;
@@ -380,7 +380,7 @@ class AmpacheMpd extends localplay_controller {
* next
* This just tells MPD to skip to the next song
*/
- function next() {
+ public function next() {
if (is_null($this->_mpd->Next())) { return false; }
return true;
@@ -391,7 +391,7 @@ class AmpacheMpd extends localplay_controller {
* prev
* This just tells MPD to skip to the prev song
*/
- function prev() {
+ public function prev() {
if (is_null($this->_mpd->Previous())) { return false; }
return true;
@@ -402,7 +402,7 @@ class AmpacheMpd extends localplay_controller {
* pause
* This tells MPD to pause the current song
*/
- function pause() {
+ public function pause() {
if (is_null($this->_mpd->Pause())) { return false; }
return true;
@@ -414,7 +414,7 @@ class AmpacheMpd extends localplay_controller {
* volume
* This tells MPD to set the volume to the parameter
*/
- function volume($volume) {
+ public function volume($volume) {
if (is_null($this->_mpd->SetVolume($volume))) { return false; }
return true;
@@ -425,19 +425,18 @@ class AmpacheMpd extends localplay_controller {
* repeat
* This tells MPD to set the repeating the playlist (i.e. loop) to either on or off
*/
- function repeat($state) {
+ public function repeat($state) {
if (is_null($this->_mpd->SetRepeat($state))) { return false; }
return true;
} // repeat
-
/**
* random
* This tells MPD to turn on or off the playing of songs from the playlist in random order
*/
- function random($onoff) {
+ public function random($onoff) {
if (is_null($this->_mpd->SetRandom($onoff))) { return false; }
return true;
@@ -448,7 +447,7 @@ class AmpacheMpd extends localplay_controller {
* move
* This tells MPD to move song from SrcPos to DestPos
*/
- function move($SrcPos, $DestPos) {
+ public function move($SrcPos, $DestPos) {
if (is_null($this->_mpd->PLMoveTrack($SrcPos, $DestPos))) { return false; }
diff --git a/server/index.ajax.php b/server/index.ajax.php
index 3ecae38d..4dc85ace 100644
--- a/server/index.ajax.php
+++ b/server/index.ajax.php
@@ -26,7 +26,7 @@ if (AJAX_INCLUDE != '1') { exit; }
switch ($_REQUEST['action']) {
case 'random_albums':
- $albums = get_random_albums('6');
+ $albums = Album::get_random_albums('6');
if (count($albums)) {
ob_start();
require_once Config::get('prefix') . '/templates/show_random_albums.inc.php';
diff --git a/templates/show_album_art.inc.php b/templates/show_album_art.inc.php
index 1bfced78..0ce49909 100644
--- a/templates/show_album_art.inc.php
+++ b/templates/show_album_art.inc.php
@@ -33,7 +33,7 @@ while ($i <= $rows) {
while ($j < 4) {
$key = $i*4+$j;
$image_url = Config::get('web_path') . '/image.php?type=session&amp;image_index=' . $key;
- $dimensions = Core::image_dimensions(get_image_from_source($_SESSION['form']['images'][$key]));
+ $dimensions = Core::image_dimensions(Album::get_image_from_source($_SESSION['form']['images'][$key]));
if (!isset($images[$key])) { echo "<td>&nbsp;</td>\n"; }
else {
?>
diff --git a/templates/sidebar_modules.inc.php b/templates/sidebar_modules.inc.php
index 92183a44..33fde36e 100644
--- a/templates/sidebar_modules.inc.php
+++ b/templates/sidebar_modules.inc.php
@@ -38,7 +38,6 @@ $ajax_info = Config::get('ajax_url'); $web_path = Config::get('web_path');
</li>
<li><h4><?php echo _('Information'); ?></h4>
<ul class="sb3" id="sb_home_info">
- <li id="sb_home_info_CurrentlyPlaying"><a href="<?php echo $web_path; ?>/index.php"><?php echo _('Currently Playing'); ?></a></li>
<li id="sb_home_info_Statistics"><a href="<?php echo $web_path; ?>/stats.php"><?php echo _('Statistics'); ?></a></li>
<li id="sb_home_info_AddStationRadio"><a href="<?php echo $web_path; ?>/radio.php?action=show_create"><?php echo _('Add Radio Station'); ?></a></li>
</ul>