Exemplo n.º 1
0
 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);
             }
         }
     }
 }
Exemplo n.º 2
0
 /**
  * @param string $stackName
  * @param string $cvID
  * @param integer $multilingualContentSource
  * @return Page
  */
 public static function getByName($stackName, $cvID = 'RECENT', $multilingualContentSource = self::MULTILINGUAL_CONTENT_SOURCE_CURRENT)
 {
     $c = Page::getCurrentPage();
     if (is_object($c) && !$c->isError()) {
         $identifier = sprintf('/stack/name/%s/%s/%s/%s', $stackName, $c->getCollectionID(), $cvID, $multilingualContentSource);
         $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()) {
                 if ($multilingualContentSource == self::MULTILINGUAL_CONTENT_SOURCE_DEFAULT) {
                     $ms = Section::getDefaultSection();
                 } else {
                     $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;
 }
Exemplo n.º 3
0
 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;
 }