diff --git a/docs/upgrades/upgrade_5.2.6-5.3.0.sql b/docs/upgrades/upgrade_5.2.6-5.3.0.sql index 56c54ef12..21c0b227c 100644 --- a/docs/upgrades/upgrade_5.2.6-5.3.0.sql +++ b/docs/upgrades/upgrade_5.2.6-5.3.0.sql @@ -523,10 +523,7 @@ delete from settings where name='sharedTrash'; insert into settings (name,value) values ('sharedTrash','0'); delete from international where languageId=1 and namespace='WebGUI' and internationalId=629; INSERT INTO international (internationalId,languageId,namespace,message,lastUpdated) VALUES (629,1,'WebGUI','Use shared clipboard?
\r\nEnables a single, system-wide clipboard shared by all users. Default is user separated clipboards.\r\n

\r\n\r\nUse shared trash?
\r\nEnables a single, system-wide trash shared by all users. Default is user separated trash.\r\n

\r\n\r\nPrevent Proxy Caching
\r\nSome companies have proxy servers that cause problems with WebGUI. If you\'re experiencing problems with WebGUI, and you have a proxy server, you may want to set this setting to Yes. Beware that WebGUI\'s URLs will not be as user-friendly after this feature is turned on.\r\n

\r\n\r\nShow debugging?
\r\nShow debugging information in WebGUI\'s output. This is primarily useful for WebGUI developers, but can also be interesting for Administrators trying to troubleshoot a problem.\r\n

\r\n\r\nTrack page statistics?
\r\nWebGUI can track some statistical information for your site. However, this will add a little extra strain on your processor and will make your database grow much more quickly. Enable this only if you do not have an external web statistics program.\r\n

\r\n',1052850265); - alter table HttpProxy change ProxiedUrl proxiedUrl varchar(255); - - delete from international where namespace='DataForm' and internationalId=78; delete from international where namespace='EventsCalendar' and internationalId=79; delete from international where namespace='FAQ' and internationalId=74; @@ -539,7 +536,6 @@ alter table WobjectProxy add column overrideDescription int not null default 0; alter table WobjectProxy add column overrideTemplate int not null default 0; alter table WobjectProxy add column overrideDisplayTitle int not null default 0; alter table WobjectProxy add column proxiedTemplateId int not null default 1; - delete from international where languageId=1 and namespace='WobjectProxy' and internationalId=10; insert into international (internationalId,languageId,namespace,message,lastUpdated,context) values (10,1,'WobjectProxy','Override template?', 1053183837,'Asking the user if s/he would like to use the template specified in the wobject proxy or the original template of the original wobject.'); delete from international where languageId=1 and namespace='WobjectProxy' and internationalId=9; @@ -548,16 +544,14 @@ delete from international where languageId=1 and namespace='WobjectProxy' and in insert into international (internationalId,languageId,namespace,message,lastUpdated,context) values (8,1,'WobjectProxy','Override display title?', 1053183719,'Asking the user if s/he would like to use the "display title" setting specified in the wobject proxy or the original display title setting of the original wobject.'); delete from international where languageId=1 and namespace='WobjectProxy' and internationalId=7; insert into international (internationalId,languageId,namespace,message,lastUpdated,context) values (7,1,'WobjectProxy','Override title?', 1053183682,'Asking the user if s/he would like to use the title specified in the wobject proxy or the original title of the original wobject.'); - - - - - - - INSERT INTO style VALUES (-10,'htmlArea Image Manager','\r\n','\r\n\r\n\r\n\r\n\r\n\r\n^-;\r\n'); - - delete from international where languageId=1 and namespace='WebGUI' and internationalId=844; insert into international (internationalId,languageId,namespace,message,lastUpdated,context) values (844,1,'WebGUI','These macros have to do with users and logins.\r\n

\r\n\r\n^a; or ^a(); - My Account Link
\r\nA link to your account information. In addition you can change the link text by creating a macro like this ^a("Account Info");. \r\n

\r\n\r\nNOTES: You can also use the special case ^a(linkonly); to return only the URL to the account page and nothing more. Also, the .myAccountLink style sheet class is tied to this macro.\r\n

\r\n\r\n\r\n^AdminText();
\r\nDisplays a small text message to a user who is in admin mode. Example: ^AdminText("You are in admin mode!");\r\n

\r\n\r\n^AdminToggle; or ^AdminToggle();
\r\nPlaces a link on the page which is only visible to content managers and adminstrators. The link toggles on/off admin mode. You can optionally specify other messages to display like this: ^AdminToggle("Edit On","Edit Off");\r\n

\r\n\r\n^CanEditText();
\r\nDisplay a message to a user that can edit the current page.\r\n

\r\nExample: ^CanEditText(^AdminToggle;);\r\n

\r\n\r\n^EditableToggle; or ^EditableToggle();
\r\nExactly the same as AdminToggle, except that the toggle is only displayed if the user has the rights to edit the current page.\r\n

\r\n\r\n^GroupText();
\r\nDisplays a small text message to the user if they belong to the specified group. And you can specify an alternate message to those who are not in the group.\r\n

\r\nExample: ^GroupText("Visitors","You need an account to do anything cool on this site!","We value our registered users!");\r\n

\r\n\r\n^L; or ^L(); - Login Box
\r\nA small login form. You can also configure this macro. You can set the width of the login box like this ^L(20);. You can also set the message displayed after the user is logged in like this ^L(20,Hi ^a(^@;);. Click %here% if you wanna log out!)\r\n

\r\n\r\nNOTE: The .loginBox style sheet class is tied to this macro.\r\n

\r\n\r\n^LoginToggle; or ^LoginToggle();
\r\nDisplays a "Login" or "Logout" message depending upon whether the user is logged in or not. You can optionally specify other labels like this: ^LoginToggle("Click here to log in.","Click here to log out.");. You can also use the special case ^LoginToggle(linkonly); to return only the URL with no label.\r\n

\r\n\r\n^@; - Username
\r\nThe username of the currently logged in user.\r\n

\r\n\r\n\r\n^#; - User ID
\r\nThe user id of the currently logged in user.\r\n

\r\n\r\n', 1053114197,NULL); +delete from international where languageId=1 and namespace='WebGUI' and internationalId=972; +insert into international (internationalId,languageId,namespace,message,lastUpdated,context) values (972,1,'WebGUI','Date and Time', 1053278234,'A field that holds a calendar date and clock time.'); +delete from international where languageId=1 and namespace='WebGUI' and internationalId=971; +insert into international (internationalId,languageId,namespace,message,lastUpdated,context) values (971,1,'WebGUI','Time', 1053278208,'A field that holds clock time.'); +delete from international where languageId=1 and namespace='WebGUI' and internationalId=970; +insert into international (internationalId,languageId,namespace,message,lastUpdated,context) values (970,1,'WebGUI','set time', 1053278089,'Click the button to use the time chooser wizard.'); + diff --git a/lib/WebGUI/DateTime.pm b/lib/WebGUI/DateTime.pm index ebdfe6c29..482f2fcec 100644 --- a/lib/WebGUI/DateTime.pm +++ b/lib/WebGUI/DateTime.pm @@ -42,9 +42,9 @@ This package provides easy to use date math functions, which are normally a comp ($startEpoch, $endEpoch) = WebGUI::DateTime::dayStartEnd($epoch); $dateString = WebGUI::DateTime::epochToHuman($epoch, $formatString); $setString = WebGUI::DateTime::epochToSet($epoch); - ($setString, $timeString) = WebGUI::DateTime::epochToSetTime($epoch); $day = WebGUI::DateTime::getDayName($dayInteger); $month = WebGUI::DateTime::getMonthName($monthInteger); + $seconds = WebGUI::DateTime::getSecondsFromEpoch($seconds); $epoch = WebGUI::DateTime::humanToEpoch($dateString); $seconds = WebGUI::DateTime::intervalToSeconds($interval, $units); @date = WebGUI::DateTime::localtime($epoch); @@ -52,7 +52,6 @@ This package provides easy to use date math functions, which are normally a comp ($interval, $units) = WebGUI::DateTime::secondsToInterval($seconds); $timeString = WebGUI::DateTime::secondsToTime($seconds); $epoch = WebGUI::DateTime::setToEpoch($setString); - $epoch = WebGUI::DateTime::setTimeToEpoch($setTimeString); $epoch = WebGUI::DateTime::time(); $seconds = WebGUI::DateTime::timeToSeconds($timeString); @@ -307,26 +306,6 @@ sub epochToSet { #------------------------------------------------------------------- -=head2 epochToSetTime ( epoch ) - -Returns a set date (used by WebGUI::HTMLForm->date) in the format of MM/DD/YYYY and a time string in the format of HH:MM:SS. - -=over - -=item epoch - -The number of seconds since January 1, 1970. - -=back - -=cut - -sub epochToSetTime { - return (epochToHuman($_[0],"%m/%d/%y"), epochToHuman($_[0],"%j:%n:%s")); -} - -#------------------------------------------------------------------- - =head2 getMonthName ( month ) Returns a string containing the calendar month name in the language of the current user. @@ -404,6 +383,28 @@ sub getDayName { } } +#------------------------------------------------------------------- + +=head2 getSecondsFromEpoch ( epoch ) + +Calculates the number of seconds into the day of an epoch date the epoch datestamp is. + +=over + +=item epoch + +The number of seconds since January 1, 1970 00:00:00. + +=back + +=cut + +sub getSecondsFromEpoch { + return timeToSeconds(epochToHuman($_[0],"%j:%n:%s")); +} + + + #------------------------------------------------------------------- =head2 humanToEpoch ( date ) @@ -598,7 +599,7 @@ Returns a time string of the format HH::MM::SS on a 24 hour clock. See also time =item seconds -A number of seconds. +A number of seconds. =back @@ -606,11 +607,11 @@ A number of seconds. sub secondsToTime { my $seconds = $_[0]; - my $timeString = int($seconds / 3600).":"; + my $timeString = sprintf("%02d",int($seconds / 3600)).":"; $seconds = $seconds % 3600; - $timeString = int($seconds / 60).":"; + $timeString .= sprintf("%02d",int($seconds / 60)).":"; $seconds = $seconds % 60; - $timeString .= $seconds; + $timeString .= sprintf("%02d",$seconds); return $timeString; } @@ -649,33 +650,7 @@ sub setToEpoch { } else { $day = $date[2]; } - return Date::Calc::Date_to_Time($year,$month,$day,12,0,0); -} - -#------------------------------------------------------------------- - -=head2 setTimeToEpoch ( setString, timeString ) - -Returns an epoch date. - -=over - -=item setString - -A string in the format of MM/DD/YYYY. - -=item timeString - -A string in the format of HH:MM:SS. - -=back - -=cut - -sub setTimeToEpoch { - my $epoch = setToEpoch($_[0]); - $epoch += timeToSeconds($_[1]); - return $epoch; + return Date::Calc::Date_to_Time($year,$month,$day,0,0,0); } #------------------------------------------------------------------- diff --git a/lib/WebGUI/Form.pm b/lib/WebGUI/Form.pm index 5c7c855b9..0167ffff1 100644 --- a/lib/WebGUI/Form.pm +++ b/lib/WebGUI/Form.pm @@ -293,12 +293,13 @@ sub date { $value = epochToSet($_[0]->{value}); $size = $_[0]->{size} || 10; $value = "" if ($_[0]->{noDate}); - $output = text({ + my $output = _javascriptFile('inputCheck.js'); + $output .= text({ name=>$_[0]->{name}, value=>$value, size=>$size, - maxlength=>10, - extras=>$_[0]->{extras} + extras=>'onKeyUp="doInputCheck(this.form.'.$_[0]->{name}.',\'0123456789\')" '.$_[0]->{extras}, + maxlength=>10 }); $output .= '$_[0]->{value} + }); + $output .= time({ + name=>$_[0]->{name}."_time", + value=>WebGUI::DateTime::getSecondsFromEpoch($_[0]->{value}) + }); + return $output; +} + + + #------------------------------------------------------------------- =head2 email ( hashRef ) @@ -400,11 +435,15 @@ sub fieldType { # without adult supervision. =) It was done this way because a huge # if/elsif construct executes much more quickly than a bunch of # unnecessary database hits. - my @types = qw(zipcode text textarea HTMLArea url date email phone integer yesNo selectList radioList checkboxList); + my @types = qw(dateTime time zipcode text textarea HTMLArea url date email phone integer yesNo selectList radioList checkboxList); $_[0]->{types} = \@types unless ($_[0]->{types}); foreach $type (@{$_[0]->{types}}) { if ($type eq "text") { $hash{text} = WebGUI::International::get(475); + } elsif ($type eq "time") { + $hash{time} = WebGUI::International::get(971); + } elsif ($type eq "dateTime") { + $hash{dateTime} = WebGUI::International::get(972); } elsif ($type eq "textarea") { $hash{textarea} = WebGUI::International::get(476); } elsif ($type eq "HTMLArea") { @@ -1364,6 +1403,57 @@ sub textarea { #------------------------------------------------------------------- +=head2 time ( hashRef ) + +Returns a time field, 24 hour format. + +=over + +=item name + +The name field for this form element. + +=item value + +The default value for this form element. Defaults to the current time (like "15:03:42"). + +=item maxlength + +The maximum number of characters to allow in this form element. Defaults to 8. + +=item extras + +If you want to add anything special to this form element like javascript actions, or stylesheet information, you'd add it in here as follows: + + 'onChange="this.form.submit()"' + +=item size + +The number of characters wide this form element should be. There should be no reason for anyone to specify this. Defaults to 8. + +=back + +=cut + +sub time { + my $value = WebGUI::DateTime::secondsToTime($_[0]->{value}); + my $output = _javascriptFile('inputCheck.js'); + $output .= text({ + name=>$_[0]->{name}, + value=>$value, + size=>$_[0]->{size} || 8, + extras=>'onKeyUp="doInputCheck(this.form.'.$_[0]->{name}.',\'0123456789:\')" '.$_[0]->{extras}, + maxlength=>$_[0]->{maxlength} || 8 + }); + $output .= ''; + return $output; +} + +#------------------------------------------------------------------- + =head2 url ( hashRef ) Returns a URL field. diff --git a/lib/WebGUI/FormProcessor.pm b/lib/WebGUI/FormProcessor.pm index a4e92ff37..cb6e5e949 100644 --- a/lib/WebGUI/FormProcessor.pm +++ b/lib/WebGUI/FormProcessor.pm @@ -170,10 +170,12 @@ The name of the form variable to retrieve. =cut sub dateTime { - return (date($_[0]."_date")+time($_[0]."_time")); + my $date = WebGUI::FormProcessor::date($_[0]."_date"); + my $time = WebGUI::FormProcessor::time($_[0]."_time"); + my $epoch = $date+$time; + return $epoch; } - #------------------------------------------------------------------- =head2 email ( name ) @@ -469,9 +471,8 @@ sub process { my ($name, $type, $default) = @_; my $value; $type = "text" if ($type eq ""); - if (exists $session{form}{$name}) { - $value = &$type($name); - } else { + $value = &$type($name); + unless (defined $value) { $value = $default; } if ($value =~ /^[\s]+$/) { @@ -627,7 +628,7 @@ The name of the form variable to retrieve. =cut sub time { - return WebGUI::DateTime::timeToEpoch($session{form}{$_[0]}); + return WebGUI::DateTime::timeToSeconds($session{form}{$_[0]}); } diff --git a/lib/WebGUI/HTMLForm.pm b/lib/WebGUI/HTMLForm.pm index 7db9ac312..a6a1d0647 100644 --- a/lib/WebGUI/HTMLForm.pm +++ b/lib/WebGUI/HTMLForm.pm @@ -480,6 +480,63 @@ sub date { +#------------------------------------------------------------------- + +=head2 dateTime ( name [ label, value, subtext, uiLevel ] ) + +Adds a date time row to this form. + +=over + +=item name + +The name field for this form element. + +=item label + +The left column label for this form row. + +=item value + +The default date and time. Pass as an epoch value. Defaults to today and now. + +=item subtext + +Extra text to describe this form element or to provide special instructions. + +=item uiLevel + +The UI level for this field. See the WebGUI developer's site for details. Defaults to "0". + +=back + +=cut + +sub dateTime { + my ($output); + my ($self, @p) = @_; + my ($name, $label, $value, $subtext, $uiLevel) = rearrange([qw(name label value subtext uiLevel)], @p); + if (_uiLevelChecksOut($uiLevel)) { + $output = WebGUI::Form::dateTime({ + "name"=>$name, + "value"=>$value + }); + $output .= _subtext($subtext); + $output = $self->_tableFormRow($label,$output); + } else { + $output = WebGUI::Form::hidden({ + "name"=>$name."_date", + "value"=>epochToSet($value) + }); + $output .= WebGUI::Form::hidden({ + "name"=>$name."_time", + "value"=>epochToHuman($value,"%j:%n:%s") + }); + } + $self->{_data} .= $output; +} + + #------------------------------------------------------------------- =head2 email ( name [ label, value, maxlength, extras, subtext, size, uiLevel ] ) @@ -1919,6 +1976,72 @@ sub textarea { $self->{_data} .= $output; } +#------------------------------------------------------------------- + +=head2 time ( name [ label, value, extras, subtext, size, noDate, uiLevel ] ) + +Adds a date row to this form. + +=over + +=item name + +The name field for this form element. + +=item label + +The left column label for this form row. + +=item value + +The default time. Pass as a number of seconds. Defaults to 0. + +=item extras + +If you want to add anything special to this form element like javascript actions, or stylesheet information, you'd add it in here as follows: + + 'onChange="this.form.submit()"' + +=item subtext + +Extra text to describe this form element or to provide special instructions. + +=item size + +The number of characters wide this form element should be. There should be no reason for anyone to specify this. + +=item uiLevel + +The UI level for this field. See the WebGUI developer's site for details. Defaults to "0". + +=back + +=cut + +sub time { + my ($output); + my ($self, @p) = @_; + my ($name, $label, $value, $extras, $subtext, $size, $uiLevel) = + rearrange([qw(name label value extras subtext size uiLevel)], @p); + if (_uiLevelChecksOut($uiLevel)) { + $output = WebGUI::Form::time({ + "name"=>$name, + "value"=>$value, + "size"=>$size, + "extras"=>$extras + }); + $output .= _subtext($subtext); + $output = $self->_tableFormRow($label,$output); + } else { + $output = WebGUI::Form::hidden({ + "name"=>$name, + "value"=>secondsToTime($value) + }); + } + $self->{_data} .= $output; +} + + #------------------------------------------------------------------- =head2 url ( name [ label, value, maxlength, extras, subtext, size, uiLevel ] ) diff --git a/lib/WebGUI/Operation/ProfileSettings.pm b/lib/WebGUI/Operation/ProfileSettings.pm index 94cb83f08..da1eb03b1 100644 --- a/lib/WebGUI/Operation/ProfileSettings.pm +++ b/lib/WebGUI/Operation/ProfileSettings.pm @@ -156,7 +156,7 @@ sub www_editProfileCategorySave { if ($session{form}{cid} eq "new") { $session{form}{cid} = getNextId("profileCategoryId"); ($sequenceNumber) = WebGUI::SQL->quickArray("select max(sequenceNumber) from userProfileCategory"); - WebGUI::SQL->write("insert into userProfileCategory values ($session{form}{cid}, " + WebGUI::SQL->write("insert into userProfileCategory (profileCategoryId,sequenceNumber) values ($session{form}{cid}, " .($sequenceNumber+1).")"); } WebGUI::SQL->write("update userProfileCategory set categoryName=".quote($session{form}{categoryName}).", diff --git a/www/extras/timeChooser.html b/www/extras/timeChooser.html new file mode 100644 index 000000000..fcfec5d48 --- /dev/null +++ b/www/extras/timeChooser.html @@ -0,0 +1,93 @@ + + +Time Chooser + + + + +

+ + + +: + + + +: + + + + +

+ + + + + +

+ + + + + + + +