# HG changeset patch # User wizard # Date 1273707989 -14400 # Node ID 0e72ad99eef760d5ce3018bbb424b74a63ef9f03 # Parent 83e356614c1e46ef450f79522e753172ed7b2eae Updated Web::TT diff -r 83e356614c1e -r 0e72ad99eef7 Lib/IMPL/Web/QueryHandler/PageFormat.pm --- 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; } ); diff -r 83e356614c1e -r 0e72ad99eef7 Lib/IMPL/Web/Security.pm --- 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) = @_; diff -r 83e356614c1e -r 0e72ad99eef7 Lib/IMPL/Web/TT/Collection.pm --- /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 diff -r 83e356614c1e -r 0e72ad99eef7 Lib/IMPL/Web/TT/Control.pm --- 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 { diff -r 83e356614c1e -r 0e72ad99eef7 Lib/IMPL/Web/TT/Document.pm --- 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 {