public function save() { $value_changed = $this->getValue() != $this->getOrigValue(); if (stripos($this->getValue(), "image/png;base64") !== false) { $data = substr($this->getValue(), strpos($this->getValue(), ",") + 1); $data = str_replace(' ', '+', $data); $data = base64_decode($data); $ext = $this->getCode() == "favicon" ? ".ico" : ".png"; $filename = $this->getCode() . $ext; $filepath = Core_Model_Directory::getBasePathTo("images/default"); if (!is_dir($filepath)) { mkdir($filepath, 0777, true); } if (!is_writable($filepath)) { throw new Exception($this->_("The folder /images/default is not writable.")); } file_put_contents("{$filepath}/{$filename}", $data); $this->setValue("/images/default/{$this->getCode()}.{$ext}"); } parent::save(); if ($this->getCode() == "system_timezone" && $value_changed) { $config = new self(); $config->find("system_territory", "code"); $value = $this->getValue(); $territories = Zend_Registry::get("Zend_Locale")->getTranslationList('TerritoryToTimezone'); $territory = $value && !empty($territories[$value]) ? $territories[$value] : null; $data = array("code" => "system_territory", "value" => $territory); $config->addData($data)->save(); } }
public function __construct($params = array()) { parent::__construct($params); $this->_db_table = 'Rss_Model_Db_Table_Feed'; return $this; }