diff --git a/docs/upgrades/upgrade_6.2.9-6.3.0.pl b/docs/upgrades/upgrade_6.2.9-6.3.0.pl index 48384720e..294622671 100644 --- a/docs/upgrades/upgrade_6.2.9-6.3.0.pl +++ b/docs/upgrades/upgrade_6.2.9-6.3.0.pl @@ -583,6 +583,7 @@ $sth->finish; print "\tDeleting files which are no longer used.\n" unless ($quiet); +#unlink("../../lib/WebGUI/Export.pm"); #unlink("../../lib/WebGUI/MetaData.pm"); #unlink("../../lib/WebGUI/Operation/MetaData.pm"); #unlink("../../lib/WebGUI/i18n/English/MetaData.pm"); diff --git a/docs/upgrades/upgrade_6.2.9-6.3.0.sql b/docs/upgrades/upgrade_6.2.9-6.3.0.sql index bd78860b6..a1703b3ee 100644 --- a/docs/upgrades/upgrade_6.2.9-6.3.0.sql +++ b/docs/upgrades/upgrade_6.2.9-6.3.0.sql @@ -2,13 +2,10 @@ insert into webguiVersion values ('6.3.0','upgrade',unix_timestamp()); delete from template where templateId='tinymce' and namespace='richEditor'; INSERT INTO template VALUES ('tinymce','TinyMCE','^JavaScript(\"/tinymce/jscripts/tiny_mce/tiny_mce.js\");\r\n\r\n\r\n','richEditor',1,1); -delete from template where templateId='1' and namespace='richEditor/pagetree'; -INSERT INTO template VALUES ('1','Rich Editor Page Tree','\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n
\r\nInsert/Edit Link\r\n\r\n
\r\n Link Settings\r\n
\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n
Link URL:
Link Target:\r\n
 
\r\n
\r\n \r\n\r\n
\r\n
\r\n\r\n\r\n
\r\n Available Page Tree\r\n\r\n\r\n \')\">
\r\n
\r\n\r\n
\r\n \r\n
\r\n\r\n','richEditor/pagetree',1,1); UPDATE template set template = '\r\n \r\n \r\n <tmpl_var session.page.title> - <tmpl_var session.setting.companyName>\r\n \r\n \r\n\r\n \r\n \r\n\r\n\r\n\r\n\r\n\r\n\r\n \r\n \r\n\r\n \r\n ' where templateId = '10' and namespace='style'; delete from userProfileField where fieldName='richEditor'; INSERT INTO userProfileField VALUES ('richEditor','WebGUI::International::get(496)',1,0,'selectList','{\'PBtmpl0000000000000126\'=>WebGUI::International::get(880),\r\nnone=>WebGUI::International::get(881),\r\n\'PBtmpl0000000000000138\'=>WebGUI::International::get(\"tinymce\")\n}','[\'PBtmpl0000000000000138\']',11,'4',0,1); update userProfileData set fieldData='PBtmpl0000000000000138' where fieldName='richEditor'; -UPDATE template set template = '\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n
\r\nInsert/Edit Link\r\n\r\n
\r\n Link Settings\r\n
\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n
Link URL:
Link Target:\r\n
 
