[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
SF.net SVN: ledger-smb:[4806] branches/1.3/LedgerSMB/Template/XML.pm
- Subject: SF.net SVN: ledger-smb:[4806] branches/1.3/LedgerSMB/Template/XML.pm
- From: ..hidden..
- Date: Wed, 30 May 2012 05:53:11 +0000
Revision: 4806
http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=4806&view=rev
Author: einhverfr
Date: 2012-05-30 05:53:11 +0000 (Wed, 30 May 2012)
Log Message:
-----------
Removing accidently committed xml.pm
Removed Paths:
-------------
branches/1.3/LedgerSMB/Template/XML.pm
Deleted: branches/1.3/LedgerSMB/Template/XML.pm
===================================================================
--- branches/1.3/LedgerSMB/Template/XML.pm 2012-05-30 02:14:17 UTC (rev 4805)
+++ branches/1.3/LedgerSMB/Template/XML.pm 2012-05-30 05:53:11 UTC (rev 4806)
@@ -1,156 +0,0 @@
-
-=head1 NAME
-
-LedgerSMB::Template::HTML - Template support module for LedgerSMB
-
-=head1 METHODS
-
-=over
-
-=item get_template ($name)
-
-Returns the appropriate template filename for this format.
-
-=item preprocess ($vars)
-
-This method returns a reference to a hash that contains a copy of the passed
-hashref's data with HTML entities converted to escapes.
-
-=item process ($parent, $cleanvars)
-
-Processes the template for HTML.
-
-=item postprocess ($parent)
-
-Currently does nothing.
-
-=item escape($string)
-
-Escapes a scalar string and returns the sanitized version.
-
-=back
-
-=head1 Copyright (C) 2007, The LedgerSMB core team.
-
-This work contains copyrighted information from a number of sources all used
-with permission.
-
-It is released under the GNU General Public License Version 2 or, at your
-option, any later version. See COPYRIGHT file for details. For a full list
-including contact information of contributors, maintainers, and copyright
-holders, see the CONTRIBUTORS file.
-=cut
-
-package LedgerSMB::Template::HTML;
-
-use warnings;
-use strict;
-
-use Error qw(:try);
-use Template;
-use LedgerSMB::Template::TTI18N;
-
-my $binmode = ':utf8';
-binmode STDOUT, $binmode;
-binmode STDERR, $binmode;
-
-sub get_template {
- my $name = shift;
- my $parent = $shift;
- return "${name}.$parent->{format_args}{filetype}";
-}
-
-sub preprocess {
- my $rawvars = shift;
- my $vars;
- my $type = ref $rawvars;
-
- return $rawvars if $type =~ /^LedgerSMB::Locale/;
- return unless defined $rawvars;
- if ( $type eq 'ARRAY' ) {
- for (@{$rawvars}) {
- push @{$vars}, preprocess( $_ );
- }
- } elsif (!$type) {
- return escape($rawvars);
- } elsif ($type eq 'SCALAR' or $type eq 'Math::BigInt::GMP') {
- return escape($$rawvars);
- } elsif ($type eq 'CODE'){
- return $rawvars;
- } elsif ($type eq 'IO::File'){
- return undef;
- } else { # Hashes and objects
- for ( keys %{$rawvars} ) {
- $vars->{preprocess($_)} = preprocess( $rawvars->{$_} );
- }
- }
-
- return $vars;
-}
-
-sub escape {
- my $vars = shift @_;
- if (defined $vars){
- $vars =~ s/&/&/gm;
- $vars =~ s/</</gm;
- $vars =~ s/>/>/gm;
- return $vars;
- }
- return undef;
-}
-
-sub process {
- my $parent = shift;
- my $cleanvars = shift;
- my $template;
- my $output;
- my $source;
- $parent->{binmode} = $binmode;
-
- if ($parent->{outputfile}) {
- $output = "$parent->{outputfile}.$parent->{format_args}{filetype}";
- } else {
- $output = \$parent->{output};
- }
- if (ref $parent->{template} eq 'SCALAR') {
- $source = $parent->{template};
- } elsif (ref $parent->{template} eq 'ARRAY') {
- $source = join "\n", @{$parent->{template}};
- } else {
- $source = get_template($parent->{template}, $parent);
- }
- my $tempdir;
- if ($LedgerSMB::Sysconfig::cache_templates){
- $tempdir = $LedgerSMB::Sysconfig::cache_template_dir;
- } else {
- $tempdir = undef;
- }
- $template = Template->new({
- INCLUDE_PATH => [$parent->{include_path_lang}, $parent->{include_path},'templates/demo','UI/lib'],
- ENCODING => 'utf8',
- START_TAG => quotemeta('<?lsmb'),
- END_TAG => quotemeta('?>'),
- DELIMITER => ';',
- TRIM => 1,
- COMPILE_DIR=> $tempdir,
- DEBUG => ($parent->{debug})? 'dirs': undef,
- DEBUG_FORMAT => '',
- }) || throw Error::Simple Template->error();
- if (not $template->process(
- $source,
- {%$cleanvars, %$LedgerSMB::Template::TTI18N::ttfuncs,
- 'escape' => \&preprocess},
- $output, {binmode => ':utf8'})) {
- throw Error::Simple $template->error();
- }
- $parent->{mimetype} = 'text/html';
-}
-
-sub postprocess {
- my $parent = shift;
- $parent->{rendered} = "$parent->{outputfile}.$parent{format_args}{filetype}"
- if $parent->{outputfile};
- return $parent->{rendered};
-}
-
-1;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.