Пример #1
0
 /**
  * Hook Callback.  Resort page match results so that results are ordered by translation, having the
  * default language first
  */
 function translation_search(&$event, $args)
 {
     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);
         }
     }
 }
Пример #2
0
 /**
  * Class constructor
  */
 function __construct()
 {
     parent::helper_plugin_translation();
     // load language names
     $this->LN = confToHash(dirname(__FILE__) . '/lang/langnames.txt');
 }
Пример #3
0
 /**
  * Class constructor
  */
 function __construct()
 {
     parent::helper_plugin_translation();
     $this->load_from_cache();
 }