本文整理汇总了PHP中Concrete\Core\Multilingual\Page\Section\Section类的典型用法代码示例。如果您正苦于以下问题:PHP Section类的具体用法?PHP Section怎么用?PHP Section使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Section类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createFromMultilingualSection
/**
* @param Section $section
* @return StackCategory
*/
public static function createFromMultilingualSection(Section $section)
{
$parent = \Page::getByPath(STACKS_PAGE_PATH);
$data = array();
$data['name'] = $section->getLocale();
$data['cHandle'] = $section->getLocale();
$type = Type::getByHandle(STACK_CATEGORY_PAGE_TYPE);
$page = $parent->add($type, $data);
$sc = new StackCategory($page);
return $sc;
}
示例2: setupSiteInterfaceLocalization
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);
}
}
示例3: getMembers
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;
}
示例4: 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());
}
示例5: getDashboardSitemapIconSRC
public function getDashboardSitemapIconSRC($page)
{
$ids = Section::getIDList();
if (in_array($page->getCollectionID(), $ids)) {
return self::getSectionFlagIcon($page, true);
}
}
示例6: setupSiteInterfaceLocalization
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);
}
}
示例7: __construct
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);
}
示例8: setupSiteInterfaceLocalization
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());
}
示例9: rescan_locale
public function rescan_locale()
{
if ($this->token->validate('rescan_locale')) {
$u = new \User();
if ($u->isSuperUser()) {
\Core::make('cache/request')->disable();
$section = Section::getByID($_REQUEST['locale']);
$target = new MultilingualProcessorTarget($section);
$processor = new Processor($target);
if ($_POST['process']) {
foreach ($processor->receive() as $task) {
$processor->execute($task);
}
$obj = new \stdClass();
$obj->totalItems = $processor->getTotalTasks();
echo json_encode($obj);
exit;
} else {
$processor->process();
}
$totalItems = $processor->getTotalTasks();
\View::element('progress_bar', array('totalItems' => $totalItems, 'totalItemsSummary' => t2("%d task", "%d tasks", $totalItems)));
exit;
}
}
}
示例10: rescan_locale
public function rescan_locale()
{
if ($this->token->validate('rescan_locale')) {
$u = new \User();
if ($u->isSuperUser()) {
\Core::make('cache/request')->disable();
$section = Section::getByID($_REQUEST['locale']);
$target = new MultilingualProcessorTarget($section);
$processor = new Processor($target);
if ($_POST['process']) {
foreach ($processor->receive() as $task) {
$processor->execute($task);
}
$obj = new \stdClass();
$obj->totalItems = $processor->getTotalTasks();
print json_encode($obj);
exit;
} else {
$processor->process();
}
$totalItems = $processor->getTotalTasks();
\View::element('progress_bar', array('totalItems' => $totalItems, 'totalItemsSummary' => t2("%d task", "%d tasks", $totalItems)));
/*
$q = Queue::get('rescan_multilingual_section');
if ($_POST['process']) {
$obj = new \stdClass;
$messages = $q->receive(\Config::get('concrete.limits.copy_pages'));
foreach($messages as $key => $p) {
// delete the page here
$page = unserialize($p->body);
$oc = \Page::getByID($page['cID']);
$q->deleteMessage($p);
}
$obj->totalItems = $q->count();
print json_encode($obj);
if ($q->count() == 0) {
$q->deleteQueue('rescan_multilingual_section');
}
exit;
} else if ($q->count() == 0) {
$oc = Section::getByID($_REQUEST['locale']);
if (is_object($oc) && !$oc->isError()) {
$oc->queueForDeletionRequest($q, false);
}
}
$totalItems = $q->count();
\View::element('progress_bar', array('totalItems' => $totalItems, 'totalItemsSummary' => t2("%d page", "%d pages", $totalItems)));
*/
exit;
}
}
}
示例11: getNewsPage
public static function getNewsPage()
{
$currentSection = Section::getCurrentSection();
if ($currentSection) {
$localeID = $currentSection->getCollectionID();
} else {
return false;
}
return self::getChildPage($localeID, "news");
}
示例12: canAccess
protected function canAccess()
{
$app = \Core::make("app");
$dashboard = $app->make('helper/concrete/dashboard');
if ($app->make('multilingual/detector')->isEnabled() && is_object(Section::getCurrentSection()) && !$dashboard->inDashboard($this->page) && $this->permissions->canEditPageMultilingualSettings()) {
return true;
}
if (!$dashboard->inDashboard($this->page) && count($this->page->getPageRelations()) > 0) {
return true;
}
return false;
}
示例13: 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);
}
}
示例14: finalizeQuery
public function finalizeQuery(QueryBuilder $query)
{
$query = parent::finalizeQuery($query);
$mslist = Section::getList();
$relation = Database::get()->createQueryBuilder();
$relation->select('mpRelationID')->from('MultilingualPageRelations', 'mppr')->where('cID = p.cID')->setMaxResults(1);
$query->addSelect('(' . $relation . ') as mpr');
foreach ($mslist as $ms) {
$section = Database::get()->createQueryBuilder();
$section->select('count(mpRelationID)')->from('MultilingualPageRelations', 'mppr')->where('mpRelationID = mpr')->andWhere($section->expr()->comparison('mpLocale', '=', $query->createNamedParameter($ms->getLocale())));
$query->addSelect('(' . $section . ') as relationCount' . $ms->getCollectionID());
}
return $query;
}
示例15: finalizeQuery
public function finalizeQuery(QueryBuilder $query)
{
$db = Database::connection();
$query = parent::finalizeQuery($query);
$mainRelation = $db->createQueryBuilder();
$mainRelation->select('mpr0.cID')->addSelect('MIN(mpr0.mpRelationID) as mpr')->from('MultilingualPageRelations', 'mpr0')->groupBy('mpr0.cID');
$query->addSelect('mppr.mpr')->leftJoin('p', '(' . $mainRelation . ')', 'mppr', 'p.cID = mppr.cID');
$mslist = Section::getList();
foreach ($mslist as $ms) {
$cID = (int) $ms->getCollectionID();
$cLocale = (string) $ms->getLocale();
$query->addSelect("count(mppr{$cID}.mpRelationID) as relationCount{$cID}")->leftJoin('mppr', 'MultilingualPageRelations', "mppr{$cID}", "mppr.mpr = mppr{$cID}.mpRelationID AND " . $db->quote($cLocale) . " = mppr{$cID}.mpLocale");
}
$query->addGroupBy(['p.cID', 'mppr.mpr']);
return $query;
}