diff options
author | Paul Arthur <paul.arthur@flowerysong.com> | 2012-04-09 16:18:13 -0400 |
---|---|---|
committer | Paul Arthur <paul.arthur@flowerysong.com> | 2012-04-09 16:18:13 -0400 |
commit | ec9389f5c64f7de1d985d364b55a7872580034c2 (patch) | |
tree | 57f572f384315853c93c1b5a51f91fff91990895 | |
parent | 8b27b6aee2e7662f1363692f647aff2d70720063 (diff) | |
download | ampache-ec9389f5c64f7de1d985d364b55a7872580034c2.tar.gz ampache-ec9389f5c64f7de1d985d364b55a7872580034c2.tar.bz2 ampache-ec9389f5c64f7de1d985d364b55a7872580034c2.zip |
Make Art->get_from_source() static
Half the calls to it were already trying to call it as a static method
anyway. The only time $this was referenced was to get the type, so pass
type as a parameter.
-rw-r--r-- | albums.php | 8 | ||||
-rw-r--r-- | image.php | 2 | ||||
-rw-r--r-- | lib/class/art.class.php | 4 | ||||
-rw-r--r-- | lib/class/catalog.class.php | 5 | ||||
-rw-r--r-- | templates/show_album_art.inc.php | 2 |
5 files changed, 10 insertions, 11 deletions
@@ -48,11 +48,9 @@ switch ($_REQUEST['action']) { } $album = new Album($_REQUEST['album_id']); - $art = new Art($album->id,'album'); - // Pull the image information $data = array('file'=>$_FILES['file']['tmp_name']); - $image_data = $art->get_from_source($data); + $image_data = Art::get_from_source($data, 'album'); // If we got something back insert it if ($image_data) { @@ -82,7 +80,7 @@ switch ($_REQUEST['action']) { $path_info = pathinfo($_FILES['file']['name']); $upload['file'] = $_FILES['file']['tmp_name']; $upload['mime'] = 'image/' . $path_info['extension']; - $image_data = $art->get_from_source($upload); + $image_data = Art::get_from_source($upload, 'album'); if ($image_data) { $art->insert($image_data,$upload['0']['mime']); @@ -155,7 +153,7 @@ switch ($_REQUEST['action']) { $album_id = $_REQUEST['album_id']; $art = new Art($album_id,'album'); - $image = $art->get_from_source($_SESSION['form']['images'][$image_id]); + $image = Art::get_from_source($_SESSION['form']['images'][$image_id], 'album'); $mime = $_SESSION['form']['images'][$image_id]['mime']; $art->insert($image,$mime); @@ -85,7 +85,7 @@ switch ($_GET['type']) { case 'session': vauth::check_session(); $key = scrub_in($_REQUEST['image_index']); - $image = Art::get_from_source($_SESSION['form']['images'][$key]); + $image = Art::get_from_source($_SESSION['form']['images'][$key], 'album'); $mime = $_SESSION['form']['images'][$key]['mime']; $data = explode("/",$mime); $extension = $data['1']; diff --git a/lib/class/art.class.php b/lib/class/art.class.php index 52b8bc88..647e5163 100644 --- a/lib/class/art.class.php +++ b/lib/class/art.class.php @@ -453,7 +453,7 @@ class Art extends database_object { * ['file'] = FILENAME *** OPTIONAL *** * ['raw'] = Actual Image data, already captured */ - public function get_from_source($data) { + public static function get_from_source($data, $type = 'album') { // Already have the data, this often comes from id3tags if (isset($data['raw'])) { @@ -464,7 +464,7 @@ class Art extends database_object { if (isset($data['db'])) { // Repull it $uid = Dba::escape($data['db']); - $type = Dba::escape($this->type); + $type = Dba::escape($type); $sql = "SELECT * FROM `image` WHERE `object_type`='$type' AND `object_id`='$uid' AND `size`='original'"; $db_results = Dba::read($sql); diff --git a/lib/class/catalog.class.php b/lib/class/catalog.class.php index addf67d2..52073202 100644 --- a/lib/class/catalog.class.php +++ b/lib/class/catalog.class.php @@ -716,7 +716,7 @@ class Catalog extends database_object { if (count($results)) { // Pull the string representation from the source - $image = $art->get_from_source($results['0']); + $image = Art::get_from_source($results['0'], 'album'); if (strlen($image) > '5') { $art->insert($image, $results['0']['mime']); // If they've enabled resizing of images generate the thumbnail now @@ -2163,7 +2163,8 @@ class Catalog extends database_object { $get_vars = parse_url($song['art']); $extension = substr($get_vars['query'],strlen($get_vars['query'])-3,3); // Pull the image - $raw = $art->get_from_source(array('url'=>$song['art'])); + $raw = Art::get_from_source( + array('url' => $song['art']), 'album'); $inserted = $art->insert($raw,'image/' . $extension); } diff --git a/templates/show_album_art.inc.php b/templates/show_album_art.inc.php index 8304d063..f6e05283 100644 --- a/templates/show_album_art.inc.php +++ b/templates/show_album_art.inc.php @@ -40,7 +40,7 @@ while ($i <= $rows) { while ($j < 4) { $key = $i*4+$j; $image_url = Config::get('web_path') . '/image.php?type=session&image_index=' . $key; - $dimensions = Core::image_dimensions(Art::get_from_source($_SESSION['form']['images'][$key])); + $dimensions = Core::image_dimensions(Art::get_from_source($_SESSION['form']['images'][$key], 'album')); if (!isset($images[$key])) { echo "<td> </td>\n"; } else { ?> |