[pLog-svn] r948 - plog/trunk/class/net
oscar at devel.plogworld.net
oscar at devel.plogworld.net
Sat Feb 5 13:57:53 GMT 2005
Author: oscar
Date: 2005-02-05 13:57:52 +0000 (Sat, 05 Feb 2005)
New Revision: 948
Modified:
plog/trunk/class/net/baserequestgenerator.class.php
Log:
fixed issue 205 (http://bugs.plogworld.net/view.php?id=205) as per kral's suggestion
Modified: plog/trunk/class/net/baserequestgenerator.class.php
===================================================================
--- plog/trunk/class/net/baserequestgenerator.class.php 2005-02-04 18:38:42 UTC (rev 947)
+++ plog/trunk/class/net/baserequestgenerator.class.php 2005-02-05 13:57:52 UTC (rev 948)
@@ -432,5 +432,53 @@
}
}
+
+ /**
+ * generates the correct path to a file in the template folder, without having to worry
+ * whether the template was installed in /templates/ or in /templates/blog_X/
+ * This is locale-aware version.
+ *
+ * @param file
+ * @return A string
+ */
+ function getTemplateLocaledFile( $file )
+ {
+ // get the current template set
+ $blogSettings = $this->_blogInfo->getSettings();
+ $template = $blogSettings->getValue( "template" );
+ $localeCode = $blogSettings->getValue( "locale" );
+
+ // if this file has extension
+ $parts = explode( ".", $file );
+ if( count($parts) > 1 && !strstr($parts[count($parts) - 1], "/")) {
+ $ext = array_pop( $parts );
+ array_push ( $parts, $localeCode, $ext);
+ $localedFile = implode( ".", $parts);
+ } else {
+ $localedFile = $file;
+ }
+ unset $parts;
+
+ $baseUrl = $this->getBaseUrl();
+ $url = "$baseUrl/templates/";
+
+ $blogTemplates = $blogSettings->getValue( "blog_templates" );
+
+ if( !is_array($blogTemplates) ) {
+ $filePath = "$template";
+ } else {
+ if( in_array( $template, $blogTemplates ))
+ $filePath = "blog_".$this->_blogInfo->getId()."/$template";
+ else
+ $filePath = "$template";
+ }
+
+ if( File::exists("$filePath/$localedFile"))
+ $url .= "$filePath/$localedFile";
+ else
+ $url .= "$filePath/$file";
+
+ return $url;
+ }
}
?>
More information about the pLog-svn
mailing list