\r\n
\r\n \r\n\r\n
\r\n
\r\n\r\n\r\n
\r\n Available Page Tree\r\n
\r\n\r\n \')\">
\r\n
\r\n
\r\n
\r\n \r\n
\r\n\r\n' where namespace='richEditor/pagetree' && templateId = '1'; INSERT INTO template VALUES ('adminConsole','Admin Console','\r\n\r\n\r\n WebGUI <tmpl_var session.webgui.version>-<tmpl_var session.webgui.status> Admin Console\r\n \r\n\r\n\r\n\r\n\r\n\r\n','style',1,0); delete from settings where name='adminStyleId'; @@ -224,4 +221,3 @@ INSERT INTO template VALUES ('15','File Folder','\"> alter table HttpProxy add column cookieJarStorageId varchar(22); - diff --git a/lib/WebGUI/Asset.pm b/lib/WebGUI/Asset.pm index 596abb5bb..0fbc2c4c3 100644 --- a/lib/WebGUI/Asset.pm +++ b/lib/WebGUI/Asset.pm @@ -23,6 +23,7 @@ use WebGUI::ErrorHandler; use WebGUI::Form; use WebGUI::FormProcessor; use WebGUI::Grouping; +use WebGUI::HTMLForm; use WebGUI::HTTP; use WebGUI::Icon; use WebGUI::Id; @@ -251,6 +252,29 @@ sub cascadeLineage { where lineage like ".quote($oldLineage.'%')); } + + +#------------------------------------------------------------------- +sub checkExportPath { + my $error; + if(defined $session{config}{exportPath}) { + if(-d $session{config}{exportPath}) { + unless (-w $session{config}{exportPath}) { + $error .= 'Error: The export path '.$session{config}{exportPath}.' is not writable.
+ Make sure that the webserver has permissions to write to that directory'; + } + } else { + $error .= 'Error: The export path '.$session{config}{exportPath}.' does not exists.'; + } + } else { + $error.= 'Error: The export path is not configured. Please set the exportPath variable in the WebGUI config file'; + } + $error = '

'.$error.'

