# # _modules/templates.pm # # Developed by Lubomir Host 'rajo' # Copyright (c) 2004-2006 Platon Group, http://platon.sk/ # Licensed under terms of GNU General Public License. # All rights reserved. # # Changelog: # 18/04/2004 - created # # $Platon: web-apps/fastcgi-gallery/_modules/templates.pm,v 1.3 2005/10/18 09:02:53 rajo Exp $ package templates; use strict; use Carp; use English; use Template::Namespace::Constants; use Cwd qw'getcwd abs_path'; use config; use vars qw($VERSION @ISA @EXPORT $AUTOLOAD); use base qw( Template ); use vars qw( $VERSION $DEBUG ); $VERSION = sprintf("%d", q$Revision: 1.5 $ =~ /(\d+)/); $DEBUG = 0 unless defined $DEBUG; sub new { #{{{ my $this = shift; my $class = ref($this) || $this; my $config = shift; my $lang = shift || 'en'; my $self = Template->new({ AUTHOR => 'Ľubomír Host (rajo)', INCLUDE_PATH => [ "./_templates/$lang", './_templates' ], RELATIVE => 1, PRE_PROCESS => 'http-header.tt2', COMPILE_DIR => "/tmp/fastcgi-gallery-ttc-$EUID" . abs_path(getcwd()), NAMESPACE => { author => Template::Namespace::Constants->new({ name => 'Ľubomír Host (rajo)', email => '', homepage => 'http://rajo.platon.sk', callto => 'rajo207', icq => 257322664, }), const => Template::Namespace::Constants->new({ site_title => $config->site_title(), }), }, PLUGIN_BASE => 'Platon::Template::Plugin', PLUGINS => { obfuscator => 'obfuscator', }, FILTERS => { 'spacer' => [ sub { # {{{ my ($text) = @_; $text =~ s/_/ /g; $text =~ s/--/ - /g; return $text; }, 0 ], # }}} 'html_remove' => [ sub { # {{{ my ($text) = @_; $text =~ s/<([^>]+)>/ /g; $text =~ s/\s+/ /g; return $text; }, 0 ], # }}} 'translator' => [ sub { # {{{ my ($context, $lang) = @_; return sub { my ($text) = shift; return '' if ($text eq ''); # remove language tags, which are not the requested language # (.*?) - non-greedy matching $text =~ s/\[lang:(?!$lang)[^\]]+](.*?)\[\/lang:(?!$lang)[^\]]+]//gis; # remove language tags $text =~ s/\[lang:$lang]//gi; $text =~ s/\[\/lang:$lang]//gi; # some cleanup etc. $text =~ s/~/ /g; $text =~ s/^\s+//g; $text =~ s/\s+$//g; return $text; }; }, 1 ], # }}} }, VARIABLES => { conf => $config, env => \%ENV, fastcgi_name => $config->fastcgi_name(), } }); bless $self, $class; return $self; } # }}} 1; __END__ =head1 NAME templates - <<>> =head1 SYNOPSIS use templates; my $xxx = new templates; =head1 DESCRIPTION The templates module allows you ... <<>> =head2 EXPORT <>> =head1 SEE ALSO =head1 AUTHORS Lubomir Host 'rajo', =cut # vim: ts=4 # vim600: fdm=marker fdl=0 fdc=3