Krang::Widget - interface widgets for use by Krang::CGI modules
use Krang::ClassLoader Widget => qw(category_chooser date_chooser decode_date);
$chooser = category_chooser(name => 'category_id',
query => $query);
$date_chooser = date_chooser(name => 'cover_date',
date=>$date_obj);
$date_obj = decode_date(name => 'cover_date',
query => $query);
$url_html = format_url(url => 'http://my.host/some/long/url.html',
linkto => "javascript:Krang.preview('media','" . $id . "')");
This modules exports a set of generally useful CGI widgets.
In list context returns the chooser interface (show button, clear button, display of selected element) separately.
Available parameters are as follows:
name
if not set.
The template for the category chooser is located in Widget/category_chooser.tmpl.
Available parameters are as follows:
name
if not set.
name and query parameters are required.
Additional optional parameters are as follows:
hour - if set (in 24 hour format, i.e. 0-23) , chooser will
be prepopulated with that hour. If not set,
will default to current hour (localtime)
unless "nochoice" is true, in which case chooser
will be set to blank ('Hour').
minute - if set, chooser will be prepopulated with that
minute. If not set, will default to current
minute (from localtime) unless "nochoice" is
true, in which chooser will be set to blank ('Minute').
nochoice - if set to a true value, Hour/Minute/AM
will be provided as default choices in the chooser.
The value "0" will be returned if a user chooses
the "no choice" option.
onchange - JavaScript code to be executed when the date is changed.
The time_chooser() implements itself in HTML via a text input with some
JavaScript popup magic. The string input from the user can be retrieved
via the CGI query object using the same name given during the creation
of the widget.
If decode_time() is unable to parse the time it will return 2
undef values.
Standard Krang time choosers can be created via time_chooser().
name and query parameters are required.
Additional optional parameters are as follows:
date - if set to a date object (Time::Piece), chooser will
be prepopulated with that datetime. If not set to a
date object, will default to current date (localtime)
unless "nochoice" is true, in which case chooser
will be set to blank. Please note that seconds are
ALWAYS set to '00', regardless of what seconds may
actually be.
nochoice - if set to a true value, Month/Day/Year/Hour/Minute/AM
will be provided as default choices in the chooser.
Used in conjunction with the "date" parameter, the
chooser may be set to default to no date.
The value "0" will be returned if a user chooses
the "no choice" option.
onchange - JavaScript code to be executed when either the date
or time values are changed.
The datetime_chooser() implements via the date_chooser()
and time_chooser(). The values input by the user can be retrieved
via decode_datetime().
name and query parameters are required.
Additional optional parameters are as follows:
date - if set to a date object (L<Time::Piece> or L<DateTime>),
chooser will be prepopulated with that date. If not set
to a date object, will default to current date (localtime)
unless "nochoice" is true, in which case chooser will be
set to blank.
nochoice - if set to a true value, blanks will be provided
as choices in the chooser. Used in conjunction
with the "date" parameter, the chooser may be
set to default to no date.
The value "0" will be returned if a user chooses
the "no choice" option.
onchange - JavaScript code to be executed when the date value
is changed.
The date_chooser() implements itself in HTML via a text input
with a JavaScript popup calendar. The full string typed by the
user can be retrieved via the CGI object, or you can retrieve
a Time::Piece object via decode_date().
name and query
parameters are required.
If decode_datetime() is unable to retrieve a date it will return undef.
Standard Krang datetime choosers can be created via datetime_chooser().
If 'no_time_is_end' is set to 1, then datetimes with no Hour/Min/Sec will translate to date:23:59:59 (defualt is to date:00:00:00)
name and query
parameters are required.
If decode_date() is unable to retrieve a date it will return undef.
Standard Krang date choosers can be created via date_chooser().
url parameter is required.
The optional linkto parameter, if provided, will be used as
the HTML ``href'' to which users are directed when they click
any line in the URL. If not specified, the URL will be
displayed as non-linking HTML.
The optional length parameter, if provided, will be used
as number of characters after which a new line should be
created. If not specified, the default length of 15 will be used.
In list context returns the chooser interface (show button, clear button, display of selected element) separately.
Available parameters are as follows:
name if not set.
The template for the category chooser is located in Widget/template_chooser.tmpl.
Available parameters are as follows:
autocomplete_values(%args)phrase, pulled from the specifed fields of the
given table.
It takes the following named arguments:
phrase param of the query string.
This is optional.
WHERE clause
using AND.