Templatized the Rich Text Editor support
This commit is contained in:
parent
fbacd3c582
commit
b566c28054
3 changed files with 40 additions and 67 deletions
|
|
@ -31,3 +31,4 @@
|
|||
- Added admin style option.
|
||||
- Added per page printable styles.
|
||||
- Wobject privileges are available per page rather than site-wide.
|
||||
- Templatized the Rich Editor support. Tnx to Len Kranendonk
|
||||
|
|
|
|||
|
|
@ -298,3 +298,15 @@ delete from international where languageId=1 and namespace='WebGUI' and internat
|
|||
insert into international (internationalId,languageId,namespace,message,lastUpdated,context) values (1080,1,'WebGUI','Use admin style?', 1073161583,'A label asking the user if they want to use a seperate admin style from the main page style.');
|
||||
insert into settings values ("useAdminStyle",1);
|
||||
insert into settings values ("adminStyleId",1000);
|
||||
INSERT INTO template VALUES (3,'Midas','<script language=\"JavaScript\">\r\nfunction fixChars(element) {\r\n element.value = element.value.replace(/~V/mg,\"-\");\r\n}\r\n</script>\r\n\r\n<tmpl_if midas.supported>\r\n <script language=\"JavaScript\">\r\n var formObj; \r\n var extrasDir=\"<tmpl_var session.config.extrasURL\";\r\n function openEditWindow(obj) {\r\n formObj = obj;\r\n window.open(\"<tmpl_var session.config.extrasURL>/midas/editor.html\",\"editWindow\",\"width=600,height=400,resizable=1\"); }\r\n </script>\r\n <tmpl_var button>\r\n</tmpl_if>\r\n\r\n<tmpl_var textarea>\r\n','richEditor');
|
||||
INSERT INTO template VALUES (4,'Classic','<script language=\"JavaScript\">\r\nfunction fixChars(element) {\r\n element.value = element.value.replace(/~V/mg,\"-\");\r\n}\r\n</script>\r\n\r\n<tmpl_if classic.supported>\r\n <script language=\"JavaScript\">\r\n var formObj; var extrasDir=\"<tmpl_var session.config.extrasURL>\";\r\n function openEditWindow(obj) {\r\n formObj = obj;\r\n window.open(\"<tmpl_var session.config.extrasURL>/ie5edit.html\",\"editWindow\",\"width=490,height=400,resizable=1\");\r\n }\r\n function setContent(content) { \r\n formObj.value = content; \r\n } \r\n </script>\r\n <tmpl_var button>\r\n</tmpl_if>\r\n\r\n<tmpl_var textarea>\r\n','richEditor');
|
||||
INSERT INTO template VALUES (2,'EditOnPro2','<script language=\"JavaScript\">\r\nfunction fixChars(element) {\r\n element.value = element.value.replace(/~V/mg,\"-\");\r\n}\r\n</script>\r\n\r\n<script language=\"JavaScript\">\r\nvar formObj;\r\nfunction openEditWindow(obj) {\r\n formObj = obj;\r\n window.open(\"<tmpl_var session.config.extrasURL>/eopro.html\",\"editWindow\",\"width=720,height=450,resizable=1\");\r\n} \r\n</script>','richEditor');
|
||||
INSERT INTO template VALUES (1,'HTMLArea','<script language=\"JavaScript\">\r\nfunction fixChars(element) {\r\n element.value = element.value.replace(/~V/mg,\"-\");\r\n}\r\n</script>\r\n\r\n<tmpl_if htmlArea.supported>\r\n <tmpl_if popup>\r\n <script language=\"JavaScript\">\r\n var formObj;\r\n var extrasDir=\"<tmpl_var session.config.extrasURL>\";\r\n function openEditWindow(obj) {\r\n formObj = obj;\r\n window.open(\"<tmpl_var session.config.extrasURL>/htmlArea/editor.html\",\"editWindow\",\"width=490,height=400,resizable=1\");\r\n }\r\n function setContent(content) {\r\n formObj.value = content;\r\n }\r\n </script>\r\n <tmpl_else>\r\n <script language=\"JavaScript\" src=\"<tmpl_var session.config.extrasURL>/htmlArea/editor.js\"></script>\r\n <script>\r\n _editor_url = \"<tmpl_var session.config.extrasURL>/htmlArea/\";\r\n </script> \r\n </tmpl_if>\r\n</tmpl_if>\r\n\r\n<tmpl_var textarea>\r\n\r\n<tmpl_if htmlArea.supported>\r\n <script language=\"Javascript1.2\">\r\n editor_generate(\"<tmpl_var form.name>\");\r\n </script>\r\n</tmpl_if>\r\n','richEditor');
|
||||
INSERT INTO template VALUES (5,'lastResort','<script language=\"JavaScript\">\r\nfunction fixChars(element) {\r\n element.value = element.value.replace(/~V/mg,\"-\");\r\n}\r\n</script>\r\n\r\n<script language=\"JavaScript\">\r\n var formObj;\r\n var extrasDir=\"<tmpl_var session.config.extrasURL>\";\r\n function openEditWindow(obj) {\r\n formObj = obj;\r\n window.open(\"<tmpl_var session.config.extrasURL>/lastResortEdit.html\",\"editWindow\",\"width=500,height=410\");\r\n }\r\n function setContent(content) {\r\n formObj.value = content;\r\n } \r\n</script>\r\n\r\n<tmpl_var button>\r\n\r\n<tmpl_var textarea>','richEditor');
|
||||
UPDATE userProfileField set dataValues = '{\r\n1=>WebGUI::International::get(495), #htmlArea\r\n#2=>WebGUI::International::get(494), #editOnPro2\r\n3=>WebGUI::International::get(887), #midas\r\n4=>WebGUI::International::get(879), #classic\r\n5=>WebGUI::International::get(880),\r\nnone=>WebGUI::International::get(881)\r\n}', dataDefault = '[1]' where fieldName = 'richEditor';
|
||||
UPDATE userProfileData set fieldData = '1' where fieldName = 'richEditor' and fieldData = 'htmlArea';
|
||||
UPDATE userProfileData set fieldData = '2' where fieldName = 'richEditor' and fieldData = 'editOnPro2';
|
||||
UPDATE userProfileData set fieldData = '3' where fieldName = 'richEditor' and fieldData = 'midas';
|
||||
UPDATE userProfileData set fieldData = '4' where fieldName = 'richEditor' and fieldData = 'classic';
|
||||
UPDATE userProfileData set fieldData = '5' where fieldName = 'richEditor' and fieldData = 'lastResort';
|
||||
|
||||
|
|
|
|||
|
|
@ -959,67 +959,22 @@ NOTE: WebGUI uses a great variety of rich editors. Not all of them are capable o
|
|||
sub HTMLArea {
|
||||
my ($output, $rows, $columns, $htmlArea);
|
||||
my $browser = HTTP::BrowserDetect->new($session{env}{HTTP_USER_AGENT});
|
||||
my $button = '<input type="button" onClick="openEditWindow(this.form.'.$_[0]->{name}.')" value="'
|
||||
.WebGUI::International::get(171).'" style="font-size: 8pt;"><br>';
|
||||
$output = '<script language="JavaScript">function fixChars(element) {element.value = element.value.replace(/~V/mg,"-");}</script>';
|
||||
if ($session{user}{richEditor} eq "editOnPro2") {
|
||||
$output .= '<script language="JavaScript">
|
||||
var formObj;
|
||||
function openEditWindow(obj) {
|
||||
formObj = obj;
|
||||
window.open("'.$session{config}{extrasURL}.'/eopro.html","editWindow","width=720,height=450,resizable=1");
|
||||
} </script>';
|
||||
} elsif ($session{user}{richEditor} eq "htmlArea" && $browser->ie && $browser->version >= 5.5) {
|
||||
if ($session{user}{richEditorMode} eq "popup" || $_[0]->{popupToggle}) {
|
||||
$output .= '<script language="JavaScript">
|
||||
var formObj;
|
||||
var extrasDir="'.$session{config}{extrasURL}.'";
|
||||
function openEditWindow(obj) {
|
||||
formObj = obj;
|
||||
window.open("'.$session{config}{extrasURL}.'/htmlArea/editor.html","editWindow","width=490,height=400,resizable=1"); }
|
||||
function setContent(content) {
|
||||
formObj.value = content;
|
||||
} </script>';
|
||||
$output .= $button;
|
||||
} else {
|
||||
$output .= _javascriptFile('htmlArea/editor.js');
|
||||
$output .= '<script>'."\n";
|
||||
$output .= '_editor_url = "'.$session{config}{extrasURL}.'/htmlArea/";'."\n";
|
||||
$output .= '</script>'."\n";
|
||||
$htmlArea = 1;
|
||||
}
|
||||
} elsif ($session{user}{richEditor} eq "midas" && (($browser->ie && $browser->version >= 6) || ($browser->gecko && $browser->version >= 1.3))) {
|
||||
$output .= '<script language="JavaScript">
|
||||
var formObj; var extrasDir="'.$session{config}{extrasURL}.'";
|
||||
function openEditWindow(obj) {
|
||||
formObj = obj;
|
||||
window.open("'.$session{config}{extrasURL}.'/midas/editor.html","editWindow","width=600,height=400,resizable=1"); }
|
||||
</script>';
|
||||
$output .= $button;
|
||||
} elsif ($session{user}{richEditor} eq "classic" && $browser->ie && $browser->version >= 5) {
|
||||
$output .= '<script language="JavaScript">
|
||||
var formObj; var extrasDir="'.$session{config}{extrasURL}.'";
|
||||
function openEditWindow(obj) {
|
||||
formObj = obj;
|
||||
window.open("'.$session{config}{extrasURL}.'/ie5edit.html","editWindow","width=490,height=400,resizable=1"); }
|
||||
function setContent(content) { formObj.value = content; } </script>';
|
||||
$output .= $button;
|
||||
} elsif ($session{user}{richEditor} eq "lastResort") {
|
||||
$output .= '<script language="JavaScript">
|
||||
var formObj;
|
||||
var extrasDir="'.$session{config}{extrasURL}.'";
|
||||
function openEditWindow(obj) {
|
||||
formObj = obj;
|
||||
window.open("'.$session{config}{extrasURL}.'/lastResortEdit.html","editWindow","width=500,height=410");
|
||||
}
|
||||
function setContent(content) {
|
||||
formObj.value = content;
|
||||
} </script>';
|
||||
$output .= $button;
|
||||
}
|
||||
$rows = $_[0]->{rows} || ($session{setting}{textAreaRows}+7);
|
||||
$columns = $_[0]->{columns} || ($session{setting}{textAreaCols}+5);
|
||||
$output .= textarea({
|
||||
my %var;
|
||||
|
||||
# Store all scalar options in template variables
|
||||
foreach (keys %{$_[0]}) {
|
||||
$var{"form.".$_} = $_[0]->{$_} unless (ref $_[0]->{$_});
|
||||
}
|
||||
|
||||
# Supported Rich Editors
|
||||
$var{"htmlArea.supported"} = ($browser->ie && $browser->version >= 5.5);
|
||||
$var{"midas.supported"} = (($browser->ie && $browser->version >= 6) || ($browser->gecko && $browser->version >= 1.3));
|
||||
$var{"classic.supported"} = ($browser->ie && $browser->version >= 5);
|
||||
|
||||
# Textarea field
|
||||
$rows = $_[0]->{rows} || ($session{setting}{textAreaRows}+7);
|
||||
$columns = $_[0]->{columns} || ($session{setting}{textAreaCols}+5);
|
||||
$var{textarea} = textarea({
|
||||
name=>$_[0]->{name},
|
||||
value=>$_[0]->{value},
|
||||
wrap=>$_[0]->{wrap},
|
||||
|
|
@ -1027,12 +982,17 @@ sub HTMLArea {
|
|||
rows=>$rows,
|
||||
extras=>$_[0]->{extras}.' onBlur="fixChars(this.form.'.$_[0]->{name}.')"'
|
||||
});
|
||||
if ($htmlArea) {
|
||||
$output .= '<script language="Javascript1.2">'."\n";
|
||||
$output .= 'editor_generate("'.$_[0]->{name}.'");'."\n";
|
||||
$output .= '</script>'."\n";
|
||||
}
|
||||
return $output;
|
||||
|
||||
# Other variables
|
||||
$var{"popup"} = ($session{user}{richEditorMode} eq "popup" || $_[0]->{popupToggle});
|
||||
$var{"button"} = '<input type="button" onClick="openEditWindow(this.form.'.$_[0]->{name}.')" value="'
|
||||
.WebGUI::International::get(171).'" style="font-size: 8pt;"><br>';
|
||||
|
||||
if ($session{user}{richEditor} eq 'none') {
|
||||
return $var{textarea};
|
||||
} else {
|
||||
return WebGUI::Template::process(WebGUI::Template::get($session{user}{richEditor},'richEditor'),\%var);
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue