# Copyright (c) 2000-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: Link.pm,v 2.3 2009/11/15 18:56:27 nagler Exp $ package Bivio::UI::HTML::Format::Link; use strict; use Bivio::Base 'Bivio::UI::HTML::Format'; # C formats external hrefs as /goto # links. our($VERSION) = sprintf('%d.%02d', q$Revision: 2.3 $ =~ /\d+/g); sub get_widget_value { # (proto, any) : string # Returns an href, possibly as an /goto link. # # href may be a L or it # may be a name of TaskId. my($source, $href) = @_; return $href if _format_task(\$href); # Not an offsite uri? Just return $href. return $href unless $href =~ /^\w+:/; return Bivio::UI::Task->format_realmless_uri( Bivio::Agent::TaskId->CLIENT_REDIRECT, undef, $source->get_request) . '?' . Bivio::Biz::Action::ClientRedirect->QUERY_TAG . '=' . Bivio::HTML->escape_query($href); } sub _format_task { # (string_ref) : boolean # Returns true if formatted as a task uri. my($href) = @_; if (ref($$href)) { Bivio::Die->die($$href, ': ref is not a TaskId') unless UNIVERSAL::isa($$href, 'Bivio::Agent::TaskId'); } elsif (Bivio::Agent::TaskId->is_valid_name($$href)) { $$href = Bivio::Agent::TaskId->$$href(); } else { return 0; } # This will result in an "onsite" uri, but may have https:/ in front $$href = Bivio::Agent::Request->get_current->format_stateless_uri($$href); return 1; } 1;