<nav class="contentHeaderNavigation">
<ul>
{content}
- {if $article->isMultilingual}
+ {if $article->isMultilingual && $__wcf->user->userID}
<li class="dropdown">
<a class="dropdownToggle boxFlag box24 button">
<span><img src="{$articleContent->getLanguage()->getIconPath()}" alt="" class="iconFlag"></span>
{/if}
{/capture}
+{capture assign='contentHeaderNavigation'}
+ {if $page->isMultilingual && $__wcf->user->userID}
+ <li class="dropdown">
+ <a class="dropdownToggle boxFlag box24 button">
+ <span><img src="{$activePageLanguage->getIconPath()}" alt="" class="iconFlag"></span>
+ <span>{$activePageLanguage->languageName}</span>
+ </a>
+ <ul class="dropdownMenu">
+ {foreach from=$page->getPageLanguages() item='pageLanguage'}
+ {if $pageLanguage->getLanguage()}
+ <li class="boxFlag">
+ <a class="box24" href="{$pageLanguage->getLink()}">
+ <span><img src="{$pageLanguage->getLanguage()->getIconPath()}" alt="" class="iconFlag"></span>
+ <span>{$pageLanguage->getLanguage()->languageName}</span>
+ </a>
+ </li>
+ {/if}
+ {/foreach}
+ </ul>
+ </li>
+ {/if}
+
+ {if $__wcf->getSession()->getPermission('admin.content.cms.canManagePage')}<li><a href="{link controller='PageEdit' id=$page->pageID isACP=true}{/link}" class="button"><span class="icon icon16 fa-pencil"></span> <span>{lang}wcf.acp.page.edit{/lang}</span></a></li>{/if}
+{/capture}
+
{include file='header'}
{if $content[content]}
{implode from=$__wcf->getLanguage()->getLanguages() item=__language}
'{@$__language->languageID}': {
iconPath: '{@$__language->getIconPath()|encodeJS}',
- languageName: '{@$__language|encodeJS}'
+ languageName: '{@$__language|encodeJS}',
+ languageCode: '{@$__language->languageCode|encodeJS}'
}
{/implode}
};
-
+
var callback = function(listItem) {
- var location = window.location.toString().replace(/#.*/, '').replace(/(\?|&)l=[0-9]+/g, '');
- var delimiter = (location.indexOf('?') == -1) ? '?' : '&';
+ var location;
+ var languageCode = elData(listItem, 'language-code');
+ var link = elBySel('link[hreflang="' + languageCode + '"]');
+ if (link !== null) {
+ location = link.href;
+ }
+ else {
+ location = window.location.toString().replace(/#.*/, '').replace(/(\?|&)l=[0-9]+/g, '');
+ }
+ var delimiter = (location.indexOf('?') == -1) ? '?' : '&';
window.location = location + delimiter + 'l=' + elData(listItem, 'language-id') + window.location.hash;
};
listItem.className = 'boxFlag';
listItem.addEventListener(WCF_CLICK_EVENT, callbackClick);
elData(listItem, 'language-id', availableLanguageId);
+ if (language.languageCode !== undefined) elData(listItem, 'language-code', language.languageCode);
dropdownMenu.appendChild(listItem);
a = elCreate('a');
<?php
namespace wcf\page;
use wcf\data\article\AccessibleArticleList;
-use wcf\data\article\CategoryArticleList;
+use wcf\data\article\category\ArticleCategory;
use wcf\data\article\content\ViewableArticleContent;
use wcf\data\article\ArticleEditor;
use wcf\data\article\ViewableArticle;
+use wcf\data\tag\Tag;
use wcf\system\database\util\PreparedStatementConditionBuilder;
use wcf\system\exception\IllegalLinkException;
use wcf\system\exception\PermissionDeniedException;
}
$this->article = ViewableArticle::getArticle($this->articleContent->articleID);
$this->category = $this->article->getCategory();
+
+ // update interface language
+ if (!WCF::getUser()->userID && $this->article->isMultilingual && $this->articleContent->languageID != WCF::getLanguage()->languageID) {
+ WCF::setLanguage($this->articleContent->languageID);
+ }
}
/**
namespace wcf\page;
use wcf\data\page\Page;
use wcf\system\exception\IllegalLinkException;
+use wcf\system\language\LanguageFactory;
use wcf\system\request\LinkHandler;
use wcf\system\request\RequestHandler;
use wcf\system\WCF;
}
$this->canonicalURL = LinkHandler::getInstance()->getCmsLink($this->pageID, $this->languageID);
+
+ // update interface language
+ if (!WCF::getUser()->userID && $this->page->isMultilingual && $this->languageID != WCF::getLanguage()->languageID) {
+ WCF::setLanguage($this->languageID);
+ }
}
/**
'content' => $this->content,
'contentLanguageID' => $this->languageID,
'page' => $this->page,
- 'pageID' => $this->pageID
+ 'pageID' => $this->pageID,
+ 'activePageLanguage' => ($this->languageID ? LanguageFactory::getInstance()->getLanguage($this->languageID) : null)
]);
}
}