From d99c03341135a2852e89a59f71b756e53f977a37 Mon Sep 17 00:00:00 2001 From: JT Smith Date: Mon, 8 Dec 2003 21:04:46 +0000 Subject: [PATCH] some new tweaks --- docs/migration.txt | 16 +- docs/previousVersion.sql | 2 +- docs/upgrades/upgrade_5.5.3-6.0.0.sql | 3 +- lib/WebGUI/DateTime.pm | 29 ++- lib/WebGUI/Form.pm | 48 ++-- lib/WebGUI/FormProcessor.pm | 5 +- lib/WebGUI/HTMLForm.pm | 15 +- lib/WebGUI/Operation/Page.pm | 14 +- www/extras/calendar.html | 308 -------------------------- 9 files changed, 73 insertions(+), 367 deletions(-) delete mode 100644 www/extras/calendar.html diff --git a/docs/migration.txt b/docs/migration.txt index 7622b8c18..a6bea8c8b 100644 --- a/docs/migration.txt +++ b/docs/migration.txt @@ -53,8 +53,18 @@ There have currently been no changes to the scheduler API. 5. System Changes Affecting Migration ------------------------------------- -5.1 Nothing Yet +5.1 Set Date Format Changes + +In 6.0 the "set date" format used by WebGUI::Form::date() and other methods +was changed from "MM/DD/YYYY" to "YYYY-MM-DD" and optionally "YYYY-MM-DD +HH:MM:SS". If you are using WebGUI::FormProcessor to handle processing of your +dates then you will notice no side effects from the format change. If you are +not, then you should convert your plugin to use WebGUI::FormProcessor. + +In addition to the format change above, we also made one related API change. +WebGUI::Form::dateTime() and WebGUI::HTMLForm->dateTime() no longer have +"dateExtras" and "timeExtras", but rather just "extras" properties. This is +because there is only one field to represent both the date and the time, +unlike before. -There have currently been no changes to the system that would affect any normal -use of the API's by plugins. diff --git a/docs/previousVersion.sql b/docs/previousVersion.sql index dfe283abe..385022ab7 100644 --- a/docs/previousVersion.sql +++ b/docs/previousVersion.sql @@ -17036,5 +17036,5 @@ update style set styleId=10 where styleId=-10; delete from style where styleId<0; update incrementer set nextValue=nextValue+1 where incrementerId='styleId'; update page set styleId=1000 where styleId=-8; -INSERT INTO style VALUES (1000,'WebGUI 6','\r\n ','\r\n^AdminBar(1);\r\n\r\n\r\n\r\n \r\n \r\n \r\n \r\n \r\n
^L(17,"",2); ^AdminToggle;
\r\n\r\n\r\n \r\n \r\n \r\n \r\n \r\n \r\n
\r\n\"home\" \n \"Email\"\r\n\"Print\" \n \"Site \"Plain\r\n^Spacer(56,1);^Spacer(26,1);
\r\n\r\n\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n
^Spacer(53,59);^D(\"%c %D, %y\");
^PageTitle;
^Spacer(53,59);
\r\n\r\n\r\n\r\n \r\n \r\n \r\n \r\n\r\n \r\n \r\n \r\n \r\n \r\n
^Spacer(53,1);\r\n
\r\n^FlexMenu;\r\n


\r\n\r\n
^-;^Spacer(53,1);
\r\n\r\n\r\n\r\n \r\n \r\n \r\n \r\n \r\n \r\n
\r\n\r\n'); +INSERT INTO style VALUES (1000,'WebGUI 6','\r\n ','\r\n^AdminBar(1);\r\n\r\n\r\n\r\n \r\n \r\n \r\n \r\n \r\n
^L(17,"",2); ^AdminToggle;
\r\n\r\n\r\n \r\n \r\n \r\n \r\n \r\n \r\n
\r\n\"home\" \n \"Email\"\r\n\"Print\" \n \"Site \"Plain\r\n^Spacer(56,1);^Spacer(26,1);
\r\n\r\n\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n
^Spacer(53,59);^D(\"%c %D, %y\");
^PageTitle;
^Spacer(53,59);
\r\n\r\n\r\n\r\n \r\n \r\n \r\n \r\n\r\n \r\n \r\n \r\n \r\n \r\n
^Spacer(53,1);\r\n
\r\n^FlexMenu;\r\n


\r\n\r\n
^-;^Spacer(53,1);
\r\n\r\n\r\n\r\n \r\n \r\n \r\n \r\n \r\n \r\n
\r\n\r\n'); diff --git a/docs/upgrades/upgrade_5.5.3-6.0.0.sql b/docs/upgrades/upgrade_5.5.3-6.0.0.sql index 420f643c9..88356e34d 100644 --- a/docs/upgrades/upgrade_5.5.3-6.0.0.sql +++ b/docs/upgrades/upgrade_5.5.3-6.0.0.sql @@ -172,6 +172,7 @@ delete from international where languageId=1 and namespace='USS' and internation insert into international (internationalId,languageId,namespace,message,lastUpdated,context) values (71,1,'USS','User Submission Systems (USS) are a great way to add a sense of community to any site as well as get free content from your users. The User Submission System name is misleading to some people, because they immediately think of users as visitors. However, users are also staff, or business partners, or even yourself. With the USS you can select who can add new content, and even who can moderate that content.\r\n

\r\nUser Submission systems are so versatile that they allow you to create all kinds of applications, just by editing a few templates. Example applications are Photo Galleries, FAQs, Link Lists, Guest Books, Classifieds, and more.\r\n\r\n\r\n

\r\nSubmission Template
\r\nChoose a layout for the individual submissions.\r\n

\r\n\r\nSubmission Form Template
\r\nChoose a layout of the form users see when submitting content.\r\n

\r\n\r\n\r\nSubmissions Per Page
\r\nHow many submissions should be listed per page in the submissions index?\r\n

\r\n\r\n\r\nFilter Content
\r\nSelect the level of content filtering you wish to perform on all submitted content.\r\n

\r\n\r\nSort By
\r\nThe field to sort the submission list by.\r\n

\r\n\r\nSort Order
\r\nThe direction to sort the submission list by.\r\n

\r\n\r\n\r\n\r\n\r\nWho can approve?
\r\nWhat group is allowed to approve and deny content?\r\n

\r\n\r\nWho can contribute?
\r\nWhat group is allowed to contribute content?\r\n

\r\n\r\n\r\nDefault Status
\r\nShould submissions be set to Approved, Pending, or Denied by default?\r\n

\r\nNote: If you set the default status to Pending, then be prepared to monitor your message log for new submissions.\r\n

\r\n\r\nKarma Per Submission
\r\nHow much karma should be given to a user when they contribute to this user submission system?\r\n

\r\n\r\n\r\nAllow discussion?
\r\nChecking this box will enable responses to your article much like Articles on Slashdot.org.\r\n

\r\n\r\n\r\n', 1070199700,NULL); INSERT INTO template VALUES (1,'Default Login Box','

\n\n \n
\n \n

\n \n
\n \n \n \n

\n
\n\n \n \">.\n \n \n \n \n
\n
\n','Macro/L_loginBox'); INSERT INTO template VALUES (2,'Horizontal Login Box','
\n\n \n \n \n \n \n \n \n \n \n \n \n \n
\n \n \n \n \n\n \n \">.\n
\n \n \n
\n
\n
\n','Macro/L_loginBox'); -INSERT INTO template VALUES (2,'DHTML Admin Bar','\n\n\n\n
\n','Macro/AdminBar'); +INSERT INTO template VALUES (2,'DHTML Admin Bar','\n\n\n\n
\n','Macro/AdminBar'); INSERT INTO template VALUES (1,'Default Admin Bar',' \n \n
\n\n \n \n \n \n \n
\n \n
\n \n
\n \n
\n
\n','Macro/AdminBar'); +delete from international where internationalId=34 and namespace='WebGUI'; diff --git a/lib/WebGUI/DateTime.pm b/lib/WebGUI/DateTime.pm index 772644809..4f76b97ca 100644 --- a/lib/WebGUI/DateTime.pm +++ b/lib/WebGUI/DateTime.pm @@ -286,9 +286,9 @@ sub epochToHuman { #------------------------------------------------------------------- -=head2 epochToSet ( epoch ) +=head2 epochToSet ( epoch, withTime ) -Returns a set date (used by WebGUI::HTMLForm->date) in the format of MM/DD/YYYY. +Returns a set date (used by WebGUI::HTMLForm->date) in the format of YYYY-MM-DD. =over @@ -296,12 +296,19 @@ Returns a set date (used by WebGUI::HTMLForm->date) in the format of MM/DD/YYYY. The number of seconds since January 1, 1970. +=item withTime + +A boolean indicating that the time should be added to the output, thust turning the format into YYYY-MM-DD HH:MM:SS. + =back =cut sub epochToSet { - return epochToHuman($_[0],"%m/%d/%y"); + if ($_[1]) { + return epochToHuman($_[0],"%y-%m-%d %j:%n:%s"); + } + return epochToHuman($_[0],"%y-%m-%d"); } #------------------------------------------------------------------- @@ -626,31 +633,33 @@ Returns an epoch date. =item set -A string in the format of MM/DD/YYYY. +A string in the format of YYYY-MM-DD or YYYY-MM-DD HH:MM:SS. =back =cut sub setToEpoch { - my @date = Date::Calc::Time_to_Date(time()); - my ($month, $day, $year) = split(/\//,$_[0]); + my @now = Date::Calc::Time_to_Date(time()); + my ($date,$time) = split(/ /,$_[0]); + my ($year, $month, $day) = split(/\-/,$date); + my ($hour, $minute, $second) = split(/\:/,$time); if (int($year) < 2038 && int($year) > 1969) { $year = int($year); } else { - $year = $date[0]; + $year = $now[0]; } if (int($month) < 13 && int($month) > 0) { $month = int($month); } else { - $month = $date[1]++; + $month = $now[1]++; } if (int($day) < 32 && int($day) > 0) { $day = int($day); } else { - $day = $date[2]; + $day = $now[2]; } - return Date::Calc::Date_to_Time($year,$month,$day,0,0,0); + return Date::Calc::Date_to_Time($year,$month,$day,$hour,$minute,$second); } #------------------------------------------------------------------- diff --git a/lib/WebGUI/Form.pm b/lib/WebGUI/Form.pm index 5c513516c..08d5ffb88 100644 --- a/lib/WebGUI/Form.pm +++ b/lib/WebGUI/Form.pm @@ -354,9 +354,8 @@ By default a date is placed in the "value" field. Set this to "1" to turn off th =cut sub date { - my ($subtext, $noDate, $class, $name, $label, $extras, $size, $value); - $value = epochToSet($_[0]->{value}) unless ($_[0]->{noDate} && $_[0]->{value} eq ''); - $size = $_[0]->{size} || 10; + my $value = epochToSet($_[0]->{value}) unless ($_[0]->{noDate} && $_[0]->{value} eq ''); + my $size = $_[0]->{size} || 10; my $output = _cssFile("calendar/calendar-win2k-1.css") ._javascriptFile('calendar/calendar.js') ._javascriptFile('calendar/lang/calendar-en.js') @@ -377,10 +376,6 @@ sub date { mondayFirst : false }); '; -# $output .= ''; return $output; } @@ -402,29 +397,36 @@ The the base name for this form element. This form element actually returns two The date and time. Pass as an epoch value. Defaults to today and now. -=item dateExtras +=item extras -Extra parameters to add to the date form element such as javascript or stylesheet information. - -=item timeExtras - -Extra parameters to add to the time form element such as javascript or stylesheet information. +Extra parameters to add to the date/time form element such as javascript or stylesheet information. =back =cut sub dateTime { - my $output = date({ - name=>$_[0]->{name}."_date", - value=>$_[0]->{value}, - extras=>$_[0]->{dateExtras} - }); - $output .= timeField({ - name=>$_[0]->{name}."_time", - value=>WebGUI::DateTime::getSecondsFromEpoch($_[0]->{value}), - extras=>$_[0]->{timeExtras} - }); + my $value = epochToSet($_[0]->{value},1); + my $output = _cssFile("calendar/calendar-win2k-1.css") + ._javascriptFile('calendar/calendar.js') + ._javascriptFile('calendar/lang/calendar-en.js') + ._javascriptFile('calendar/calendar-setup.js'); + $output .= text({ + name=>$_[0]->{name}, + value=>$value, + size=>19, + extras=>'id="'.$_[0]->{name}.'Id" '.$_[0]->{extras}, + maxlength=>19 + }); + $output .= ''; return $output; } diff --git a/lib/WebGUI/FormProcessor.pm b/lib/WebGUI/FormProcessor.pm index 33094da3b..e411f746d 100644 --- a/lib/WebGUI/FormProcessor.pm +++ b/lib/WebGUI/FormProcessor.pm @@ -191,10 +191,7 @@ The name of the form variable to retrieve. =cut sub dateTime { - my $date = date($_[0]."_date"); - my $time = timeField($_[0]."_time"); - my $epoch = $date+$time; - return $epoch; + return WebGUI::DateTime::setToEpoch($session{form}{$_[0]}); } #------------------------------------------------------------------- diff --git a/lib/WebGUI/HTMLForm.pm b/lib/WebGUI/HTMLForm.pm index aff63d556..57c650d15 100644 --- a/lib/WebGUI/HTMLForm.pm +++ b/lib/WebGUI/HTMLForm.pm @@ -587,13 +587,9 @@ Extra text to describe this form element or to provide special instructions. The UI level for this field. See the WebGUI developer's site for details. Defaults to "0". -=item dateExtras +=item extras -Extra parameters such as javascript or style sheet information that you wish to add to the date form element. - -=item timeExtras - -Extra parameters such as javascript or style sheet information that you wish to add to the time form element. +Extra parameters such as javascript or style sheet information that you wish to add to the form element. =back @@ -602,14 +598,13 @@ Extra parameters such as javascript or style sheet information that you wish to sub dateTime { my ($output); my ($self, @p) = @_; - my ($name, $label, $value, $subtext, $uiLevel, $dateExtras, $timeExtras) = - rearrange([qw(name label value subtext uiLevel dateExtras timeExtras)], @p); + my ($name, $label, $value, $subtext, $uiLevel, $extras) = + rearrange([qw(name label value subtext uiLevel extras)], @p); if (_uiLevelChecksOut($uiLevel)) { $output = WebGUI::Form::dateTime({ "name"=>$name, "value"=>$value, - "dateExtras"=>$dateExtras, - "timeExtras"=>$timeExtras + "extras"=>$extras }); $output .= _subtext($subtext); $output = $self->_tableFormRow($label,$output); diff --git a/lib/WebGUI/Operation/Page.pm b/lib/WebGUI/Operation/Page.pm index 0f902dc2f..3665989c7 100644 --- a/lib/WebGUI/Operation/Page.pm +++ b/lib/WebGUI/Operation/Page.pm @@ -101,7 +101,7 @@ sub _selectPositions { ); $output = ' - - -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- - -
-
-
- - - - - -
-
Su
Mo
Tu
We
Th
Fr
Sa
- - -
- -