diff --git a/lib/WebGUI/FilePump/Admin.pm b/lib/WebGUI/FilePump/Admin.pm index 43a1434e8..0d3dce743 100644 --- a/lib/WebGUI/FilePump/Admin.pm +++ b/lib/WebGUI/FilePump/Admin.pm @@ -115,6 +115,29 @@ sub www_deleteBundle { #------------------------------------------------------------------ +=head2 www_deleteFile ( session ) + +Deletes a file from it's bundle. The kind of file is set by the form variable filetype, +the id of the bundle is bundleId, and the id of the file to move is fileId. + +=head3 session + +A reference to the current session. + +=cut + +sub www_deleteFile { + my $session = shift; + return $session->privilege->insufficient() unless canView($session); + my $form = $session->form; + my $bundle = WebGUI::FilePump::Bundle->new($session, $form->get("bundleId")); + return www_editBundle($session) unless $bundle; + $bundle->deleteFile($form->get('fileType'), $form->get('fileId')); + return www_editBundle($session); +} + +#------------------------------------------------------------------ + =head2 www_demoteFile ( session ) Moves a bundle file down one position. The kind of file is set by the form variable filetype, @@ -137,6 +160,68 @@ sub www_demoteFile { #------------------------------------------------------------------ +=head2 www_editBundle ( session ) + +Interface for managing URIs in a bundle, given by the form param bundleId. Add, delete, +promote and demote are supported for all three file types. + +=head3 session + +A reference to the current session. + +=cut + +sub www_editBundle { + my ($session, $error) = @_; + return $session->privilege->insufficient() unless canView($session); + my $bundle = WebGUI::FilePump::Bundle->new($session, $session->form->get("bundleId")); + my $i18n = WebGUI::International->new($session, 'FilePump'); + if (!defined $bundle) { + return www_addBundle($session); + } + my $tableStub = <%s + + +%s +
 URI%s
+

%s

+EOTABLE + my $output = ''; + my $bundleId = $bundle->getId; + my $dt = $session->datetime; + my $lastModifiedi18n = $i18n->get('last modified'); + foreach my $fileType (qw/jsFiles cssFiles/) { + my $type = $fileType eq 'jsFiles' ? 'JS' + : $fileType eq 'cssFiles' ? 'CSS' + : 'OTHER'; + my $rows = ''; + my $form = ''; + my $files = $bundle->get($fileType); + foreach my $file (@{ $files }) { + my $urlFrag = 'bundleId='.$bundleId.'fileType='.$type.'fileId='.$file->{fileId}; + $rows .= sprintf '%s%s%s', + $session->icon->delete( 'op=filePump;func=deleteFile;' . $urlFrag). + $session->icon->moveUp( 'op=filePump;func=promoteFile;' . $urlFrag). + $session->icon->moveDown( 'op=filePump;func=demoteFile;' . $urlFrag) , + $file->{uri}, + $dt->epochToHuman($file->{lastModified}) + ; + } + $output .= sprintf $tableStub, $i18n->get($fileType), $lastModifiedi18n, $rows, $form; + $output .= WebGUI::Form::text($session, { + name => 'uri', + }); + } + + my $ac = WebGUI::AdminConsole->new($session,'filePump'); + $ac->addSubmenuItem($session->url->page('op=filePump;'), $i18n->get('list bundles')); + $ac->addSubmenuItem($session->url->page('op=filePump;func=addBundle'), $i18n->get('add a bundle')); + return $ac->render($error.$output, 'File Pump'); +} + +#------------------------------------------------------------------ + =head2 www_promoteFile ( session ) Moves a bundle file up one position. The kind of file is set by the form variable filetype, @@ -175,16 +260,21 @@ sub www_manage { my $i18n = WebGUI::International->new($session, 'FilePump'); my $error = shift; my $rows = ''; + my $dt = $session->datetime; + my $url = $session->url; my $getABundle = WebGUI::FilePump::Bundle->getAllIterator($session,{ orderBy => 'bundleName' } ); while (my $bundle = $getABundle->()) { - $rows .= sprintf '%s%s', + $rows .= sprintf '%s%s%s%s', $session->icon->delete('op=filePump;func=deleteBundle;bundleId='.$bundle->getId), - $bundle->get('bundleName') + $url->gateway($url->getRequestedUrl,'op=filePump;func=editBundle;bundleId='.$bundle->getId), + $bundle->get('bundleName'), + $dt->epochToHuman($bundle->get('lastModified')), + $dt->epochToHuman($bundle->get('lastBuild')), ; } - my $output = sprintf <get('bundle name'), $rows; + my $output = sprintf <get('bundle name'), $i18n->get('last modified'), $i18n->get('last build'), $rows; - + %s
 %s
 %s%s%s
EOHTML diff --git a/lib/WebGUI/i18n/English/FilePump.pm b/lib/WebGUI/i18n/English/FilePump.pm index 067a87ef4..9cbf780ac 100644 --- a/lib/WebGUI/i18n/English/FilePump.pm +++ b/lib/WebGUI/i18n/English/FilePump.pm @@ -3,12 +3,25 @@ package WebGUI::i18n::English::FilePump; use strict; our $I18N = { + 'bundle name' => { message => q|Bundle name|, lastUpdated => 1131394070, context => q|Label for the name of a bundle (group, clump) of files.| }, + 'last build' => { + message => q|Last Build|, + lastUpdated => 1242493652, + context => q|The time the bundle was built last| + }, + + 'last modified' => { + message => q|Last Modified|, + lastUpdated => 1242493669, + context => q|The time the bundle was last modified.| + }, + 'bundle name help' => { message => q|A unique, human readable name for this bundle. Bundle names must be unique.|, lastUpdated => 1131394072, @@ -39,6 +52,24 @@ our $I18N = { context => q|Admin console label. Bundle is a loose set of similar, but not identical objects. Similar to pile.| }, + 'list bundles' => { + message => q|List Bundles|, + lastUpdated => 1242495011, + context => q|Admin console label. Bundle is a loose set of similar, but not identical objects. Similar to pile.| + }, + + 'jsFiles' => { + message => q|JavaScript|, + lastUpdated => 1242495011, + context => q|Edit bundle label.| + }, + + 'cssFiles' => { + message => q|CSS|, + lastUpdated => 1242495011, + context => q|Edit bundle label.| + }, + }; 1;