From a7838e2a13cf2f8875a34e122c44c9c923648bc6 Mon Sep 17 00:00:00 2001 From: dipsol Date: Mon, 14 Dec 2009 08:06:20 +0000 Subject: Replaced almost every dba::query to dba::read or dba::write. --- lib/ui.lib.php | 248 ++++++++++++++++++++++++++++----------------------------- 1 file changed, 124 insertions(+), 124 deletions(-) (limited to 'lib/ui.lib.php') diff --git a/lib/ui.lib.php b/lib/ui.lib.php index dc2ca675..34e7fb4d 100644 --- a/lib/ui.lib.php +++ b/lib/ui.lib.php @@ -85,10 +85,10 @@ if (!function_exists('_')) { * ngettext * checks for ngettext and defines it if it doesn't exist */ -if (!function_exists('ngettext')) { - function ngettext($string) { - return $string; - } +if (!function_exists('ngettext')) { + function ngettext($string) { + return $string; + } } // if no ngettext /** @@ -97,11 +97,11 @@ if (!function_exists('ngettext')) { * that they aren't allowed to */ function access_denied() { - + // Clear any crap we've got up top - ob_end_clean(); - require_once Config::get('prefix') . '/templates/show_denied.inc.php'; - exit; + ob_end_clean(); + require_once Config::get('prefix') . '/templates/show_denied.inc.php'; + exit; } // access_denied @@ -119,11 +119,11 @@ function return_referer() { } else { $file = basename($referer); - /* Strip off the filename */ - $referer = substr($referer,0,strlen($referer)-strlen($file)); + /* Strip off the filename */ + $referer = substr($referer,0,strlen($referer)-strlen($file)); } - - if (substr($referer,strlen($referer)-6,6) == 'admin/') { + + if (substr($referer,strlen($referer)-6,6) == 'admin/') { $file = 'admin/' . $file; } @@ -141,8 +141,8 @@ function return_referer() { */ function truncate_with_ellipsis($text, $max='') { - $max = $max ? $max : '27'; - + $max = $max ? $max : '27'; + /* If we want it to be shorter than three, just throw it back */ if ($max > 3) { @@ -171,9 +171,9 @@ function truncate_with_ellipsis($text, $max='') { * This shows the header.inc.php, it may do something * more in the future */ -function show_header() { +function show_header() { - require_once Config::get('prefix') . '/templates/header.inc.php'; + require_once Config::get('prefix') . '/templates/header.inc.php'; } // show_header @@ -203,9 +203,9 @@ function img_resize($image,$size,$type,$album_id) { return $image['raw']; } // Already resized - if ($image['db_resized']) { - debug_event('using_resized','using resized image for Album:' . $album_id,'2'); - return $image['raw']; + if ($image['db_resized']) { + debug_event('using_resized','using resized image for Album:' . $album_id,'2'); + return $image['raw']; } $image = $image['raw']; @@ -226,11 +226,11 @@ function img_resize($image,$size,$type,$album_id) { } $src = imagecreatefromstring($image); - - if (!$src) { + + if (!$src) { debug_event('IMG_RESIZE','Failed to create from string','3'); - return false; - } + return false; + } $width = imagesx($src); $height = imagesy($src); @@ -239,13 +239,13 @@ function img_resize($image,$size,$type,$album_id) { $new_h = $size['height']; $img = imagecreatetruecolor($new_w,$new_h); - - if (!imagecopyresampled($img,$src,0,0,0,0,$new_w,$new_h,$width,$height)) { + + if (!imagecopyresampled($img,$src,0,0,0,0,$new_w,$new_h,$width,$height)) { debug_event('IMG_RESIZE','Failed to copy resample image','3'); return false; } - ob_start(); + ob_start(); // determine image type and send it to the client switch ($type) { @@ -262,19 +262,19 @@ function img_resize($image,$size,$type,$album_id) { } // Grab this image data and save it into the thumbnail - $data = ob_get_contents(); + $data = ob_get_contents(); ob_end_clean(); // If our image create failed don't save it, just return - if (!$data) { - debug_event('IMG_RESIZE','Failed to resize Art from Album:' . $album_id,'3'); + if (!$data) { + debug_event('IMG_RESIZE','Failed to resize Art from Album:' . $album_id,'3'); return $image; } // Save what we've got - Album::save_resized_art($data,'image/' . $type,$album_id); + Album::save_resized_art($data,'image/' . $type,$album_id); - return $data; + return $data; } // img_resize @@ -293,10 +293,10 @@ function get_location() { $location = array(); - if (strlen($_SERVER['PHP_SELF'])) { + if (strlen($_SERVER['PHP_SELF'])) { $source = $_SERVER['PHP_SELF']; } - else { + else { $source = $_SERVER['REQUEST_URI']; } @@ -388,8 +388,8 @@ function get_location() { * it takes a chunck of the crazy preference array and then displays it out * it does not contain the
tags */ -function show_preference_box($preferences) { - +function show_preference_box($preferences) { + require Config::get('prefix') . '/templates/show_preference_box.inc.php'; } // show_preference_box @@ -432,9 +432,9 @@ function good_email($email) { /** * show_album_select * This displays a select of every album that we've got in Ampache, (it can be hella long) it's used - * by the Edit page, it takes a $name and a $album_id + * by the Edit page, it takes a $name and a $album_id */ -function show_album_select($name='album',$album_id=0,$allow_add=0,$song_id=0) { +function show_album_select($name='album',$album_id=0,$allow_add=0,$song_id=0) { // Generate key to use for HTML element ID static $id_cnt; if ($song_id) { @@ -447,17 +447,17 @@ function show_album_select($name='album',$album_id=0,$allow_add=0,$song_id=0) { echo "\n"; - + $sql = "SELECT `id`, `name`, `prefix` FROM `artist` ORDER BY `name`"; - $db_results = Dba::query($sql); - - while ($r = Dba::fetch_assoc($db_results)) { + $db_results = Dba::read($sql); + + while ($r = Dba::fetch_assoc($db_results)) { $selected = ''; $artist_name = trim($r['prefix'] . " " . $r['name']); - if ($r['id'] == $artist_id) { + if ($r['id'] == $artist_id) { $selected = "selected=\"selected\""; } @@ -509,18 +509,18 @@ function show_artist_select($name='artist', $artist_id=0, $allow_add=0, $song_id /** * show_catalog_select - * Yet another one of these buggers. this shows a drop down of all of your catalogs + * Yet another one of these buggers. this shows a drop down of all of your catalogs */ -function show_catalog_select($name='catalog',$catalog_id=0,$style='') { +function show_catalog_select($name='catalog',$catalog_id=0,$style='') { echo "\n"; echo "\t\n"; $sql = "SELECT `id`,`username`,`fullname` FROM `user` ORDER BY `fullname`"; - $db_results = Dba::query($sql); + $db_results = Dba::read($sql); - while ($row = Dba::fetch_assoc($db_results)) { + while ($row = Dba::fetch_assoc($db_results)) { $select_txt = ''; - if ($row['id'] == $selected) { + if ($row['id'] == $selected) { $select_txt = 'selected="selected"'; } // If they don't have a full name, revert to the username - $row['fullname'] = $row['fullname'] ? $row['fullname'] : $row['username']; + $row['fullname'] = $row['fullname'] ? $row['fullname'] : $row['username']; echo "\t\n"; } // end while users @@ -565,17 +565,17 @@ function show_user_select($name,$selected='',$style='') { * This one is for users! shows a select/option statement so you can pick a user * to blame */ -function show_playlist_select($name,$selected='',$style='') { +function show_playlist_select($name,$selected='',$style='') { echo "