' if $error; + return $error; +} + + + #------------------------------------------------------------------- =head2 cut ( ) @@ -451,6 +475,91 @@ sub duplicateTree { return $newAsset; } +#------------------------------------------------------------------- + +=head2 exportAsHtml ( hashref ) + +Executes the export and returns html content. + +=head3 hashref + +A hashref containing one of the following properties: + +=head4 extrasUrl + +The URL where the page will be able to find the WebGUI extras folder. Defaults to the extrasURL in the config file. + +=head4 stripHtml + +A boolean indicating whether the resulting output should be stripped of HTML tags. + +=head4 uploadsUrl + +The URL where the page will be able to find the files uploaded to WebGUI. Defaults to the uploadsURL in the config file. + +=head4 userId + +The unique id of the user to become when exporting this page. Defaults to '1' (Visitor). + +=cut + +sub exportAsHtml { + my $self = shift; + my $params = shift; + my $uploadsUrl = $params->{uploadsUrl} || $session{config}{uploadsUrl}; + my $extrasUrl = $params->{extrasUrl} || $session{config}{extrasUrl}; + my $userId = $params->{userId} || 1; + my $stripHtml = $params->{stripHtml} || undef; + + # Save current session information because we need to restore current session after the export has finished. + my %oldSession = %session; + + # Change the stuff we need to change to do the export + WebGUI::Session::refreshUserInfo($userId) unless ($userId == $session{user}{userId}); + delete $session{form}; + $session{var}{adminOn} = $self->get('adminOn'); + WebGUI::Session::refreshPageInfo($self->get('pageId')); + $self->{_properties}{cacheTimeout} = $self->{_properties}{cacheTimeoutVisitor} = 1; + $session{config}{uploadsURL} = $uploadsUrl; + $session{config}{extrasURL} = $extrasUrl; + + # Generate the page + my $content = $self->www_view; + if($stripHtml) { + $content = WebGUI::HTML::html2text($content); + } + + # Restore session + %session = %oldSession; + delete $session{page}{noHttpHeader}; + return $content; +} + + +#------------------------------------------------------------------- + +=head2 new ( [ options ] ) + +Constructor. + +Options can be set when a new Export object is constructed, or +afterwards with the set method. None of the options is required. + +=head3 pageId + +Sets the page to be generated. Defaults to current page. + +=head3 styleId + +Use this to override the default styleId. +Defaults to the page styleId. + +=head3 userId + +Runs the export as this user. Defaults to 1 (Visitor). + + + #------------------------------------------------------------------- =head2 fixUrl ( string ) @@ -2496,6 +2605,144 @@ sub www_emptyTrash { return $self->www_manageTrash(); } +#------------------------------------------------------------------- + +=head2 www_export + +Displays the export page administrative interface + +=cut + +sub www_export { + my $self = shift; + return $self->getAdminConsole->render(WebGUI::Privilege::insufficient()) unless (WebGUI::Grouping::isInGroup(13)); + $self->getAdminConsole->setHelp("page export"); + my $f = WebGUI::HTMLForm->new(-action=>$self->getUrl); + $f->hidden("func","exportStatus"); + $f->integer( + -label=>WebGUI::International::get('Depth'), + -name=>"depth", + -value=>99, + ); + $f->selectList( + -label=>WebGUI::International::get('Export as user'), + -name=>"userId", + -options=>WebGUI::SQL->buildHashRef("select userId, username from users"), + -value=>[1], + ); + $f->text( + -label=>"Directory Index", + -name=>"index", + -value=>"index.html" + ); + $f->text( + -label=>WebGUI::International::get('Extras URL'), + -name=>"extrasURL", + -value=>$session{config}{extrasURL} + ); + $f->text( + -label=>WebGUI::International::get('Uploads URL'), + -name=>"uploadsURL", + -value=>$session{config}{uploadsURL} + ); + $f->submit; + $self->getAdminConsole->render($self->checkExportPath.$f->print,WebGUI::International::get('Export Page')); +} + + +#------------------------------------------------------------------- + +=head2 www_exportStatus + +Displays the export status page + +=cut + +sub www_exportStatus { + my $self = shift; + return $self->getAdminConsole->render(WebGUI::Privilege::insufficient()) unless (WebGUI::Grouping::isInGroup(13)); + my $iframeUrl = $self->getUrl('func=exportGenerate'); + $iframeUrl = WebGUI::URL::append($iframeUrl, 'index='.$session{form}{index}); + $iframeUrl = WebGUI::URL::append($iframeUrl, 'depth='.$session{form}{depth}); + $iframeUrl = WebGUI::URL::append($iframeUrl, 'userId='.$session{form}{userId}); + $iframeUrl = WebGUI::URL::append($iframeUrl, 'extrasURL='.$session{form}{extrasURL}); + $iframeUrl = WebGUI::URL::append($iframeUrl, 'uploadsURL='.$session{form}{uploadsURL}); + my $output = ''; + $self->getAdminConsole->render($output,WebGUI::International::get('Page Export Status')); +} + +#------------------------------------------------------------------- + +=head2 www_exportPageGenerate + +Executes the export process and displays real time status. This operation is displayed by exportPageStatus in an IFRAME. + +=cut + +sub www_exportGenerate { + my $self = shift; + return $self->getAdminConsole->render(WebGUI::Privilege::insufficient()) unless (WebGUI::Grouping::isInGroup(13)); + # This routine is called in an IFRAME and prints status output directly to the browser. + $|++; # Unbuffered data output + $session{page}{empty} = 1; # Write directly to the browser + print WebGUI::HTTP::getHeader(); + my $startTime = time(); + my $error = $self->checkExportPath(); + if ($error) { + print $error; + return; + } + my $userId = $session{form}{userId}; + my $extrasURL = $session{form}{extrasURL}; + my $uploadsURL = $session{form}{uploadsURL}; + my $index = $session{form}{index}; + my $assets = $self->getLineage(["self","descendants"],{returnObjects=>1,endingLineageLength=>$self->getLineageLength+$session{form}{depth}}); + foreach my $asset (@{$assets}) { + my $url = $asset->get("url"); + print "Exporting page ".$url."......"; + unless ($asset->canView($userId)) { + print "User has no privileges to view.
\n"; + next; + } + my $path; + my $filename; + if ($url =~ /\./) { + $url =~ /^(.*)\/(.*)$/; + $path = $1; + $filename = $2; + if ($filename eq "") { + $filename = $path; + $path = undef; + } + } else { + $path = $url; + $filename = $index; + } + if($path) { + $path = $session{config}{exportPath} . $session{os}{slash} . $path; + eval { mkpath($path) }; + if($@) { + print "Couldn't create $path because $@
\n"; + print "This most likely means that you have a page with the same name as folder that you're trying to create.
\n"; + return; + } + } + $path .= $session{os}{slash}.$filename; + eval { open(FILE, "> $path") or die "$!" }; + if ($@) { + print "Couldn't open $path because $@
\n"; + return; + } else { + print FILE $self->exportAsHtml({userId=>$userId,extrasUrl=>$extrasURL,uploadsUrl=>$uploadsURL}); + close(FILE); + } + print "DONE
"; + } + print "

