From 0a004d72a080510ae4727aff4d7afbad7f72c756 Mon Sep 17 00:00:00 2001 From: JT Smith Date: Thu, 18 Jun 2009 22:36:42 +0000 Subject: [PATCH] spew forth more data! --- .../packages-7.7.11/admin_progress_bar.wgpkg | Bin 1849 -> 1258 bytes lib/WebGUI/AssetClipboard.pm | 51 ++----- lib/WebGUI/ProgressBar.pm | 131 ++++++++---------- 3 files changed, 72 insertions(+), 110 deletions(-) diff --git a/docs/upgrades/packages-7.7.11/admin_progress_bar.wgpkg b/docs/upgrades/packages-7.7.11/admin_progress_bar.wgpkg index 192d61b2461b9d4a796c0c8c9ca242f136da0121..e9e20f6402ac4d5cdfe9740e1cae5013abc2090e 100644 GIT binary patch literal 1258 zcmV@Q{y%i&GY^WPaZnEoh7joCqPJ5^7A7V#W_v(J0V>fEgf4Q!^-Rab7>fSYXx8>Jr zPI)tS93hi>$)`uwm$!r35htk_C<;rk@3a@VcT@NQL2N3`0V|Wt^Xwv z`0To#{q1(mLgR~I^obk=i(Mb;4fl2R@A|FP`ul#nU2`Ct&wo8v{Tt8k`cs_n*DDyp zy2P_IK@#5}DNzv5FqNY2^qk-Sc&p_?GL9l#T}nAiF_#4EjoOT|6mSf7!gmX`x8AO6 zeI-bckVp3^;~+iIIy6g?QVioIwf%aUO%ftv99mt9=U0S=Y_5&ERv;FXrGh*(hwmjv z1B}8kio^&7w_r{=)K3V#bz+XEKV8>9AE{m9H40~h9x^Ief}7PpjX;Pud)IYGE>a8% z63jMX4OTc#U_r=5g27iTVX3)q9bJ$-*RInkv@NViJN3Bnb(SB#hojA`=Xi zDDZXN^6-HRbH;BG%)kaO zu0VWX#HFF-c#2e?!$4%vY5SjtRANqbgeZBfED#zs8jZJCc=F+5_-1d}ul456Fc<-+ zR>F5Y7vgv3B$RQ_@znDKrbU&BhFbwk81FfgB*Q94KhTLtS58|#yRS1xrVa@h-CtiM zCEAc3U8A9vFK36$B1iB5%4SYbwb4gZBAPHBV!ovV>`_MXUS48<2f{KD>POJgbzQP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git a/lib/WebGUI/AssetClipboard.pm b/lib/WebGUI/AssetClipboard.pm index 6766920d5..269d525c6 100644 --- a/lib/WebGUI/AssetClipboard.pm +++ b/lib/WebGUI/AssetClipboard.pm @@ -169,7 +169,7 @@ sub getAssetsInClipboard { #------------------------------------------------------------------- -=head2 paste ( assetId ) +=head2 paste ( assetId , [ outputSub ] ) Returns 1 if can paste an asset to a Parent. Sets the Asset to published. Otherwise returns 0. @@ -177,17 +177,23 @@ Returns 1 if can paste an asset to a Parent. Sets the Asset to published. Otherw Alphanumeric ID tag of Asset. +=head3 outputSub + +A reference to a subroutine that output messages should be sent to. + =cut sub paste { my $self = shift; my $assetId = shift; + my $outputSub = shift; my $pastedAsset = WebGUI::Asset->newByDynamicClass($self->session,$assetId); return 0 unless ($self->get("state") eq "published"); return 0 unless ($pastedAsset->canPaste()); ##Allow pasted assets to have a say about pasting. # Don't allow a shortcut to create an endless loop return 0 if ($pastedAsset->get("className") eq "WebGUI::Asset::Shortcut" && $pastedAsset->get("shortcutToAssetId") eq $self->getId); + $outputSub->("pasting ".$pastedAsset->getTitle) if defined $outputSub; if ($self->getId eq $pastedAsset->get("parentId") || $pastedAsset->setParent($self)) { $pastedAsset->publish(['clipboard','clipboard-limbo']); # Paste only clipboard items $pastedAsset->updateHistory("pasted to parent ".$self->getId); @@ -196,6 +202,7 @@ sub paste { my $updateAssets = $pastedAsset->getLineage(['self', 'descendants'], {returnObjects => 1}); foreach (@{$updateAssets}) { + $outputSub->("indexing ".$_->getTitle) if defined $outputSub; $_->indexContent(); } @@ -508,50 +515,16 @@ sub www_pasteList { my $pb = WebGUI::ProgressBar->new($session); ##Need to store the list of assetIds for the status subroutine my @assetIds = $form->param('assetId'); - $session->scratch->set('assetPasteList', JSON::to_json(\@assetIds)); - if ($form->param('proceed') eq 'manageAssets') { - $session->scratch->set('assetPasteReturnUrl', $self->getUrl('op=assetManager')); - } - else { - $session->scratch->set('assetPasteReturnUrl', $self->getUrl); - } ##Need to set the URL that should be displayed when it is done my $i18n = WebGUI::International->new($session, 'Asset'); - $pb->setIcon($session->url->extras('adminConsole/assets.gif')); - return $pb->render({ - title => $i18n->get('Paste Assets'), - statusUrl => $self->getUrl('func=pasteListStatus'), - }); -} - -#------------------------------------------------------------------- - -=head2 www_pasteListStatus ( ) - -Pastes a selection of assets. If canEdit is False, returns an insufficient privileges page. -Returns the user to the manageAssets screen. - -=cut - -sub www_pasteListStatus { - my $self = shift; - my $session = $self->session; - my $pb = WebGUI::ProgressBar->new($session); - if (! $self->canEdit ) { - return $session->privilege->insufficient('no style')."return to site"; - } - my $assetIds = $session->scratch->get('assetPasteList') || '[]'; - $session->scratch->delete('assetPasteList'); - my @assetIds = @{ JSON::from_json($assetIds) }; - my $i18n = WebGUI::International->new($session, 'Asset'); + $pb->start($i18n->get('Paste Assets'), $session->url->extras('adminConsole/assets.gif')); ASSET: foreach my $clipId (@assetIds) { my $pasteAsset = WebGUI::Asset->newPending($session, $clipId); next ASSET unless $pasteAsset && $pasteAsset->canEdit; - $pb->print(sprintf $i18n->get("Pasting %s"), $pasteAsset->getTitle); - $self->paste($clipId); + #$pb->update(sprintf $i18n->get("Pasting %s"), $pasteAsset->getTitle); + $self->paste($clipId, sub {$pb->update(@_);}); } - $pb->redirect( $session->scratch->get('assetPasteReturnUrl') ); - return "redirect"; + return $pb->finish( ($form->param('proceed') eq 'manageAssets') ? $self->getUrl('op=assetManager') : $self->getUrl ); } diff --git a/lib/WebGUI/ProgressBar.pm b/lib/WebGUI/ProgressBar.pm index 16307cbbe..14a35509c 100644 --- a/lib/WebGUI/ProgressBar.pm +++ b/lib/WebGUI/ProgressBar.pm @@ -28,6 +28,11 @@ Render a progress bar for the user inside a nice style. use WebGUI::ProgressBar; + my $pb = WebGUI::ProgressBar->new($session); + $pb->start($title, $iconUrl); + $pb->update($message); + $pb->finish($redirectUrl); + =head1 METHODS These methods are available from this class: @@ -49,6 +54,7 @@ A reference to the current session. sub new { my $class = shift; my $session = shift; + my $recordCount = shift; my $self = {}; $self->{_session} = $session; $self->{_counter} = 1; @@ -58,34 +64,7 @@ sub new { #------------------------------------------------------------------- -=head2 print ( $message ) - -Sends a message and increments the status bar. - -=head3 $message - -A message to be displayed in the status bar. - -=cut - -sub print { - my $self = shift; - my $message = shift; ##JS string escaping? - $self->session->log->preventDebugOutput; - $self->{_counter} += 1; - my $text = sprintf(<{_counter}, $message); - -EOJS - $self->session->output->print($text); - return ''; -} - -#------------------------------------------------------------------- - -=head2 redirect ( $url ) +=head2 finish ( $url ) Redirects the user out of the status page. @@ -95,7 +74,7 @@ The URL to send the user to. =cut -sub redirect { +sub finish { my $self = shift; my $url = shift; my $text = sprintf(< EOJS - $self->session->output->print($text); - return ''; -} - -#------------------------------------------------------------------- - -=head2 render ( $options ) - -Returns a templated progress bar implemented in CSS and JS. - -=head3 options - -A hashref of options to configure the progress bar - -=head3 title - -A title to display above the progress bar. - -=head3 statusUrl - -The URL that the progress bar should use to get status information. - -=cut - -sub render { - my $self = shift; - my $options = shift; - $self->session->http->setCacheControl("none"); - my %var = %{ $options }; - $var{"icon"} = $self->{_icon}; - my $template = WebGUI::Asset::Template->new($self->session, 'YP9WaMPJHvCJl-YwrLVcPw'); - my $output = $template->process(\%var); - return $self->session->style->process($output,"PBtmpl0000000000000137"); + $self->session->output->print($text . $self->{_foot}); + return 'redirect'; } #------------------------------------------------------------------- @@ -153,24 +101,65 @@ sub session { #------------------------------------------------------------------- -=head2 setIcon ( icon ) +=head2 start ( title, icon ) -Sets the _function icon to parameter. +Returns a templated progress bar implemented in CSS and JS. + +=head3 title + +A title to display above the progress bar. =head3 icon -A string representing the location of the icon. +The url to the icon you want to display. =cut -sub setIcon { - my $self = shift; - my $icon = shift; - if ($icon) { - $self->{_icon} = $icon; - } +sub start { + my ($self, $title, $icon) = @_; + $self->session->http->setCacheControl("none"); + my %var = ( + title => $title, + icon => $icon + ); + my $template = WebGUI::Asset::Template->new($self->session, 'YP9WaMPJHvCJl-YwrLVcPw'); + my $output = $self->session->style->process($template->process(\%var).'~~~', "PBtmpl0000000000000137"); + my ($head, $foot) = split '~~~', $output; + $self->session->http->sendHeader; + $self->session->output->print($head); + $self->{_foot} = $foot; + return ''; } +#------------------------------------------------------------------- + +=head2 update ( $message ) + +Sends a message and increments the status bar. + +=head3 $message + +A message to be displayed in the status bar. + +=cut + +sub update { + my $self = shift; + my $message = shift; ##JS string escaping? + $self->session->log->preventDebugOutput; + $self->{_counter} += 1; + my $text = sprintf(<{_counter}, $message); + +EOJS + $self->session->output->print($text); + if ($self->{_counter} > 600) { + $self->{_counter} = 1; + } + return ''; +} 1;