view release on metacpan or search on metacpan
3.49 Mon Apr 30 16:45:07 CDT 2007
- add datetime_now db-agnostic wrapper to Gantry::Utils::DBIxClass
- add post_body parsing to Plugins::SOAP::Doc
- modify Gantry handler to work with the PageCache plugin
- add Gantry::Plugins::PageCache
- modify cache plugins
- tie Gantry::Conf into Gantry cache. Specifying a cache plugin will
enable caching for Gantry::Conf
- add engine_cycle method to the Gantry object.
- add javascript helper for YUI popup calendaring
- factor out login, logout routines in AuthCookie. AuthCookie now
provides login/logout methods that can be called at anytime from
anywhere in the app. (think registration form)
- add add row level error messages to moxie form.tt
- modify Gantry handler to store action
- add js_root and js_rootp
- add search cpan link to pod/doc viewing module
- patch uninitialized warning in CGI engine
- replaced dojo with jquery javascript libraries for the Gantry samples.
- patch Gantry::Utils::DBConnHelper::MP20, the server starting test
lib/Gantry/Docs/Tutorial.pod view on Meta::CPAN
html_form_type date;
date_select_text `Popup Calendar`;
}
foreign_display `%name`;
}
I've chosen to store the actual date of birth (which leads to recording
women's ages, shame on me). This is to show how date selection works
smoothly for your users. There are three steps to this process. The
first one is shown here: use the date_select_text statement. Its value
becomes the link text the user clicks to popup the calendar selection
mini-window. See, the controller below for the other two steps.
controller Birth is AutoCRUD {
controls_table birth;
rel_location birthday;
uses Gantry::Plugins::Calendar;
Step two in easy dates is to use Gantry::Plugins::Calendar which provides
javascript code generation routines.
lib/Gantry/Docs/Tutorial.pod view on Meta::CPAN
form_name birthday_form;
all_fields_but id;
extra_keys
legend => `$self->path_info =~ /edit/i ? 'Edit' : 'Add'`,
javascript => `$self->calendar_month_js( 'birthday_form' )`;
}
}
Now the name of the form becomes important. The calendar_month_js
method (mixed in by Gantry::Plugins::Calendar) generates the javascript
for the popup and its callback, which populates the date fields.
Note that we don't tell it which fields to handle. It will work on
all fields that have date_select_text statements.
Once these changes are made, we can regenerate the application:
bigtop docs/address.bigtop all
Execute this command while in the build directory (the one with the Changes
file in it).
lib/Gantry/Plugins/Calendar.pm view on Meta::CPAN
# $site->calendar_month_js( $form_id )
#-------------------------------------------------
sub calendar_month_js {
my( $site, $form_id ) = @_;
# prepend document. to form_id id is not specified
if ( $form_id !~ /^document\./i ) {
$form_id = 'document.' . $form_id;
}
my $popup_url = $site->location . "/calendar_month/";
return( qq!
<script type="text/javascript">
function SetDate(field, date) {
eval( '${form_id}.' + field + '.value = date;' );
}
function datepopup(name) {
window.open('$popup_url'+name, 'Shortcut',
'height=250,width=250' +
',screenX=' + (window.screenX+150) +
',screenY=' + (window.screenY+100) +
',scrollbars,resizable' );
}
</script>
! );
lib/Gantry/Plugins/Calendar.pm view on Meta::CPAN
happening behind the scenes.
When you use the Calendar template, methods are exported into the site
object. The important ones are calendar_month_js and do_calendar_month.
The global handler will call do_calendar_month for you.
calendar_month_js creates two Javascript functions:
=over 4
=item datepopup(form_name)
makes the calendar window popup.
=item SetDate(field_name, date)
sets the date when the user clicks on a date in the popup window.
=back
You must pass the name of the form to calendar_month_js, otherwise
its Javascript won't be able to tell the name to the popup window,
which will then be unable to set any dates on your form.
do_calendar_month is the method called by the handler when the window
pops up. It generates the calendar and manages user interaction with
it. It relies on the internal _calendar_month to make the actual
output. When the user clicks on a date, its Javascript first
calls SetDate with the field name and the date value
and then closes the popup window.
=head1 FUNCTIONS
The other functions are not directly useful to normal callers
but here is a complete list.
=head2 Method you call
=over 4
lib/Gantry/Utils/HTML.pm view on Meta::CPAN
@EXPORT = qw();
@EXPORT_OK = qw( ht_a
ht_b ht_br
ht_checkbox
ht_div ht_udiv
ht_form ht_form_js
ht_h
ht_help
ht_i ht_img ht_input
ht_lines
ht_p ht_popup
ht_qt
ht_radio
ht_select ht_submit
ht_table ht_tr ht_td ht_utd
ht_uform ht_up ht_uqt ht_utable ht_utr );
%EXPORT_TAGS =( 'common' => [qw/ ht_a ht_br ht_img ht_lines ht_qt ht_uqt/ ],
'style' => [qw/ ht_div ht_udiv ht_b ht_h ht_i ht_p ht_up/],
'form' => [qw/ ht_checkbox ht_form ht_form_js
ht_input ht_radio ht_select
ht_submit ht_uform / ],
'table' => [qw/ ht_table ht_tr ht_td ht_utd ht_utr
ht_utable / ],
'jscript' => [qw/ ht_help ht_popup / ],
'all' => [qw/ ht_a
ht_div ht_udiv
ht_b ht_br
ht_checkbox
ht_form ht_form_js
ht_h
ht_help
ht_i ht_img ht_input
ht_lines
ht_p ht_popup
ht_qt
ht_radio
ht_select ht_submit
ht_table ht_tr ht_td ht_utd
ht_uform ht_up ht_uqt ht_utable ht_utr / ]);
############################################################
# Functions #
############################################################
lib/Gantry/Utils/HTML.pm view on Meta::CPAN
qq!onClick="window.open('$url', 'helpwindow', !,
q! 'height=300,width=400' + !,
q! ',screenX=' + (window.screenX+150) + !,
q! ',screenY=' + (window.screenY+100) + !,
q! ',scrollbars,resizable' );"!,
'class="help"' ),
']' ) );
} # END ht_help
#-------------------------------------------------
# ht_popup( $url, $text, $winname, $x, $y )
#-------------------------------------------------
sub ht_popup {
my ( $url, $text, $winname, $height, $width ) = @_;
$height = '250' if ( ! defined $height );
$width = '250' if ( ! defined $width );
return( ht_a( 'javascript://', $text,
qq!onClick="window.open('$url', '$winname', !,
qq! 'height=$height,width=$width' + !,
q! ',screenX=' + (window.screenX+150) + !,
q! ',screenY=' + (window.screenY+100) + !,
q! ',scrollbars,resizable' );"! ) );
} # END ht_popup
#-------------------------------------------------
# ht_table( $options )
#-------------------------------------------------
sub ht_table {
my $options = shift;
my @params;
for my $option ( keys %{$options} ) {
lib/Gantry/Utils/HTML.pm view on Meta::CPAN
ht_b ht_h ht_i ht_p ht_up ht_div ht_udiv
:form
ht_checkbox ht_form ht_form_js ht_input ht_radio ht_select ht_submit
ht_uform
:table
ht_table ht_tr ht_td ht_utd ht_utr ht_utable
:jscript
ht_popup
ht_a
@href = ht_a( $url, $text, @extra )
ht_b
@bold = ht_b( @text )
ht_br
$br = ht_br()
lib/Gantry/Utils/HTML.pm view on Meta::CPAN
ht_input
@input = ht_input( $name, $type, $value @params )
ht_lines
$lines = ht_lines( @lines )
ht_p
$p = ht_p()
ht_popup
@popup = ht_popup( $url, $text, $winname, $height, $width )
ht_qt
$string = ht_qt( $string )
ht_radio
$radio = ht_radio( $name, $value, $form_value, @params )
ht_select
@select = ht_select( $name, $size, $value, $multiple,
$opts, @items )
lib/Gantry/Utils/HTML.pm view on Meta::CPAN
This function takes a "C<$level>" which is an integer between 1 and 6
corisponding to the h1 ... h6 tag that is used, there is not checking on
the value of the integer so any value of level is acceptable to the function
if not as valid html. The "C<@text>" is wrapped in the "h" tags.
=item @help = ht_help( $help_root, $type, $ident )
this function takes the help root, generally '$site{help}' a type,
either 'category' or 'item' and the ident of the help item. It returns
and array of html containing a link that will generate a help popup.
=item @i = ht_i( @text )
This function takes "C<@text>" and wraps it in "C<<I>>" tags.
=item @img = ht_img( $url, @extra )
This function creates an "C<<IMG SRC=..>>" tag. "C<$url>" is the url to the
image, "C<@extra>" should contain any extra tags that the image tage should
contain. The "C<@extra>" array should contain values of the form "WIDTH='10'".
lib/Gantry/Utils/HTML.pm view on Meta::CPAN
=item $lines = ht_lines( @lines )
This function takes the "C<@lines>" array and concatanates it together with
newlines "C<\n>" to create a single string.
=item $p = ht_p()
This function takes no arguements and returns a simple C<<P>> tag.
=item @popup = ht_popup( $url, $text, $winname, $height, $width )
This function creates a special html "ref" call. It creates a link to a new
javascript window with the properties specified. The "C<$url>" is the URL
of the new window, "C<$text>" is the text to be displayed by the link.
"C<$winname>" is the name of the window that will be created. "C<$height>" and
"C<$width>" are the height and the width of the window, respectively.
=item $string = ht_qt( $string )
This function will escape the html special characters in "C<$string>" and
root/css/gantry_datepicker.css view on Meta::CPAN
a.date-picker { width: 16px; height: 16px; border: none; color: #fff; padding: 0; margin: 0; float: left; overflow: hidden; cursor: pointer; background: url(calendar.png) no-repeat;}
a.date-picker span { margin: 0 0 0 -2000px;}
div.date-picker-holder, div.date-picker-holder * { margin: 0; padding: 0;}
div.date-picker-holder { position: relative;}
div.date-picker-holder input { float: left;}
div.popup-calendar { display: none; position: absolute; z-index: 2; top: 0; font-size: 9px; left: -16px; /* value for IE */ padding: 4px; border: 2px solid #000; background: #fff; color: #000; overflow:hidden; width: 163px;}
html>body div.popup-calendar { left: 99px; /* value for decent browsers */}
div.popup-calendar div.link-close { float: right;}
div.popup-calendar div.link-prev { float: left;}
div.popup-calendar h3 { font-size: 1.3em; margin: 2px 0 5px 3px;}
div.popup-calendar div.link-next { float: right;}
div.popup-calendar div a { padding: 1px 2px; color: #000;}
div.popup-calendar div a:hover { background-color: #000; color: #fff;}
div.popup-calendar table { margin: 0;}
* html div.popup-calendar table { display: inline;}
div.popup-calendar table th, div.popup-calendar table td { background: #eee; width: 21px; height: 17px; text-align: center;}
div.popup-calendar table td.inactive { color: #aaa; padding: 1px 0 0;}
div.popup-calendar table th.weekend, div.popup-calendar table td.weekend { background: #f6f6f6;}
div.popup-calendar table td a { display: block; border: 1px solid #eee; width: 19px; height: 15px; text-decoration: none; color: #333;}
div.popup-calendar table td.today a { border-color: #aaa;}
div.popup-calendar table td a.selected, div.popup-calendar table td a:hover { background: #333; color: #fff;}
root/form.tt view on Meta::CPAN
Parameters:
self - the site object (if self has a params hash values shown on
the form are taken from it)
view.title - thr browser window title
view.form - a hash with these keys:
method - POST or GET (defaults to POST)
action - url of page to process form (defaults to self.uri)
name - the name of the form (useful for javascript references)
row - the current row object from the table (if available)
javascript - javascript code the form needs (like for date popups.
Consider using Gantry::Plugins::Calendar and calling
its calendar_month_js.
(This could actually be anything, it just gets copied to
the output immediately after the form opening tag)
legend - The title for the legend box wrapping the form.
change_log - An array of change_log entries (optional). Each entry
is a hash with these keys:
date - the date the change happened
by - the name of the person making the change
message - what happened
root/form.tt view on Meta::CPAN
select_multiple
options - just as for select
selected - a code reference which accepts one
value, and the form params. Return
true if the value is selected, false
otherwise. Usually
Gantry::Plugins::CRUD's
select_multiple_closure works well.
text
date_select_text - the text of the href link for
the date popup window.
You must include this to
get a date popup link.
display_size - the size attribute of the
input element
(this is called display_size because TT has
a pseudo-method .size which tells how many keys
are in the field's hash)
textarea
rows - how tall the area is
cols - how wide the area is
checkbox
checked - true if you want initial check mark
root/form.tt view on Meta::CPAN
<input type="[% field.type %]"
size="[% field.display_size || 30 %]"
[%- UNLESS input_value.match('^$') -%]
value="[% input_value %]"
[%- END -%]
class="[% field.class %]"
name="[% field.name %]"
id="[% field.name %]"
/>
[%- IF field.date_select_text -%]
[% popup = "datepopup('$field.name')" %]
<a href="javascript://" onClick="[% popup %]" >
[% field.date_select_text %]
</a>
[%- END %]
[%- END %]
<div class="hint">
[% field.hint ? field.hint : '' %]
</div>
</td>
</tr>
root/js/datePicker.js view on Meta::CPAN
* http://kelvinluck.com/assets/jquery/datePicker
*
* Copyright (c) 2006 Kelvin Luck (kelvinluck.com)
* Licensed under the MIT License:
* http://www.opensource.org/licenses/mit-license.php
*
* $LastChangedDate: 2007-02-14 12:01:15 +0000 (Wed, 14 Feb 2007) $
* $Rev: 1342 $
*/
eval(function(p,a,c,k,e,d){e=function(c){return(c<a?"":e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};whi...
root/search.tt view on Meta::CPAN
>[% self.params.${field.name} || view.form.row.${field.name}
|| field.default_value %]</textarea>
[% ELSE %]
<input type="[% field.type %]"
size="[% field.display_size %]"
value="[% self.params.${field.name} || view.form.row.${field.name} || field.default_value %]"
name="[% field.name %]"
/>
[% IF field.date_select_text %]
[% popup = "datepopup('$field.name')" %]
<a href="javascript://" onClick="[% popup %]" >
[% field.date_select_text %]
</a>
[% END %]
[% END %]
</td>
</tr>
[% END %]
[% END %]
<tr>