Exported ".scalar(@{$assets})." pages in ".(time()-$startTime)." seconds.

"; + print '
'.WebGUI::International::get(493).''; + return; +} + #------------------------------------------------------------------- @@ -2678,6 +2925,7 @@ sub www_promote { return ""; } + #------------------------------------------------------------------- =head2 www_setParent ( ) diff --git a/lib/WebGUI/Operation.pm b/lib/WebGUI/Operation.pm index d59b1075b..cd2b25a19 100644 --- a/lib/WebGUI/Operation.pm +++ b/lib/WebGUI/Operation.pm @@ -95,6 +95,8 @@ sub getOperations { 'editDatabaseLink' => 'WebGUI::Operation::DatabaseLink', 'editDatabaseLinkSave' => 'WebGUI::Operation::DatabaseLink', 'listDatabaseLinks' => 'WebGUI::Operation::DatabaseLink', + 'richEditPageTree' => 'WebGUI::Operation::RichEdit', + 'richEditImage' => 'WebGUI::Operation::RichEdit', 'manageUsersInGroup' => 'WebGUI::Operation::Group', 'deleteGroup' => 'WebGUI::Operation::Group', 'deleteGroupConfirm' => 'WebGUI::Operation::Group', diff --git a/lib/WebGUI/i18n/English/WebGUI.pm b/lib/WebGUI/i18n/English/WebGUI.pm index cfdb2ca1a..587af5e98 100644 --- a/lib/WebGUI/i18n/English/WebGUI.pm +++ b/lib/WebGUI/i18n/English/WebGUI.pm @@ -5979,11 +5979,6 @@ A randomly generated number. This is often used on images (such as banner ads) t lastUpdated => 1089039511, context => q|Field label for the Export Page operation| }, - 'Alternate style' => { - message => q|Alternate style|, - lastUpdated => 1089039511, - context => q|Field label for the Export Page operation| - }, 'Page Export Status' => { message => q|Page Export Status|, lastUpdated => 1089039511, diff --git a/sbin/generateContent.pl b/sbin/generateContent.pl index ddaab3667..bd9bc180e 100644 --- a/sbin/generateContent.pl +++ b/sbin/generateContent.pl @@ -23,7 +23,6 @@ use Getopt::Long; use strict qw(subs vars); use WebGUI; use WebGUI::Session; -use WebGUI::Export; $|=1; @@ -35,7 +34,6 @@ GetOptions( 'configFile:s'=>\$configFile, 'pageId:i'=>\$pageId, 'userId:i'=>\$userId, - 'styleId:i'=>\$styleId, 'toFile:s'=>\$toFile, 'stripHTML'=>\$stripHTML, 'help'=>\$help, diff --git a/www/extras/tinymce/jscripts/tiny_mce/plugins/pagetree/editor_plugin.js b/www/extras/tinymce/jscripts/tiny_mce/plugins/pagetree/editor_plugin.js index 4353dfdee..4e43c7062 100755 --- a/www/extras/tinymce/jscripts/tiny_mce/plugins/pagetree/editor_plugin.js +++ b/www/extras/tinymce/jscripts/tiny_mce/plugins/pagetree/editor_plugin.js @@ -21,11 +21,11 @@ function TinyMCE_pagetree_execCommand(editor_id, element, command, user_interfac case "wgPageTree": var template = new Array(); - alert(getWebguiProperty("pageURL")); + //alert(getWebguiProperty("pageURL")); - template['file'] = "../../../../../.." + getWebguiProperty ("pageURL") + '?op=richEditPageTree'; // Relative to theme + template['file'] = "../../../../../.." + getWebguiProperty ("pageURL") + '?op=richEditPageTree'; - alert(template['file']); + // alert(template['file']); template['width'] = 500; template['height'] = 500;