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(); } }
/** * * Initialize object * * @return class * **/ public static function init(array $data, array $option = array(), $environment = Environments::STAGING_URL) { # Instance. $self = new self(); # Validate data. $self->validateData($data); # Set Enviroment. $self->environment = $environment; $self->path = Operations::PREAUTHORIZATION_URL; # Configure extra data. if (isset($option['return_url']) and $option['return_url'] !== "") { $data['return_url'] = $option['return_url']; } else { $data['return_url'] = Config::get('return_url'); } if (isset($option['cancel_url']) and $option['cancel_url'] !== "") { $data['cancel_url'] = $option['cancel_url']; } else { $data['cancel_url'] = Config::get('cancel_url'); } # Attach data. foreach ($data as $key => $value) { $self->addData($key, $value); } # Generate token. $self->getToken('pre_authorization'); # Create operation array. $self->makeOperationObject(); return $self; }
/** * Creation of segment code with default values. Segment code = Segment Title. * @param string $segmentCode */ public function createNewSegment($segmentCode) { $newSegment = new self(); $data = array('code' => $segmentCode, 'title' => $segmentCode, 'default_store' => 0, 'default_category' => AW_Advancednewsletter_Helper_Data::ANY_CATEGORY_VALUE, 'display_in_store' => 0, 'display_in_category' => AW_Advancednewsletter_Helper_Data::ANY_CATEGORY_VALUE, 'frontend_visibility' => 0, 'checkout_visibility' => 0); try { $newSegment->addData($data)->save(); } catch (Exception $ex) { } }
public function getDummy() { $color = str_replace('#', '', $this->getApplication()->getBlock('tabbar')->getImageColor()); $option = new Application_Model_Option(); $option->find('newswall', 'code'); $dummy = new self(); $dummy->addData($option->getData())->setTabbarName('Sample')->setIsDummy(1)->setIsActive(1)->setIconUrl(Core_Model_Url::create("template/block/colorize", array('id' => $dummy->getIconId(), 'color' => $color)))->setId(0); return $dummy; }
/** * Create a tree hash from a content body * * @param string|resource|EntityBody $content Content to create a tree hash for * @param string $algorithm A valid hash algorithm name as returned by `hash_algos()` * * @return TreeHash */ public static function fromContent($content, $algorithm = self::DEFAULT_ALGORITHM) { $treeHash = new self($algorithm); // Read the data in 1MB chunks and add to tree hash $content = EntityBody::factory($content); while ($data = $content->read(Size::MB)) { $treeHash->addData($data); } // Pre-calculate hash $treeHash->getHash(); return $treeHash; }
public static function findKeysFor($provider_code) { if (empty(self::$__keys[$provider_code])) { $key = new self(); $provider = new Api_Model_Provider(); $provider->find($provider_code, 'code'); if (!$provider->getId()) { return $keys; } foreach ($provider->getKeys() as $tmp_key) { $key->addData($tmp_key->getKey(), $tmp_key->getValue()); } self::$__keys[$provider_code] = $key; } return self::$__keys[$provider_code]; }
public function update() { $last_id = $this->findLastId(); $url = 'http://www.tigerappcreator.com/en/front/notification/list/last_id/' . $last_id; try { if ($datas = @file_get_contents($url)) { $datas = Zend_Json::decode($datas); if (is_array($datas)) { foreach ($datas as $data) { $notif = new self(); $notif->addData($data)->save(); } } } } catch (Exception $e) { } }
/** * * Initialize object * * @return class * **/ public static function init(array $data, $environment = Environments::STAGING_URL) { # Instance. $self = new self(); # Validate data. $self->validateData($data); # Set Enviroment. $self->environment = $environment; $self->path = Operations::PREAUTHORIZATION_ROLLBACK_URL; # Attach data. foreach ($data as $key => $value) { $self->addData($key, $value); } # Generate token. $self->getToken('single_buy_rollback'); # Create operation array. $self->makeOperationObject(); return $self; }
/** * * Initialize object * * @return class * **/ public static function init(array $data, $environment = Environments::STAGING_URL) { # Instance. $self = new self(); # Validate data. $self->validateData($data); # Set Enviroment. $self->environment = $environment; $self->path = Operations::PREAUTHORIZATION_URL; # Configure extra data. $data['return_url'] = Config::get('return_url'); $data['cancel_url'] = Config::get('cancel_url'); # Attach data. foreach ($data as $key => $value) { $self->addData($key, $value); } # Generate token. $self->getToken('single_buy'); # Create operation array. $self->makeOperationObject(); return $self; }