[svn:p5ee] r6500 - p5ee/trunk/App-Widget/lib/App

[email protected]
Newsgroups perl.cvs.p5ee
Message-ID <[email protected]>
Author: spadkins
Date: Mon Jun 12 15:20:25 2006
New Revision: 6500

Modified:
   p5ee/trunk/App-Widget/lib/App/TemplateEngine.pm

Log:
Added themable templates

Modified: p5ee/trunk/App-Widget/lib/App/TemplateEngine.pm
==============================================================================
--- p5ee/trunk/App-Widget/lib/App/TemplateEngine.pm	(original)
+++ p5ee/trunk/App-Widget/lib/App/TemplateEngine.pm	Mon Jun 12 15:20:25 2006
@@ -190,14 +190,22 @@
     &App::sub_entry if ($App::trace);
     my ($self, $template) = @_;
 
+    my $context = $self->{context};
+    my $theme = $context->get_user_option("theme");
+    my $options = $context->{options};
+
     my ($template_dir, $template_text);
     local(*App::FILE);
-    $template_dir = $self->{template_dir};
-    $template_dir = $self->{context}->get_option("template_dir") if (!$template_dir);
-    $template_dir = "templates" if (!$template_dir);
+    $template_dir = $self->{template_dir} || $options->{template_dir} || "$options->{prefix}/templates";
 
-    if (open(App::FILE,"< $template_dir/$template")) {
-        $template_text = join("",<App::FILE>);
+    if ($theme && open(App::FILE,"< $template_dir/$theme/$template")) {
+        local($/) = undef;
+        $template_text = <App::FILE>;
+        close(App::FILE);
+    }
+    elsif (open(App::FILE,"< $template_dir/$template")) {
+        local($/) = undef;
+        $template_text = <App::FILE>;
         close(App::FILE);
     }
     else {
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.