Mercurial > pub > Impl
changeset 107:0e72ad99eef7
Updated Web::TT
author | wizard |
---|---|
date | Thu, 13 May 2010 03:46:29 +0400 |
parents | 83e356614c1e |
children | c6fb6964de4c |
files | Lib/IMPL/Web/QueryHandler/PageFormat.pm Lib/IMPL/Web/Security.pm Lib/IMPL/Web/TT/Collection.pm Lib/IMPL/Web/TT/Control.pm Lib/IMPL/Web/TT/Document.pm |
diffstat | 5 files changed, 72 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/Lib/IMPL/Web/QueryHandler/PageFormat.pm Wed May 12 17:52:12 2010 +0400 +++ b/Lib/IMPL/Web/QueryHandler/PageFormat.pm Thu May 13 03:46:29 2010 +0400 @@ -37,6 +37,7 @@ $doc->LoadFile ( File::Spec->catfile($this->templatesBase,@path), $this->templatesCharset ); $doc->AddVar( result => $nextHandler->() ); + $doc->AddVar( absoluteUrl => sub { "/$_[0]" } ); { local $@; $doc->AddVar( user => eval { IMPL::Security::Context->current->principal; } );
--- a/Lib/IMPL/Web/Security.pm Wed May 12 17:52:12 2010 +0400 +++ b/Lib/IMPL/Web/Security.pm Thu May 13 03:46:29 2010 +0400 @@ -14,6 +14,13 @@ public property sourceSession => prop_all; } +sub CTOR { + my ($this) = @_; + + die new IMPL::InvalidArgumentException("An argument is required",'sourceUser') unless $this->sourceUser; + die new IMPL::InvalidArgumentException("An argument is required",'sourceSession') unless $this->sourceSession; +} + sub AuthUser { my ($this,$name,$package,$challenge) = @_;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/IMPL/Web/TT/Collection.pm Thu May 13 03:46:29 2010 +0400 @@ -0,0 +1,23 @@ +package IMPL::Web::TT::Collection; +use strict; + +use base qw(IMPL::DOM::Node); + +__PACKAGE__->PassThroughArgs; + +our $AUTOLOAD; +sub AUTOLOAD { + my $this = shift; + my ($method) = ($AUTOLOAD =~ /(\w+)$/); + + my @result = $this->selectNodes($method); + + return $result[0] if @result; + return; +} + +sub as_list { + $_[0]->childNodes; +} + +1; \ No newline at end of file
--- a/Lib/IMPL/Web/TT/Control.pm Wed May 12 17:52:12 2010 +0400 +++ b/Lib/IMPL/Web/TT/Control.pm Thu May 13 03:46:29 2010 +0400 @@ -4,14 +4,20 @@ use IMPL::Class::Property; -our %CTOR = ( - 'IMPL::DOM::Node' => sub { - #TODO: Pass arguments - } -); +__PACKAGE__->PassThroughArgs; BEGIN { public property template => prop_all; + public property id => prop_all; +} + +my $nextId = 1; + +sub CTOR { + my ($this,%args) = @_; + + $this->template($args{template}) if $args{template}; + $this->id($this->nodeName . '-' . $nextId++); } sub Render {
--- a/Lib/IMPL/Web/TT/Document.pm Wed May 12 17:52:12 2010 +0400 +++ b/Lib/IMPL/Web/TT/Document.pm Thu May 13 03:46:29 2010 +0400 @@ -8,18 +8,31 @@ use IMPL::Class::Property; use File::Spec; use Scalar::Util qw(blessed); +use IMPL::Web::TT::Collection; +use IMPL::Web::TT::Control; BEGIN { private property _provider => prop_all; private property _context => prop_all; public property template => prop_get | owner_set; public property presenter => prop_all, { validate => \&_validatePresenter }; + public property controls => { get => \&_getControls }; } our %CTOR = ( 'IMPL::DOM::Document' => sub { nodeName => 'document' } ); +sub CTOR { + my ($this) = @_; + + $this->appendChild( + $this->Create( + controls => 'IMPL::Web::TT::Collection' + ) + ) +} + sub provider { my ($this,%args) = @_; @@ -45,7 +58,8 @@ this => $this, render => sub { $this->_process(@_); - } + }, + controls => $this->controls }, TRIM => 1, RECURSION => 1, @@ -55,6 +69,20 @@ } } +sub createControl { + my ($this,$name,$args) = @_; + + my $node = $this->Create($name,'IMPL::Web::TT::Control',$args); + $this->controls->appendChild($node); +} + +sub _getControls { + my ($this) = @_; + + my ($node) = $this->selectNodes('controls'); + return $node; +} + sub _validatePresenter { my ($this,$value) = @_; @@ -122,7 +150,7 @@ } } - return join '',@items; + return join '',@result; } sub Dispose {