CHips L MINI SHELL

CHips L pro

Current Path : /proc/2/root/usr/local/rvglobalsoft/rvglobalsoft/lib/RVL/
Upload File :
Current File : //proc/2/root/usr/local/rvglobalsoft/rvglobalsoft/lib/RVL/HtmlSimpleView.pm

#!/usr/bin/perl
package RVL::HtmlSimpleView;
##LICENSE##
use Template;
use Template::Constants qw( :debug );
use RVL::Template::Plugin::Output;
use RVL::Template::Plugin::MgrOutput;
use Class::Std::Utils;
{
    sub new {
        my ($class, $output) = @_;
        my ($this) = bless( {}, $class);

        return $this;
    }
    
    sub singleton {
        my ($class) = __PACKAGE__;
        if (!defined $RVL::INSTANCE{$class}) {
            $RVL::INSTANCE{$class} = $class->new();
        }
        return $RVL::INSTANCE{$class}
    }
    
    sub output { 
        my ($out) = shift; 
        $oHtml = RVL::HtmlSimpleView::singleton();
        $oHtml->{OUTPUT} = $out;
    }
    
    sub render {
        my ($this, $data) = @_;
        $this->{data} = $data;
        my ($tt) = Template->new({
            DEBUG => DEBUG_PLUGINS,
            INTERPOLATE => 1,
            ANYCASE => 1,
            INCLUDE_PATH => $this->incpath_generator,
            COMPILE_DIR => __CONSTANT__::RVL_CACHE_DIR,
            WRAPPER => $data->{masterTemplate},
            ERROR => 'error.html',
            OUTPUT => \&output,
            PLUGINS => {
                O => 'RVL::Template::Plugin::Output',
                'this.plugin' => 'RVL::Template::Plugin::MgrOutput',
            },
        });
        $tt->process($data->{template}, $data) || 
        do {
            my ($error) = $tt->error();
            
            my ($ett) = Template->new({
                INTERPOLATE => 1,
                ANYCASE => 1,
                INCLUDE_PATH => $this->incpath_generator(),
                COMPILE_DIR => __CONSTANT__::RVL_CACHE_DIR,
                OUTPUT => \&output,
                PLUGINS => {
                    O => 'RVL::Template::Plugin::Output',
                    'this.plugin' => 'RVL::Template::Plugin::MgrOutput',
                },
            });
            $ett->process('error.html', {
                error => {
                    type => $error->type(),
                    info => $error->info(),
                    detail => $error,
                    incpath => $this->incpath_generator(),
                }
            });
        };
        
        return $this->{OUTPUT};
    }
    
    sub incpath_generator {
        my ($this) = @_;
        my ($moduleName) = $this->{data}->{moduleName};
        my ($theme) = $this->{data}->{theme};
        my ($handle) = (defined($this->{data}->{themeHandle})) ? $this->{data}->{themeHandle}: "";
        my (@incpath);
        
        push(@incpath, __CONSTANT__::RVL_THEME_DIR . '/' . $theme . '/' . $moduleName);
        push(@incpath, __CONSTANT__::RVL_MOD_DIR . '/' . $moduleName . '/templates');
        
        if ($handle ne "") {
            push(@incpath, __CONSTANT__::RVL_MOD_DIR . '/' . $moduleName . '/templates/'. $handle);
        }
        
        if ($moduleName ne 'default') {
            push(@incpath, __CONSTANT__::RVL_THEME_DIR . '/' . $theme . '/default');
            push(@incpath, __CONSTANT__::RVL_MOD_DIR . '/default/templates');
        }
        return \@incpath;
    }

}
1;

Copyright 2K16 - 2K18 Indonesian Hacker Rulez