From ac2a8ccc05388dcd538ed4adfed19d765b1014be Mon Sep 17 00:00:00 2001 From: Igor Date: Wed, 10 Nov 2010 15:44:14 +0300 Subject: Support for Translate plugin (looking for uploaded files in language namespace) --- syntax.php | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/syntax.php b/syntax.php index 27c1eb6..ac925b3 100644 --- a/syntax.php +++ b/syntax.php @@ -82,17 +82,21 @@ class syntax_plugin_papers extends DokuWiki_Syntax_Plugin // begin: display options, not BiBTeX fields $source = ''; - $lang = $this->getLangPart($ID); - if (!empty($lang)) $source .= $lang . ':'; if (isset($spec['source'])) { - $source .= $spec['source']; + $source = $spec['source']; unset($spec['source']); } else { - $source .= $this->getConf($tag); + $source = $this->getConf($tag); } + + // Prepend language namespace if any and if not in root (:) + $lang = $this->getLangPart($ID); + if (!empty($lang) && !preg_match('/^:/', $source)) + $source = $lang . ':' . $source; + $source = wikiFN($source); $options = array('byyear' => 0); @@ -179,12 +183,18 @@ class syntax_plugin_papers extends DokuWiki_Syntax_Plugin global $ID; global $conf; - $save_lang = $this->getLangPart($ID); - if (!empty($save_lang)) + $lang = $this->getLangPart($ID); + $save_lang = ''; + if (!empty($lang)) { $save_lang = $conf['lang']; - $conf['lang'] = $this->getLangPart($ID); + $conf['lang'] = $lang; } + + $papers_ns = $this->getConf('papers_ns'); + if (!empty($lang) && !preg_match('/^:/', $papers_ns)) + $papers_ns = $lang . '/' . $papers_ns; + // $papers_ns = wikiFN($papers_ns); $res = ''; $year = ''; $year_prev = ''; @@ -259,7 +269,7 @@ class syntax_plugin_papers extends DokuWiki_Syntax_Plugin $links = array(); foreach ($this->getConf('filetypes') as $type) { - $file = $this->getConf('papers_ns') . '/' . $entry['id'] . '.' . mb_strtolower($type); + $file = $papers_ns . '/' . $entry['id'] . '.' . mb_strtolower($type); if (file_exists(PAPERS_DATADIR . $file)) { $size = round(filesize(PAPERS_DATADIR . $file) / 1024) . ' ' . $this->getLang('KiB'); -- cgit v1.2.3