From 66f68e96236848e8f1dd5992f1d7d0c5cc6da2a9 Mon Sep 17 00:00:00 2001 From: thomascube <thomas@roundcube.net> Date: Thu, 21 May 2009 16:02:43 -0400 Subject: [PATCH] Make links with /this/ pointing to the plugins skin directory --- program/include/rcube_template.php | 19 ++++++++++++++++++- 1 files changed, 18 insertions(+), 1 deletions(-) diff --git a/program/include/rcube_template.php b/program/include/rcube_template.php index 6ceb9ce..f6718e3 100755 --- a/program/include/rcube_template.php +++ b/program/include/rcube_template.php @@ -332,6 +332,17 @@ private function parse($name = 'main', $exit = true) { $skin_path = $this->config['skin_path']; + $plugin = false; + + $temp = explode(".", $name, 2); + if (count($temp) > 1) { + $plugin = $temp[0]; + $name = $temp[1]; + $skin_path = $this->config['plugins_dir'] . '/' . $temp[0] . '/skins/' . $this->config['skin']; + if (!is_dir($skin_path)) // fallback to default skin + $skin_path = $this->config['plugins_dir'] . '/' . $temp[0] . '/skins/default'; + } + $path = "$skin_path/templates/$name.html"; // read template file @@ -344,6 +355,12 @@ 'message' => 'Error loading template for '.$name ), true, true); return false; + } + + // replace all path references to plugins/... with the configured plugins dir + // and /this/ to the current plugin skin directory + if ($plugin) { + $templ = preg_replace(array('/\bplugins\//', '/(["\']?)\/this\//'), array($this->config['plugins_dir'].'/', "\\1$skin_path/"), $templ); } // parse for specialtags @@ -358,7 +375,7 @@ ); } $output = $this->parse_with_globals($output); - $this->write(trim($output), $skin_path); + $this->write(trim($output)); if ($exit) { exit; } -- Gitblit v1.9.1