/** * Constructor. * @param mixed $locale locale ID (string) or CLocale instance */ public function __construct($locale) { if(is_string($locale)) $this->_locale=CLocale::getInstance($locale); else $this->_locale=$locale; }
/** * This function is here because we aren't creating a locale file for every client. * Thus we provide a fallback to "en". */ public function getLocale($localeID = null) { try { return parent::getLocale($localeID); } catch (Exception $e) { return CLocale::getInstance('en'); } }
/** * Set the locale to use for formatting values. * @param CLocale|string $locale an instance of CLocale or a locale ID */ public function setLocale($locale) { if (is_string($locale)) { $locale = CLocale::getInstance($locale); } $this->sizeFormat['decimalSeparator'] = $locale->getNumberSymbol('decimal'); $this->_locale = $locale; }
/** * Returns a key value map of the available languages, including the source * language, where the key is the locale and the value is the display name * @return array */ public static function getAvailableLanguages() { $locales = array('en'); $translations = new FilesystemIterator(Yii::app()->basePath . '/messages'); foreach ($translations as $fileInfo) { // Skip the .gitkeep file if ($fileInfo->isDir()) { $locales[] = $fileInfo->getFilename(); } } $languages = array(); foreach ($locales as $language) { $languages[$language] = CLocale::getInstance('en')->getLanguage($language); } return $languages; }
public function getLocale($localeID = null) { return CLocale::getInstance($localeID === null ? $this->getLanguage() : $localeID); }
if (!isset($this->breadcrumbs)) { $this->breadcrumbs = array('Grupocontactos' => array(Yii::t('app', 'index')), Yii::t('app', 'Manage')); } if (!isset($this->menu) || $this->menu === array()) { $this->menu = array(array('label' => Yii::t('app', 'List') . ' Grupocontacto', 'url' => array('index')), array('label' => Yii::t('app', 'Create') . ' Grupocontacto', 'url' => array('create'))); } Yii::app()->clientScript->registerScript('search', "\n\t\t\t\$('.search-button').click(function(){\n\t\t\t\t\$('.search-form').toggle();\n\t\t\t\treturn false;\n\t\t\t\t});\n\t\t\t\$('.search-form form').submit(function(){\n\t\t\t\t\$.fn.yiiGridView.update('grupocontacto-grid', {\ndata: \$(this).serialize()\n});\n\t\t\t\treturn false;\n\t\t\t\t});\n\t\t\t"); ?> <h1> <?php echo Yii::t('app', 'Manage'); ?> Grupocontactos</h1> <?php echo "<ul>"; foreach ($model->relations() as $key => $relation) { echo "<li>" . substr(str_replace("Relation", "", $relation[0]), 1) . " " . CHtml::link(Yii::t("app", $relation[1]), array($this->resolveRelationController($relation) . "/admin")) . " (" . $relation[2] . ")" . " </li>"; } echo "</ul>"; echo CHtml::link(Yii::t('app', 'Advanced Search'), '#', array('class' => 'search-button')); ?> <div class="search-form" style="display:none"> <?php $this->renderPartial('_search', array('model' => $model)); ?> </div> <?php $locale = CLocale::getInstance(Yii::app()->language); $this->widget('zii.widgets.grid.CGridView', array('id' => 'grupocontacto-grid', 'dataProvider' => $model->search(), 'filter' => $model, 'columns' => array('id', array('name' => 'contactoid', 'value' => 'CHtml::value($data,\'contacto.recordTitle\')', 'filter' => CHtml::listData(Contacto::model()->findAll(), 'contactoid', 'recordTitle')), array('name' => 'grupoid', 'value' => 'CHtml::value($data,\'grupo.nombre\')', 'filter' => CHtml::listData(Grupo::model()->findAll(), 'grupoid', 'nombre')), array('class' => 'CButtonColumn'))));
/** * @dataProvider providerGetTerritory */ public function testGetTerritory($ctorLocale, $methodLocale, $assertion) { $locale = CLocale::getInstance($ctorLocale); $this->assertEquals($assertion, $locale->getTerritory($methodLocale)); }
/** * Returns the supported SourceBans languages * * @return array the supported SourceBans languages */ public function getLanguages() { static $_data = array(); if (empty($_data)) { $basePath = Yii::app()->getMessages()->basePath; $folder = @opendir($basePath); while (($file = @readdir($folder)) !== false) { if ($file[0] === '.' || !is_dir($basePath . DIRECTORY_SEPARATOR . $file)) { continue; } $_data[$file] = CLocale::getInstance($file)->getLocaleDisplayName($file); if ($file !== Yii::app()->language) { $_data[$file] .= ' (' . Yii::app()->locale->getLocaleDisplayName($file) . ')'; } } closedir($folder); asort($_data); } return $_data; }
/** * @param $localeId * * @return array */ private function _processFrameworkData($localeId) { $wideMonthKeys = array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'); $abbreviatedMonthKeys = array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'); $wideWeekdayNameKeys = array('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'); $abbreviatedWeekdayNameKeys = array('Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'); $formattedFrameworkData = array(); $locale = \CLocale::getInstance($localeId); $formattedFrameworkData = array_merge($formattedFrameworkData, array_combine($wideMonthKeys, $locale->getMonthNames())); $formattedFrameworkData = array_merge($formattedFrameworkData, array_combine($abbreviatedMonthKeys, $locale->getMonthNames('abbreviated'))); $formattedFrameworkData = array_merge($formattedFrameworkData, array_combine($wideWeekdayNameKeys, $locale->getWeekDayNames())); $formattedFrameworkData = array_merge($formattedFrameworkData, array_combine($abbreviatedWeekdayNameKeys, $locale->getWeekDayNames('abbreviated'))); // Because sometimes Twig (ultimately PHP) will return 'pm' or 'am' and sometimes it will return 'PM' or 'AM' // and array indexes are case sensitive. $amName = $locale->getAMName(); $pmName = $locale->getPMName(); $formattedFrameworkData['AM'] = $amName; $formattedFrameworkData['am'] = $amName; $formattedFrameworkData['PM'] = $pmName; $formattedFrameworkData['pm'] = $pmName; return $formattedFrameworkData; }
protected static function resolveMergeTagToStandardOrRelatedAttribute($attributeAccessorString, $model, $language, $timeQualifier, $errorOnFirstMissing, $params) { $attributeName = strtok($attributeAccessorString, '->'); if (SpecialMergeTagsAdapter::isSpecialMergeTag($attributeName, $timeQualifier)) { return SpecialMergeTagsAdapter::resolve($attributeName, $model, $errorOnFirstMissing, $params); } else { if (!isset($model)) { return static::PROPERTY_NOT_FOUND; } elseif (!method_exists($model, 'isAttribute') || !$model->isAttribute($attributeName)) { if ($model instanceof Activity) { $metadata = $model::getMetadata(); $activityItemsModelClassNamesData = $metadata['Activity']['activityItemsModelClassNames']; foreach ($model->activityItems as $activityItem) { if (ucfirst($attributeName) == get_class($activityItem)) { $attributeAccessorString = str_replace($attributeName . '->', '', $attributeAccessorString); return static::resolveMergeTagToStandardOrRelatedAttribute($attributeAccessorString, $activityItem, $language, $timeQualifier, $errorOnFirstMissing, $params); } if (get_class($activityItem) == 'Item' && array_search(ucfirst($attributeName), $activityItemsModelClassNamesData) !== false) { try { $modelDerivationPathToItem = RuntimeUtil::getModelDerivationPathToItem(ucfirst($attributeName)); $castedDownModel = $activityItem->castDown(array($modelDerivationPathToItem)); if (ucfirst($attributeName) == get_class($castedDownModel)) { $attributeAccessorString = str_replace($attributeName . '->', '', $attributeAccessorString); return static::resolveMergeTagToStandardOrRelatedAttribute($attributeAccessorString, $castedDownModel, $language, $timeQualifier, $errorOnFirstMissing, $params); } } catch (NotFoundException $e) { //Do nothing } } unset($activityItemsModelClassNamesData[get_class($activityItem)]); } foreach ($activityItemsModelClassNamesData as $relationModelClassName) { if (ucfirst($attributeName) == $relationModelClassName) { $model = new $relationModelClassName(); $attributeAccessorString = str_replace($attributeName . '->', '', $attributeAccessorString); return static::resolveMergeTagToStandardOrRelatedAttribute($attributeAccessorString, $model, $language, $timeQualifier, $errorOnFirstMissing, $params); } } } return static::PROPERTY_NOT_FOUND; } elseif ($model->{$attributeName} instanceof CurrencyValue) { $model = $model->{$attributeName}; if ($attributeName === $attributeAccessorString) { $attributeAccessorString = null; } else { $attributeAccessorString = str_replace($attributeName . '->', '', $attributeAccessorString); } if (empty($attributeAccessorString)) { // If a user specific a relation merge tag but not a property, we assume he meant "value" property. $currencyValueModel = $model; $value = static::getAttributeValue($currencyValueModel, 'value', $timeQualifier); return CLocale::getInstance($language)->getCurrencySymbol($currencyValueModel->currency->code) . $value; // We can't use code below because it converts integer values in flat and also add slashes to '.' in float numbers //return Yii::app()->numberFormatter->formatCurrency($value, // $currencyValueModel->currency->code); } return static::resolveMergeTagToStandardOrRelatedAttribute($attributeAccessorString, $model, $language, $timeQualifier, $errorOnFirstMissing, $params); } elseif ($model->{$attributeName} instanceof CustomField) { $value = static::getAttributeValue($model->{$attributeName}, 'value', $timeQualifier); // TODO: @Shoaibi/@Jason: Low: need to apply localizations(Date/time/currency formats, ...) here besides translation if ($value) { $value = Zurmo::t($model::getModuleClassName(), $value, array(), null, $language); } return $value; } elseif ($model->isRelation($attributeName)) { $model = $model->{$attributeName}; if ($attributeName === $attributeAccessorString) { $attributeAccessorString = null; } else { $attributeAccessorString = str_replace($attributeName . '->', '', $attributeAccessorString); } if (empty($attributeAccessorString)) { // If a user specific a relation merge tag but not a property, we assume he meant "value" property. if (empty($timeQualifier)) { return strval($model); } else { return static::PROPERTY_NOT_FOUND; } } if ($model instanceof RedBeanModels) { $modelClassName = $model->getModelClassName(); if ($attributeAccessorString == lcfirst($modelClassName)) { $values = array(); foreach ($model as $relatedModel) { $values[] = strval($relatedModel); } return ArrayUtil::stringify($values); } } return static::resolveMergeTagToStandardOrRelatedAttribute($attributeAccessorString, $model, $language, $timeQualifier, $errorOnFirstMissing, $params); } else { $attributeType = ModelAttributeToMixedTypeUtil::getType($model, $attributeName); //We don't have any accessor operator after the attributeName e.g. its the last in list if ($attributeName === $attributeAccessorString) { $content = static::getAttributeValue($model, $attributeName, $timeQualifier); if ($attributeType == 'DateTime') { $content .= ' GMT'; } return $content; } else { return static::PROPERTY_NOT_FOUND; } } } }
private function getBlankTempTrans($rownum, $invDate = null) { $comp = Company::model()->findbyPk(Yii::app()->user->getState('selectedCompanyId')); $per = Period::model()->findbyPk(Yii::app()->user->getState('selectedPeriodId')); $model = new TempTrans(); $model->rownum = $rownum; $model->regDate = date('Y-m-d'); if ($invDate == null) { $invDate = $model->regDate; } $model->invDate = $invDate; $model->changedBy = Yii::app()->user->getState('displayname'); $model->dateChanged = $model->regDate; $model->periodNum = $per->lastPeriodTransNum + 1; $model->companyNum = $comp->lastAbsTransNum + 1; $model->notesheader = ''; $model->fileInfo = ''; $model->fileInfo = 1; $model->accountId = 0; $model->customerId = 0; $model->donorId = 0; $model->notes = ''; $model->amountdebit = ""; $model->amountcredit = ""; $model->userId = Yii::app()->user->id; $model->save(); $cLoc = CLocale::getInstance('en'); $model->invDate = User::getDateFormatted($model->invDate, $cLoc); $model->regDate = User::getDateFormatted($model->regDate, $cLoc); $model->dateChanged = $model->regDate; return $model; }
?> </th> <th><?php echo $sort->link('dateChanged'); ?> </th> <th><?php echo CHtml::encode(Yii::t('lazy8', 'Actions')); ?> </th> </tr> </thead> <tbody> <?php $cLoc = CLocale::getInstance('en'); $dateformatter = new CDateFormatter($cLoc); foreach ($models as $n => $model) { ?> <tr class="<?php echo $n % 2 ? 'even' : 'odd'; ?> "> <td><?php echo CHtml::encode($model->code); ?> </td> <td><?php echo CHtml::encode($model->name); ?> </td>
public function getLanguages() { if ($this->_languages === null) { $basePath = Yii::getPathOfAlias('application.data.guide') . DIRECTORY_SEPARATOR . $this->getVersion(); $dir = opendir($basePath); $this->_languages = array('en' => 'English'); if ($this->language !== 'en') { $this->_languages['en'] .= ' (' . CLocale::getInstance($this->language)->getLocaleDisplayName('en') . ')'; } while (($file = readdir($dir)) !== false) { if (!is_dir($basePath . DIRECTORY_SEPARATOR . $file) || $file === '.' || $file === '..' || $file === 'source') { continue; } $this->_languages[$file] = CLocale::getInstance($file)->getLocaleDisplayName($file); if ($file !== $this->language) { $this->_languages[$file] .= ' (' . CLocale::getInstance($this->language)->getLocaleDisplayName($file) . ')'; } } ksort($this->_languages); } return $this->_languages; }
/** * Displays the requested report * */ public function actionReport() { //throw(new Exception('just die')); if ((isset($_POST['ShowReport']) || isset($_POST['DownloadPDF']) || isset($_POST['DownloadExcel'])) && isset($_POST['reportId'])) { $this->_model = Report::model()->findbyPk($_POST['reportId']); if ($this->_model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } //delete all the old report parameter values ReportUserLastUsedParams::model()->dbConnection->createCommand('DELETE FROM ReportUserLastUsedParams WHERE reportId=' . $this->_model->id . ' AND userId=' . Yii::app()->user->id)->execute(); //build the Sql sats $aliases = array(); $replacements = array(); $repParams = $this->_model->reportparameters; $parameterValues = array(); $graphicFilename = ""; $title = ""; if (isset($repParams) && count($repParams) > 0) { foreach ($repParams as $n => $repParam) { //get the new parameter values if ($repParam->dataType == 'HIDDEN_NO_SHOW_HEAD' || $repParam->dataType == 'HIDDEN_SHOW_HEAD') { if (strlen($repParam->phpSecondaryInfo) > 0) { eval($repParam->phpSecondaryInfo); } else { $defaultValue = $repParam->defaultValue; if ($repParam->isDefaultPhp) { eval($defaultValue); } } $parameterValues[$n] = $defaultValue; } else { if (isset($_POST[$n])) { if ($repParam->dataType == 'DATE') { $parameterValues[$n] = User::parseDate($_POST[$n]); } else { $parameterValues[$n] = $_POST[$n]; } if (strlen($title) == 0) { $title = $_POST[$n]; } $negateGraphicValues = false; if ($repParam->name == 'Negate values for graphics') { $negateGraphicValues = (int) $_POST[$n]; } //save the parameter values $saveLast = new ReportUserLastUsedParams(); $saveLast->reportId = $this->_model->id; $saveLast->userId = Yii::app()->user->id; $saveLast->paramId = $n; $saveLast->LastUsedValue = $parameterValues[$n]; $saveLast->save(); } } //get the aliases if (strlen($repParam->alias) > 0) { $aliases[] = $repParam->alias; if ($repParam->dataType == 'HIDDEN_NO_SHOW_HEAD' || $repParam->dataType == 'HIDDEN_SHOW_HEAD') { $defaultValue = $repParam->defaultValue; if ($repParam->isDefaultPhp) { eval($defaultValue); } $replacements[] = $defaultValue; } else { if ($repParam->dataType == 'DATE') { $replacements[] = User::parseDate($_POST[$n]); } else { $replacements[] = $_POST[$n]; } } if ($repParam->alias == '{ShowGraph}' && strlen($_POST[$n]) > 0) { $graphicFilename = $_POST[$n]; } } } } $sqlSelect = str_replace($aliases, $replacements, $this->_model->selectSql); // var_dump($aliases); // var_dump($replacements); //echo $sqlSelect.'<br><br>'; // echo $sqlSelect; die(); //execute the Sql sats //Yii::log($sqlSelect, CLogger::LEVEL_INFO, 'system.web.CController'); $command = Report::model()->dbConnection->createCommand($sqlSelect); try { $reader = $command->query(); //foreach($reader as $row)print_r($row); //die(); } catch (Exception $e) { echo '<h2>Died on Sql execution</h2>' . $sqlSelect; throw $e; } $imageFileNames = array(); $imageFilePaths = array(); if (strlen($graphicFilename) > 0) { $images = $this->readXmlGraphicFile($graphicFilename, false, $reader, $title, $negateGraphicValues, $imageFileNames); $imageFileNames = $images[1]; $imageFilePaths = $images[0]; //must do this again because the reader can only go forwards $reader = $command->query(); } //update last used report for printout $printoutview = ""; if (isset($_POST['printoutview'])) { $printoutview = $_POST['printoutview']; } $option = Options::model()->find('name=\'isReportForPrintout\' AND companyId=0 AND userId=' . Yii::app()->user->id); $option->datavalue = $printoutview == 1 ? 'true' : 'false'; $option->save(); Yii::app()->user->setState('isReportForPrintout', $printoutview); //update last used black and white $option = Options::model()->find('name=\'isReportBlackAndWhite\' AND companyId=0 AND userId=' . Yii::app()->user->id); $option->datavalue = false; $option->datavalue = isset($_POST['blackandwhite']) && $_POST['blackandwhite'] == 1 ? 'true' : 'false'; $option->save(); Yii::app()->user->setState('isReportBlackAndWhite', isset($_POST['blackandwhite']) && $_POST['blackandwhite'] == 1 ? 1 : 0); if (isset($_POST['blackandwhite']) && $_POST['blackandwhite'] == 1) { Yii::app()->user->setState('reportCssFile', $this->_model->cssBwFileName); } else { Yii::app()->user->setState('reportCssFile', $this->_model->cssColorFileName); } //get the number and date formats $cLoc = CLocale::getInstance('en'); $numberFormatter = $cLoc->getNumberFormatter(); $dateFormatter = $cLoc->getDateFormatter(); // echo "<pre>"; // var_dump($dateFormatter); // echo "</pre>"; // die(); $numberFormat = User::getNumberFormat(); $pdf_name = ""; $cron_job = FALSE; // if from cron job if (isset($_POST['cron'])) { $pdf_name = "reports/lazy8report_" . date('Y-m-d_H.i.s'); $cron_job = TRUE; } if (isset($_POST['DownloadExcel'])) { Yii::import('application.controllers.excel.*'); require_once "exportExcel.php"; new exportExcel($this->_model, $reader, $pdf_name, $numberFormatter, $dateFormatter, $numberFormat, $printoutview, $parameterValues); die; } else { if (isset($_POST['DownloadPDF'])) { // var_dump($numberFormat); // die(); Yii::import('application.controllers.tcpdf.*'); require_once "lazy8tcpdf.php"; new lazy8tcpdf($this->_model, $reader, $pdf_name, $cron_job, $numberFormatter, $dateFormatter, $numberFormat, $printoutview, $parameterValues, $imageFileNames, isset($_POST['blackandwhite']) && $_POST['blackandwhite'] == 1 ? 1 : 0, strpos(Yii::app()->user->getState('reportCssFile'), "wide") === false); // if cron job was run then email user with the pdf attatchment if (isset($_POST['cron'])) { $accountID = $_POST['accountID']; $sql = "SELECT Account.code AS accountcode, Account.name AS accountname, Account.email AS email, Account.balance_threshold AS threshold, Account.days AS days\n\t\t\t\t\t\t\t\tFROM Account\n\t\t\t\t\t\t\t\tWHERE Account.code = '{$accountID}'"; $account = Yii::app()->db->createCommand($sql)->queryAll(); $to = $account['email']; $subject = 'Weekly Report'; $headers = "From: Accounting@thaiconnections.org \r\n"; $headers .= "Reply-To: no-reply@thaiconnections.org\r\n"; $headers .= "MIME-Version: 1.0\r\n"; $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n"; $message = '<html><body>'; $message .= '<p>Hello,</p>'; $message .= '<p>This a automated notification from Thaiconnections Accounting website that your weekly report for: <strong>' . $account['accountname'] . ' </strong>is ready to be downloaded. Please click the link to view your report.<p>'; $message .= '<phttp://accounting.thaiconnections.org/' . $pdf_name . '.pdf<p>'; $message .= '<p>Kindest Regards,<br>'; $message .= 'Thaiconnections Accounting</p>'; $message .= '</body></html>'; if (mail($to, $subject, $message, $headers)) { echo "Email sent...<br>"; } else { echo "Mail did not send. Error occurred"; } } } else { //show the report $this->render('report', array('model' => $this->_model, 'reader' => $reader, 'numberFormatter' => $numberFormatter, 'dateFormatter' => $dateFormatter, 'numberFormat' => $numberFormat, 'printoutview' => $printoutview, 'parameterValues' => $parameterValues, 'imageFileNames' => $imageFilePaths)); } } } else { //show the report parameter selection page. $noActivityLogSelectionString = ""; if (!Yii::app()->user->getState('allowChangeLog')) { $noActivityLogSelectionString = " AND name<>'Activity log'"; } $allRepModels = Report::model()->findAll(array('select' => 'id,name', 'order' => 'sortOrder', 'condition' => '(companyId=' . Yii::app()->user->getState('selectedCompanyId') . ' OR companyId=0)' . $noActivityLogSelectionString)); $reports = CHtml::listData($allRepModels, 'id', 'name'); foreach ($reports as $n => $reportsTrans) { $reports[$n] = Yii::t('lazy8', $reportsTrans); } if (isset($_POST['reportId']) && $_POST['reportId']) { $model = Report::model()->findbyPk($_POST['reportId']); //update last used report $option = Options::model()->find('name=\'lastPrintedReportId\' AND companyId=0 AND userId=' . Yii::app()->user->id); $option->datavalue = $_POST['reportId']; $option->save(); Yii::app()->user->setState('lastPrintedReportId', $_POST['reportId']); } else { //always try to select any report $selectReport = Yii::app()->user->getState('lastPrintedReportId'); $model = Report::model()->findbyPk($selectReport); if (isset($model)) { $_POST['reportId'] = $selectReport; } elseif (isset($allRepModels) && count($allRepModels) > 0) { $_POST['reportId'] = $allRepModels[0]->id; $model = $allRepModels[0]; } } //preselect the values to what was done before... $repParams = $model->reportparameters; if (isset($repParams) && count($repParams) > 0) { foreach ($repParams as $n => $repParam) { if ($repParam->dataType == 'FREE_TEXT' || $repParam->dataType == 'DROP_DOWN' || $repParam->dataType == 'DATE' || $repParam->dataType == 'BOOLEAN') { $lastChosen = ReportUserLastUsedParams::model()->find('reportId=' . $model->id . ' AND userId=' . Yii::app()->user->id . ' AND paramId=' . $n); if (isset($lastChosen)) { $defaultValue = $lastChosen->LastUsedValue; } else { $defaultValue = $repParam->defaultValue; if ($repParam->isDefaultPhp) { eval($defaultValue); } } if ($repParam->dataType == 'DATE') { $_POST[$n] = User::getDateFormatted($defaultValue); } else { $_POST[$n] = $defaultValue; } } } } $_POST['blackandwhite'] = Yii::app()->user->getState('isReportBlackAndWhite') ? 1 : 0; $_POST['printoutview'] = Yii::app()->user->getState('isReportForPrintout') ? 1 : 0; $this->render('reportparams', array('reports' => $reports, 'model' => $model)); } }
/** * @param $localeId * * @return array */ private function _processFrameworkData($localeId) { $wideMonthKeys = array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'); $abbreviatedMonthKeys = array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'); $wideWeekdayNameKeys = array('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'); $abbreviatedWeekdayNameKeys = array('Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'); $amNameKey = 'AM'; $pmNameKey = 'PM'; $formattedFrameworkData = array(); $locale = \CLocale::getInstance($localeId); $formattedFrameworkData = array_merge($formattedFrameworkData, array_combine($wideMonthKeys, $locale->getMonthNames())); $formattedFrameworkData = array_merge($formattedFrameworkData, array_combine($abbreviatedMonthKeys, $locale->getMonthNames('abbreviated'))); $formattedFrameworkData = array_merge($formattedFrameworkData, array_combine($wideWeekdayNameKeys, $locale->getWeekDayNames())); $formattedFrameworkData = array_merge($formattedFrameworkData, array_combine($abbreviatedWeekdayNameKeys, $locale->getWeekDayNames('abbreviated'))); $formattedFrameworkData[$amNameKey] = $locale->getAMName(); $formattedFrameworkData[$pmNameKey] = $locale->getPMName(); return $formattedFrameworkData; }
public static function getNumberFormat() { $numberFormat = trim(Yii::app()->user->getState('NonStandardNumberDecimalFormat')); if (strlen($numberFormat) > 0) { return $numberFormat; } else { $cLoc = CLocale::getInstance('en'); if ($cLoc == null) { $cLoc = CLocale::getInstance(); } return $cLoc->getDecimalFormat(); } }