Exemplo n.º 1
0
 public function createDefaultEntity()
 {
     $tree = new SiteTree();
     $tree->setSiteHomePageID(HOME_CID);
     $locale = new Locale();
     $locale->setLanguage('en');
     $locale->setCountry('US');
     $locale->setSiteTree($tree);
     $site = new Site($this->config);
     $site->setSiteHandle('default');
     $site->setIsDefault(true);
     $tree->setLocale($locale);
     return $site;
 }
Exemplo n.º 2
0
 /**
  * Receives a page in a different language tree, and tries to return the corresponding page in the current language tree.
  *
  * @return int|null
  */
 public function getTranslatedPageID($page)
 {
     $ids = static::getIDList();
     if (in_array($page->getCollectionID(), $ids)) {
         return $this->locale->getSiteTree()->getSiteHomePageID();
     }
     $mpRelationID = self::getMultilingualPageRelationID($page->getCollectionID());
     if ($mpRelationID) {
         $cID = self::getCollectionIDForLocale($mpRelationID, $this->getLocale());
         return $cID;
     }
 }
Exemplo n.º 3
0
 protected function getLocaleDisplayName(Locale $locale)
 {
     $name = $locale->getLanguageText();
     foreach ($this->getLocales() as $otherLocale) {
         if ($otherLocale->getSiteLocaleID() != $locale->getSiteLocaleID() && $otherLocale->getLanguage() == $locale->getLanguage()) {
             $name = sprintf('%s (%s)', $locale->getLanguageText(), $this->countries->getCountryName($locale->getCountry()));
         }
     }
     return $name;
 }
Exemplo n.º 4
0
 public static function getLocaleFlagIcon(Locale $locale, $filePathOnly = false)
 {
     $icon = $locale->getCountry();
     return self::getFlagIcon($icon, $filePathOnly);
 }
Exemplo n.º 5
0
 public function delete(Locale $locale)
 {
     $tree = $locale->getSiteTree();
     if (is_object($tree)) {
         $locale->setSiteTree(null);
         $this->entityManager->remove($tree);
         $this->entityManager->flush();
     }
     $this->entityManager->remove($locale);
     $this->entityManager->flush();
 }
Exemplo n.º 6
0
 public function installDefault($locale = null)
 {
     if (!$locale) {
         $locale = Localization::BASE_LOCALE;
     }
     $siteConfig = $this->config->get('site');
     $defaultSite = array_get($siteConfig, 'default');
     $factory = new Factory($this->config);
     $site = $factory->createEntity();
     $site->setSiteHandle(array_get($siteConfig, "sites.{$defaultSite}.handle"));
     $site->setIsDefault(true);
     $data = explode('_', $locale);
     $locale = new Locale();
     $locale->setSite($site);
     $locale->setIsDefault(true);
     $locale->setLanguage($data[0]);
     $locale->setCountry($data[1]);
     $tree = new SiteTree();
     $tree->setSiteHomePageID(HOME_CID);
     $tree->setLocale($locale);
     $locale->setSiteTree($tree);
     $site->getLocales()->add($locale);
     $service = $this->app->make('site/type');
     $type = $service->getDefault();
     $site->setType($type);
     $this->entityManager->persist($site);
     $this->entityManager->flush();
     return $site;
 }