00001 <?php 00028 require_once(FAREOFFICE_LIB_ROOT . 'General/Files.php'); 00029 require_once('SiteConfig.php'); 00030 require_once('DbConfig.php'); 00031 00035 class Config 00036 { 00040 public function Config() 00041 { 00042 $dbConfig = $this->getDbConfig(); 00043 00044 include(FAREOFFICE_LIB_ROOT . 'Settings.php'); 00045 } 00046 00053 public function setEnvironmentDir($name_) 00054 { 00055 $this->_environmentDir = rtrim($name_, '/') . '/'; 00056 } 00057 00064 public function getEnvironmentDir() 00065 { 00066 return $this->_environmentDir; 00067 } 00068 00076 public function getLogDir() 00077 { 00078 return $this->getEnvironmentDir() . 'Log/'; 00079 } 00080 00088 public function getSiteDir() 00089 { 00090 return $this->getEnvironmentDir() . 'Site/'; 00091 } 00092 00098 public function getSites() 00099 { 00100 if (!is_array($this->sites)) 00101 { 00102 $this->_sites = array(); 00103 foreach(fileList($this->getSiteDir(), 'DIR', FALSE) as $site) 00104 { 00105 $this->_sites[basename($site)] = new SiteConfig($site . '/'); 00106 } 00107 } 00108 return $this->_sites; 00109 } 00110 00116 public function getSite($siteName_) 00117 { 00118 $siteArr = $this->getSites(); 00119 return $siteArr[$siteName_]; 00120 } 00121 00136 public function getDBDSN($configName_) 00137 { 00138 return $this->getDbConfig()->getDSN($configName_); 00139 } 00140 00148 public function getDbConfig() 00149 { 00150 if (!is_object($this->dbConfig)) 00151 { 00152 $this->dbConfig = new DbConfig(); 00153 } 00154 00155 return $this->dbConfig; 00156 } 00157 00161 private $_environmentDir; 00162 00169 private $_dbConfig; 00170 00174 private $_sites; 00175 } 00176 00177 ?>