added export and rich edit page tree picker, and started on image picker

This commit is contained in:
JT Smith 2005-01-10 03:52:08 +00:00
parent a096a753ba
commit 28b6653e2a
7 changed files with 254 additions and 14 deletions

View file

@ -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");

View file

@ -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(\"<tmpl_var session.config.extrasURL>/tinymce/jscripts/tiny_mce/tiny_mce.js\");\r\n<script language=\"javascript\" type=\"text/javascript\">\r\n tinyMCE.init({\r\n theme : \"advanced\",\r\n mode : \"specific_textareas\",\r\n plugins : \"collateral,emotions,insertImage,iespell,pagetree\",\r\n theme_advanced_buttons2_add : \"insertImage,pagetree,collateral\", \r\n theme_advanced_buttons3_add : \"emotions,iespell\" \r\n });\r\n</script>\r\n\r\n<tmpl_var textarea>','richEditor',1,1);
delete from template where templateId='1' and namespace='richEditor/pagetree';
INSERT INTO template VALUES ('1','Rich Editor Page Tree','<html>\r\n\r\n<script language=\"javascript\" src=\"<tmpl_var session.config.extrasURL>/tinymce/jscripts/tiny_mce/tiny_mce_popup.js\"></script>\r\n\r\n<script language=\"javascript\">\r\n\r\nfunction setLink(page) {\r\n document.getElementById(\"url\").value=\"^\" + \"/\" + \";\" + page;\r\n}\r\n\r\nfunction createLink() {\r\n if (window.opener) { \r\n if (document.getElementById(\"url\").value == \"\") {\r\n alert(\"You must enter a link url\");\r\n document.getElementById(\"url\").focus();\r\n }\r\n\r\ntinyMCE.insertLink(document.getElementById(\"url\").value,document.getElementById(\"target\").value);\r\n window.close();\r\n }\r\n}\r\n\r\n</script>\r\n\r\n<body>\r\n\r\n<fieldset>\r\n<legend>Insert/Edit Link</legend>\r\n\r\n <fieldset>\r\n <legend>Link Settings</legend>\r\n <form name=\"linkchooser\">\r\n <table border=\"0\">\r\n <tr>\r\n <td>Link URL:</td>\r\n <td><input id=\"url\" name=\"url\" type=\"text value=\"\" style=\"width: 200px\"></td>\r\n </tr>\r\n <tr>\r\n <td>Link Target:</td>\r\n <td><select id=\"target\" name=\"target\" style=\"width: 200px\">\r\n <option value=\"_self\">Open link in same window</option>\r\n <option value=\"_blank\">Open link in new window</option>\r\n </select>\r\n </td>\r\n </tr>\r\n <tr><td colspan=\"2\">&nbsp;</td></tr>\r\n <tr>\r\n <td colspan=\"2\" align=\"right\"><input type=\"button\" value=\"Cancel\" onClick=\"window.close()\"><input type=\"button\" value=\"Create Link\" onClick=\"createLink()\"></td>\r\n </tr>\r\n </table>\r\n </form>\r\n \r\n\r\n </fieldset> \r\n<br>\r\n\r\n\r\n <fieldset>\r\n <legend>Available Page Tree</legend>\r\n\r\n<tmpl_loop page_loop>\r\n <tmpl_var indent><a href=\"#\" onClick=\"setLink(\'<tmpl_var url>\')\"><tmpl_var title></a><br />\r\n</tmpl_loop>\r\n\r\n </fieldset>\r\n \r\n</fieldset>\r\n</body>\r\n</html>','richEditor/pagetree',1,1);
UPDATE template set template = '<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\r\n <html>\r\n <head>\r\n <title><tmpl_var session.page.title> - <tmpl_var session.setting.companyName></title>\r\n <tmpl_var head.tags>\r\n <style type=\"text/css\">\r\nTD { font: 8pt \'MS Shell Dlg\', Helvetica, sans-serif; }\r\nTD.delete { font: italic 7pt \'MS Shell Dlg\', Helvetica, sans-serif; }\r\nTD.label { font: 8pt \'MS Shell Dlg\', Helvetica, sans-serif; background-color: #c0c0c0; }\r\nTD.none { font: italic 12pt \'MS Shell Dlg\', Helvetica, sans-serif; }\r\n\r\n</style>\r\n\r\n </head>\r\n <script language=\"javascript\">\r\n</script>\r\n<script language=\"javascript\">\r\n\r\nfunction actionComplete(action, path, error, info) {\r\n\r\n if (window.parent && window.parent.resetForm) {\r\n window.parent.resetForm();\r\n }\r\n\r\n}\r\n</script>\r\n\r\n<script language=\"javascript\">\r\nfunction deleteCollateral(options) {\r\n var lister = window.parent.document.getElementById(\"lister\");\r\n\r\n if(lister && confirm(\"Are you sure you want to delete this item ?\"))\r\n lister.src=\'^/;?op=htmlAreaDelete&\' + options;\r\n}\r\n</script>\r\n</head>\r\n<body leftmargin=\"0\" topmargin=\"0\" marginwidth=\"0\" marginheight=\"0\">\r\n\r\n <tmpl_var body.content>\r\n \r\n</body>\r\n </html>\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 = '<html>\r\n\r\n<script language=\"javascript\" src=\"<tmpl_var session.config.extrasURL>/tinymce/jscripts/tiny_mce/tiny_mce_popup.js\"></script>\r\n\r\n<script language=\"javascript\">\r\n\r\nfunction setLink(page) {\r\n document.getElementById(\"url\").value=\"^/;\" + page;\r\n}\r\n\r\nfunction createLink() {\r\n if (window.opener) { \r\n if (document.getElementById(\"url\").value == \"\") {\r\n alert(\"You must enter a link url\");\r\n document.getElementById(\"url\").focus();\r\n }\r\n\r\ntinyMCE.insertLink(document.getElementById(\"url\").value,document.getElementById(\"target\").value);\r\n window.close();\r\n }\r\n}\r\n\r\n</script>\r\n\r\n<body>\r\n\r\n<fieldset>\r\n<legend>Insert/Edit Link</legend>\r\n\r\n <fieldset>\r\n <legend>Link Settings</legend>\r\n <form name=\"linkchooser\">\r\n <table border=\"0\">\r\n <tr>\r\n <td>Link URL:</td>\r\n <td><input id=\"url\" name=\"url\" type=\"text value=\"\" style=\"width: 200px\"></td>\r\n </tr>\r\n <tr>\r\n <td>Link Target:</td>\r\n <td><select id=\"target\" name=\"target\" style=\"width: 200px\">\r\n <option value=\"_self\">Open link in same window</option>\r\n <option value=\"_blank\">Open link in new window</option>\r\n </select>\r\n </td>\r\n </tr>\r\n <tr><td colspan=\"2\">&nbsp;</td></tr>\r\n <tr>\r\n <td colspan=\"2\" align=\"right\"><input type=\"button\" value=\"Cancel\" onClick=\"window.close()\"><input type=\"button\" value=\"Create Link\" onClick=\"createLink()\"></td>\r\n </tr>\r\n </table>\r\n </form>\r\n \r\n\r\n </fieldset> \r\n<br>\r\n\r\n\r\n <fieldset>\r\n <legend>Available Page Tree</legend>\r\n<div id=\"pagetree\" style=\"overflow: auto; height: 280; width: 441\">\r\n<tmpl_loop page_loop>\r\n <tmpl_var indent><a href=\"#\" onClick=\"setLink(\'<tmpl_var url>\')\"><tmpl_var title></a><br />\r\n</tmpl_loop>\r\n</div>\r\n </fieldset>\r\n \r\n</fieldset>\r\n</body>\r\n</html>' where namespace='richEditor/pagetree' && templateId = '1';
INSERT INTO template VALUES ('adminConsole','Admin Console','<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"\r\n \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\r\n<html xmlns=\"http://www.w3.org/1999/xhtml\">\r\n<head>\r\n <title>WebGUI <tmpl_var session.webgui.version>-<tmpl_var session.webgui.status> Admin Console</title>\r\n <tmpl_var head.tags> \r\n</head>\r\n<body>\r\n<tmpl_var body.content>\r\n</body>\r\n</html>\r\n','style',1,0);
delete from settings where name='adminStyleId';
@ -224,4 +221,3 @@ INSERT INTO template VALUES ('15','File Folder','<a href=\"<tmpl_var assetId>\">
alter table HttpProxy add column cookieJarStorageId varchar(22);

View file

@ -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.<br>
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 = '<p><b>'.$error.'</b></p>' 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 = '<IFRAME SRC="'.$iframeUrl.'" TITLE="'.WebGUI::International::get('Page Export Status').'" WIDTH="410" HEIGHT="200"></IFRAME>';
$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.<br />\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 $@ <br />\n";
print "This most likely means that you have a page with the same name as folder that you're trying to create.<br />\n";
return;
}
}
$path .= $session{os}{slash}.$filename;
eval { open(FILE, "> $path") or die "$!" };
if ($@) {
print "Couldn't open $path because $@ <br />\n";
return;
} else {
print FILE $self->exportAsHtml({userId=>$userId,extrasUrl=>$extrasURL,uploadsUrl=>$uploadsURL});
close(FILE);
}
print "DONE<br />";
}
print "<p>Exported ".scalar(@{$assets})." pages in ".(time()-$startTime)." seconds.</p>";
print '<a target="_parent" href="'.$self->getUrl.'">'.WebGUI::International::get(493).'</a>';
return;
}
#-------------------------------------------------------------------
@ -2678,6 +2925,7 @@ sub www_promote {
return "";
}
#-------------------------------------------------------------------
=head2 www_setParent ( )

View file

@ -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',

View file

@ -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,

View file

@ -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,

View file

@ -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;