# Copyright (c) 2005-2007 bivio Software, Inc. All Rights Reserved. # # Visit http://www.bivio.biz for more info. # # This library is free software; you can redistribute it and/or modify # it under the terms of the GNU Lesser General Public License as # published by the Free Software Foundation; either version 2.1 of the # License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; If not, you may get a copy from: # http://www.opensource.org/licenses/lgpl-license.html # # $Id: StyleSheet.pm,v 1.12 2009/11/28 03:08:30 nagler Exp $ package Bivio::UI::HTML::Widget::StyleSheet; use strict; use Bivio::Base 'HTMLWidget.ControlBase'; use Bivio::UI::ViewLanguageAUTOLOAD; our($VERSION) = sprintf('%d.%02d', q$Revision: 1.12 $ =~ /\d+/g); my($_HTML) = b_use('Bivio.HTML'); sub control_off_render { return _do(sub { my($self, $source, $buffer, $value) = @_; $$buffer .= qq{\n"; return; }, @_); } sub control_on_render { return _do(sub { my($self, $source, $buffer, $value) = @_; $$buffer .= qq{\n}; return; }, @_); } sub initialize { my($self) = @_; my($v); if ($v = $self->unsafe_get('value') and Bivio::Agent::TaskId->is_valid_name($v), ) { $v = Bivio::Agent::TaskId->from_name($v); my($rt) = Bivio::Agent::Task->get_by_id($v)->get('realm_type'); $self->put(value => And( #TODO: This doesn't seem private enough, but it simplifies ThreePartPage # General renders always. Unless doesn't have uri $rt->eq_general ? () : [['->get_request'], qw(auth_realm type ->equals), $rt], vs_task_has_uri($v), URI({task_id => $v}), )); } $self->initialize_attr('value'); $self->initialize_attr(control => [ ['->get_request'], 'Bivio::UI::Facade', 'want_local_file_cache', ]); return shift->SUPER::initialize(@_); } sub internal_as_string { return shift->unsafe_get('value'); } sub internal_new_args { return shift->internal_compute_new_args([qw(value)], \@_); } sub _do { my($op, $self, $source, $buffer) = @_; my($v) = ''; $op->($self, $source, $buffer, $v) if $self->unsafe_render_attr('value', $source, \$v) && length($v); return; } 1;