/** * Returns the preferred section based on session, cookie, * user object, default browser (if allowed), and finally * site preferences. * Since the user's language is not a locale but a language, * attempts to determine best section for the given language. * * @return Section */ public static function getPreferredSection() { $site = \Site::getSite(); $locale = false; $app = Facade::getFacadeApplication(); // they have a language in a certain session going already $session = $app->make('session'); if ($session->has('multilingual_default_locale')) { $locale = $session->get('multilingual_default_locale'); } else { $cookie = $app->make('cookie'); if ($cookie->has('multilingual_default_locale')) { $locale = $cookie->get('multilingual_default_locale'); } } if ($locale) { $home = Section::getByLocale($locale); if ($home) { return $home; } } $u = new \User(); if ($u->isRegistered()) { $userDefaultLanguage = $u->getUserDefaultLanguage(); if ($userDefaultLanguage) { $home = Section::getByLocaleOrLanguage($userDefaultLanguage); if ($home) { return $home; } } } $config = $site->getConfigRepository(); if ($config->get('multilingual.use_browser_detected_locale')) { $home = false; $locales = \Punic\Misc::getBrowserLocales(); foreach (array_keys($locales) as $locale) { $home = Section::getByLocaleOrLanguage($locale); if ($home) { break; } } if ($home) { return $home; } } $site = \Site::getSite(); return Section::getByLocale($site->getDefaultLocale()); }
/** * * Returns the preferred section based on session, cookie, * user object, default browser (if allowed), and finally * site preferences. * Since the user's language is not a locale but a language, * attempts to determine best section for the given language. * @return Section */ public static function getPreferredSection() { $locale = false; // they have a language in a certain session going already if (Session::has('multilingual_default_locale')) { $locale = Session::get('multilingual_default_locale'); } else { if (Cookie::has('multilingual_default_locale')) { $locale = Cookie::get('multilingual_default_locale'); } } if ($locale) { $home = Section::getByLocale($locale); if ($home) { return $home; } } $u = new \User(); if ($u->isRegistered()) { $userDefaultLanguage = $u->getUserDefaultLanguage(); if ($userDefaultLanguage) { $home = Section::getByLocaleOrLanguage($userDefaultLanguage); if ($home) { return $home; } } } if (Config::get('concrete.multilingual.use_browser_detected_locale')) { $home = false; $locales = \Punic\Misc::getBrowserLocales(); foreach (array_keys($locales) as $locale) { $home = Section::getByLocaleOrLanguage($locale); if ($home) { break; } } if ($home) { return $home; } } return Section::getByLocale(Config::get('concrete.multilingual.default_locale')); }
/** * {@inheritdoc} */ public function __construct(string $name, string $label = null) { parent::__construct($name, $label); self::translator()->addFile(__DIR__ . '/../../../lang/global', 'bootstrap'); $this->add((new Group(self::trans('bootstrap.googlePlace/street')))->add($this->fields['number'] = (new Text($name . '[number]'))->setPlaceholder(self::trans('bootstrap.googlePlace/number')))->add($this->fields['street'] = (new Text($name . '[street]'))->setPlaceholder(self::trans('bootstrap.googlePlace/street'))))->add((new Group(Misc::joinUnits([self::trans('bootstrap.googlePlace/zipcode'), self::trans('bootstrap.googlePlace/city')])))->add($this->fields['zipcode'] = (new Text($name . '[zipcode]'))->setPlaceholder(self::trans('bootstrap.googlePlace/zipcode')))->add($this->fields['city'] = (new Text($name . '[city]'))->setPlaceholder(self::trans('bootstrap.googlePlace/city'))))->add($this->fields['state'] = new Text($name . '[state]', self::trans('bootstrap.googlePlace/state')))->add($this->fields['country'] = new Select($name . '[country]', self::trans('bootstrap.googlePlace/country'), Territory::getCountries()))->add($this->fields['lat'] = new Hidden($name . '[lat]'))->add($this->fields['long'] = new Hidden($name . '[long]')); }
/** * @param string $type * * @return string */ public function display($type = self::DISPLAY_SHORT) : string { if ($type == self::DISPLAY_DURATION) { $format = []; if ($this->hour) { $format[] = Unit::format($this->hour, 'duration/hour'); } if ($this->minute) { $format[] = Unit::format($this->minute, 'duration/minute'); } if ($this->second) { $format[] = Unit::format($this->second, 'duration/second'); } return Misc::joinUnits($format, 'narrow'); } return Calendar::formatTime($this, $type); }
}); $('#ccm-tab-content-redirect-by-usergroup a[data-button=assign-groups]').dialog(); }); </script> </div> <div class="ccm-tab-content" id="ccm-tab-content-redirect-by-ip"> <?php foreach (array(array('redirectIPs', t('Redirect these IP addresses')), array('dontRedirectIPs', t('Never redirect these IP addresses'))) as $info) { $varName = $info[0]; $value = isset(${$varName}) ? implode("\n", preg_split('/[\\s,]+/', str_replace('|', ' ', ${$varName}), -1, PREG_SPLIT_NO_EMPTY)) : ''; ?> <div class="form-group"> <?php echo $form->label($varName, $info[1], array('class' => 'launch-tooltip', 'data-placement' => 'right', 'data-html' => 'true', 'title' => t("Separate multiple values by spaces, new lines or commas.<br />IPv4 and IPv6 addresses are supported.<br />You can specify single IP addresses as well as ranges (examples: %s)", \Punic\Misc::join(array('<code>100.200.*.*</code>', '<code>100.200.0.0/16</code>', '<code>1:2::0/8</code>', '<code>1:2::*:*</code>)'))))); ?> <?php echo $form->textarea($varName, $value, array('rows' => '5', 'style' => 'resize: vertical;')); ?> </div> <?php } if ($ip !== '') { ?> <div class="text-muted"><?php echo t('Your IP address is %s', "<code>{$ip}</code>"); ?> </div><?php } ?>
/** * isRtl - is text order right to left? * * @return bool true if right to left */ public static function isRtl() { return 'right-to-left' === Misc::getCharacterOrder(); }
/** * Retrieve the relative day name (eg 'yesterday', 'tomorrow'), if available * @param \DateTime $datetime The date for which you want the relative day name * @param bool $ucFirst = false Force first letter to be upper case? * @param string $locale = '' The locale to use. If empty we'll use the default locale set in \Punic\Data * @return Returns the relative name if available, otherwise returns an empty string */ public static function getDateRelativeName($datetime, $ucFirst = false, $locale = '') { $result = ''; $deltaDays = static::getDeltaDays($datetime); $data = \Punic\Data::get('dateFields', $locale); if (array_key_exists('day', $data)) { $data = $data['day']; $key = "relative-type-{$deltaDays}"; if (array_key_exists($key, $data)) { $result = $data[$key]; if ($ucFirst) { $result = \Punic\Misc::fixCase($result, 'titlecase-firstword'); } } } return $result; }