view Lib/IMPL/Web/TT/Control.pm @ 122:a7efb3117295

Fixed bug in IMPL::DOM::Navigator::selectNodes Fixed bug in IMPL::DOM::Node::selectNodes renamed operator 'type' to 'typeof' in IMPL::Object::Abstract A proper implementation of the IMPL::DOM::Node::nodeProperty and a related changes in the IMPL::DOM::Property module, now the last is very simple.
author wizard
date Tue, 08 Jun 2010 20:12:45 +0400
parents 0475eb382085
children c8dfbbdd8005
line wrap: on
line source

package IMPL::Web::TT::Control;

use base qw(IMPL::Web::TT::Collection);

use IMPL::Class::Property;
use IMPL::DOM::Property qw(_dom);

__PACKAGE__->PassThroughArgs;

BEGIN {
	public property controlClass => prop_all;
	public property template => prop_all;
	public property id => prop_all;
}

my $nextId = 1;

sub CTOR {
	my ($this,%args) = @_;
	
	if ($this->document) {
		# load a template
		$args{template} = $this->document->context->template($args{template}) if ($args{template} and not ref $args{template});
	}
	$this->template($args{template}) if $args{template};

	$this->id($this->nodeName . '-' . $nextId++);
	$this->controlClass($args{controlClass} || 'Control');
}

sub Render {
	my ($this) = @_;
	
	if ($this->document) {
		if ($this->template) {
			return $this->document->context->include($this->template,{ this => $this }) ;
		} elsif ($this->document->presenter) {
			return $this->document->presenter->print($this);
		} else {
			return $this->toString().": ".$this->controlClass() . ": ".$this->path;
		}
	}
}

1;