本文整理汇总了PHP中Zend_Locale_Format类的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Locale_Format类的具体用法?PHP Zend_Locale_Format怎么用?PHP Zend_Locale_Format使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Zend_Locale_Format类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: smarty_modifier_number
/**
* Returns a number in local specific format.
*
* @link http://framework.zend.com/manual/de/zend.locale.parsing.html
* @param int|float $value
* @param array $format
* @return mixed
*/
function smarty_modifier_number($value, $format = array())
{
if (empty($format['locale'])) {
$format['locale'] = Enlight_Application::Instance()->Locale();
}
return Zend_Locale_Format::toNumber($value, $format);
}
示例2: get
/**
* Return a value for get, using some validations from the table data.
*
* @param string $type Type of field.
* @param mixed $value Value to transform.
*
* @return mixed Value of the var.
*/
public static function get($type, $value)
{
switch ($type) {
case 'float':
$value = Zend_Locale_Format::toFloat($value, array('precision' => 2));
break;
case 'time':
if (!empty($value)) {
$value = date("H:i:s", Phprojekt_Converter_Time::utcToUser($value));
}
break;
case 'datetime':
case 'timestamp':
if (!empty($value)) {
$value = date("Y-m-d H:i:s", Phprojekt_Converter_Time::utcToUser($value));
}
break;
case 'text':
// Get html only if the text contain some html code
if (preg_match("/([\\<])([^\\>]{1,})*([\\>])/i", $value)) {
$value = stripslashes($value);
}
break;
}
return $value;
}
示例3: createForm
public function createForm($id_hopdong)
{
$kh = new Model_Hopdong();
$hopdong = $kh->getWhereIdHopDong($id_hopdong);
$this->setDisableLoadDefaultDecorators(true);
$this->setDecorators(array(array('ViewScript', array('viewScript' => 'formnoindex/hopdong_layout.phtml')), 'Form'));
$data = new My_Data();
$opMau = $data->getOptionMau();
$opLoaiVai = $data->getOptionLoaiVai();
$opNCC = $data->getOptionNCC();
$tenhopdong = $this->createElement('text', 'tenhopdong', array('decorators' => array('ViewHelper')));
$mota = $this->createElement('text', 'mota', array('decorators' => array('ViewHelper')));
$ngayky = $this->createElement('text', 'ngayky', array('decorators' => array('ViewHelper')));
$sotansoi = $this->createElement('text', 'sotansoi', array('decorators' => array('ViewHelper')));
$thanhtien = $this->createElement('text', 'thanhtien', array('decorators' => array('ViewHelper')));
$mamau = $this->createElement('select', 'mamau', array('multioptions' => $opMau, 'decorators' => array('ViewHelper')));
$maloaivai = $this->createElement('select', 'maloaivai', array('multioptions' => $opLoaiVai, 'decorators' => array('ViewHelper')));
$manhacungcap = $this->createElement('select', 'manhacungcap', array('multioptions' => $opNCC, 'decorators' => array('ViewHelper')));
$them = $this->createElement('submit', 'them', array('decorators' => array('ViewHelper'), 'label' => 'Chỉnh sửa'));
$mydate = Zend_Locale_Format::getDate($hopdong['NgayKy'], array("date_format" => "yyyy.MM.dd"));
$date_str = $mydate['day'] . "/" . $mydate['month'] . "/" . $mydate['year'];
$tenhopdong->setAttrib('class', 'formEdit')->setValue($hopdong['TenHopDong']);
$mota->setAttrib('class', 'formEdit')->setValue($hopdong['MoTa']);
$ngayky->setAttrib('class', 'formEdit')->setValue($date_str);
$sotansoi->setAttrib('class', 'formEdit')->setValue($hopdong['SoTanSoi']);
$thanhtien->setAttrib('class', 'formEdit')->setValue($hopdong['ThanhTien']);
$mamau->setAttrib('class', 'formEdit')->setValue($hopdong['MaMau']);
$maloaivai->setAttrib('class', 'formEdit')->setValue($hopdong['MaLoaiVai']);
$manhacungcap->setAttrib('class', 'formEdit')->setValue($hopdong['MaNhaCungCap']);
$this->addElement($tenhopdong)->addElement($mota)->addElement($ngayky)->addElement($sotansoi)->addElement($thanhtien)->addElement($mamau)->addElement($maloaivai)->addElement($manhacungcap)->addElement($them);
}
示例4: startLocale
protected function startLocale()
{
require_once "Zend/Translate.php";
// silenciando strict até arrumar zend_locale
date_default_timezone_set("America/Sao_Paulo");
$i18n = new Zend_Translate('gettext', $this->config->system->path->base . '/lang/pt_BR.mo', 'pt_BR');
Zend_Registry::set('i18n', $i18n);
$translation_files = $this->config->system->path->base . "/lang/";
foreach (scandir($translation_files) as $filename) {
// Todos os arquivos .php devem ser classes de descrição de modulos
if (preg_match("/.*\\.mo\$/", $filename)) {
$translation_id = basename($filename, '.mo');
if ($translation_id != "pt_BR") {
$i18n->addTranslation($translation_files . "/{$filename}", $translation_id);
}
}
}
require_once "Zend/Locale.php";
if (Zend_Locale::isLocale($this->config->system->locale)) {
$locale = $this->config->system->locale;
} else {
$locale = "pt_BR";
}
Zend_Registry::set('Zend_Locale', new Zend_Locale($locale));
Zend_Locale::setDefault($locale);
Zend_Locale_Format::setOptions(array("locale" => $locale));
$i18n->setLocale($locale);
Zend_Registry::set("Zend_Translate", $i18n);
$zend_validate_translator = new Zend_Translate_Adapter_Array($this->config->system->path->base . "/lang/Zend_Validate/{$locale}/Zend_Validate.php", $locale);
Zend_Validate_Abstract::setDefaultTranslator($zend_validate_translator);
}
示例5: dataValue
/**
* extracts the
* @return type
*/
public function dataValue()
{
require_once THIRDPARTY_PATH . "/Zend/Locale/Format.php";
$locale = new Zend_Locale(i18n::get_locale());
$number = Zend_Locale_Format::getNumber($this->value, array('locale' => $locale));
return $number;
}
示例6: _getValueToSaveFromPostData
protected function _getValueToSaveFromPostData($postData)
{
$ret = parent::_getValueToSaveFromPostData($postData);
$l = $this->_floatValidator->getLocale();
$ret = Zend_Locale_Format::getNumber($ret, array('locale' => $l));
return $ret;
}
示例7: format
/**
* Formats a given value
* @see library/Bvb/Grid/Formatter/Bvb_Grid_Formatter_FormatterInterface::format()
*/
public function format($value)
{
if (!is_numeric($value)) {
return $value;
}
return Zend_Locale_Format::toNumber($value, $this->_options);
}
示例8: getUserDate
/**
* return date in user timezone
*/
public function getUserDate()
{
// get user session
$session = new Zend_Session_Namespace('user');
// return date with user timezone in locale format
return $this->getDate($session->timezone)->toString(Zend_Locale_Format::getDateTimeFormat($session->language));
}
示例9: _createRowObject
/**
* Converts map array to microdata Object
*
* @param array $map map array returned by the generator
* @return null|Varien_Object
*/
protected function _createRowObject($map)
{
if (empty($map['price']) || empty($map['availability']) || empty($map['title'])) {
return null;
}
$microdata = new Varien_Object();
$microdata->setName($map['title']);
$microdata->setId($map['id']);
if (!empty($map['sale_price'])) {
$price = $map['sale_price'];
} else {
$price = $map['price'];
}
$microdata->setPrice(Zend_Locale_Format::toNumber($price, array('precision' => 2, 'number_format' => '#0.00')));
$microdata->setCurrency(Mage::app()->getStore()->getCurrentCurrencyCode());
if ($map['availability'] == 'in stock') {
$microdata->setAvailability('http://schema.org/InStock');
} else {
$microdata->setAvailability('http://schema.org/OutOfStock');
}
if (array_key_exists('condition', $map)) {
if (strcasecmp('new', $map['condition']) == 0) {
$microdata->setCondition('http://schema.org/NewCondition');
} else {
if (strcasecmp('used', $map['condition']) == 0) {
$microdata->setCondition('http://schema.org/UsedCondition');
} else {
if (strcasecmp('refurbished', $map['condition']) == 0) {
$microdata->setCondition('http://schema.org/RefurbishedCondition');
}
}
}
}
return $microdata;
}
示例10: getAnualPercentageRate
public function getAnualPercentageRate($format = true)
{
$s = Zend_Locale_Format::toNumber($this->_anualPercentageRate, array('precision' => 2));
if ($format) {
return $s . '%';
} else {
return $s;
}
}
示例11: getForm
protected function getForm()
{
// Create object Snep_Form
$form = new Snep_Form();
// Set form action
$form->setAction($this->getFrontController()->getBaseUrl() . '/services-report/index');
$form_xml = new Zend_Config_Xml('./modules/default/forms/services_report.xml');
$config = Zend_Registry::get('config');
$period = new Snep_Form_SubForm($this->view->translate("Period"), $form_xml->period);
$validatorDate = new Zend_Validate_Date(Zend_Locale_Format::getDateFormat(Zend_Registry::get('Zend_Locale')));
$locale = Snep_Locale::getInstance()->getLocale();
$now = Zend_Date::now();
if ($locale == 'en_US') {
$now = $now->toString('YYYY-MM-dd HH:mm');
} else {
$now = $now->toString('dd/MM/YYYY HH:mm');
}
$yesterday = Zend_Date::now()->subDate(1);
$initDay = $period->getElement('init_day');
$initDay->setValue($now);
//$initDay->addValidator($validatorDate);
$tillDay = $period->getElement('till_day');
$tillDay->setValue($now);
//$tillDay->addValidator($validatorDate);
$form->addSubForm($period, "period");
$exten = new Snep_Form_SubForm($this->view->translate("Extensions"), $form_xml->exten);
$groupLib = new Snep_GruposRamais();
$groupsTmp = $groupLib->getAll();
$groupsData = array();
foreach ($groupsTmp as $key => $group) {
switch ($group['name']) {
case 'administrator':
$groupsData[$this->view->translate('Administrators')] = $group['name'];
break;
case 'users':
$groupsData[$this->view->translate('Users')] = $group['name'];
break;
case 'all':
$groupsData[$this->view->translate('All')] = $group['name'];
break;
default:
$groupsData[$group['name']] = $group['name'];
}
}
$selectGroup = $exten->getElement('group_select');
$selectGroup->addMultiOption(null, '----');
foreach ($groupsData as $key => $value) {
$selectGroup->addMultiOption($value, $key);
}
$selectGroup->setAttrib('onSelect', "enableField('exten-group_select', 'exten-exten_select');");
$form->addSubForm($exten, "exten");
$service = new Snep_Form_SubForm($this->view->translate("Services"), $form_xml->service);
$form->addSubForm($service, "service");
$form->getElement('submit')->setLabel($this->view->translate("Show Report"));
$form->removeElement("cancel");
return $form;
}
示例12: getFormattedTaxRate
/**
* Retrieves formatted string of tax rate for user output
*
* @return string
*/
public function getFormattedTaxRate()
{
if ($this->getTaxRate() === null || $this->getProduct()->getTypeId() == 'bundle') {
return '';
}
$locale = Mage::app()->getLocale()->getLocaleCode();
$taxRate = Zend_Locale_Format::toFloat($this->getTaxRate(), array('locale' => $locale));
return $this->__('%s%%', $taxRate);
}
示例13: isValid
/**
* Defined by Zend_Validate_Interface
*
* Returns true if and only if $value is a floating-point value
*
* @todo http://framework.zend.com/issues/browse/ZF-2895
* @param string $value
* @return boolean
*/
public function isValid($value)
{
$valueString = (string) $value;
$this->_setValue($valueString);
if (!Zend_Locale_Format::isFloat($valueString, $this->_options)) {
$this->_error();
return false;
}
return true;
}
示例14: dataValue
/**
* Extracts the number value from the localised string value
*
* @return string number value
*/
public function dataValue()
{
require_once "Zend/Locale/Format.php";
if (!$this->isNumeric()) {
return 0;
}
$locale = new Zend_Locale($this->getLocale());
$number = Zend_Locale_Format::getNumber($this->clean($this->value), array('locale' => $locale));
return $number;
}
示例15: LocalizedToNormalized
public function LocalizedToNormalized($value)
{
if (substr(Mage::app()->getLocale()->getLocaleCode(), 0, 2) != 'en') {
$dateFormatIso = Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT);
} else {
$dateFormatIso = Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_LONG);
}
$_options = array('locale' => Mage::app()->getLocale()->getLocaleCode(), 'date_format' => $dateFormatIso, 'precision' => null);
return Zend_Locale_Format::getDate($value, $_options);
}