# Copyright (c) 2008-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: SearchForm.pm,v 1.6 2010/04/04 21:18:47 nagler Exp $ package Bivio::UI::XHTML::Widget::SearchForm; use strict; use Bivio::Base 'XHTMLWidget.Form'; use Bivio::UI::ViewLanguageAUTOLOAD; our($VERSION) = sprintf('%d.%02d', q$Revision: 1.6 $ =~ /\d+/g); my($_SEARCH_LIST) = b_use('Agent.TaskId')->SEARCH_LIST; my($_GROUP_SEARCH_LIST) = b_use('Agent.TaskId')->GROUP_SEARCH_LIST; sub initialize { my($self) = @_; $self->map_invoke(put_unless_exists => [ [action => [sub { my($req) = shift->req; return $req->format_stateless_uri({ task_id => $req->get('auth_realm')->has_owner ? $_GROUP_SEARCH_LIST : $_SEARCH_LIST, }); }]], [form_class => 'SearchForm'], [want_hidden_fields => 0], [form_method => 'GET'], [value => sub { return Join([ ClearOnFocus( Text({ field => 'search', size => $self->get_or_default(text_size => 30), }), b_use('Model.' . $self->get('form_class')) ->CLEAR_ON_FOCUS_HINT, ), $self->get_or_default(image_form_button => ImageFormButton(qw(ok_button magnifier go))), DIV_b_realm_only( Checkbox({ field => 'b_realm_only', label => Prose(vs_text(qw(SearchForm b_realm_only))), control => [[qw(->req auth_realm)], '->has_owner'], }), {control => $self->get_or_default( 'show_b_realm_only', [qw(auth_realm type ->is_group)], )}, ), ]); }], [class => 'search'], ]); return shift->SUPER::initialize(@_); } sub internal_new_args { # Implements positional argument parsing for L. return shift->internal_compute_new_args([qw(value href ?class)], \@_); } 1;