cvs: pear /HTML_Template_Flexy Flexy.php /HTML_Template_Flexy/Flexy example.ini
| From: | Alan Knowles | Date: | Wed, 15 Oct 2003 01:34:16 +0000 |
| Subject: | cvs: pear /HTML_Template_Flexy Flexy.php /HTML_Template_Flexy/Flexy example.ini | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-13614@lists.php.net to get a copy of this message | ||
alan_k Tue Oct 14 21:34:16 2003 EDT
Modified files:
/pear/HTML_Template_Flexy Flexy.php
/pear/HTML_Template_Flexy/Flexy example.ini
Log:
support multiple directories for templateDir (Demian Turner)
Index: pear/HTML_Template_Flexy/Flexy.php
diff -u pear/HTML_Template_Flexy/Flexy.php:1.45 pear/HTML_Template_Flexy/Flexy.php:1.46
--- pear/HTML_Template_Flexy/Flexy.php:1.45 Wed Sep 3 21:26:30 2003
+++ pear/HTML_Template_Flexy/Flexy.php Tue Oct 14 21:34:15 2003
@@ -51,7 +51,7 @@
*
*
*
-* @version $Id: Flexy.php,v 1.45 2003/09/04 01:26:30 alan_k Exp $
+* @version $Id: Flexy.php,v 1.46 2003/10/15 01:34:15 alan_k Exp $
*/
class HTML_Template_Flexy
{
@@ -151,12 +151,12 @@
$baseoptions =
&PEAR::getStaticProperty('HTML_Template_Flexy','options');
if ($baseoptions ) {
- foreach( $baseoptions as $key=>$aOption ) {
+ foreach( $baseoptions as $key=>$aOption) {
$this->options[$key] = $aOption;
}
}
- foreach( $options as $key=>$aOption ) {
+ foreach( $options as $key=>$aOption) {
$this->options[$key] = $aOption;
}
@@ -165,8 +165,14 @@
$this->options['filters']= explode(',',$filters);
}
- if(!@is_dir($this->options['compileDir']) )
+ if (is_string($this->options['templateDir'])) {
+ $this->options['templateDir'] = explode(';', $templateDirs);
+ }
+
+
+ if(!@is_dir($this->options['compileDir']) ) {
return new PEAR_Error('The compile-directory doesnt exist yet!');
+ }
}
/**
@@ -340,8 +346,9 @@
foreach( $path as $aDir ) {
$compileDest = $compileDest. DIRECTORY_SEPARATOR . $aDir;
if( !@is_dir($compileDest) ) {
- umask(0000); // make that the users of this group
(mostly 'nogroup') can erase the compiled templates too
- if( !@mkdir($compileDest,0770) ) {
+ umask(0000); // make that the users of this group (mostly
'nogroup')
+ // can erase the compiled templates too
+ if( !@mkdir($compileDest, 0770) ) {
PEAR::raiseError( "couldn't make directory:
<b>'$aDir'</b> under
<b>'".$this->options['compileDir']."'</b><br>".
"Please give write permission to the
'compileDir', so HTML_Template_Flexy can create directories inside",
null, PEAR_ERROR_DIE);
@@ -352,7 +359,7 @@
/*
- incomming file looks like xxxxxxxx.yyyy
+ incoming file looks like xxxxxxxx.yyyy
if xxxxxxxx.{locale}.yyy exists - use that...
*/
$parts = array();
@@ -363,12 +370,27 @@
}
}
+ // look in all the posible locations for the template directory..
+ $this->currentTemplate = false;
- $this->currentTemplate = $this->options['templateDir'].DIRECTORY_SEPARATOR
.$file;
-
- if( !@file_exists($this->currentTemplate )) {
+ if (is_array($this->options['templateDir'])) {
+
+ foreach ($this->options['templateDir'] as $tmplDir) {
+ if (!@file_exists($tmplDir . DIRECTORY_SEPARATOR . $file)) {
+ continue;
+ }
+ if ($this->currentTemplate !== false) {
+ return PEAR::raiseError("You have more than one template Named {$file} in
your paths, found in both".
+ "<BR>{$this->currentTemplate }<BR>{$tmplDir}" .
DIRECTORY_SEPARATOR . $file, null, PEAR_ERROR_DIE);
+
+ }
+ $this->currentTemplate = $tmplDir . DIRECTORY_SEPARATOR . $file;
+ }
+ }
+ if ($this->currentTemplate === false) {
// check if the compile dir has been created
- PEAR::raiseError("Template {$this->currentTemplate} does not
exist<br>", null, PEAR_ERROR_DIE);
+ return PEAR::raiseError("Could not find Template {$file} in any of the
directories<br>" .
+ implode("<BR>",$this->options['templateDir']) , null,
PEAR_ERROR_DIE);
}
@@ -570,4 +592,4 @@
}
-?>
+?>
\ No newline at end of file
Index: pear/HTML_Template_Flexy/Flexy/example.ini
diff -u pear/HTML_Template_Flexy/Flexy/example.ini:1.3
pear/HTML_Template_Flexy/Flexy/example.ini:1.4
--- pear/HTML_Template_Flexy/Flexy/example.ini:1.3 Wed Oct 8 21:31:34 2003
+++ pear/HTML_Template_Flexy/Flexy/example.ini Tue Oct 14 21:34:16 2003
@@ -12,6 +12,9 @@
templateDir = /home/me/Projects/myapplication/templates
; where the original templates are.
+;templateDir = /home/me/Projects/myapplication/english;/home/me/Projects/myapplication/spanish
+ ; or use multiple paths..
+
forceCompile = 0
; force compile template every time...
@@ -27,15 +30,4 @@
; not it is only on the left of the url (not anywhere inside it)
-; global function - The reason these are disabled by default is for
-; a) security
-; b) hidden magic.. - flexy has enough hidden magic.. already :)
-;
-; they are suppored by the Flexy/Compiler/Standard/Functions.php code
-
-;valid_functions = "include"
- ; functions that are handled.. by a hander (at present include is the only one..
-
-;function_handlers = "myClass"
- ; class that as some methods called handle******** where ******* is in the list above.