00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 class Mage_Adminhtml_Model_System_Config_Backend_Admin_Custom extends Mage_Core_Model_Config_Data
00036 {
00037 const CONFIG_SCOPE = 'stores';
00038 const CONFIG_SCOPE_ID = 0;
00039
00040 const XML_PATH_UNSECURE_BASE_URL = 'web/unsecure/base_url';
00041 const XML_PATH_SECURE_BASE_URL = 'web/secure/base_url';
00042
00043 protected function _beforeSave()
00044 {
00045 $value = $this->getValue();
00046
00047 if (!empty($value) && substr($value, -2) !== '}}') {
00048 $value = rtrim($value, '/').'/';
00049 }
00050
00051 $this->setValue($value);
00052 return $this;
00053 }
00054
00055 public function _afterSave()
00056 {
00057 $useCustomUrl = $this->getData('groups/url/fields/use_custom/value');
00058 $value = $this->getValue();
00059
00060 if ($useCustomUrl == 1 && empty($value)) {
00061 return $this;
00062 }
00063
00064 if ($useCustomUrl == 1) {
00065 Mage::getConfig()->saveConfig(self::XML_PATH_SECURE_BASE_URL, $value, self::CONFIG_SCOPE, self::CONFIG_SCOPE_ID);
00066 Mage::getConfig()->saveConfig(self::XML_PATH_UNSECURE_BASE_URL, $value, self::CONFIG_SCOPE, self::CONFIG_SCOPE_ID);
00067 }
00068 else {
00069 Mage::getConfig()->deleteConfig(self::XML_PATH_SECURE_BASE_URL, self::CONFIG_SCOPE, self::CONFIG_SCOPE_ID);
00070 Mage::getConfig()->deleteConfig(self::XML_PATH_UNSECURE_BASE_URL, self::CONFIG_SCOPE, self::CONFIG_SCOPE_ID);
00071 }
00072
00073 return $this;
00074 }
00075 }