本文整理匯總了PHP中Concrete\Core\Multilingual\Page\Section\Section::getByLocale方法的典型用法代碼示例。如果您正苦於以下問題:PHP Section::getByLocale方法的具體用法?PHP Section::getByLocale怎麽用?PHP Section::getByLocale使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Concrete\Core\Multilingual\Page\Section\Section
的用法示例。
在下文中一共展示了Section::getByLocale方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: view
public function view()
{
$this->requireAsset('javascript', 'jquery');
$ml = Section::getList();
$c = \Page::getCurrentPage();
$al = Section::getBySectionOfSite($c);
$languages = [];
$locale = null;
if ($al !== null) {
$locale = $al->getLanguage();
}
if (!$locale) {
$locale = \Localization::activeLocale();
$al = Section::getByLocale($locale);
}
foreach ($ml as $m) {
$languages[$m->getCollectionID()] = $m->getLanguageText($m->getLocale());
}
$this->set('languages', $languages);
$this->set('languageSections', $ml);
$this->set('activeLanguage', $al ? $al->getCollectionID() : null);
$dl = $this->app->make('multilingual/detector');
$this->set('defaultLocale', $dl->getPreferredSection());
$this->set('locale', $locale);
$this->set('cID', $c->getCollectionID());
}
示例2: getDashboardSitemapIconSRC
public static function getDashboardSitemapIconSRC($page)
{
if ($page->getPageTypeHandle() == STACK_CATEGORY_PAGE_TYPE) {
$section = Section::getByLocale($page->getCollectionName());
if (is_object($section)) {
return self::getSectionFlagIcon($section, true);
}
}
$ids = Section::getIDList();
if (in_array($page->getCollectionID(), $ids)) {
return self::getSectionFlagIcon($page, true);
}
}
示例3: getPreferredSection
/**
* 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());
}
示例4: getPreferredSection
/**
*
* 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'));
}
示例5: rescanMultilingualStacks
public static function rescanMultilingualStacks()
{
$sl = new static();
$stacks = $sl->get();
foreach ($stacks as $stack) {
$section = $stack->getMultilingualSection();
if (!$section) {
$section = false;
$parent = \Page::getByID($stack->getCollectionParentID());
if ($parent->getCollectionPath() == STACKS_PAGE_PATH) {
// this is the default
$section = Section::getDefaultSection();
} else {
if ($parent->getPageTypeHandle() == STACK_CATEGORY_PAGE_TYPE) {
$locale = $parent->getCollectionHandle();
$section = Section::getByLocale($locale);
}
}
if ($section) {
$stack->updateMultilingualSection($section);
}
}
}
}
示例6: export_translations
public function export_translations($localeCode)
{
$result = new EditResponse();
try {
if (!Core::make('token')->validate('export_translations')) {
throw new \Exception(Core::make('token')->getErrorMessage());
}
$section = Section::getByLocale($localeCode);
if (is_object($section) && !$section->isError()) {
if ($section->getLocale() == Config::get('concrete.multilingual.default_source_locale')) {
$section = null;
}
} else {
$section = null;
}
if (!isset($section)) {
throw new \Exception(t('Invalid language identifier'));
}
$translations = $section->getSectionInterfaceTranslations();
$extractor = Core::make('multilingual/extractor');
$extractor->mergeTranslationsWithSectionFile($section, $translations);
$extractor->saveSectionTranslationsToFile($section, $translations);
\Localization::clearCache();
$result->setAdditionalDataAttribute('newToken', Core::make('token')->generate('export_translations'));
$result->message = t('The translations have been exported to file and will be used by the website.');
} catch (\Exception $x) {
$result->setError($x);
}
$result->outputJSON();
}
示例7: add_content_section
public function add_content_section()
{
if (Loader::helper('validation/token')->validate('add_content_section')) {
if (!Loader::helper('validation/numbers')->integer($this->post('pageID')) || $this->post('pageID') < 1) {
$this->error->add(t('You must specify a page for this multilingual content section.'));
} else {
$pc = Page::getByID($this->post('pageID'));
}
if (!$this->error->has()) {
$lc = Section::getByID($this->post('pageID'));
if (is_object($lc)) {
$this->error->add(t('A multilingual section page at this location already exists.'));
}
}
if (!$this->error->has()) {
if ($this->post('msLanguage')) {
$combination = $this->post('msLanguage') . '_' . $this->post('msCountry');
$locale = Section::getByLocale($combination);
if (is_object($locale)) {
$this->error->add(t('This language/region combination already exists.'));
}
}
}
if (!$this->error->has()) {
Section::assign($pc, $this->post('msLanguage'), $this->post('msCountry'));
$this->redirect('/dashboard/system/multilingual/setup', 'multilingual_content_updated');
}
} else {
$this->error->add(Loader::helper('validation/token')->getErrorMessage());
}
$this->view();
}
示例8: relatePage
public static function relatePage($oldPage, $newPage, $locale)
{
$db = Database::get();
$mpRelationID = self::getMultilingualPageRelationID($oldPage->getCollectionID());
$section = Section::getByLocale($locale);
if ($mpRelationID && $section) {
$v = array($mpRelationID, $newPage->getCollectionID(), $section->getLocale(), $section->getLanguage());
$db->Execute('delete from MultilingualPageRelations where mpRelationID = ? and mpLocale = ?', array($mpRelationID, $section->getLocale()));
$db->Execute('delete from MultilingualPageRelations where cID = ?', array($newPage->getCollectionID()));
$db->Execute('insert into MultilingualPageRelations (mpRelationID, cID, mpLocale, mpLanguage) values (?, ?, ?, ?)', $v);
$pde = new Event($newPage);
$pde->setLocale($locale);
\Events::dispatch('on_multilingual_page_relate', $pde);
}
}