# Copyright (c) 2007-2009 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: MIMEEntityView.pm,v 1.3 2009/11/20 17:57:00 nagler Exp $ package Bivio::UI::Widget::MIMEEntityView; use strict; use Bivio::Base 'Widget.ControlBase'; our($VERSION) = sprintf('%d.%02d', q$Revision: 1.3 $ =~ /\d+/g); my($_V) = b_use('UI.View'); sub control_on_render { my($self, $source, $buffer) = @_; my($req) = $source->get_request; $$buffer .= ${$_V->render( $self->render_simple_attr(view_name => $source), $req, )}; $req->put("$self" => $req->get('reply')->get_output_type); return; } sub control_off_render { my($self, $source, $buffer) = @_; my($req) = $source->get_request; # So mime_type render doesn't blow up when control is false $req->put("$self" => ''); return; } sub initialize { my($self) = @_; $self->map_invoke(initialize_attr => [ ['view_name'], [mime_type => ['->req', "$self"]], [mime_charset => 'us-ascii'], [mime_encoding => [sub { shift->req("$self") =~ m{^text/}i ? 'quoted-printable' : 'base64'; }]], ]); return; } sub internal_new_args { my(undef, $view_name, $attributes) = @_; return '"view_name" attribute must be defined' unless defined($view_name); return { view_name => $view_name, ($attributes ? %$attributes : ()), }; } 1;