# ================================================================== # Gossamer List - enhanced mailing list management system # # Website : http://gossamer-threads.com/ # Support : http://gossamer-threads.com/scripts/support/ # CVS Info : # Revision : $Id: GUI.pm,v 1.5 2004/08/24 19:28:37 bao Exp $ # # Copyright (c) 2004 Gossamer Threads Inc. All Rights Reserved. # Redistribution in part or in whole strictly prohibited. Please # see LICENSE file for full details. # ================================================================== # package GList::GUI; # ================================================================== use strict; use GList qw/:objects/; sub gui_profile_form { # ------------------------------------------------------------------- require GT::SQL::Display::HTML; require GT::SQL::Display::HTML::Table; my $opts = {@_}; my $user_tb = $DB->table('Users'); $opts->{cols} ||= [ grep(/^pro_/, $user_tb->ordered_columns) ]; $opts->{tr} ||= 'class="body"'; $opts->{td_l} ||= 'class="body" width="40%" align="right"'; $opts->{td_r} ||= 'class="body" align="left"'; $opts->{cols} ||= []; $opts->{mode} ||= 'edit'; $opts->{required} ||= ($opts->{mode} eq 'search') ? '' : '*'; my $tags = GT::Template->tags; my $cols = $user_tb->cols; my $disp = $DB->html($user_tb, GT::Template->tags); my $html = ''; my $prefix = $opts->{prefix} || ''; if ( $opts->{mode} eq 'hidden' ) { # Preserve all columns that relate to the Users database my $cols = $user_tb->cols; my $hidden_html = ''; foreach my $col ( keys %$cols ) { foreach my $name ( map { "$col$_" } ( '', qw( -opt -gt -lt -le -ge -ne )) ) { my $v = $tags->{$name}; next unless defined $v; my $input_html = gui_form_control({ form_type => 'hidden', value => $v, name => $name }); $html .= $$input_html; } } return \$html; } my %search_defs = ( string => { names => [qw( LIKE <> = )] }, number => { names => [qw( = <> < <= > >= )] }, date => { names => [ '', qw( = <> < <= > >= )] }, radio => { names => [qw( = <> )] }, minimal => { names => [qw( = )] } ); foreach my $col (@{$opts->{cols}}) { my $control_opts = {%{$cols->{$col}||{}}}; $control_opts->{name} = $col; $control_opts->{value} = $tags->{$col}; my $title = GList::language( $cols->{$col}{form_display} ); my $input_html = gui_form_control({ name => "$prefix$col", value=> ($opts->{mode} eq 'search') ? '' : $tags->{"$prefix$col"}, def => $control_opts }); $html .= ( $cols->{$col}->{not_null} ) ? "{tr}>{td_l}>