Changed wobjects to inherit their start/end dates from their parent page.
This commit is contained in:
parent
fa1f4145c5
commit
6156e72fba
7 changed files with 35 additions and 32 deletions
|
|
@ -77,10 +77,7 @@ sub epochToHuman {
|
|||
$offset = $offset*3600;
|
||||
$temp = $_[0] || time();
|
||||
$temp = $temp+$offset;
|
||||
@date = localtime($temp);
|
||||
$date[4]++; # offset the months starting from 0
|
||||
$date[5] += 1900; # original value is Year-1900
|
||||
$date[6]++; # offset for weekdays starting from 0
|
||||
@date = &localtime($temp);
|
||||
$output = $_[1] || "%z %Z";
|
||||
#---dealing with percent symbol
|
||||
$output =~ s/\%\%/\%/g;
|
||||
|
|
@ -91,27 +88,27 @@ sub epochToHuman {
|
|||
$temp = $session{user}{timeFormat} || '%H:%n %p';
|
||||
$output =~ s/\%Z/$temp/g;
|
||||
#---year stuff
|
||||
$output =~ s/\%y/$date[5]/g;
|
||||
$value = substr($date[5],2,2);
|
||||
$output =~ s/\%y/$date[0]/g;
|
||||
$value = substr($date[0],2,2);
|
||||
$output =~ s/\%Y/$value/g;
|
||||
#---month stuff
|
||||
$value = sprintf("%02d",$date[4]);
|
||||
$value = sprintf("%02d",$date[1]);
|
||||
$output =~ s/\%m/$value/g;
|
||||
$output =~ s/\%M/$date[4]/g;
|
||||
$output =~ s/\%M/$date[1]/g;
|
||||
if ($output =~ /\%c/) {
|
||||
%month = _getMonth();
|
||||
$output =~ s/\%c/$month{$date[4]}/g;
|
||||
$output =~ s/\%c/$month{$date[1]}/g;
|
||||
}
|
||||
#---day stuff
|
||||
$value = sprintf("%02d",$date[3]);
|
||||
$value = sprintf("%02d",$date[2]);
|
||||
$output =~ s/\%d/$value/g;
|
||||
$output =~ s/\%D/$date[3]/g;
|
||||
$output =~ s/\%D/$date[2]/g;
|
||||
if ($output =~ /\%w/) {
|
||||
%weekday = _getWeekday();
|
||||
$output =~ s/\%w/$weekday{$date[6]}/g;
|
||||
}
|
||||
#---hour stuff
|
||||
$hour12 = $date[2];
|
||||
$hour12 = $date[3];
|
||||
if ($hour12 > 12) {
|
||||
$hour12 = $hour12 - 12;
|
||||
if ($hour12 == 0) {
|
||||
|
|
@ -121,10 +118,10 @@ sub epochToHuman {
|
|||
$value = sprintf("%02d",$hour12);
|
||||
$output =~ s/\%h/$value/g;
|
||||
$output =~ s/\%H/$hour12/g;
|
||||
$value = sprintf("%02d",$date[2]);
|
||||
$value = sprintf("%02d",$date[3]);
|
||||
$output =~ s/\%j/$value/g;
|
||||
$output =~ s/\%J/$date[2]/g;
|
||||
if ($date[2] > 11) {
|
||||
$output =~ s/\%J/$date[3]/g;
|
||||
if ($date[3] > 11) {
|
||||
$output =~ s/\%p/pm/g;
|
||||
$output =~ s/\%P/PM/g;
|
||||
} else {
|
||||
|
|
@ -132,10 +129,10 @@ sub epochToHuman {
|
|||
$output =~ s/\%P/AM/g;
|
||||
}
|
||||
#---minute stuff
|
||||
$value = sprintf("%02d",$date[1]);
|
||||
$value = sprintf("%02d",$date[4]);
|
||||
$output =~ s/\%n/$value/g;
|
||||
#---second stuff
|
||||
$value = sprintf("%02d",$date[0]);
|
||||
$value = sprintf("%02d",$date[5]);
|
||||
$output =~ s/\%s/$value/g;
|
||||
return $output;
|
||||
}
|
||||
|
|
@ -179,7 +176,7 @@ sub monthStartEnd {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
sub setToEpoch {
|
||||
my @date = localtime(time());
|
||||
my @date = &localtime(time());
|
||||
my ($month, $day, $year) = split(/\//,$_[0]);
|
||||
if (int($year) < 2038 && int($year) > 1900) {
|
||||
$year = int($year);
|
||||
|
|
|
|||
|
|
@ -159,7 +159,7 @@ sub www_editPage {
|
|||
} else {
|
||||
%page = %{$session{page}};
|
||||
}
|
||||
$page{endDate} = (time()+315360000) if ($page{endDate} < 0);
|
||||
$page{endDate} = (addToDate(time(),10)) if ($page{endDate} < 0);
|
||||
$output = helpIcon(1);
|
||||
$output .= '<h1>'.WebGUI::International::get(102).'</h1>';
|
||||
$f->hidden("pageId",$page{pageId});
|
||||
|
|
@ -225,7 +225,7 @@ sub www_editPageSave {
|
|||
$session{form}{urlizedTitle} = $session{form}{menuTitle} if ($session{form}{urlizedTitle} eq "");
|
||||
$session{form}{urlizedTitle} = WebGUI::URL::makeUnique(WebGUI::URL::urlize($session{form}{urlizedTitle}),$session{form}{pageId});
|
||||
$session{form}{startDate} = setToEpoch($session{form}{startDate}) || setToEpoch(time());
|
||||
$session{form}{endDate} = setToEpoch($session{form}{endDate}) || setToEpoch(time()+315360000);
|
||||
$session{form}{endDate} = setToEpoch($session{form}{endDate}) || setToEpoch(addToDate(time(),10));
|
||||
WebGUI::SQL->write("update page set
|
||||
title=".quote($session{form}{title}).",
|
||||
styleId=$session{form}{styleId},
|
||||
|
|
|
|||
|
|
@ -422,7 +422,7 @@ sub www_deleteConfirm {
|
|||
=cut
|
||||
|
||||
sub www_edit {
|
||||
my ($f, $displayTitle, $title, $templatePosition, $endDate);
|
||||
my ($f, $startDate, $displayTitle, $title, $templatePosition, $endDate);
|
||||
if ($_[0]->get("wobjectId") eq "new") {
|
||||
$displayTitle = 1;
|
||||
} else {
|
||||
|
|
@ -430,7 +430,8 @@ sub www_edit {
|
|||
}
|
||||
$title = $_[0]->get("title") || $_[0]->get("namespace");
|
||||
$templatePosition = $_[0]->get("templatePosition") || '0';
|
||||
$endDate = $_[0]->get("endDate") || (time()+315360000);
|
||||
$startDate = $_[0]->get("startDate") || $session{page}{startDate};
|
||||
$endDate = $_[0]->get("endDate") || $session{page}{endDate};
|
||||
$f = WebGUI::HTMLForm->new;
|
||||
$f->hidden("wid",$_[0]->get("wobjectId"));
|
||||
$f->hidden("namespace",$_[0]->get("namespace")) if ($_[0]->get("wobjectId") eq "new");
|
||||
|
|
@ -441,7 +442,7 @@ sub www_edit {
|
|||
$f->yesNo("displayTitle",WebGUI::International::get(174),$displayTitle);
|
||||
$f->yesNo("processMacros",WebGUI::International::get(175),$_[0]->get("processMacros"));
|
||||
$f->select("templatePosition",WebGUI::Template::getPositions($session{page}{templateId}),WebGUI::International::get(363),[$templatePosition]);
|
||||
$f->date("startDate",WebGUI::International::get(497),$_[0]->get("startDate"));
|
||||
$f->date("startDate",WebGUI::International::get(497),$startDate);
|
||||
$f->date("endDate",WebGUI::International::get(498),$endDate);
|
||||
$f->HTMLArea("description",WebGUI::International::get(85),$_[0]->get("description"));
|
||||
$f->raw($_[1]);
|
||||
|
|
@ -463,8 +464,8 @@ sub www_editSave {
|
|||
my ($title, $templatePosition, $startDate, $endDate);
|
||||
$title = $session{form}{title} || $_[0]->get("namespace");
|
||||
$templatePosition = $session{form}{templatePosition} || '0';
|
||||
$startDate = setToEpoch($session{form}{startDate}) || setToEpoch(time());
|
||||
$endDate = setToEpoch($session{form}{endDate}) || setToEpoch(time()+315360000);
|
||||
$startDate = setToEpoch($session{form}{startDate}) || $session{page}{startDate};
|
||||
$endDate = setToEpoch($session{form}{endDate}) || $session{page}{endDate};
|
||||
$session{form}{description} = WebGUI::HTML::cleanSegment($session{form}{description});
|
||||
$_[0]->set({
|
||||
title=>$title,
|
||||
|
|
|
|||
|
|
@ -176,7 +176,7 @@ sub www_edit {
|
|||
$f = WebGUI::HTMLForm->new;
|
||||
%hash = (list => WebGUI::International::get(17,$namespace),
|
||||
calendarMonth => WebGUI::International::get(18,$namespace),
|
||||
calendarMonthSmall => WebGUI::International::get(74,$namespace);
|
||||
calendarMonthSmall => WebGUI::International::get(74,$namespace));
|
||||
$f->select("calendarLayout",\%hash,WebGUI::International::get(16,$namespace),[$_[0]->get("calendarLayout")]);
|
||||
$f->integer("paginateAfter",WebGUI::International::get(19,$namespace),$paginateAfter);
|
||||
$f->yesNo("proceed",WebGUI::International::get(21,$namespace),$proceed);
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ package WebGUI::Wobject::ExtraColumn;
|
|||
|
||||
use strict;
|
||||
use Tie::CPHash;
|
||||
use WebGUI::DateTime;
|
||||
use WebGUI::HTMLForm;
|
||||
use WebGUI::Icon;
|
||||
use WebGUI::International;
|
||||
|
|
@ -63,7 +64,7 @@ sub www_copy {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_edit {
|
||||
my ($output, $f, $endDate, $width, $class, $spacer);
|
||||
my ($output, $f, $endDate, $width, $class, $spacer,$startDate);
|
||||
if (WebGUI::Privilege::canEditPage()) {
|
||||
$output = helpIcon(1,$namespace);
|
||||
$output .= '<h1>'.WebGUI::International::get(6,$namespace).'</h1>';
|
||||
|
|
@ -75,7 +76,8 @@ sub www_edit {
|
|||
$spacer = $_[0]->get("spacer");
|
||||
}
|
||||
$class = $_[0]->get("class") || "content";
|
||||
$endDate = $_[0]->get("endDate") || (time()+315360000);
|
||||
$startDate = $_[0]->get("startDate") || $session{page}{startDate};
|
||||
$endDate = $_[0]->get("endDate") || $session{page}{endDate};
|
||||
$f = WebGUI::HTMLForm->new;
|
||||
$f->hidden("wid",$_[0]->get("wobjectId"));
|
||||
$f->hidden("namespace",$_[0]->get("namespace")) if ($_[0]->get("wobjectId") eq "new");
|
||||
|
|
@ -85,7 +87,7 @@ sub www_edit {
|
|||
$f->hidden("displayTitle",0);
|
||||
$f->hidden("processMacros",0);
|
||||
$f->hidden("templatePosition",0);
|
||||
$f->date("startDate",WebGUI::International::get(497),$_[0]->get("startDate"));
|
||||
$f->date("startDate",WebGUI::International::get(497),$startDate);
|
||||
$f->date("endDate",WebGUI::International::get(498),$endDate);
|
||||
$f->integer("spacer",WebGUI::International::get(3,$namespace),$spacer);
|
||||
$f->integer("width",WebGUI::International::get(4,$namespace),$width);
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ package WebGUI::Wobject::WobjectProxy;
|
|||
|
||||
use strict;
|
||||
use Tie::CPHash;
|
||||
use WebGUI::DateTime;
|
||||
use WebGUI::HTMLForm;
|
||||
use WebGUI::Icon;
|
||||
use WebGUI::International;
|
||||
|
|
@ -61,7 +62,7 @@ sub www_copy {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_edit {
|
||||
my ($output, $f, $endDate, $templatePosition,%wobjects, %page, %wobject, $a, $b);
|
||||
my ($output, $f, $startDate, $endDate, $templatePosition,%wobjects, %page, %wobject, $a, $b);
|
||||
tie %wobject, 'Tie::CPHash';
|
||||
tie %page, 'Tie::CPHash';
|
||||
tie %wobjects, 'Tie::IxHash';
|
||||
|
|
@ -69,7 +70,8 @@ sub www_edit {
|
|||
$output = helpIcon(1,$namespace);
|
||||
$output .= '<h1>'.WebGUI::International::get(2,$namespace).'</h1>';
|
||||
$templatePosition = $_[0]->get("templatePosition") || '0';
|
||||
$endDate = $_[0]->get("endDate") || (time()+315360000);
|
||||
$startDate = $_[0]->get("startDate") || $session{page}{startDate};
|
||||
$endDate = $_[0]->get("endDate") || $session{page}{endDate};
|
||||
$f = WebGUI::HTMLForm->new;
|
||||
$f->hidden("wid",$_[0]->get("wobjectId"));
|
||||
$f->hidden("namespace",$_[0]->get("namespace")) if ($_[0]->get("wobjectId") eq "new");
|
||||
|
|
@ -79,7 +81,7 @@ sub www_edit {
|
|||
$f->hidden("displayTitle",0);
|
||||
$f->hidden("processMacros",0);
|
||||
$f->select("templatePosition",WebGUI::Template::getPositions($session{page}{templateId}),WebGUI::International::get(363),[$templatePosition]);
|
||||
$f->date("startDate",WebGUI::International::get(497),$_[0]->get("startDate"));
|
||||
$f->date("startDate",WebGUI::International::get(497),$startDate);
|
||||
$f->date("endDate",WebGUI::International::get(498),$endDate);
|
||||
$a = WebGUI::SQL->read("select pageId,menuTitle from page where pageId<2 or pageId>25 order by title");
|
||||
while (%page = $a->hash) {
|
||||
|
|
|
|||
|
|
@ -93,6 +93,7 @@ use WebGUI::Wobject ();
|
|||
|
||||
print "[ OK ]";
|
||||
|
||||
|
||||
1;
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue