Changeset 738 for trunk/Common/Config.php
- Timestamp:
- Apr 14, 2015, 10:20:16 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Common/Config.php
r593 r738 1 1 <?php 2 2 3 class Config 3 class Config 4 4 { 5 5 var $Data; 6 6 7 7 function __construct() 8 8 { 9 9 $this->Data = array(); 10 10 } 11 11 12 12 function ReadValue($Name) 13 13 { 14 15 16 17 18 19 20 21 return($Data[$Last]); 14 if(!is_array($Name)) $Name = explode('/', $Name); 15 $Last = array_pop($Name); 16 $Data = &$this->Data; 17 foreach($Name as $Item) 18 { 19 $Data = &$Data[$Item]; 20 } 21 return($Data[$Last]); 22 22 } 23 23 24 24 function WriteValue($Name, $Value) 25 25 { 26 27 28 29 30 31 32 26 if(!is_array($Name)) $Name = explode('/', $Name); 27 $Last = array_pop($Name); 28 $Data = &$this->Data; 29 foreach($Name as $Item) 30 { 31 $Data = &$Data[$Item]; 32 } 33 33 $Data[$Item] = $Value; 34 34 } 35 35 36 36 function LoadFromFile($FileName) 37 37 { 38 38 $ConfigData = array(); 39 39 include $FileName; 40 40 foreach($this->Data as $Index => $Item) 41 41 { 42 42 if(array_key_exits($Index, $ConfigData)) 43 43 $this->Data[$Index] = $ConfigData[$Index]; 44 44 } 45 } 46 45 } 46 47 47 function SaveToFile($FileName) 48 48 { 49 49 file_put_contents($FileName, "<?php \n\n\$ConfigData = ".var_export($this->Data, true).";\n"); 50 50 } 51 51 52 52 function GetAsArray() 53 53 { 54 54 return($this->Data); 55 55 } 56 56 }
Note:
See TracChangeset
for help on using the changeset viewer.