Public Member Functions | |
__construct () | |
setConfigData ($data) | |
getConfigData () | |
install () | |
getFormData () | |
replaceTmpInstallDate ($date=null) | |
replaceTmpEncryptKey ($key=null) | |
Public Attributes | |
const | TMP_INSTALL_DATE_VALUE = 'd-d-d-d-d' |
const | TMP_ENCRYPT_KEY_VALUE = 'k-k-k-k-k' |
Protected Member Functions | |
_checkHostsInfo ($data) | |
_checkUrl ($url, $secure=false) | |
Protected Attributes | |
$_localConfigFile | |
$_configData = array() |
Definition at line 33 of file Config.php.
__construct | ( | ) |
Definition at line 47 of file Config.php.
00048 { 00049 $this->_localConfigFile = Mage::getBaseDir('etc').DS.'local.xml'; 00050 }
_checkHostsInfo | ( | $ | data | ) | [protected] |
Definition at line 129 of file Config.php.
00130 { 00131 $url = $data['protocol'] . '://' . $data['host'] . ':' . $data['port'] . $data['base_path']; 00132 $surl= $data['secure_protocol'] . '://' . $data['secure_host'] . ':' . $data['secure_port'] . $data['secure_base_path']; 00133 00134 $this->_checkUrl($url); 00135 $this->_checkUrl($surl, true); 00136 00137 return $this; 00138 }
_checkUrl | ( | $ | url, | |
$ | secure = false | |||
) | [protected] |
Definition at line 140 of file Config.php.
00141 { 00142 $prefix = $secure ? 'install/wizard/checkSecureHost/' : 'install/wizard/checkHost/'; 00143 $client = new Varien_Http_Client($url.'index.php/'.$prefix); 00144 try { 00145 $response = $client->request('GET'); 00146 /* @var $responce Zend_Http_Response */ 00147 $body = $response->getBody(); 00148 } 00149 catch (Exception $e){ 00150 $this->_getInstaller()->getDataModel()->addError(Mage::helper('install')->__('Url "%s" is not accessible', $url)); 00151 throw $e; 00152 } 00153 00154 if ($body != Mage_Install_Model_Installer::INSTALLER_HOST_RESPONSE) { 00155 $this->_getInstaller()->getDataModel()->addError(Mage::helper('install')->__('Url "%s" is invalid', $url)); 00156 Mage::throwException(Mage::helper('install')->__('This Url is invalid')); 00157 } 00158 return $this; 00159 }
getConfigData | ( | ) |
getFormData | ( | ) |
Definition at line 105 of file Config.php.
00106 { 00107 $uri = Zend_Uri::factory(Mage::getBaseUrl('web')); 00108 00109 $baseUrl = $uri->getUri(); 00110 if ($uri->getScheme()!=='https') { 00111 $uri->setPort(null); 00112 $baseSecureUrl = str_replace('http://', 'https://', $uri->getUri()); 00113 } else { 00114 $baseSecureUrl = $uri->getUri(); 00115 } 00116 00117 $data = Mage::getModel('varien/object') 00118 ->setDbHost('localhost') 00119 ->setDbName('magento') 00120 ->setDbUser('root') 00121 ->setDbPass('') 00122 ->setSecureBaseUrl($baseSecureUrl) 00123 ->setUnsecureBaseUrl($baseUrl) 00124 ->setAdminFrontname('admin') 00125 ; 00126 return $data; 00127 }
install | ( | ) |
Definition at line 65 of file Config.php.
00066 { 00067 $data = $this->getConfigData(); 00068 foreach (Mage::getModel('core/config')->getDistroServerVars() as $index=>$value) { 00069 if (!isset($data[$index])) { 00070 $data[$index] = $value; 00071 } 00072 } 00073 00074 if (isset($data['unsecure_base_url'])) { 00075 $data['unsecure_base_url'] .= substr($data['unsecure_base_url'],-1) != '/' ? '/' : ''; 00076 if (!$this->_getInstaller()->getDataModel()->getSkipBaseUrlValidation()) { 00077 $this->_checkUrl($data['unsecure_base_url']); 00078 } 00079 } 00080 if (isset($data['secure_base_url'])) { 00081 $data['secure_base_url'] .= substr($data['secure_base_url'],-1) != '/' ? '/' : ''; 00082 00083 if (!empty($data['use_secure']) 00084 && !$this->_getInstaller()->getDataModel()->getSkipUrlValidation()) { 00085 $this->_checkUrl($data['secure_base_url']); 00086 } 00087 } 00088 00089 $data['date'] = self::TMP_INSTALL_DATE_VALUE; 00090 $data['key'] = self::TMP_ENCRYPT_KEY_VALUE; 00091 $data['var_dir'] = $data['root_dir'] . '/var'; 00092 00093 $data['use_script_name'] = isset($data['use_script_name']) ? 'true' : 'false'; 00094 00095 $this->_getInstaller()->getDataModel()->setConfigData($data); 00096 00097 $template = file_get_contents(Mage::getBaseDir('etc').DS.'local.xml.template'); 00098 foreach ($data as $index=>$value) { 00099 $template = str_replace('{{'.$index.'}}', '<![CDATA['.$value.']]>', $template); 00100 } 00101 file_put_contents($this->_localConfigFile, $template); 00102 chmod($this->_localConfigFile, 0777); 00103 }
replaceTmpEncryptKey | ( | $ | key = null |
) |
Definition at line 173 of file Config.php.
00174 { 00175 if (!$key) { 00176 $key = md5(time()); 00177 } 00178 $localXml = file_get_contents($this->_localConfigFile); 00179 $localXml = str_replace(self::TMP_ENCRYPT_KEY_VALUE, $key, $localXml); 00180 file_put_contents($this->_localConfigFile, $localXml); 00181 00182 return $this; 00183 }
replaceTmpInstallDate | ( | $ | date = null |
) |
Definition at line 161 of file Config.php.
00162 { 00163 if (is_null($date)) { 00164 $date = date('r'); 00165 } 00166 $localXml = file_get_contents($this->_localConfigFile); 00167 $localXml = str_replace(self::TMP_INSTALL_DATE_VALUE, date('r'), $localXml); 00168 file_put_contents($this->_localConfigFile, $localXml); 00169 00170 return $this; 00171 }
setConfigData | ( | $ | data | ) |
Definition at line 52 of file Config.php.
00053 { 00054 if (is_array($data)) { 00055 $this->_configData = $data; 00056 } 00057 return $this; 00058 }
$_configData = array() [protected] |
Definition at line 45 of file Config.php.
$_localConfigFile [protected] |
Definition at line 43 of file Config.php.
const TMP_ENCRYPT_KEY_VALUE = 'k-k-k-k-k' |
Definition at line 36 of file Config.php.
const TMP_INSTALL_DATE_VALUE = 'd-d-d-d-d' |
Definition at line 35 of file Config.php.