Skip to content

Commit

Permalink
work with the new SEARCH_QUERY_PAGELOOKUP event result
Browse files Browse the repository at this point in the history
  • Loading branch information
splitbrain committed Jun 26, 2010
1 parent 39ecab8 commit d75e50b
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 14 deletions.
48 changes: 35 additions & 13 deletions action.php
Expand Up @@ -77,19 +77,41 @@ function translation_hook(&$event, $args) {
* default language first
*/
function translation_search(&$event, $args) {
// sort into translation slots
$res = array();
foreach($event->result as $r){
$tr = $this->hlp->getLangPart($r);
if(!is_array($res["x$tr"])) $res["x$tr"] = array();
$res["x$tr"][] = $r;
}
// sort by translations
ksort($res);
// combine
$event->result = array();
foreach($res as $r){
$event->result = array_merge($event->result,$r);

if($event->data['has_titles']){
// sort into translation slots
$res = array();
foreach($event->result as $r => $t){
$tr = $this->hlp->getLangPart($r);
if(!is_array($res["x$tr"])) $res["x$tr"] = array();
$res["x$tr"][] = array($r,$t);
}
// sort by translations
ksort($res);
// combine
$event->result = array();
foreach($res as $r){
foreach($r as $l){
$event->result[$l[0]] = $l[1];
}
}
}else{
# legacy support for old DokuWiki hooks

// sort into translation slots
$res = array();
foreach($event->result as $r){
$tr = $this->hlp->getLangPart($r);
if(!is_array($res["x$tr"])) $res["x$tr"] = array();
$res["x$tr"][] = $r;
}
// sort by translations
ksort($res);
// combine
$event->result = array();
foreach($res as $r){
$event->result = array_merge($event->result,$r);
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion plugin.info.txt
Expand Up @@ -2,7 +2,7 @@
base translation
author Andreas Gohr
email andi@splitbrain.org
date 2009-10-25
date 2010-06-26
name Translation Plugin
desc Supports the easy setup of a multi-language wiki.
url http://www.dokuwiki.org/plugin:translation

0 comments on commit d75e50b

Please sign in to comment.