public function getMembers() { // get locale $locale = \Localization::activeLocale(); $c = $this->getCollectionObject(); if (is_object($c)) { $al = Section::getBySectionOfSite($c); if (is_object($al)) { $locale = $al->getLocale(); } } // fix for sorting if ($locale == 'en_US') { $locale = 'en'; } $params = array('limit' => 100, 'member_of' => $this->parentId, 'sort' => '1058', 'l' => $locale); // build URL with params $uh = \Core::make('helper/url'); $url = \Config::get('worldskills.api_url', 'https://api.worldskills.org') . '/org/members'; $url = $uh->buildQuery($url, $params); // fetch JSON $data = \Core::make("helper/file")->getContents($url); $data = json_decode($data, true); return $data; }
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()); }
public static function setupSiteInterfaceLocalization(Page $c = null) { if (!$c) { $c = Page::getCurrentPage(); } $app = Facade::getFacadeApplication(); // don't translate dashboard pages $dh = $app->make('helper/concrete/dashboard'); if ($dh->inDashboard($c)) { return; } $ms = Section::getBySectionOfSite($c); if (!is_object($ms)) { $ms = static::getPreferredSection(); } if (!$ms) { return; } $locale = $ms->getLocale(); if ($locale) { $app->make('session')->set('multilingual_default_locale', $locale); $loc = Localization::getInstance(); $loc->setContextLocale('site', $locale); } }
public static function setupSiteInterfaceLocalization(Page $c = null) { if (\User::isLoggedIn() && Config::get('concrete.multilingual.keep_users_locale')) { return; } if (!$c) { $c = Page::getCurrentPage(); } // don't translate dashboard pages $dh = \Core::make('helper/concrete/dashboard'); if ($dh->inDashboard($c)) { return; } $ms = Section::getBySectionOfSite($c); if (!is_object($ms)) { $ms = static::getPreferredSection(); } if (!$ms) { return; } $locale = $ms->getLocale(); if (strlen($locale)) { \Localization::changeLocale($locale); } }
public function assign() { $pr = new PageEditResponse(); if ($this->request->request->get('destID') == $this->page->getCollectionID()) { throw new \Exception(t("You cannot assign this page to itself.")); } $destPage = \Page::getByID($_POST['destID']); if (Section::isMultilingualSection($destPage)) { $ms = Section::getByID($destPage->getCollectionID()); } else { $ms = Section::getBySectionOfSite($destPage); } if (is_object($ms)) { // we need to assign/relate the source ID too, if it doesn't exist if (!Section::isAssigned($this->page)) { Section::registerPage($this->page); } Section::relatePage($this->page, $destPage, $ms->getLocale()); $ih = Core::make('multilingual/interface/flag'); $icon = (string) $ih->getSectionFlagIcon($ms); $pr->setAdditionalDataAttribute('name', $destPage->getCollectionName()); $pr->setAdditionalDataAttribute('link', $destPage->getCollectionLink()); $pr->setAdditionalDataAttribute('icon', $icon); $pr->setMessage(t('Page assigned.')); $pr->outputJSON(); } else { throw new \Exception(t("The destination page doesn't appear to be in a valid multilingual section.")); } }
public static function setupSiteInterfaceLocalization(Page $c = null) { $loc = \Localization::getInstance(); if (!(\User::isLoggedIn() && Config::get('concrete.multilingual.keep_users_locale'))) { if (!$c) { $c = Page::getCurrentPage(); } // don't translate dashboard pages $dh = \Core::make('helper/concrete/dashboard'); if ($dh->inDashboard($c)) { return; } $locale = null; $ms = Section::getBySectionOfSite($c); if ($ms) { $locale = $ms->getLocale(); } if (!$locale) { if (Config::get('concrete.multilingual.use_previous_locale') && Session::has('previous_locale')) { $locale = Session::get('previous_locale'); } if (!$locale) { $ms = static::getPreferredSection(); if ($ms) { $locale = $ms->getLocale(); } } } if ($locale) { $loc->setLocale($locale); } } Session::set('previous_locale', $loc->getLocale()); }
public static function getSectionFlagIcon($page, $filePathOnly = false) { $db = Database::get(); $section = Section::getBySectionOfSite($page); $icon = $section->getCountry(); return self::getFlagIcon($icon, $filePathOnly); }
public function __construct(Page $page, Dashboard $dashboard, Flag $flagService) { $this->page = $page; $this->dashboard = $dashboard; $this->flagService = $flagService; $this->multilingualSection = \Concrete\Core\Multilingual\Page\Section\Section::getBySectionOfSite($page); }
/** * @param string $stackName * @param string $cvID * * @return Page */ public static function getByName($stackName, $cvID = 'RECENT') { $c = Page::getCurrentPage(); if (is_object($c) && !$c->isError()) { $identifier = sprintf('/stack/name/%s/%s', $stackName, $c->getCollectionID()); $cache = Core::make('cache/request'); $item = $cache->getItem($identifier); if (!$item->isMiss()) { $cID = $item->get(); } else { $item->lock(); $db = Database::connection(); $ms = false; $detector = Core::make('multilingual/detector'); if ($detector->isEnabled()) { $ms = Section::getBySectionOfSite($c); if (!is_object($ms)) { $ms = $detector->getPreferredSection(); } } if (is_object($ms)) { $cID = $db->GetOne('select cID from Stacks where stName = ? and stMultilingualSection = ?', array($stackName, $ms->getCollectionID())); } else { $cID = $db->GetOne('select cID from Stacks where stName = ?', array($stackName)); } $item->set($cID); } } else { $cID = Database::connection()->GetOne('select cID from Stacks where stName = ?', array($stackName)); } return $cID ? static::getByID($cID, $cvID) : false; }
public function filterByPageLanguage(\Concrete\Core\Page\Page $page) { $ms = Section::getBySectionOfSite($page); if (!is_object($ms)) { $ms = static::getPreferredSection(); } if (is_object($ms)) { $this->filterByLanguageSection($ms); } }
public function filterByPageLanguage(\Concrete\Core\Page\Page $page) { $ms = Section::getBySectionOfSite($page); if (!is_object($ms)) { $ms = static::getPreferredSection(); } if (is_object($ms)) { $this->filter('stMultilingualSection', $ms->getCollectionID()); } }
public function getMember() { // get locale $locale = \Localization::activeLocale(); $c = $this->getCollectionObject(); if (is_object($c)) { $al = Section::getBySectionOfSite($c); if (is_object($al)) { $locale = $al->getLocale(); } } // build URL with params $uh = \Core::make('helper/url'); $url = \Config::get('worldskills.api_url', 'https://api.worldskills.org') . '/org/members/' . $this->memberId; $url = $uh->buildQuery($url, array('l' => $locale)); // fetch JSON $data = \Core::make("helper/file")->getContents($url); $data = json_decode($data, true); return $data; }
public function getSkills($sort = 'name_asc') { // get locale $locale = \Localization::activeLocale(); $c = $this->getCollectionObject(); if (is_object($c)) { $al = Section::getBySectionOfSite($c); if (is_object($al)) { $locale = $al->getLocale(); } } // fix for sorting if ($locale == 'en_US') { $locale = 'en'; } // defaults $params = array('limit' => 100, 'sort' => $sort, 'l' => $locale); // build URL with params $url = \Config::get('worldskills.api_url', 'https://api.worldskills.org') . '/events/' . $this->eventId . '/skills'; $url .= '?'; $url .= http_build_query($params); // block settings if ($this->sectorId) { $url .= '&'; $url .= http_build_query(array('sector' => $this->sectorId)); } if ($this->types) { $skillTypes = explode(',', $this->types); foreach ($skillTypes as $skillType) { $url .= '&'; $url .= http_build_query(array('type' => $skillType)); } } // fetch JSON $data = \Core::make("helper/file")->getContents($url); $data = json_decode($data, true); return $data; }
/** * Get the site name localized for a specific page. * * @param \Concrete\Core\Page\Page $page * * @return string */ public function getSiteNameForPage(\Concrete\Core\Page\Page $page) { static $multilingual; static $defaultLocale; if (!isset($multilingual)) { $multilingual = $this->app->make('multilingual/detector')->isEnabled(); } if ($multilingual) { if (!isset($defaultLocale)) { $defaultLocale = $this->app->make('config')->get('concrete.locale') ?: 'en_US'; } $section = Section::getBySectionOfSite($page); if ($section) { $locale = $section->getLocale(); } else { $locale = $defaultLocale; } $siteName = $this->getSiteNameForLocale($locale); } else { $siteName = $this->app->make('config')->get('concrete.site'); } return $siteName; }
<?php use Concrete\Core\Multilingual\Page\Section\Section as MultilingualSection; defined('C5_EXECUTE') or die("Access Denied."); if (Core::make('helper/validation/token')->validate('get_url_slug', $_REQUEST['token'])) { $lang = Localization::activeLanguage(); if (isset($_REQUEST['parentID']) && Core::make('multilingual/detector')->isEnabled()) { $ms = MultilingualSection::getBySectionOfSite(Page::getByID($_REQUEST['parentID'])); if (is_object($ms)) { $lang = $ms->getLanguage(); } } $text = Core::make('helper/text'); $name = $text->urlify($_REQUEST['name'], Config::get('concrete.seo.segment_max_length'), $lang); echo $name; }
$page = unserialize($p->body); $oc = Page::getByID($page['cID']); // this is the page we're going to copy. // now we check to see if the parent ID of the current record has already been duplicated somewhere. $newCID = $db->GetOne('select cID from QueuePageDuplicationRelations where originalCID = ? and queue_name = ?', array($page['cParentID'], 'copy_page')); if ($newCID > 0) { $dc = Page::getByID($newCID); } else { $dc = Page::getByID($page['destination']); } if ($_POST['multilingual']) { // Find multilingual section of the destination if (Section::isMultilingualSection($dc)) { $ms = Section::getByID($dc->getCollectionID()); } else { $ms = Section::getBySectionOfSite($dc); } // Is page already copied? $existingCID = Section::getRelatedCollectionIDForLocale($page['cID'], $ms->getLocale()); if ($existingCID) { $nc = Page::getById($existingCID); if ($dc->getCollectionID() != $nc->getCollectionParentID()) { $nc->move($dc); } } else { $nc = $oc->duplicate($dc); } } else { $nc = $oc->duplicate($dc); } $ocID = $oc->getCollectionID();
<?php defined('C5_EXECUTE') or die("Access Denied."); ?> <?php if (!is_array($messages)) { $messages = array(); } $u = new User(); $ui = UserInfo::getByID($u->getUserID()); $page = Page::getByID($cID); $ms = \Concrete\Core\Multilingual\Page\Section\Section::getBySectionOfSite($page); if (is_object($ms)) { Localization::changeLocale($ms->getLocale()); } $editor = \Concrete\Core\Conversation\Editor\Editor::getActive(); $editor->setConversationObject($args['conversation']); $val = Loader::helper('validation/token'); $form = Loader::helper('form'); ?> <?php Loader::element('conversation/message/add_form', array('blockAreaHandle' => $blockAreaHandle, 'cID' => $cID, 'bID' => $bID, 'editor' => $editor, 'addMessageLabel' => $addMessageLabel, 'attachmentsEnabled' => $attachmentsEnabled, 'displayForm' => $displayForm, 'displayPostingForm' => $displayPostingForm, 'position' => 'top', 'enablePosting' => $enablePosting, 'conversation' => $conversation)); ?> <div class="ccm-conversation-message-list ccm-conversation-messages-<?php echo $displayMode; ?> ">
/** Check if the specified page should be included in the sitemap.xml file; if so adds it to the XML document. * @param SimpleXMLElement $xmlDoc The xml document containing the sitemap nodes. * @param int $cID The page collection id. * @param array $instances An array with some already instantiated helpers, models, ... * * @throws \Exception Throws an exception in case of errors. */ private static function addPage($xmlDoc, $cID, $instances) { $page = Page::getByID($cID, 'ACTIVE'); if (!static::canIncludePageInSitemap($page, $instances)) { return; } $lastmod = new DateTime($page->getCollectionDateLastModified()); $changefreq = $page->getAttribute($instances['ak_sitemap_changefreq']); $priority = $page->getAttribute($instances['ak_sitemap_priority']); $xmlNode = $xmlDoc->addChild('url'); $xmlNode->addChild('loc', $instances['navigation']->getLinkToCollection($page)); $xmlNode->addChild('lastmod', $lastmod->format(DateTime::ATOM)); $xmlNode->addChild('changefreq', Core::make('helper/validation/strings')->notempty($changefreq) ? $changefreq : Config::get('concrete.sitemap_xml.frequency')); $xmlNode->addChild('priority', is_numeric($priority) ? $priority : Config::get('concrete.sitemap_xml.priority')); if ($instances['multilingualSections']) { $thisSection = MultilingualSection::getBySectionOfSite($page); if (is_object($thisSection) && !$thisSection->isError()) { foreach ($instances['multilingualSections'] as $section) { $relatedPageID = $section->getTranslatedPageID($page); if ($relatedPageID) { $relatedPage = Page::getByID($relatedPageID); if (static::canIncludePageInSitemap($relatedPage, $instances)) { $xmlAltNode = $xmlNode->addChild('link', null, 'http://www.w3.org/1999/xhtml'); $xmlAltNode->addAttribute('rel', 'alternate'); $xmlAltNode->addAttribute('hreflang', strtolower(str_replace('_', '-', $section->getLocale()))); $xmlAltNode->addAttribute('href', $instances['navigation']->getLinkToCollection($relatedPage)); } } } } } $event = new \Symfony\Component\EventDispatcher\GenericEvent(); $event->setArgument('xmlNode', $xmlNode); $event->setArgument('page', $page); Events::dispatch('on_sitemap_xml_addingpage', $event); if (!empty($ret) && $ret < 0) { for ($i = count($xmlDoc->url) - 1; $i >= 0; $i--) { if ($xmlDoc->url[$i] == $xmlNode) { unset($xmlDoc->url[$i]); break; } } } }
protected function getMultilingualSectionFromType($type) { $detector = Core::make('multilingual/detector'); if ($type == self::MULTILINGUAL_CONTENT_SOURCE_DEFAULT) { $ms = Section::getDefaultSection(); } else { $c = \Page::getCurrentPage(); $ms = Section::getBySectionOfSite($c); if (!is_object($ms)) { $ms = $detector->getPreferredSection(); } } return $ms; }