diff options
author | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2007-08-06 01:57:29 +0000 |
---|---|---|
committer | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2007-08-06 01:57:29 +0000 |
commit | fb5c43b2df8a190fecfe4bf04bcd64aa1bad9c2d (patch) | |
tree | 86cee2ea4acaaf51dae5f4732d13e54213f12137 /lib | |
parent | 573c3014b982bd52f0b6959f51d65dfc86ae35c0 (diff) | |
download | ampache-fb5c43b2df8a190fecfe4bf04bcd64aa1bad9c2d.tar.gz ampache-fb5c43b2df8a190fecfe4bf04bcd64aa1bad9c2d.tar.bz2 ampache-fb5c43b2df8a190fecfe4bf04bcd64aa1bad9c2d.zip |
proof of concept, nothing one should actually use
Diffstat (limited to 'lib')
-rw-r--r-- | lib/class/artist.class.php | 31 | ||||
-rw-r--r-- | lib/class/metadata.class.php | 44 | ||||
-rw-r--r-- | lib/class/plugin.class.php | 12 | ||||
-rw-r--r-- | lib/class/song.class.php | 63 | ||||
-rw-r--r-- | lib/init.php | 1 | ||||
-rw-r--r-- | lib/preferences.php | 3 |
6 files changed, 113 insertions, 41 deletions
diff --git a/lib/class/artist.class.php b/lib/class/artist.class.php index 2d12e8c6..15258e66 100644 --- a/lib/class/artist.class.php +++ b/lib/class/artist.class.php @@ -31,18 +31,21 @@ class Artist { public $albums; public $prefix; + // Constructed vars + public $_fake = false; // Set if construct_from_array() used + /** * Artist * Artist class, for modifing a artist * Takes the ID of the artist and pulls the info from the db */ - function Artist($artist_id = 0) { + public function __construct($id='') { /* If they failed to pass in an id, just run for it */ - if (!$artist_id) { return false; } + if (!$id) { return false; } /* Assign id for use in get_info() */ - $this->id = intval($artist_id); + $this->id = intval($id); /* Get the information from the db */ $info = $this->_get_info(); @@ -56,6 +59,25 @@ class Artist { } //constructor /** + * construct_from_array + * This is used by the metadata class specifically but fills out a Artist object + * based on a key'd array, it sets $_fake to true + */ + public static function construct_from_array($data) { + + $artist = new Artist(0); + foreach ($data as $key=>$value) { + $artist->$key = $value; + } + + //Ack that this is not a real object from the DB + $artist->_fake = true; + + return $artist; + + } // construct_from_array + + /** * _get_info * get's the vars for $this out of the database taken from the object */ @@ -186,6 +208,9 @@ class Artist { $name = truncate_with_ellipsis(trim($this->prefix . " " . $this->name)); $this->f_name = $name; + // If this is a fake object, we're done here + if ($this->_fake) { return true; } + $this->f_name_link = "<a href=\"" . Config::get('web_path') . "/artists.php?action=show&artist=" . $this->id . "\" title=\"" . $this->full_name . "\">" . $name . "</a>"; // Get the counts diff --git a/lib/class/metadata.class.php b/lib/class/metadata.class.php new file mode 100644 index 00000000..01db6072 --- /dev/null +++ b/lib/class/metadata.class.php @@ -0,0 +1,44 @@ +<?php +/* + + Copyright 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 + as published by the Free Software Foundation; version 2 + of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY 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. + +*/ + +/** + * metadata class + * This class is a abstraction layer for getting + * meta data for any object in Ampache, this includes + * album art, lyrics, id3tags, recommendations etc + * it makes use of Object::construct_from_array() as needed + */ +class metadata { + + /** + * constructor + * We don't use this, as its really a static class + */ + private __construct() { + + // Rien a faire + + } // constructor + +} // metadata + +?> diff --git a/lib/class/plugin.class.php b/lib/class/plugin.class.php index e5b9c485..37f707da 100644 --- a/lib/class/plugin.class.php +++ b/lib/class/plugin.class.php @@ -147,13 +147,13 @@ class Plugin { /** * is_installed - * This checks to see if the current plugin is currently installed in the + * This checks to see if the specified plugin is currently installed in the * database, it doesn't check the files for integrity */ - function is_installed() { + public static function is_installed($plugin_name) { /* All we do is check the version */ - return $this->get_plugin_version(); + return self::get_plugin_version($plugin_name); } // is_installed @@ -187,11 +187,11 @@ class Plugin { /** * get_plugin_version - * This returns the version of the currently installed plugin + * This returns the version of the specified plugin */ - function get_plugin_version() { + public static function get_plugin_version($plugin_name) { - $name = Dba::escape('Plugin_' . $this->_plugin->name); + $name = Dba::escape('Plugin_' . $plugin_name); $sql = "SELECT * FROM `update_info` WHERE `key`='$name'"; $db_results = Dba::query($sql); diff --git a/lib/class/song.class.php b/lib/class/song.class.php index 123d33ad..2b63be6b 100644 --- a/lib/class/song.class.php +++ b/lib/class/song.class.php @@ -23,40 +23,40 @@ class Song { /* Variables from DB */ - var $id; - var $file; - var $album; // album.id (Int) - var $artist; // artist.id (Int) - var $title; - var $year; - var $bitrate; - var $rate; - var $mode; - var $size; - var $time; - var $track; - var $genre; // genre.id (Int) - var $type; - var $mime; - var $played; - var $enabled; - var $addition_time; - var $update_time; + public $id; + public $file; + public $album; // album.id (Int) + public $artist; // artist.id (Int) + public $title; + public $year; + public $bitrate; + public $rate; + public $mode; + public $size; + public $time; + public $track; + public $genre; // genre.id (Int) + public $type; + public $mime; + public $played; + public $enabled; + public $addition_time; + public $update_time; /* Setting Variables */ - var $_transcoded = false; + public $_transcoded = false; + public $_fake = false; // If this is a 'construct_from_array' object - /*! - @function Song - @discussion Song class, for modifing a song. - @param $song_id The ID of the song + /** + * Constructor + * Song class, for modifing a song. */ - function Song($song_id = 0) { - - if (!$song_id) { return false; } + public function __construct($id='') { /* Assign id for use in get_info() */ - $this->id = intval($song_id); + $this->id = intval($id); + + if (!$this->id) { return false; } /* Get the information from the db */ if ($info = $this->_get_info()) { @@ -64,12 +64,13 @@ class Song { foreach ($info as $key=>$value) { $this->$key = $value; } - // Format the Type of the song - $this->format_type(); + // Format the Type of the song + $this->format_type(); } - } //constructor + return true; + } // constructor /*! @function _get_info diff --git a/lib/init.php b/lib/init.php index ad4a913e..6efa68a2 100644 --- a/lib/init.php +++ b/lib/init.php @@ -130,6 +130,7 @@ require_once $prefix . '/modules/getid3/getid3.php'; require_once $prefix . '/modules/infotools/Snoopy.class.php'; require_once $prefix . '/modules/infotools/AmazonSearchEngine.class.php'; require_once $prefix . '/modules/infotools/lastfm.class.php'; +require_once $prefix . '/modules/infotools/openstrands.class.php'; //require_once $prefix . '/modules/infotools/jamendoSearch.class.php'; /* Temp Fixes */ diff --git a/lib/preferences.php b/lib/preferences.php index b35f3036..66338a05 100644 --- a/lib/preferences.php +++ b/lib/preferences.php @@ -113,7 +113,8 @@ function update_preferences($pref_id=0) { case 'sample_rate': $value = validate_bitrate($value); break; - /* MD5 the LastFM so it's not plainTXT */ + /* MD5 the LastFM & MyStrands so it's not plainTXT */ + case 'mystrands_pass': case 'lastfm_pass': /* If it's our default blanking thing then don't use it */ if ($value == '******') { unset($_REQUEST[$name]); break; } |