Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions system/core/base.php
Original file line number Diff line number Diff line change
Expand Up @@ -783,8 +783,9 @@ function hypha_incrementStats($timestamp) {
Parameters:
$page - DOMElement containing page settings
$language - page language
$subpage - added to the page url, a / is added automatically
*/
function hypha_indexLanguages($page, $language) {
function hypha_indexLanguages($page, $language, $subpage='') {
$langList = hypha_getUsedContentLanguages();
if (count($langList)) asort($langList);

Expand All @@ -797,8 +798,12 @@ function hypha_indexLanguages($page, $language) {
foreach($langList as $lang) {
if ($lang == $language) $index.= '<span class="language selected">'.$lang.'</span>';
elseif (!$page || array_key_exists($lang, $pageLangList)) {
if ($page) $index.= '<span class="language"><a href="'.$lang.'/'.$pageLangList[$lang].'">'.$lang.'</a></span>';
else $index.= '<span class="language"><a href="index/'.$lang.'">'.$lang.'</a></span>';
if ($page)
$url = $lang.'/'.$pageLangList[$lang];
else
$url = 'index/' . $lang;
if ($subpage) $url .= '/'.$subpage;
$index.= '<span class="language"><a href="'.$url.'">'.$lang.'</a></span>';
}
else $index.= '<span class="language disabled">'.$lang.'</span>';
}
Expand Down
12 changes: 12 additions & 0 deletions system/core/pages.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,18 @@ public function renderExcerpt(HyphaDomElement $container) {
$this->renderSingleLine($container);
}

/**
* Returns a list of language codes this page is
* translated in, based on the languages listed in
* hypha.xml.
*/
public function getLanguages() {
$result = [];
foreach($this->pageListNode->getElementsByTagName('language') as $lang)
$result[] = $lang->getAttribute('id');
return $result;
}

/*
* Returns a date typically used for sorting these pages
* (i.e. the publish date or last update date).
Expand Down
Loading