added replacements
This commit is contained in:
parent
fea0adcf1c
commit
b9de5b1a3c
5 changed files with 158 additions and 34 deletions
|
|
@ -222,8 +222,27 @@ alter table forum add column archiveAfter int not null default 31536000;
|
|||
alter table forum add column postsPerPage int not null default 30;
|
||||
insert into international (internationalId,languageId,namespace,message,lastUpdated,context) values (1045,1,'WebGUI','Nested', 1066405110,'A label indicating the layout of a forum thread.');
|
||||
insert into international (internationalId,languageId,namespace,message,lastUpdated,context) values (1046,1,'WebGUI','Archived', 1066406723,'A label indicating that the content has a status of archived.');
|
||||
|
||||
|
||||
|
||||
|
||||
create table replacements (replacementId int not null primary key, searchFor varchar(255), replaceWith text);
|
||||
update userProfileField set dataValues='{\n threaded=>WebGUI::International::get(511),\n flat=>WebGUI::International::get(510),\n nested=>WebGUI::International::get(1045)\n}\n' where fieldName='discussionLayout';
|
||||
insert into international (internationalId,languageId,namespace,message,lastUpdated,context) values (1053,1,'WebGUI','Manage Replacements', 1066419031,'A heading for the replacement listings page.');
|
||||
insert into international (internationalId,languageId,namespace,message,lastUpdated,context) values (1052,1,'WebGUI','Edit Replacement', 1066418983,'A heading for the edit replacement page. ');
|
||||
insert into international (internationalId,languageId,namespace,message,lastUpdated,context) values (1051,1,'WebGUI','Replace With', 1066418940,'Prompt the admin to enter a string to replace the search for string with in the replacement text.');
|
||||
insert into international (internationalId,languageId,namespace,message,lastUpdated,context) values (1050,1,'WebGUI','Search For', 1066418903,'Prompt the admin to enter a string to search for in the replacement text.');
|
||||
insert into international (internationalId,languageId,namespace,message,lastUpdated,context) values (1049,1,'WebGUI','Replacement ID', 1066418840,'Show the admin what the unique identifier for this replacement is.');
|
||||
insert into international (internationalId,languageId,namespace,message,lastUpdated,context) values (1048,1,'WebGUI','Manage replacements.', 1066418767,'A label for a link that lists all replacements.');
|
||||
insert into international (internationalId,languageId,namespace,message,lastUpdated,context) values (1047,1,'WebGUI','Add a replacement.', 1066418669,'A label for a link that adds a new replacement (used in message boards).');
|
||||
insert into incrementer values ("replacementId","1000");
|
||||
INSERT INTO replacements VALUES (1,'[quote]','<blockquote><i>');
|
||||
INSERT INTO replacements VALUES (2,'[/quote]','</i></blockquote>');
|
||||
INSERT INTO replacements VALUES (3,'[image]','<img src=\"');
|
||||
INSERT INTO replacements VALUES (4,'[/image]','\" border=\"0\" / >');
|
||||
INSERT INTO replacements VALUES (5,'shit','crap');
|
||||
INSERT INTO replacements VALUES (6,'fuck','farg');
|
||||
INSERT INTO replacements VALUES (7,'asshole','icehole');
|
||||
INSERT INTO replacements VALUES (8,'nigger','guy');
|
||||
INSERT INTO replacements VALUES (9,'[b]','<b>');
|
||||
INSERT INTO replacements VALUES (10,'[/b]','</b>');
|
||||
INSERT INTO replacements VALUES (11,'[i]','<i>');
|
||||
INSERT INTO replacements VALUES (12,'[/i]','</i>');
|
||||
INSERT INTO replacements VALUES (0,NULL,NULL);
|
||||
|
||||
|
|
|
|||
|
|
@ -422,9 +422,9 @@ sub getPostTemplateVars {
|
|||
$var->{'post.message'} = '<div style="font-family: fixed;">'.$var->{'post.message'}.'</div>';
|
||||
}
|
||||
if ($forum->get("allowReplacements")) {
|
||||
my $sth = WebGUI::SQL->read("select pattern,replaceWith from forumReplacement");
|
||||
while (my ($pattern,$replaceWith) = $sth->array) {
|
||||
$var->{'post.message'} =~ s/\Q$pattern/$replaceWith/g;
|
||||
my $sth = WebGUI::SQL->read("select searchFor,replaceWith from replacements");
|
||||
while (my ($searchFor,$replaceWith) = $sth->array) {
|
||||
$var->{'post.message'} =~ s/\Q$searchFor/$replaceWith/gs;
|
||||
}
|
||||
$sth->finish;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ use WebGUI::Operation::International;
|
|||
use WebGUI::Operation::Package;
|
||||
use WebGUI::Operation::Page;
|
||||
use WebGUI::Operation::ProfileSettings;
|
||||
use WebGUI::Operation::Replacements;
|
||||
use WebGUI::Operation::Root;
|
||||
use WebGUI::Operation::Scratch;
|
||||
use WebGUI::Operation::Search;
|
||||
|
|
|
|||
103
lib/WebGUI/Operation/Replacements.pm
Normal file
103
lib/WebGUI/Operation/Replacements.pm
Normal file
|
|
@ -0,0 +1,103 @@
|
|||
package WebGUI::Operation::Replacements;
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001-2003 Plain Black LLC.
|
||||
#-------------------------------------------------------------------
|
||||
# Please read the legal notices (docs/legal.txt) and the license
|
||||
# (docs/license.txt) that came with this distribution before using
|
||||
# this software.
|
||||
#-------------------------------------------------------------------
|
||||
# http://www.plainblack.com info@plainblack.com
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
use Exporter;
|
||||
use strict;
|
||||
use WebGUI::Icon;
|
||||
use WebGUI::HTMLForm;
|
||||
use WebGUI::International;
|
||||
use WebGUI::Operation::Shared;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::SQL;
|
||||
|
||||
our @ISA = qw(Exporter);
|
||||
our @EXPORT = qw(&www_deleteReplacement &www_editReplacement &www_editReplacementSave &www_listReplacements);
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub _submenu {
|
||||
my (%menu);
|
||||
tie %menu, 'Tie::IxHash';
|
||||
$menu{WebGUI::URL::page("op=editReplacement&replacementId=new")} = WebGUI::International::get(1047);
|
||||
$menu{WebGUI::URL::page("op=listReplacements")} = WebGUI::International::get(1048);
|
||||
$menu{WebGUI::URL::page('op=manageSettings')} = WebGUI::International::get(4);
|
||||
return menuWrapper($_[0],\%menu);
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_deleteReplacement {
|
||||
return WebGUI::Privilege::adminOnly() unless (WebGUI::Privilege::isInGroup(3));
|
||||
WebGUI::SQL->write("delete from replacements where replacementId=$session{form}{replacementId}");
|
||||
return www_listReplacements();
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_editReplacement {
|
||||
return WebGUI::Privilege::adminOnly() unless (WebGUI::Privilege::isInGroup(3));
|
||||
my $data = WebGUI::SQL->getRow("replacements","replacementId",$session{form}{replacementId});
|
||||
my $f = WebGUI::HTMLForm->new;
|
||||
$f->hidden(
|
||||
-name=>"op",
|
||||
-value=>"editReplacementSave"
|
||||
);
|
||||
$f->hidden(
|
||||
-name=>"replacementId",
|
||||
-value=>$session{form}{replacementId}
|
||||
);
|
||||
$f->readOnly(
|
||||
-label=>WebGUI::International::get(1049),
|
||||
-value=>$session{form}{replacementId}
|
||||
);
|
||||
$f->text(
|
||||
-name=>"searchFor",
|
||||
-label=>WebGUI::International::get(1050),
|
||||
-value=>$data->{searchFor}
|
||||
);
|
||||
$f->textarea(
|
||||
-label=>WebGUI::International::get(1051),
|
||||
-name=>"replaceWith",
|
||||
-value=>$data->{replaceWith}
|
||||
);
|
||||
$f->submit;
|
||||
return _submenu("<h1>".WebGUI::International::get(1052)."</h1>".$f->print);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_editReplacementSave {
|
||||
return WebGUI::Privilege::adminOnly() unless (WebGUI::Privilege::isInGroup(3));
|
||||
WebGUI::SQL->setRow("replacements","replacementId",{
|
||||
replacementId=>$session{form}{replacementId},
|
||||
searchFor=>$session{form}{searchFor},
|
||||
replaceWith=>$session{form}{replaceWith}
|
||||
});
|
||||
return www_listReplacements();
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_listReplacements {
|
||||
return WebGUI::Privilege::adminOnly() unless (WebGUI::Privilege::isInGroup(3));
|
||||
my $output = "<h1>".WebGUI::International::get(1053)."</h1>";
|
||||
$output .= '<table>';
|
||||
my $sth = WebGUI::SQL->read("select replacementId,searchFor from replacements order by searchFor");
|
||||
while (my $data = $sth->hashRef) {
|
||||
$output .= '<tr><td>'.deleteIcon("op=deleteReplacement&replacementId=".$data->{replacementId})
|
||||
.editIcon("op=editReplacement&replacementId=".$data->{replacementId}).'</td>';
|
||||
$output .= '<td class="tableData">'.$data->{searchFor}.'</td></tr>';
|
||||
}
|
||||
$sth->finish;
|
||||
$output .= '</table>';
|
||||
return _submenu($output);
|
||||
}
|
||||
|
||||
|
||||
|
||||
1;
|
||||
|
|
@ -36,33 +36,6 @@ sub _submenu {
|
|||
return menuWrapper($_[0],\%menu);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_editUserSettings {
|
||||
return WebGUI::Privilege::adminOnly() unless (WebGUI::Privilege::isInGroup(3));
|
||||
my ($output, $f, $cmd, $html, $options);
|
||||
$output .= helpIcon(2);
|
||||
$output .= '<h1>'.WebGUI::International::get(117).'</h1>';
|
||||
$f = WebGUI::HTMLForm->new;
|
||||
$f->hidden("op","saveSettings");
|
||||
$f->yesNo("anonymousRegistration",WebGUI::International::get(118),$session{setting}{anonymousRegistration});
|
||||
$f->text("runOnRegistration",WebGUI::International::get(559),$session{setting}{runOnRegistration});
|
||||
$f->yesNo("useKarma",WebGUI::International::get(539),$session{setting}{useKarma});
|
||||
$f->integer("karmaPerLogin",WebGUI::International::get(540),$session{setting}{karmaPerLogin});
|
||||
$f->interval("sessionTimeout",WebGUI::International::get(142),WebGUI::DateTime::secondsToInterval($session{setting}{sessionTimeout}));
|
||||
$f->yesNo("selfDeactivation",WebGUI::International::get(885),$session{setting}{selfDeactivation});
|
||||
$f->yesNo("encryptLogin",WebGUI::International::get(1006),$session{setting}{encryptLogin});
|
||||
foreach (@{$session{config}{authMethods}}) {
|
||||
$options->{$_} = $_;
|
||||
}
|
||||
$f->select("authMethod",$options,WebGUI::International::get(119),[$session{setting}{authMethod}]);
|
||||
foreach (@{$session{config}{authMethods}}) {
|
||||
$f->raw(WebGUI::Authentication::settingsForm($_));
|
||||
}
|
||||
$f->submit;
|
||||
$output .= $f->print;
|
||||
return _submenu($output);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_editCompanyInformation {
|
||||
return WebGUI::Privilege::adminOnly() unless (WebGUI::Privilege::isInGroup(3));
|
||||
|
|
@ -152,6 +125,33 @@ sub www_editMiscSettings {
|
|||
return _submenu($output);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_editUserSettings {
|
||||
return WebGUI::Privilege::adminOnly() unless (WebGUI::Privilege::isInGroup(3));
|
||||
my ($output, $f, $cmd, $html, $options);
|
||||
$output .= helpIcon(2);
|
||||
$output .= '<h1>'.WebGUI::International::get(117).'</h1>';
|
||||
$f = WebGUI::HTMLForm->new;
|
||||
$f->hidden("op","saveSettings");
|
||||
$f->yesNo("anonymousRegistration",WebGUI::International::get(118),$session{setting}{anonymousRegistration});
|
||||
$f->text("runOnRegistration",WebGUI::International::get(559),$session{setting}{runOnRegistration});
|
||||
$f->yesNo("useKarma",WebGUI::International::get(539),$session{setting}{useKarma});
|
||||
$f->integer("karmaPerLogin",WebGUI::International::get(540),$session{setting}{karmaPerLogin});
|
||||
$f->interval("sessionTimeout",WebGUI::International::get(142),WebGUI::DateTime::secondsToInterval($session{setting}{sessionTimeout}));
|
||||
$f->yesNo("selfDeactivation",WebGUI::International::get(885),$session{setting}{selfDeactivation});
|
||||
$f->yesNo("encryptLogin",WebGUI::International::get(1006),$session{setting}{encryptLogin});
|
||||
foreach (@{$session{config}{authMethods}}) {
|
||||
$options->{$_} = $_;
|
||||
}
|
||||
$f->select("authMethod",$options,WebGUI::International::get(119),[$session{setting}{authMethod}]);
|
||||
foreach (@{$session{config}{authMethods}}) {
|
||||
$f->raw(WebGUI::Authentication::settingsForm($_));
|
||||
}
|
||||
$f->submit;
|
||||
$output .= $f->print;
|
||||
return _submenu($output);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_manageSettings {
|
||||
return WebGUI::Privilege::adminOnly() unless (WebGUI::Privilege::isInGroup(3));
|
||||
|
|
@ -164,6 +164,7 @@ sub www_manageSettings {
|
|||
$output .= '<li><a href="'.WebGUI::URL::page('op=editMessagingSettings').'">'.WebGUI::International::get(133).'</a>';
|
||||
$output .= '<li><a href="'.WebGUI::URL::page('op=editMiscSettings').'">'.WebGUI::International::get(140).'</a>';
|
||||
$output .= '<li><a href="'.WebGUI::URL::page('op=editProfileSettings').'">'.WebGUI::International::get(308).'</a>';
|
||||
$output .= '<li><a href="'.WebGUI::URL::page('op=listReplacements').'">'.WebGUI::International::get(1048).'</a>';
|
||||
$output .= '<li><a href="'.WebGUI::URL::page('op=editUserSettings').'">'.WebGUI::International::get(117).'</a>';
|
||||
$output .= '</ul>';
|
||||
return _submenu($output);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue