Changeset 1728

Show
Ignore:
Timestamp:
08/31/08 08:39:40 (3 months ago)
Author:
vollmerk
Message:

massivly simplify parse_url() and make it so random urls show up correctly in the localplay playlist

Location:
trunk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/lib/class/localplay.abstract.php

    r1545 r1728  
    8989         * parse_url  
    9090         * This takes an Ampache URL and then returns the 'primary' part of it 
    91          * So that it's easier for localplay module sto return valid song information 
     91         * So that it's easier for localplay modules to return valid song information 
    9292         */ 
    9393        public function parse_url($url) {  
    9494 
    9595                // Define possible 'primary' keys 
    96                 $primary_array = array('song','demo_id');   
     96                $primary_array = array('song','demo_id','random');   
    9797 
    9898                // Delete everything before the first ?  
    9999                $file = preg_replace("/.*\?(.+)/",'$1',$url); 
    100100 
    101                 // Split on & symbol 
    102                 $data = explode("&",$file); 
     101                $variables = parse_url($url,PHP_URL_QUERY);  
     102                parse_str($variables,$data);  
    103103 
    104                 foreach ($data as $pair) {   
    105                         $elements = explode("=",$pair);  
    106                         $key = $elements['0']; 
    107                         $value = $elements['1']; 
    108                         $results[$key] = $value; 
    109  
    110                         if (in_array($key,$primary_array)) {  
    111                                 $primary = $key;  
    112                         }  
     104                foreach ($primary_array as $pkey) {  
     105                        if ($data[$pkey]) {  
     106                                $data['primary_key'] = $pkey;  
     107                                return $data;  
     108                        } 
    113109 
    114110                } // end foreach 
    115111 
    116                 $results['primary_key'] = $primary; 
    117  
    118                 return $results;  
     112                return $data; 
    119113 
    120114        } // parse_url  
  • trunk/modules/localplay/mpd.controller.php

    r1560 r1728  
    493493                                        $data['link']   = ''; 
    494494                                break;  
     495                                case 'random': 
     496                                        $data['name'] = _('Random') . ' - ' . scrub_out(ucfirst($url_data['type']));  
     497                                        $data['link'] = '';  
     498                                break; 
    495499                                default:  
    496500