diff options
author | rvelices <rv-github@modusoptimus.com> | 2006-11-01 05:04:24 +0000 |
---|---|---|
committer | rvelices <rv-github@modusoptimus.com> | 2006-11-01 05:04:24 +0000 |
commit | 525c9bc40ab6a99c44292388ce4385574057da86 (patch) | |
tree | 6e336766919f308bb490fcd92c9f50152adaa031 | |
parent | 5aeff9b233863456a04b0616fd099bc497283ce6 (diff) |
fix: get_filename_wo_extension (check for ===false) and template make_filename
improvement: can retrieve template output outside the template
git-svn-id: http://piwigo.org/svn/trunk@1589 68402e56-0260-453c-a942-63ccdbb3a9ee
-rw-r--r-- | include/functions.inc.php | 3 | ||||
-rw-r--r-- | include/template.php | 13 |
2 files changed, 10 insertions, 6 deletions
diff --git a/include/functions.inc.php b/include/functions.inc.php index 3b7c88bc6..973bd2fbe 100644 --- a/include/functions.inc.php +++ b/include/functions.inc.php @@ -184,7 +184,8 @@ function get_extension( $filename ) // get_filename_wo_extension( 'test.tar.gz' ) -> 'test.tar' function get_filename_wo_extension( $filename ) { - return substr( $filename, 0, strrpos( $filename, '.' ) ); + $pos = strrpos( $filename, '.' ); + return ($pos===false) ? $filename : substr( $filename, 0, $pos); } /** diff --git a/include/template.php b/include/template.php index f58b7a0e3..8de10e0d9 100644 --- a/include/template.php +++ b/include/template.php @@ -147,9 +147,9 @@ class Template { } /** - * fills $output template var + * fills $output template var by default or returns the content */ - function parse($handle) + function parse($handle, $return=false) { if (!$this->loadfile($handle)) { @@ -166,6 +166,10 @@ class Template { // Run the compiled code. $_str = ''; eval($this->compiled_code[$handle]); + if ($return) + { + return $_str; + } $this->output.= $_str; return true; @@ -302,9 +306,8 @@ class Template { function make_filename($filename) { // Check if it's an absolute or relative path. - if (substr($filename, 0, 1) != '/' - and substr($filename, 0, 1) != '\\' //Windows UNC path - and !preg_match('/^[a-z]:\\\/i', $filename) ) + // if (substr($filename, 0, 1) != '/') + if (preg_match('/^[a-z_][^:]/i', $filename) ) { $filename = $this->root.'/'.$filename; } |