Updated docs for AssetVersioning, WebGUI::DateTime

Added some Help/i18n for Calendar
Fixed some Asset::Event formatting issues
Step one in fixing AssetExportHtml
This commit is contained in:
Doug Bell 2007-02-01 16:36:48 +00:00
parent 687d439c79
commit d6be45a1c0
6 changed files with 1843 additions and 1699 deletions

File diff suppressed because it is too large Load diff

View file

@ -41,15 +41,17 @@ These methods are available from this class:
=head2 checkExportPath ( )
Returns a descriptive error message (HTML) if the export path is not writable, does not exist, or is not specified in the per-domain WebGUI config file.
Returns a descriptive error message (HTML) if the export path is not
writable, does not exist, or is not specified in the per-domain WebGUI
config file.
=cut
sub checkExportPath {
my $self = shift;
my $error;
if(defined $self->session->config->get("exportPath")) {
if(-d $self->session->config->get("exportPath")) {
if (defined $self->session->config->get("exportPath")) {
if (-d $self->session->config->get("exportPath")) {
unless (-w $self->session->config->get("exportPath")) {
$error .= 'Error: The export path '.$self->session->config->get("exportPath").' is not writable.<br />
Make sure that the webserver has permissions to write to that directory';
@ -76,22 +78,22 @@ sub checkExportPath {
# further
sub _exportAsHtml {
my $self = shift;
my $quiet = shift;
my $userId = shift;
my $index = shift;
my $self = shift;
my $quiet = shift;
my $userId = shift;
my $index = shift;
my $extrasUploadsAction = shift;
my $rootUrlAction = shift;
my $startTime = $self->session->datetime->time();
my $rootUrlAction = shift;
my $startTime = $self->session->datetime->time();
my $exportPathError = $self->checkExportPath();
my $exportPathError = $self->checkExportPath();
if ($exportPathError) {
return (0, $exportPathError);
}
my $exportPath = $self->session->config->get('exportPath');
my $defaultAssetId = $self->session->setting->get('defaultPage');
my $defaultAssetPath = undef;
my $exportPath = $self->session->config->get('exportPath');
my $defaultAssetId = $self->session->setting->get('defaultPage');
my $defaultAssetPath = undef;
my $i18n = WebGUI::International->new($self->session, 'Asset');
@ -99,14 +101,15 @@ sub _exportAsHtml {
$tempSession->user({userId=>$userId});
my $newSelf = WebGUI::Asset->new($tempSession, $self->getId, $self->get("className"), $self->get("revisionDate"));
my $assetIds = $newSelf->getLineage(["self","descendants"],{endingLineageLength=>$newSelf->getLineageLength+$self->session->form->process("depth")});
$tempSession->var->end;
$tempSession->close;
# Get a list of the asset IDs we need, reverse sorted by URL
my $assetIds
= $newSelf->getLineage(["self","descendants"],{
endingLineageLength => $newSelf->getLineageLength+$self->session->form->process("depth")
});
# We're going to walk up the URL branch, making the deepest paths first
foreach my $assetId (@{$assetIds}) {
my $assetSession = WebGUI::Session->open($self->session->config->getWebguiRoot, $self->session->config->getFilename);
$assetSession->user({userId => $userId});
my $asset = WebGUI::Asset->newByDynamicClass($assetSession, $assetId);
my $asset = WebGUI::Asset->newByDynamicClass($tempSession, $assetId);
my $url = $asset->get("url");
$self->session->output->print(sprintf($i18n->get('exporting page'), $url)) unless $quiet;
@ -121,8 +124,8 @@ sub _exportAsHtml {
return (0, $error);
}
my $path = $pathData->{'path'};
my $filename = $pathData->{'filename'};
my $path = $pathData->{'path'};
my $filename = $pathData->{'filename'};
my $fullPath = (length($path)? "$path/" : "").$filename;
if ($asset->getId eq $defaultAssetId) {
@ -156,7 +159,12 @@ sub _exportAsHtml {
$self->session->output->print($i18n->get('done')) unless $quiet;
}
if ($extrasUploadsAction eq 'symlink') {
# We're done with the export sessions
$tempSession->var->end;
$tempSession->close;
if ($extrasUploadsAction eq 'symlink') {
my ($extrasPath, $uploadsPath) = ($self->session->config->get('extrasPath'), $self->session->config->get('uploadsPath'));
my ($extrasUrl, $uploadsUrl) = ($self->session->config->get('extrasURL'), $self->session->config->get('uploadsURL'));
s#^/*## for ($extrasUrl, $uploadsUrl);
@ -218,48 +226,33 @@ index filename passed in from the UI
=cut
sub _translateUrlToPath {
my $self = shift;
my $url = shift;
my $index = shift;
my $self = shift;
my $url = shift;
my $index = shift;
my $dataRef;
if ($url !~ m{\.}) { # If there is not a dot in the URL, this is easy
$dataRef->{'path'} = $url;
$dataRef->{'filename'} = $index;
# If there is not a dot in the URL, this is easy
if ($url !~ m{[.]}) {
$dataRef->{'path' } = $url;
$dataRef->{'filename' } = $index;
}
elsif ($url =~ /^(.*)\/(.*)$/) { # If there is a dot and a slash in the url
my $dotCounter = 0; # Track how many dots we found
my $preSlash = $1;
my $postSlash = $2;
# There is a dot
else {
# The last part after a slash is the "name"
my ($path,$name) = $url =~ m{(.*) /? ([^/]+) $}x; # NOTE: Might be more efficient to use index() and substr()
if ($preSlash =~ /\./) { # webgui url index.html/foo becomes folder foo, filename index user specified
$dotCounter++;
$dataRef->{'path'} = $postSlash;
$dataRef->{'filename'} = $index;
}
if ($postSlash =~ /\./) { # webgui url foo/page.html becomes folder foo, filename page.html
$dotCounter++;
$dataRef->{'path'} = $preSlash;
$dataRef->{'filename'} = $postSlash;
}
if ($postSlash eq "") { # webgui url foo.html/ becomes no path, filename foo.html
$dataRef->{'path'} = undef;
$dataRef->{'filename'} = $preSlash;
}
if ($dotCounter == 2) { # webgui url foo.html/page.html becomes an error because this is non-sensical
$self->session->errorHandler->error("Cannot generate path for url $url. Ambiguious.");
$dataRef->{'path'} = undef;
$dataRef->{'filename'} = undef;
$dataRef->{'error'} = "Cannot generate path for url $url. Ambiguious.";
}
}
else { # Dots in the url but no slash
$dataRef->{'path'} = undef;
$dataRef->{'filename'} = $url; # webgui url foo.html becomes no path, filename foo.html
}
# If it ends in a known file type handled by apache, use that
if ($name =~ m{[.](?:html|htm|txt)$}) {
$dataRef->{'path' } = $path;
$dataRef->{'filename' } = $name;
}
else {
# It doesn't end in a known file type
# Make a directory for it
$dataRef->{'path' } = $url;
$dataRef->{'filename' } = $index;
}
}
return $dataRef;
}

View file

@ -31,6 +31,11 @@ This is a mixin package for WebGUI::Asset that contains all versioning related f
use WebGUI::Asset;
my $newAsset = $asset->addRevision(\%properties);
my $newAsset = $asset->addRevision(\%properties, $revisionDate, \%options);
# TODO: Add usage for all methods available from this class
=head1 METHODS
These methods are available from this class:
@ -42,7 +47,11 @@ These methods are available from this class:
=head2 addRevision ( properties [ , revisionDate, options ] )
Adds a revision of an existing asset. Note that programmers should almost never call this method directly, but rather use the update() method instead.
Creates a new revision of an existing asset. Returns the new revision of
the asset.
Note that programmers should almost never call this method directly, but
rather use the update() method instead.
=head3 properties
@ -63,30 +72,46 @@ If this is set to 1 then assets that would normally autocommit their workflow (l
=cut
sub addRevision {
my $self = shift;
my $properties = shift;
my $now = shift ||$self->session->datetime->time();
my $options = shift;
my $autoCommitId = $self->getAutoCommitWorkflowId() unless ($options->{skipAutoCommitWorkflows});
my $workingTag = ($autoCommitId) ? WebGUI::VersionTag->create($self->session, {groupToUse=>'12', workflowId=>$autoCommitId}) : WebGUI::VersionTag->getWorking($self->session);
my $self = shift;
my $properties = shift;
my $now = shift || $self->session->datetime->time();
my $options = shift;
my $autoCommitId = $self->getAutoCommitWorkflowId() unless ($options->{skipAutoCommitWorkflows});
my $workingTag
= ($autoCommitId)
? WebGUI::VersionTag->create($self->session, {groupToUse=>'12', workflowId=>$autoCommitId})
: WebGUI::VersionTag->getWorking($self->session)
;
$self->session->db->beginTransaction;
$self->session->db->write("insert into assetData (assetId, revisionDate, revisedBy, tagId, status, url,
ownerUserId, groupIdEdit, groupIdView) values (?, ?, ?, ?, 'pending', ?, '3','3','7')",
[$self->getId, $now, $self->session->user->userId, $workingTag->getId, $self->getId] );
foreach my $definition (@{$self->definition($self->session)}) {
unless ($definition->{tableName} eq "assetData") {
$self->session->db->write("insert into ".$definition->{tableName}." (assetId,revisionDate) values (?,?)", [$self->getId, $now]);
}
$self->session->db->write(
"insert into assetData "
. "(assetId, revisionDate, revisedBy, tagId, status, url, ownerUserId, groupIdEdit, groupIdView) "
. "values (?, ?, ?, ?, 'pending', ?, '3','3','7')",
[$self->getId, $now, $self->session->user->userId, $workingTag->getId, $self->getId]
);
foreach my $definition (@{$self->definition($self->session)}) {
unless ($definition->{tableName} eq "assetData") {
$self->session->db->write(
"insert into ".$definition->{tableName}." (assetId,revisionDate) values (?,?)",
[$self->getId, $now]
);
}
$self->session->db->commit;
my $newVersion = WebGUI::Asset->new($self->session,$self->getId, $self->get("className"), $now);
$newVersion->updateHistory("created revision");
$newVersion->update($self->get);
$newVersion->setVersionLock;
$properties->{status} = 'pending';
$newVersion->update($properties);
$newVersion->setAutoCommitTag($workingTag) if (defined $autoCommitId);
return $newVersion;
}
$self->session->db->commit;
my $newVersion = WebGUI::Asset->new($self->session,$self->getId, $self->get("className"), $now);
$newVersion->updateHistory("created revision");
$newVersion->update($self->get);
$newVersion->setVersionLock;
$properties->{status} = 'pending';
$newVersion->update($properties);
$newVersion->setAutoCommitTag($workingTag) if (defined $autoCommitId);
return $newVersion;
}

View file

@ -49,17 +49,27 @@ WebGUI::DateTime - DateTime subclass with additional WebGUI methods
my $dt = WebGUI::DateTime->new( year => 2006, month => 11, day => 6 );
my $mysql = $dt->toMysql; # Make a MySQL date/time string
my $mysqlDate = $dt->toMysqlDate; # Make a MySQL date string
my $mysqlTime = $dt->toMysqlTime; # Make a MySQL time string
# Get a string to give to MySQL
my $mysqlDatetime = $dt->toDatabase;
my $mysqlDate = $dt->toDatabaseDate;
my $mysqlTime = $dt->toDatabaseTime
# Get a string for WebGUI::Form elements
my $userDatetime = $dt->toUserTimeZone;
my $userDate = $dt->toUserTimeZoneDate;
my $userTime = $dt->toUserTimeZoneTime;
# Get strings to be used for iCalendar feeds
my $ical = $dt->toIcal;
my $icalDate = $dt->toIcalDate;
my $icalTime = $dt->toIcalTime;
my $ical = $dt->toIcal; # Make an iCal date/time string
my $icalDate = $dt->toIcalDate; # Make an iCal date string
my $icalTime = $dt->toIcalTime; # Make an iCal time string
my $webguiDate = $dt->webguiDate($webguiFormat) #return the date based on WebGUI's date format string
# Get a string based on the user's preferred date/time format in the user's
# time zone.
my $webguiDate = $dt->webguiDate;
# Get a string based on a passed WebGUI date/time format
my $webguiDate = $dt->webguiDate($webguiFormat);
### See perldoc DateTime for additional methods ###
@ -209,13 +219,17 @@ sub cloneToUserTimeZone {
Handle copying all WebGUI::DateTime specific data. This is a class method.
This method overrides the from_object in DateTime to keep WebGUI::DateTime
specific information being passed between object instances. Most DateTime
math actually creates new objects.
=cut
sub from_object {
my $class = shift;
my %args = @_;
my $class = shift;
my %args = @_;
my $session = $args{object}->session;
my $copy = $class->SUPER::from_object(@_);
my $copy = $class->SUPER::from_object(@_);
$copy->session($session);
return $copy;
}
@ -239,7 +253,7 @@ sub toDatabase {
=head2 toDatabaseDate
Returns a MySQL Date string. Any time data stored by this object will be
ignored. Is not adjusted for time zone.
ignored. Is adjusted to the UTC time zone.
=cut

View file

@ -1,5 +1,108 @@
package WebGUI::Help::Asset_Calendar;
our $HELP = {};
#### Edit Calendar Page
$editPage = $HELP->{'calendar add/edit'} = {};
$editPage->{ title } = 'help add/edit title';
$editPage->{ body } = 'help add/edit body';
push @{$editPage->{ isa }}, {
tag => 'asset fields',
namespace => 'Asset',
},
;
push @{$editPage->{ fields }},
{
title => "defaultView label",
description => "defaultView description",
namespace => "Asset_Calendar",
},
{
title => "defaultDate label",
description => "defaultDate description",
namespace => "Asset_Calendar",
},
{
title => "groupIdEventEdit label",
description => "groupIdEventEdit description",
namespace => "Asset_Calendar",
},
{
title => "templateIdMonth label",
description => "templateIdMonth description",
namespace => "Asset_Calendar",
},
{
title => "templateIdWeek label",
description => "templateIdWeek description",
namespace => "Asset_Calendar",
},
{
title => "templateIdDay label",
description => "templateIdDay description",
namespace => "Asset_Calendar",
},
{
title => "templateIdEvent label",
description => "templateIdEvent description",
namespace => "Asset_Calendar",
},
{
title => "templateIdEventEdit label",
description => "templateIdEventEdit description",
namespace => "Asset_Calendar",
},
{
title => "templateIdSearch label",
description => "templateIdSearch description",
namespace => "Asset_Calendar",
},
{
title => "templateIdPrintMonth label",
description => "templateIdPrintMonth description",
namespace => "Asset_Calendar",
},
{
title => "templateIdPrintWeek label",
description => "templateIdPrintWeek description",
namespace => "Asset_Calendar",
},
{
title => "templateIdPrintDay label",
description => "templateIdPrintDay description",
namespace => "Asset_Calendar",
},
{
title => "templateIdPrintEvent label",
description => "templateIdPrintEvent description",
namespace => "Asset_Calendar",
},
;
push @{$editPage->{ related }},
"",
"",
;
#### View Calendar Page
#### Search Calendar Page
#### ICal Calendar Page
#### View Month Template
#### View Week Template
#### View Day Template
#### Search Template
our $HELP = {
'calendar add/edit' => {
title => 'add/edit title',

View file

@ -276,13 +276,10 @@ our $I18N = {
context => q{Description of what the Calendar Update Feeds workflow activity does},
},
#################### ASSET NAME ####################
'assetName' => {
message => q{Calendar},
lastUpdated => 1131394072,
},
'add/edit title' => {
#################### HELP PAGES ####################
'add/edit title' => {
message => q|Calendar, Add/Edit|,
lastUpdated => 1165878391,
},
@ -292,6 +289,13 @@ our $I18N = {
lastUpdated => 1165878391,
},
#################### ASSET NAME ####################
'assetName' => {
message => q{Calendar},
lastUpdated => 1131394072,
},
};
1;