本文整理汇总了PHP中eZLocale::instance方法的典型用法代码示例。如果您正苦于以下问题:PHP eZLocale::instance方法的具体用法?PHP eZLocale::instance怎么用?PHP eZLocale::instance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZLocale
的用法示例。
在下文中一共展示了eZLocale::instance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: convertFromLocaleCurrency
function convertFromLocaleCurrency($toCurrency, $value, $applyRounding = true)
{
$locale = eZLocale::instance();
$fromCurrency = $locale->currencyShortName();
$retValue = $this->convert($fromCurrency, $toCurrency, $value, $applyRounding);
return $retValue;
}
示例2: getMeta
function getMeta($keyword)
{
$locale = eZLocale::instance();
$siteURL = $this->siteIni->variable('SiteSettings', 'SiteURL');
$metaData = $this->siteIni->variable('SiteSettings', 'MetaDataArray');
return array('title' => sprintf("%s - %s", $keyword, $this->siteIni->variable('SiteSettings', 'SiteName')), 'description' => sprintf('Items on %s related to %s', $siteURL, $keyword), 'language' => $locale->httpLocaleCode(), 'authorName' => $metaData['author'], 'authorMail' => $this->siteIni->variable('MailSettings', 'AdminEmail'), 'siteURL' => $siteURL);
}
示例3: locale
function locale()
{
if ( $this->Locale !== null )
return $this->Locale;
$this->Locale = eZLocale::instance( $this->LanguageCode );
return $this->Locale;
}
示例4: __construct
function __construct($identifier)
{
$locale = eZLocale::instance();
$format = OCCalendarData::FULLDAY_IDENTIFIER_FORMAT;
$this->identifier = $identifier;
$dateTime = DateTime::createFromFormat($format, $identifier, OCCalendarData::timezone());
if (!$dateTime instanceof DateTime) {
throw new Exception("{$identifier} in format '{$format}' is not a valid DateTime");
}
$dateTime->setTime(0, 0, 0);
$this->day = $dateTime->format('j');
$this->shortDayName = $locale->shortDayName($dateTime->format('w'));
$this->longDayName = $locale->longDayName($dateTime->format('w'));
$this->month = $dateTime->format('n');
$this->longMonthName = $locale->longMonthName($this->month);
$this->shortMonthName = $locale->shortMonthName($this->month);
$this->year = $dateTime->format('Y');
$this->urlSuffix = "/(day)/{$this->day}/(month)/{$this->month}/(year)/{$this->year}";
$this->dayStartDateTime = clone $dateTime;
$this->dayStartDateTime->setTime(0, 0, 0);
$this->dayStartTimestamp = $this->dayStartDateTime->format('U');
$today = mktime(0, 0, 0, date('n'), date('j'), date('Y'));
$tomorrow = mktime(0, 0, 0, date('n'), date('j') + 1, date('Y'));
$this->isToday = $this->dayStartTimestamp == $today;
$this->isTomorrow = $this->dayStartTimestamp == $tomorrow;
$this->isInWeek = date('W', $this->dayStartTimestamp) == date('W', $today);
$this->isInMonth = date('n', $this->dayStartTimestamp) == date('n', $today);
$this->dayEndDateTime = clone $dateTime;
$this->dayEndDateTime->setTime(23, 59, 59);
$this->dayEndTimestamp = $this->dayEndDateTime->format('U');
$this->container = array();
}
示例5: testIssue13497
/**
* Test for regression #13497:
* attribute operator throws a PHP fatal error on a node without parent in a displayable language
*
* Situation:
* - siteaccess with one language (fre-FR) and ShowUntranslatedObjects disabled
* - parent content node in another language (eng-GB) with always available disabled
* - content node in the siteaccess' language (fre-FR)
* - fetch this fre-FR node from anywhere, and call attribute() on it
*
* Result:
* - Fatal error: Call to a member function attribute() on a non-object in
* kernel/classes/ezcontentobjecttreenode.php on line 4225
*
* Explanation: the error actually comes from the can_remove_location attribute
**/
public function testIssue13497()
{
// Create a folder in english only
$folder = new ezpObject("folder", 2, 14, 1, 'eng-GB');
$folder->setAlwaysAvailableLanguageID(false);
$folder->name = "Parent for " . __FUNCTION__;
$folder->publish();
$locale = eZLocale::instance('fre-FR');
$translation = eZContentLanguage::addLanguage($locale->localeCode(), $locale->internationalLanguageName());
// Create an article in french only, as a subitem of the previously created folder
$article = new ezpObject("article", $folder->attribute('main_node_id'), 14, 1, 'fre-FR');
$article->title = "Object for " . __FUNCTION__;
$article->short_description = "Description of test for " . __FUNCTION__;
$article->publish();
$articleNodeID = $article->attribute('main_node_id');
// INi changes: set language to french only, untranslatedobjects disabled
ezpINIHelper::setINISetting('site.ini', 'RegionalSettings', 'ContentObjectLocale', 'fre-FR');
ezpINIHelper::setINISetting('site.ini', 'RegionalSettings', 'SiteLanguageList', array('fre-FR'));
ezpINIHelper::setINISetting('site.ini', 'RegionalSettings', 'ShowUntranslatedObjects', 'disabled');
eZContentLanguage::expireCache();
// This should crash
eZContentObjectTreeNode::fetch($articleNodeID)->attribute('can_remove_location');
ezpINIHelper::restoreINISettings();
// re-expire cache for further tests
eZContentLanguage::expireCache();
}
示例6: testIssue19174
/**
* Regression test for issue {@see #19174 http://issues.ez.no/19174}
*/
public function testIssue19174()
{
$bkpLanguages = eZContentLanguage::prioritizedLanguageCodes();
// add a secondary language
$locale = eZLocale::instance('fre-FR');
$translation = eZContentLanguage::addLanguage($locale->localeCode(), $locale->internationalLanguageName());
// create related objects
$relatedObjectsIds = array($this->createObjectForRelation(), $this->createObjectForRelation(), $this->createObjectForRelation(), $this->createObjectForRelation());
$xmlTextEn = "<embed href=\"ezobject://{$relatedObjectsIds[0]}\" /><link href=\"ezobject://{$relatedObjectsIds[1]}\">link</link>";
$xmlTextFr = "<embed href=\"ezobject://{$relatedObjectsIds[2]}\" /><link href=\"ezobject://{$relatedObjectsIds[3]}\">link</link>";
// Create an article in eng-GB, and embed related object one in the intro
$article = new ezpObject('article', 2, 14, 1, 'eng-GB');
$article->title = __METHOD__ . ' eng-GB';
$article->intro = $xmlTextEn;
$articleId = $article->publish();
// Workaround as setting folder->name directly doesn't produce the expected result
$article->addTranslation('fre-FR', array('title' => __METHOD__ . ' fre-FR', 'intro' => $xmlTextFr));
$relatedObjects = eZContentObject::fetch($articleId)->relatedObjects(false, false, 0, false, array('AllRelations' => eZContentObject::RELATION_LINK | eZContentObject::RELATION_EMBED));
self::assertEquals(4, count($relatedObjects));
$expectedRelations = array_flip($relatedObjectsIds);
foreach ($relatedObjects as $relatedObject) {
if (isset($expectedRelations[$relatedObject->ID])) {
unset($expectedRelations[$relatedObject->ID]);
}
}
self::assertEquals(0, count($expectedRelations));
$article->remove();
$translation->removeThis();
eZContentLanguage::setPrioritizedLanguages($bkpLanguages);
}
示例7: __construct
function __construct($value)
{
if ($value instanceof eZCurrency) {
$value = $value->value();
}
$this->Value = $value;
$this->Locale = eZLocale::instance();
}
示例8: countryISO3166Code
/**
* @param bool $localeString
* @return string
*/
public static function countryISO3166Code( $localeString = false )
{
if ( $localeString === false )
{
$localeString = eZLocale::instance()->localeFullCode();
}
$isoCodes = self::isoCodes( $localeString );
return $isoCodes[1];
}
示例9: __construct
/**
* Creates a new date object with default locale, if $date is not supplied
* the current date is used.
*
* @note this uses the current Timezone
*
* @param int $date
*/
function __construct($date = false)
{
$dt = new DateTime();
if ($date !== false) {
$dt->setTimestamp($date);
}
$dt->setTime(0, 0, 0);
$this->Date = $dt->getTimestamp();
$this->Locale = eZLocale::instance();
$this->IsValid = $date !== null;
}
示例10: i18n
/**
* i18n
* Provides all i18n strings for use by TinyMCE and other javascript dialogs.
*
* @static
* @param array $args
* @param string $fileExtension
* @return string returns json string with translation data
*/
public static function i18n($args, $fileExtension)
{
$lang = '-en';
$locale = eZLocale::instance();
if ($args && $args[0]) {
$lang = $args[0];
}
$i18nArray = array($lang => array('soextra' => array('font_size' => ezi18n('design/standard/soextra', "Font size"), 'font_class' => ezi18n('design/standard/soextra', "Font style"), 'class' => ezi18n('design/standard/soextra', "Element style"), 'remove_tag' => ezi18n('design/standard/soextra', 'Remove "%tag" tag', null, array('%tag' => '<tag>')), 'remove_tag_keep_contents' => ezi18n('design/standard/soextra', 'Remove "%tag" tag (keep contents)', null, array('%tag' => '<tag>')), 'cursor_before' => ezi18n('design/standard/soextra', 'Place cursor before "%tag"', null, array('%tag' => '<tag>')), 'cursor_after' => ezi18n('design/standard/soextra', 'Place cursor after "%tag"', null, array('%tag' => '<tag>')))));
$i18nString = json_encode($i18nArray);
return 'tinyMCE.addI18n( ' . $i18nString . ' );';
}
示例11: modify
/**
* Executes the operators
*
* @param eZTemplate $tpl
* @param string $operatorName
* @param array $operatorParameters
* @param string $rootNamespace
* @param string $currentNamespace
* @param mixed $operatorValue
* @param array $namedParameters
*/
function modify(&$tpl, &$operatorName, &$operatorParameters, &$rootNamespace, &$currentNamespace, &$operatorValue, &$namedParameters)
{
switch ($operatorName) {
case 'opengraph':
$operatorValue = $this->generateOpenGraphTags($namedParameters['nodeid']);
break;
case 'language_code':
$operatorValue = eZLocale::instance()->httpLocaleCode();
break;
}
}
示例12: eZDate
function eZDate($date = false)
{
if ($date === false) {
$date = mktime(0, 0, 0);
} else {
$arr = getdate($date);
$date = mktime(0, 0, 0, $arr['mon'], $arr['mday'], $arr['year']);
}
$this->Date = $date;
$this->Locale = eZLocale::instance();
$this->IsValid = true;
}
示例13: fetchTranslatedNames
static function fetchTranslatedNames( &$countries )
{
$locale = eZLocale::instance();
$translatedCountryNames = $locale->translatedCountryNames();
foreach ( array_keys( $countries ) as $countryKey )
{
$translatedName = isset( $translatedCountryNames[$countryKey] ) ? $translatedCountryNames[$countryKey] : false;
if ( $translatedName )
$countries[$countryKey]['Name'] = $translatedName;
}
usort( $countries, array( 'eZCountryType', 'compareCountryNames' ) );
}
示例14: createRedirectionUrl
function createRedirectionUrl($process)
{
//__DEBUG__
$this->logger->writeTimedString("createRedirectionUrl");
//___end____
$paypalINI = eZINI::instance('paypal.ini');
$paypalServer = $paypalINI->variable('ServerSettings', 'ServerName');
$requestURI = $paypalINI->variable('ServerSettings', 'RequestURI');
$business = urlencode($paypalINI->variable('PaypalSettings', 'Business'));
$processParams = $process->attribute('parameter_list');
$orderID = $processParams['order_id'];
$indexDir = eZSys::indexDir();
$localHost = eZSys::serverURL();
$localURI = eZSys::serverVariable('REQUEST_URI');
$order = eZOrder::fetch($orderID);
$amount = urlencode($order->attribute('total_inc_vat'));
$currency = urlencode($order->currencyCode());
// include_once( 'lib/ezlocale/classes/ezlocale.php' );
$locale = eZLocale::instance();
$countryCode = urlencode($locale->countryCode());
$maxDescLen = $paypalINI->variable('PaypalSettings', 'MaxDescriptionLength');
$itemName = urlencode($this->createShortDescription($order, $maxDescLen));
$accountInfo = $order->attribute('account_information');
$first_name = urlencode($accountInfo['first_name']);
$last_name = urlencode($accountInfo['last_name']);
$street = urlencode($accountInfo['street2']);
$zip = urlencode($accountInfo['zip']);
$state = urlencode($accountInfo['state']);
$place = urlencode($accountInfo['place']);
$image_url = "{$localHost}" . urlencode($paypalINI->variable('PaypalSettings', 'LogoURI'));
$background = urlencode($paypalINI->variable('PaypalSettings', 'BackgroundColor'));
$pageStyle = urlencode($paypalINI->variable('PaypalSettings', 'PageStyle'));
$noNote = urlencode($paypalINI->variable('PaypalSettings', 'NoNote'));
$noteLabel = $noNote == 1 ? '' : urlencode($paypalINI->variable('PaypalSettings', 'NoteLabel'));
$noShipping = 1;
$url = $paypalServer . $requestURI . "?cmd=_ext-enter" . "&redirect_cmd=_xclick" . "&business={$business}" . "&item_name={$itemName}" . "&custom={$orderID}" . "&amount={$amount}" . "¤cy_code={$currency}" . "&first_name={$first_name}" . "&last_name={$last_name}" . "&address1={$street}" . "&zip={$zip}" . "&state={$state}" . "&city={$place}" . "&image_url={$image_url}" . "&cs={$background}" . "&page_style={$pageStyle}" . "&no_shipping={$noShipping}" . "&cn={$noteLabel}" . "&no_note={$noNote}" . "&lc={$countryCode}" . "¬ify_url={$localHost}" . $indexDir . "/paypal/notify_url/" . "&return={$localHost}" . $indexDir . "/shop/checkout/" . "&cancel_return={$localHost}" . $indexDir . "/shop/basket/";
//__DEBUG__
$this->logger->writeTimedString("business = {$business}");
$this->logger->writeTimedString("item_name = {$itemName}");
$this->logger->writeTimedString("custom = {$orderID}");
$this->logger->writeTimedString("no_shipping = {$noShipping}");
$this->logger->writeTimedString("localHost = {$localHost}");
$this->logger->writeTimedString("amount = {$amount}");
$this->logger->writeTimedString("currency_code = {$currency}");
$this->logger->writeTimedString("notify_url = {$localHost}" . $indexDir . "/paypal/notify_url/");
$this->logger->writeTimedString("return = {$localHost}" . $indexDir . "/shop/checkout/");
$this->logger->writeTimedString("cancel_return = {$localHost}" . $indexDir . "/shop/basket/");
//___end____
return $url;
}
示例15: number
function number($number, $is_integer)
{
$locale = eZLocale::instance();
if ($is_integer && is_numeric($number) && (int) $number == $number) {
$neg = $number < 0;
$num = $neg ? -$number : $number;
$text = number_format($num, 0, '', $locale->thousandsSeparator());
$text = ($neg ? $locale->negativeSymbol() : $locale->positiveSymbol()) . $text;
return $text;
} else {
if (is_numeric($number)) {
return $locale->formatNumber($number);
} else {
return $number;
}
}
}