public function __() { $args = func_get_args(); if (isset($args[0]) && is_array($args[0]) && count($args) == 1) { $args = $args[0]; } $message = array_shift($args); if ($message instanceof OS_Message) { $args = $message->args; $message = $message->message; } $output = parent::__($message); /*if (true) { $translations = @file_get_contents('translations.os2'); $translations = eval('return '.$translations.';'); if (!is_array($translations)) $translations = array(); $file = 'NC'; $line = 'NC'; $backtrace = debug_backtrace(); foreach ($backtrace as $trace) { if (!isset($trace['function'])) continue; if (substr($trace['function'], strlen($trace['function'])-2, strlen($trace['function']))=='__') { $file = ltrim(str_replace(Mage::getBaseDir(), '', $trace['file']), '/'); $line = $trace['line']; continue; } //$file = ltrim(str_replace(Mage::getBaseDir(), '', $trace['file']), '/'); //echo $file.', '.$trace['function'].'(), '.$line.', '.$message.'<br/>'; break; } $translations[Mage::app()->getLocale()->getLocaleCode()][$file][$message] = $output; ksort($translations[Mage::app()->getLocale()->getLocaleCode()]); file_put_contents('translations.os2', var_export($translations, true)); }*/ if (count($args) == 0) { $result = $output; } else { if (!isset($this->_translate_inline)) { $this->_translate_inline = Mage::getSingleton('core/translate')->getTranslateInline(); } if ($this->_translate_inline) { $parts = explode('}}{{', $output); $parts[0] = vsprintf($parts[0], $args); $result = implode('}}{{', $parts); } else { $result = vsprintf($output, $args); } } return $result; }
/** * Create theme customization * * @param Mage_Core_Model_Theme $theme * @return Mage_Core_Model_Theme */ public function createThemeCustomization($theme) { $themeCopyCount = $this->_getThemeCustomizations()->addFilter('parent_id', $theme->getId())->count(); $themeData = $theme->getData(); $themeData['parent_id'] = $theme->getId(); $themeData['theme_id'] = null; $themeData['theme_path'] = null; $themeData['theme_title'] = $theme->getThemeTitle() . ' - ' . $this->_helper->__('Copy') . ' #' . ($themeCopyCount + 1); /** @var $themeCustomization Mage_Core_Model_Theme */ $themeCustomization = $this->_themeFactory->create()->setData($themeData); $themeCustomization->createPreviewImageCopy()->save(); return $themeCustomization; }
/** * Save file to storage * * @param string $filePath * @param string $content * @param bool $overwrite * @return bool */ public function saveFile($filePath, $content, $overwrite = false) { if (strpos($filePath, $this->getMediaBaseDirectory()) !== 0) { $filePath = $this->getMediaBaseDirectory() . DS . $filePath; } try { if (!$this->_filesystem->isFile($filePath) || $overwrite && $this->_filesystem->delete($filePath)) { $this->_filesystem->write($filePath, $content); return true; } } catch (Magento_Filesystem_Exception $e) { $this->_logger->log($e->getMessage()); Mage::throwException($this->_helper->__('Unable to save file: %s', $filePath)); } return false; }
/** * Validate value by attribute input validation rule * * @param string $value * @return string */ protected function _validateInputRule($value) { // skip validate empty value if (empty($value)) { return true; } $label = $this->getAttribute()->getStoreLabel(); $validateRules = $this->getAttribute()->getValidateRules(); if (!empty($validateRules['input_validation'])) { switch ($validateRules['input_validation']) { case 'alphanumeric': $validator = new Zend_Validate_Alnum(true); $validator->setMessage($this->_translationHelper->__('"%s" invalid type entered.', $label), Zend_Validate_Alnum::INVALID); $validator->setMessage($this->_translationHelper->__('"%s" has not only alphabetic and digit characters.', $label), Zend_Validate_Alnum::NOT_ALNUM); $validator->setMessage($this->_translationHelper->__('"%s" is an empty string.', $label), Zend_Validate_Alnum::STRING_EMPTY); if (!$validator->isValid($value)) { return $validator->getMessages(); } break; case 'numeric': $validator = new Zend_Validate_Digits(); $validator->setMessage($this->_translationHelper->__('"%s" invalid type entered.', $label), Zend_Validate_Digits::INVALID); $validator->setMessage($this->_translationHelper->__('"%s" contains not only digit characters.', $label), Zend_Validate_Digits::NOT_DIGITS); $validator->setMessage($this->_translationHelper->__('"%s" is an empty string.', $label), Zend_Validate_Digits::STRING_EMPTY); if (!$validator->isValid($value)) { return $validator->getMessages(); } break; case 'alpha': $validator = new Zend_Validate_Alpha(true); $validator->setMessage($this->_translationHelper->__('"%s" invalid type entered.', $label), Zend_Validate_Alpha::INVALID); $validator->setMessage($this->_translationHelper->__('"%s" has not only alphabetic characters.', $label), Zend_Validate_Alpha::NOT_ALPHA); $validator->setMessage($this->_translationHelper->__('"%s" is an empty string.', $label), Zend_Validate_Alpha::STRING_EMPTY); if (!$validator->isValid($value)) { return $validator->getMessages(); } break; case 'email': /** $this->__("'%value%' appears to be a DNS hostname but the given punycode notation cannot be decoded") $this->__("Invalid type given. String expected") $this->__("'%value%' appears to be a DNS hostname but contains a dash in an invalid position") $this->__("'%value%' does not match the expected structure for a DNS hostname") $this->__("'%value%' appears to be a DNS hostname but cannot match against hostname schema for TLD '%tld%'") $this->__("'%value%' does not appear to be a valid local network name") $this->__("'%value%' does not appear to be a valid URI hostname") $this->__("'%value%' appears to be an IP address, but IP addresses are not allowed") $this->__("'%value%' appears to be a local network name but local network names are not allowed") $this->__("'%value%' appears to be a DNS hostname but cannot extract TLD part") $this->__("'%value%' appears to be a DNS hostname but cannot match TLD against known list") */ $validator = new Zend_Validate_EmailAddress(); $validator->setMessage($this->_translationHelper->__('"%s" invalid type entered.', $label), Zend_Validate_EmailAddress::INVALID); $validator->setMessage($this->_translationHelper->__('"%s" is not a valid email address.', $label), Zend_Validate_EmailAddress::INVALID_FORMAT); $validator->setMessage($this->_translationHelper->__('"%s" is not a valid hostname.', $label), Zend_Validate_EmailAddress::INVALID_HOSTNAME); $validator->setMessage($this->_translationHelper->__('"%s" is not a valid hostname.', $label), Zend_Validate_EmailAddress::INVALID_MX_RECORD); $validator->setMessage($this->_translationHelper->__('"%s" is not a valid hostname.', $label), Zend_Validate_EmailAddress::INVALID_MX_RECORD); $validator->setMessage($this->_translationHelper->__('"%s" is not a valid email address.', $label), Zend_Validate_EmailAddress::DOT_ATOM); $validator->setMessage($this->_translationHelper->__('"%s" is not a valid email address.', $label), Zend_Validate_EmailAddress::QUOTED_STRING); $validator->setMessage($this->_translationHelper->__('"%s" is not a valid email address.', $label), Zend_Validate_EmailAddress::INVALID_LOCAL_PART); $validator->setMessage($this->_translationHelper->__('"%s" exceeds the allowed length.', $label), Zend_Validate_EmailAddress::LENGTH_EXCEEDED); $validator->setMessage($this->_translationHelper->__("'%value%' appears to be an IP address, but IP addresses are not allowed"), Zend_Validate_Hostname::IP_ADDRESS_NOT_ALLOWED); $validator->setMessage($this->_translationHelper->__("'%value%' appears to be a DNS hostname but cannot match TLD against known list"), Zend_Validate_Hostname::UNKNOWN_TLD); $validator->setMessage($this->_translationHelper->__("'%value%' appears to be a DNS hostname but contains a dash in an invalid position"), Zend_Validate_Hostname::INVALID_DASH); $validator->setMessage($this->_translationHelper->__("'%value%' appears to be a DNS hostname but cannot match against hostname schema for TLD '%tld%'"), Zend_Validate_Hostname::INVALID_HOSTNAME_SCHEMA); $validator->setMessage($this->_translationHelper->__("'%value%' appears to be a DNS hostname but cannot extract TLD part"), Zend_Validate_Hostname::UNDECIPHERABLE_TLD); $validator->setMessage($this->_translationHelper->__("'%value%' does not appear to be a valid local network name"), Zend_Validate_Hostname::INVALID_LOCAL_NAME); $validator->setMessage($this->_translationHelper->__("'%value%' appears to be a local network name but local network names are not allowed"), Zend_Validate_Hostname::LOCAL_NAME_NOT_ALLOWED); $validator->setMessage($this->_translationHelper->__("'%value%' appears to be a DNS hostname but the given punycode notation cannot be decoded"), Zend_Validate_Hostname::CANNOT_DECODE_PUNYCODE); if (!$validator->isValid($value)) { return array_unique($validator->getMessages()); } break; case 'url': $parsedUrl = parse_url($value); if ($parsedUrl === false || empty($parsedUrl['scheme']) || empty($parsedUrl['host'])) { return array($this->_translationHelper->__('"%s" is not a valid URL.', $label)); } $validator = new Zend_Validate_Hostname(); if (!$validator->isValid($parsedUrl['host'])) { return array($this->_translationHelper->__('"%s" is not a valid URL.', $label)); } break; case 'date': $validator = new Zend_Validate_Date(Varien_Date::DATE_INTERNAL_FORMAT); $validator->setMessage($this->_translationHelper->__('"%s" invalid type entered.', $label), Zend_Validate_Date::INVALID); $validator->setMessage($this->_translationHelper->__('"%s" is not a valid date.', $label), Zend_Validate_Date::INVALID_DATE); $validator->setMessage($this->_translationHelper->__('"%s" does not fit the entered date format.', $label), Zend_Validate_Date::FALSEFORMAT); if (!$validator->isValid($value)) { return array_unique($validator->getMessages()); } break; } } return true; }
/** * Return labels collection for backend system configuration with empty value "No Theme" * * @return array */ public function getLabelsCollectionForSystemConfiguration() { return $this->getLabelsCollection($this->_helper->__('-- No Theme --')); }