示例#1
0
 public function view()
 {
     $uh = Loader::helper('concrete/urls');
     $bt = BlockType::getByHandle('switch_language');
     Loader::model('section', 'multilingual');
     $ml = MultilingualSection::getList();
     $c = Page::getCurrentPage();
     $al = MultilingualSection::getBySectionOfSite($c);
     $languages = array();
     $locale = ACTIVE_LOCALE;
     if (is_object($al)) {
         $locale = $al->getLanguage();
     }
     foreach ($ml as $m) {
         $languages[$m->getCollectionID()] = $m->getLanguageText($locale) . ' ' . (strlen($m->msIcon) ? '(' . $m->msIcon . ')' : '');
     }
     $this->set('languages', $languages);
     $this->set('languageSections', $ml);
     $this->set('action', $uh->getBlockTypeToolsURL($bt) . '/switch');
     if (is_object($al)) {
         $this->set('activeLanguage', $al->getCollectionID());
     }
     $pkg = Package::getByHandle('multilingual');
     $mdl = Loader::helper('default_language', 'multilingual');
     $this->set('defaultLanguage', $mdl->getSessionDefaultLocale());
     $this->set('cID', $c->getCollectionID());
 }
示例#2
0
 public function assign_page()
 {
     Loader::model('section', 'multilingual');
     if (Loader::helper('validation/token')->validate('assign_page', $_POST['token'])) {
         if ($_REQUEST['destID'] == $_REQUEST['sourceID']) {
             print '<span class="ccm-error">' . t("You cannot assign this page to itself.") . '</span>';
             exit;
         }
         $destPage = Page::getByID($_POST['destID']);
         if (MultilingualSection::isMultilingualSection($destPage)) {
             $ms = MultilingualSection::getByID($destPage->getCollectionID());
         } else {
             $ms = MultilingualSection::getBySectionOfSite($destPage);
         }
         if (is_object($ms)) {
             $page = Page::getByID($_POST['sourceID']);
             // we need to assign/relate the source ID too, if it doesn't exist
             if (!MultilingualSection::isAssigned($page)) {
                 MultilingualSection::assignAdd($page);
             }
             MultilingualSection::relatePage($page, $destPage, $ms->getLocale());
             print '<a href="' . Loader::helper("navigation")->getLinkToCollection($destPage) . '">' . $destPage->getCollectionName() . '</a>';
         } else {
             print '<span class="ccm-error">' . t("The destination page doesn't appear to be in a valid multilingual section.") . '</span>';
         }
     }
     exit;
 }
示例#3
0
<?php

defined('C5_EXECUTE') or die("Access Denied.");
if (Loader::helper('validation/token')->validate('get_url_slug', $_REQUEST['token'])) {
    $lang = LANGUAGE;
    if (isset($_REQUEST['parentID']) && ($multilingual = Package::getByHandle('multilingual'))) {
        $ms = MultilingualSection::getBySectionOfSite(Page::getByID($_REQUEST['parentID']));
        if (is_object($ms)) {
            $lang = $ms->getLanguage();
        }
    }
    $text = Loader::helper('text');
    $name = $text->urlify($_REQUEST['name'], PAGE_PATH_SEGMENT_MAX_LENGTH, $lang);
    $ret = Events::fire('on_page_urlify', $_REQUEST['name']);
    if ($ret) {
        $name = $ret;
    }
    echo $name;
}
示例#4
0
 public static function assignMove($page, $oldParent, $newParent)
 {
     if (self::isMultilingualSection($newParent)) {
         $ms = MultilingualSection::getByID($newParent->getCollectionID());
     } else {
         $ms = MultilingualSection::getBySectionOfSite($newParent);
     }
     if (self::isMultilingualSection($oldParent)) {
         $msx = MultilingualSection::getByID($oldParent->getCollectionID());
     } else {
         $msx = MultilingualSection::getBySectionOfSite($oldParent);
     }
     $db = Loader::db();
     if (is_object($ms)) {
         $cID = $db->GetOne('select cID from MultilingualPageRelations where cID = ?', array($page->getCollectionID()));
         if (!$cID) {
             $mpRelationID = $db->GetOne('select max(mpRelationID) as mpRelationID from MultilingualPageRelations');
             if (!$mpRelationID) {
                 $mpRelationID = 1;
             } else {
                 $mpRelationID++;
             }
             $v = array($mpRelationID, $page->getCollectionID(), $ms->getLanguage(), $ms->getLocale());
             $db->Execute('insert into MultilingualPageRelations (mpRelationID, cID, mpLanguage, mpLocale) values (?, ?, ?, ?)', $v);
         } else {
             $db->Execute('update MultilingualPageRelations set mpLanguage = ? where cID = ?', array($ms->getLanguage(), $page->getCollectionID()));
         }
         // now we check to see if the new target section has a different theme
         if (is_object($ms) && is_object($msx)) {
             if ($ms->getCollectionThemeID() != $msx->getCollectionThemeID()) {
                 $pt = $ms->getCollectionThemeObject();
                 $page->setTheme($pt);
             }
         }
     } else {
         self::assignDelete($page);
     }
 }
示例#5
0
文件: page.php 项目: Zyqsempai/amanet
 /** Adds the link rel="alternate" hreflang=".." href=".." tag to the specified page.
  * @param Page $page
  */
 public function addAlternateHrefLang($page)
 {
     if ($page || ($page = Page::getCurrentPage())) {
         if (!$page->isAdminArea()) {
             if ($lang = MultilingualSection::getBySectionOfSite($page)) {
                 if (!is_array(self::$_allLanguages)) {
                     self::$_allLanguages = MultilingualSection::getList();
                 }
                 $html = Loader::helper('html');
                 $navigation = Loader::helper('navigation');
                 $v = View::getInstance();
                 if (!$page->isAlias() && $page->cID == $lang->cID) {
                     $isRoot = true;
                 } else {
                     $isRoot = false;
                 }
                 foreach (self::$_allLanguages as $otherLang) {
                     if ($otherLang->msLocale != $lang->msLocale) {
                         if ($isRoot) {
                             $otherPage = $otherLang;
                         } else {
                             $otherPage = $this->getTranslatedPageWithAliasSupport($page, $otherLang, false);
                         }
                         if ($otherPage) {
                             $v->addHeaderItem('<link rel="alternate" hreflang="' . $otherLang->msLocale . '" href="' . $navigation->getLinkToCollection($otherPage) . '" />');
                         }
                     }
                 }
             }
         }
     }
 }