Changeset 1730

Show
Ignore:
Timestamp:
08/31/08 08:57:33 (3 months ago)
Author:
vollmerk
Message:

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)

Location:
trunk
Files:
1 removed
10 modified

Legend:

Unmodified
Added
Removed
  • trunk/image.php

    r1536 r1730  
    6868                vauth::check_session();  
    6969                $key = scrub_in($_REQUEST['image_index']);  
    70                 $image = get_image_from_source($_SESSION['form']['images'][$key]); 
     70                $image = Album::get_image_from_source($_SESSION['form']['images'][$key]); 
    7171                $mime = $_SESSION['form']['images'][$key]['mime']; 
    7272                $data = explode("/",$mime);  
  • trunk/lib/class/album.class.php

    r1665 r1730  
    823823        } // save_resized_art 
    824824 
     825        /** 
     826         * get_random_albums 
     827         * This returns a random number of albums from the catalogs 
     828         * this is used by the index to return some 'potential' albums to play 
     829         */ 
     830        public static function get_random_albums($count=6) { 
     831 
     832                $sql = 'SELECT `id` FROM `album` ORDER BY RAND() LIMIT ' . ($count*2); 
     833                $db_results = Dba::query($sql); 
     834 
     835                $in_sql = '`album_id` IN ('; 
     836 
     837                while ($row = Dba::fetch_assoc($db_results)) { 
     838                        $in_sql .= "'" . $row['id'] . "',"; 
     839                        $total++; 
     840                } 
     841 
     842                if ($total < $count) { return false; } 
     843 
     844                $in_sql = rtrim($in_sql,',') . ')'; 
     845 
     846                $sql = "SELECT `album_id`,ISNULL(`art`) AS `no_art` FROM `album_data` WHERE $in_sql"; 
     847                $db_results = Dba::query($sql); 
     848                $results = array(); 
     849 
     850                while ($row = Dba::fetch_assoc($db_results)) { 
     851                        $results[$row['album_id']] = $row['no_art']; 
     852                } // end for 
     853         
     854                asort($results); 
     855                $albums = array_keys($results); 
     856                $results = array_slice($albums,0,$count); 
     857         
     858                return $results; 
     859 
     860        } // get_random_albums 
     861 
     862        /** 
     863         * get_image_from_source 
     864         * This gets an image for the album art from a source as  
     865         * defined in the passed array. Because we don't know where 
     866         * its comming from we are a passed an array that can look like 
     867         * ['url']      = URL *** OPTIONAL *** 
     868         * ['file']     = FILENAME *** OPTIONAL *** 
     869         * ['raw']      = Actual Image data, already captured 
     870         */ 
     871        public static function get_image_from_source($data) { 
     872 
     873                // Already have the data, this often comes from id3tags 
     874                if (isset($data['raw'])) { 
     875                        return $data['raw']; 
     876                } 
     877 
     878                // If it came from the database 
     879                if (isset($data['db'])) { 
     880                        // Repull it  
     881                        $album_id = Dba::escape($data['db']); 
     882                        $sql = "SELECT * FROM `album_data` WHERE `album_id`='$album_id'"; 
     883                        $db_results = Dba::query($sql); 
     884                        $row = Dba::fetch_assoc($db_results); 
     885                        return $row['art']; 
     886                } // came from the db 
     887 
     888                // Check to see if it's a URL 
     889                if (isset($data['url'])) { 
     890                        $snoopy = new Snoopy(); 
     891                        $snoopy->fetch($data['url']); 
     892                        return $snoopy->results; 
     893                } 
     894 
     895                // Check to see if it's a FILE 
     896                if (isset($data['file'])) { 
     897                        $handle = fopen($data['file'],'rb'); 
     898                        $image_data = fread($handle,filesize($data['file'])); 
     899                        fclose($handle); 
     900                        return $image_data; 
     901                } 
     902         
     903                // Check to see if it is embedded in id3 of a song 
     904                if (isset($data['song'])) { 
     905                        // If we find a good one, stop looking 
     906                        $getID3 = new getID3(); 
     907                        $id3 = $getID3->analyze($data['song']); 
     908         
     909                        if ($id3['format_name'] == "WMA") { 
     910                                return $id3['asf']['extended_content_description_object']['content_descriptors']['13']['data']; 
     911                        } 
     912                        elseif (isset($id3['id3v2']['APIC'])) { 
     913                                // Foreach incase they have more then one  
     914                                foreach ($id3['id3v2']['APIC'] as $image) { 
     915                                        return $image['data']; 
     916                                } 
     917                        } 
     918                } // if data song 
     919 
     920                return false; 
     921 
     922        } // get_image_from_source 
     923 
    825924} //end of album class 
    826925 
  • trunk/lib/class/catalog.class.php

    r1663 r1730  
    641641                        if (count($results)) {  
    642642                                // Pull the string representation from the source 
    643                                 $image = get_image_from_source($results['0']);   
     643                                $image = Album::get_image_from_source($results['0']);   
    644644                                if (strlen($image) > '5') {  
    645645                                        $album->insert_art($image,$results['0']['mime']);  
  • trunk/lib/init.php

    r1722 r1730  
    122122 
    123123// Library and module includes we can't do with the autoloader 
    124 require_once $prefix . '/lib/album.lib.php'; 
    125124require_once $prefix . '/lib/search.php'; 
    126125require_once $prefix . '/lib/preferences.php'; 
  • trunk/logout.php

    r1363 r1730  
    22/* 
    33 
    4  Copyright (c) 2001 - 2007 Ampache.org 
     4 Copyright (c) Ampache.org 
    55 All rights reserved. 
    66 
  • trunk/modules/localplay/httpq.controller.php

    r1560 r1730  
    313313         * This deletes the entire Httpq playlist... nuff said 
    314314         */ 
    315         function clear_playlist() {  
     315        public function clear_playlist() {  
    316316 
    317317                if (is_null($this->_httpq->clear())) { return false; } 
     
    359359         * This tells HttpQ to skip to the specified song 
    360360         */ 
    361         function skip($song) {  
     361        public function skip($song) {  
    362362 
    363363                if (is_null($this->_httpq->skip($song))) { return false; } 
     
    369369         * This tells Httpq to increase the volume by WinAmps default amount 
    370370         */ 
    371         function volume_up() {  
     371        public function volume_up() {  
    372372 
    373373                if (is_null($this->_httpq->volume_up())) { return false; }  
     
    379379         * This tells HttpQ to decrease the volume by Winamps default amount 
    380380         */ 
    381         function volume_down() {  
     381        public function volume_down() {  
    382382 
    383383                if (is_null($this->_httpq->volume_down())) { return false; } 
     
    388388        /** 
    389389         * next 
    390          * This just tells MPD to skip to the next song  
    391          */ 
    392         function next() {  
     390         * This just tells HttpQ to skip to the next song  
     391         */ 
     392        public function next() {  
    393393 
    394394                if (is_null($this->_httpq->next())) { return false; }  
     
    400400        /** 
    401401         * prev 
    402          * This just tells MPD to skip to the prev song 
    403          */ 
    404         function prev() {  
     402         * This just tells HttpQ to skip to the prev song 
     403         */ 
     404        public function prev() {  
    405405 
    406406                if (is_null($this->_httpq->prev())) { return false; }  
     
    412412        /** 
    413413         * pause 
    414          * This tells MPD to pause the current song  
    415          */ 
    416         function pause() {  
     414         * This tells HttpQ to pause the current song  
     415         */ 
     416        public function pause() {  
    417417                 
    418418                if (is_null($this->_httpq->pause())) { return false; }  
     
    426426        * is 0-100 
    427427        */ 
    428        function volume($volume) { 
     428       public function volume($volume) { 
    429429 
    430430               if (is_null($this->_httpq->set_volume($volume))) { return false; } 
     
    478478 
    479479                        $url_data = $this->parse_url($entry);  
     480 
    480481                        switch ($url_data['primary_key']) { 
    481482                                case 'song': 
     
    490491                                        $data['link']   = ''; 
    491492                                break; 
     493                                case 'random':  
     494                                        $data['name'] = _('Random') . ' - ' . scrub_out(ucfirst($url_data['type']));  
     495                                        $data['link'] = '';  
     496                                break;  
    492497                                default: 
    493498 
     
    510515                        } // end switch on primary key type 
    511516 
    512  
    513517                        $data['track']  = $key+1; 
    514518 
  • trunk/modules/localplay/mpd.controller.php

    r1728 r1730  
    314314         * This deletes the entire MPD playlist... nuff said 
    315315         */ 
    316         function clear_playlist() {  
     316        public function clear_playlist() {  
    317317 
    318318                if (is_null($this->_mpd->PLClear())) { return false; } 
     
    327327         * take any arguments 
    328328         */ 
    329         function play() {  
     329        public function play() {  
    330330 
    331331                if (is_null($this->_mpd->Play())) { return false; }  
     
    339339         * any arguments 
    340340         */ 
    341         function stop() {  
     341        public function stop() {  
    342342 
    343343                if (is_null($this->_mpd->Stop())) { return false; }  
     
    350350         * This tells MPD to skip to the specified song 
    351351         */ 
    352         function skip($song) {  
     352        public function skip($song) {  
    353353 
    354354                if (is_null($this->_mpd->SkipTo($song))) { return false; } 
     
    360360         * This tells MPD to increase the volume by 5 
    361361         */ 
    362         function volume_up() {  
     362        public function volume_up() {  
    363363 
    364364                if (is_null($this->_mpd->AdjustVolume('5'))) { return false; }  
     
    370370         * This tells MPD to decrese the volume by 5 
    371371         */ 
    372         function volume_down() {  
     372        public function volume_down() {  
    373373 
    374374                if (is_null($this->_mpd->AdjustVolume('-5'))) { return false; } 
     
    381381         * This just tells MPD to skip to the next song  
    382382         */ 
    383         function next() {  
     383        public function next() {  
    384384 
    385385                if (is_null($this->_mpd->Next())) { return false; }  
     
    392392         * This just tells MPD to skip to the prev song 
    393393         */ 
    394         function prev() {  
     394        public function prev() {  
    395395 
    396396                if (is_null($this->_mpd->Previous())) { return false; }  
     
    403403         * This tells MPD to pause the current song  
    404404         */ 
    405         function pause() {  
     405        public function pause() {  
    406406                 
    407407                if (is_null($this->_mpd->Pause())) { return false; }  
     
    415415        * This tells MPD to set the volume to the parameter 
    416416        */ 
    417       function volume($volume) { 
     417        public function volume($volume) { 
    418418 
    419419               if (is_null($this->_mpd->SetVolume($volume))) { return false; } 
     
    426426        * This tells MPD to set the repeating the playlist (i.e. loop) to either on or off 
    427427        */ 
    428       function repeat($state) { 
     428        public function repeat($state) { 
    429429         
    430430                if (is_null($this->_mpd->SetRepeat($state))) { return false; } 
     
    432432 
    433433       } // repeat 
    434  
    435434 
    436435       /** 
     
    438437        * This tells MPD to turn on or off the playing of songs from the playlist in random order 
    439438        */ 
    440        function random($onoff) { 
     439       public function random($onoff) { 
    441440 
    442441               if (is_null($this->_mpd->SetRandom($onoff))) { return false; } 
     
    449448        * This tells MPD to move song from SrcPos to DestPos 
    450449        */ 
    451        function move($SrcPos, $DestPos) { 
     450       public function move($SrcPos, $DestPos) { 
    452451 
    453452                if (is_null($this->_mpd->PLMoveTrack($SrcPos, $DestPos))) { return false; } 
  • trunk/server/index.ajax.php

    r1720 r1730  
    2727switch ($_REQUEST['action']) {  
    2828        case 'random_albums':  
    29                 $albums = get_random_albums('6');  
     29                $albums = Album::get_random_albums('6');  
    3030                if (count($albums)) {  
    3131                        ob_start();  
  • trunk/templates/show_album_art.inc.php

    r1692 r1730  
    3434                $key = $i*4+$j; 
    3535                $image_url = Config::get('web_path') . '/image.php?type=session&amp;image_index=' . $key;  
    36                 $dimensions = Core::image_dimensions(get_image_from_source($_SESSION['form']['images'][$key]));  
     36                $dimensions = Core::image_dimensions(Album::get_image_from_source($_SESSION['form']['images'][$key]));  
    3737                if (!isset($images[$key])) { echo "<td>&nbsp;</td>\n"; }  
    3838                else {  
  • trunk/templates/sidebar_modules.inc.php

    r1608 r1730  
    3939  <li><h4><?php echo _('Information'); ?></h4> 
    4040    <ul class="sb3" id="sb_home_info"> 
    41       <li id="sb_home_info_CurrentlyPlaying"><a href="<?php echo $web_path; ?>/index.php"><?php echo _('Currently Playing'); ?></a></li> 
    4241      <li id="sb_home_info_Statistics"><a href="<?php echo $web_path; ?>/stats.php"><?php echo _('Statistics'); ?></a></li> 
    4342      <li id="sb_home_info_AddStationRadio"><a href="<?php echo $web_path; ?>/radio.php?action=show_create"><?php echo _('Add Radio Station'); ?></a></li>