Exemplo n.º 1
0
 public function getTranslatedPages($page = false, $sans = false)
 {
     $langms = new MultilingualSection();
     if ($page) {
         $ms = MultilingualSection::getByID($page->getCollectionID());
     } else {
         $page = Page::getCurrentPage();
         $ms = MultilingualSection::getCurrentSection();
     }
     if (is_object($ms)) {
         $lang = $ms->getLocale();
     }
     if ($sans) {
         $locales = self::getLocales($sans);
     } else {
         $locales = self::getLocales($lang);
     }
     $tpages = array();
     foreach ($locales as $locale) {
         $langms->msLocale = $locale;
         $id = $langms->getTranslatedPageID($page);
         $transPage = Page::getByID($id);
         $transPage->locale = $locale;
         if ($id > 0) {
             $tpages[$locale] = $transPage;
         }
     }
     return $tpages;
 }
Exemplo n.º 2
0
 /**
  * gets the locale string for the current page
  * based first on path within the site (section) or session if not available
  * @return string
  */
 public function getLocale()
 {
     $ms = MultilingualSection::getCurrentSection();
     if (is_object($ms)) {
         $lang = $ms->getLocale();
     } else {
         $lang = Loader::helper('default_language', 'multilingual')->getSessionDefaultLocale();
     }
     $_SESSION['DEFAULT_LOCALE'] = (string) $lang;
     return (string) $lang;
 }
Exemplo n.º 3
0
 public function getMenuLinkHTML()
 {
     $sect = MultilingualSection::getCurrentSection();
     $ih = Loader::helper('interface/flag', 'multilingual');
     $icon = $ih->getFlagIcon($sect->getIcon(), true);
     $class = 'ccm-page-edit-nav-multilingual-flag';
     if (!$icon) {
         $icon = $this->menuItem->getMenuItemFileURL('generic_language.png');
         $class = 'ccm-page-edit-nav-multilingual-no-flag';
     }
     $page = Page::getCurrentPage();
     $this->menuItem->linkAttributes['href'] .= '?cID=' . $page->getCollectionID();
     $this->menuItem->linkAttributes['class'] = $class;
     $this->menuItem->linkAttributes['style'] = 'background-image: url(' . $icon . ')';
     $this->menuItem->setName($sect->getLanguageText());
     return parent::getMenuLinkHTML();
 }
Exemplo n.º 4
0
 public static function setupSiteInterfaceLocalization()
 {
     // don't translate dashboard pages
     $c = Page::getCurrentPage();
     if ($c instanceof Page && Loader::helper('section', 'multilingual')->section('dashboard')) {
         return;
     }
     $ms = MultilingualSection::getCurrentSection();
     if (is_object($ms)) {
         $locale = $ms->getLocale();
     } else {
         $locale = DefaultLanguageHelper::getSessionDefaultLocale();
     }
     // change core language to translate e.g. core blocks/themes
     if (strlen($locale)) {
         Localization::changeLocale($locale);
     }
     // site translations
     if (is_dir(DIR_LANGUAGES_SITE_INTERFACE)) {
         if (file_exists(DIR_LANGUAGES_SITE_INTERFACE . '/' . $locale . '.mo')) {
             $loc = Localization::getInstance();
             $loc->addSiteInterfaceLanguage($locale);
         }
     }
     // add package translations
     if (strlen($locale)) {
         $ms = MultilingualSection::getByLocale($locale);
         if ($ms instanceof MultilingualSection) {
             $pl = PackageList::get();
             $installed = $pl->getPackages();
             foreach ($installed as $pkg) {
                 if ($pkg instanceof Package) {
                     $pkg->setupPackageLocalization($ms->getLocale());
                 }
             }
         }
     }
 }
Exemplo n.º 5
0
$class2 = 'icon-select-page';
if (version_compare(APP_VERSION, '5.5.2.2', '>')) {
    $class1 = 'item-select-list';
    $class2 = 'item-select-page';
}
$c = Page::getByID($_REQUEST['cID'], 'RECENT');
$cp = new Permissions($c);
$pc = Page::getByPath('/dashboard/multilingual');
$pcp = new Permissions($pc);
$nav = Loader::helper('navigation');
$ih = Loader::helper('interface/flag', 'multilingual');
if ($cp->canRead() && $pcp->canRead()) {
    // grab all languages
    Loader::model('section', 'multilingual');
    $mlist = MultilingualSection::getList();
    $currentSection = MultilingualSection::getCurrentSection();
    $ml[] = $currentSection;
    foreach ($mlist as $m) {
        if ($m->getCollectionID() != $currentSection->getCollectionID()) {
            $ml[] = $m;
        }
    }
    // then loop through them and show if a page exists
    ?>

	<ul class="<?php 
    echo $class1;
    ?>
">
	<?php 
    foreach ($ml as $m) {