Assembla home | Assembla project page
 

Changeset 220

Show
Ignore:
Timestamp:
04/08/08 18:40:06 (8 months ago)
Author:
Slynderdale
Message:

Fixed up Set.php to behave more like the built in INI parsing routines in PHP. This is a temp fix until the new Config Util class gets implemented.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/Phergie/Plugin/Set.php

    r217 r220  
    4040                $this->setIni($var, $this->parseIniValue($value)); 
    4141            } 
     42            $this->doNotice($user, 'Updated Setting: ' . $var . ' = ' . $this->getIni($var)); 
    4243            // Save ini file 
    4344            file_put_contents(PHERGIE_INI_PATH, $contents); 
     
    6768        $new = trim($new, "\" '"); 
    6869        $old = trim($old, "\" \n\r"); 
     70 
    6971        if ($append && !empty($old)) { 
    7072            return '"' . $old . ', ' . $new . '"'; 
    7173        } 
     74 
    7275        if (is_numeric($new)) { 
    7376            return $new; 
    7477        } 
    75         switch (strtolower($new)) { 
    76             case 'true': 
    77             case 'false': 
    78             case 'on': 
    79             case 'off': 
    80             case '': 
    81                 return $new; 
    82             default: 
    83                 return '"' . $new . '"'; 
     78 
     79        if ($this->parseIniValue($new) != $new) { 
     80            return (strtolower($new) != 'null' ? $new : ''); 
     81        } else { 
     82            return '"' . $new . '"'; 
    8483        } 
    8584    } 
     
    9089    protected function parseIniValue($value) 
    9190    { 
    92         $value = trim($value, '" '); 
     91        $value = trim($value); 
     92        if (strpos($value, ':') !== false) { 
     93            return $value; 
     94        } 
     95 
     96        $const = get_defined_constants(); 
     97 
    9398        switch (strtolower($value)) { 
    9499            case 'true': 
     100            case 'yes': 
    95101            case 'on': 
    96102            case '1': 
    97                 return '1'; 
     103                $return = '1'; 
     104            break; 
    98105            case 'false': 
     106            case 'no': 
    99107            case 'off': 
    100108            case '0': 
    101109            case '': 
    102                 return ''; 
     110                $return = ''; 
     111            break; 
     112            case 'null': 
     113                $return = null; 
     114            break; 
    103115            default: 
    104                 return $value; 
     116                $return = (isset($const[$value]) ? $const[$value] : $value); 
     117            break; 
    105118        } 
     119        unset($const, $value); 
     120 
     121        return $return; 
    106122    } 
    107123}