GEDAFE-WIDGETS(1)                   gedafe                   GEDAFE-WIDGETS(1)



NNAAMMEE
       gedafe-widgets - Plugin widgets for Gedafe

DDEESSCCRRIIPPTTIIOONN
       Sometimes you just want to have a special kind of widget for your
       application. This can be a custom calculation of a custom way of enter-
       ing your data in a gui.  Gedafe out of the box (although we don't have
       boxes) supports a very usefull set of widgets. For the custom widgets
       you might want to add yourself this module helps you do that in an
       object oriented and plugable way.

       Plugin widgets are object oriented perl modules sitting in sepcial
       directory.  Each module has to offer a 2 methodes which will be used
       from within Gedafe. These are WidgetWrite to create the widget and Wid-
       getRead to read the data from the widget.

       To enable the widget you can just set the name of the widgetmodule as
       the name of the widget for a field in meta_fields.  Check the documen-
       tation for more information on the meta_fields table.

UUSSAAGGEE
       First you have to tell Gedafe that it should go looking for Widgets.
       This is done by placing the line

        widget_dir     => '/path/to/widgets',

       into the Start command of your Gedafe CGI. Be carefull not to mix
       Gedafe-Pearls and plugin widgets in the same directory or else you
       would get widgets as pearls and pearls as widgets.

       Then you have to write your widget and store it in _/_p_a_t_h_/_t_o_/_w_i_d_g_e_t_s.
       When you restart gedafe it will go looking there and integrate all wid-
       gets in its own widget handeling code.

       Widgets are object oriented Perl modles which inherit from _G_e_d_a_f_e_:_:_W_i_d_-
       _g_e_t.  A Widget has to override the following methodes:

       WidgetWrite
           Returns the html code to construct the widget. You have to name
           your input-field acording to $input_name. The $warg hash contains
           the key-value pairs found in meta_fields just like with other wid-
           gets.

       WidgetRead
           Returns the value that should be inserted into the database for
           this widget.  You get access to all relevant information like
           $input_name and $warg.

       See the example below for details.

EEXXAAMMPPLLEE
       Commented example Widget (password.pm).

       package password;

       use strict; use Gedafe::Global qw(%g); use Gedafe::Widget; use vars
       qw(@ISA); @ISA = qw(Gedafe::Widget);

       # construct the html for the widget sub WidgetWrite($$$$){

           #since we are doing object stuff the first argument is
           #a reference to ourselves
           my $self = shift;

           # $warg is a hash of key value pairs as it is in meta_fields
           # $input_name is used to link database fields to input fields
           # if you have inputs that should not be processed seperately
           # make sure that their names do not start with field_
           # $value is the default or (in case of update) original value
           my ($s, $input_name, $value,$warg) = @_;
           my $html;

           #here you have your database handle
           my $dbh = $s->{dbh};
           # and your cgi object handle incase you need it.
           my $q = $s->{cgi};
           $html = "<input type=\"password\" name=\"$input_name\" value=\"$value\">";
           return $html;
       }

       # read the widget data sub WidgetRead($$$$){
           my $self = shift;
           my ($s, $input_name, $value,$warg) = @_;
           my $dbh = $s->{dbh};
           my $q = $s->{cgi};
           #see above for information about the individual arguments.

           #$value is the data sent by the browser in the field mentioned
           #in $input_name, since for passwords we don't need to do anything
           #special we just return this data.
           #in a very secure setup one coulf for instance hash the password
           #through md5 here.

           return $value;
       }

       1;

SSEEEE AALLSSOO
       _g_e_d_a_f_e_-_s_q_l_._p_o_d, _g_e_d_a_f_e_-_t_e_m_p_l_a_t_e_s_._t_x_t, _T_e_x_t_:_:_C_P_P_T_e_m_p_l_a_t_e,
       _g_e_d_a_f_e_-_p_e_a_r_l_s_._p_o_d,

CCOOPPYYRRIIGGHHTT
       Copyright (c) 2000-2003 Zindel Multimedia Engineering,  All rights
       reserved.

LLIICCEENNSSEE
       This program is free software; you can redistribute it and/or modify it
       under the terms of the GNU General Public License as published by the
       Free Software Foundation; either version 2 of the License, or (at your
       option) any later version.

       This program is distributed in the hope that it will be useful, but
       WITHOUT ANY WARRANTY; without even the implied warranty of MER-
       CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
       Public License for more details.

       You should have received a copy of the GNU General Public License along
       with this program; if not, write to the Free Software Foundation, Inc.,
       675 Mass Ave, Cambridge, MA 02139, USA.

AAUUTTHHOORR
       Freek Zindel <freek@zindel.nl>

       This module is based on a shameless copy of the Gedafe::Pearls module
       by

       Tobias Oetiker <oetiker@ee.ethz.ch>



1.4.0                             2007-03-16                 GEDAFE-WIDGETS(1)
