templatized the login box macro

This commit is contained in:
JT Smith 2003-12-07 22:16:57 +00:00
parent 6eff2851e1
commit 50b3aafb7c
4 changed files with 45 additions and 39 deletions

View file

@ -13,5 +13,7 @@
wobject.
- Migrated Link Lists to USS submissions and removed the Link List wobject.
- Re-enabled the Date macro by default.
- Templatized the Login Box macro.
- Added the new WebGUI 6 design.

File diff suppressed because one or more lines are too long

View file

@ -170,4 +170,6 @@ insert into international (internationalId,languageId,namespace,message,lastUpda
delete from international where languageId=1 and namespace='USS' and internationalId=71;
insert into international (internationalId,languageId,namespace,message,lastUpdated,context) values (71,1,'USS','User Submission Systems (USS) are a great way to add a sense of community to any site as well as get free content from your users. The User Submission System name is misleading to some people, because they immediately think of users as visitors. However, users are also staff, or business partners, or even yourself. With the USS you can select who can add new content, and even who can moderate that content.\r\n<br><br>\r\nUser Submission systems are so versatile that they allow you to create all kinds of applications, just by editing a few templates. Example applications are Photo Galleries, FAQs, Link Lists, Guest Books, Classifieds, and more.\r\n\r\n\r\n<p>\r\n<b>Submission Template</b><br/>\r\nChoose a layout for the individual submissions.\r\n<p/>\r\n\r\n<b>Submission Form Template</b><br>\r\nChoose a layout of the form users see when submitting content.\r\n<p>\r\n\r\n\r\n<b>Submissions Per Page</b><br>\r\nHow many submissions should be listed per page in the submissions index?\r\n<br><br>\r\n\r\n\r\n<b>Filter Content</b><br>\r\nSelect the level of content filtering you wish to perform on all submitted content.\r\n<p>\r\n\r\n<b>Sort By</b><br>\r\nThe field to sort the submission list by.\r\n<p>\r\n\r\n<b>Sort Order</b><br>\r\nThe direction to sort the submission list by.\r\n<p>\r\n\r\n\r\n\r\n\r\n<b>Who can approve?</b><br>\r\nWhat group is allowed to approve and deny content?\r\n<br><br>\r\n\r\n<b>Who can contribute?</b><br>\r\nWhat group is allowed to contribute content?\r\n<br><br>\r\n\r\n\r\n<b>Default Status</b><br>\r\nShould submissions be set to <i>Approved</i>, <i>Pending</i>, or <i>Denied</i> by default?\r\n<br><br>\r\n<i>Note:</i> If you set the default status to Pending, then be prepared to monitor your message log for new submissions.\r\n<p>\r\n\r\n<b>Karma Per Submission</b><br>\r\nHow much karma should be given to a user when they contribute to this user submission system?\r\n<p>\r\n\r\n\r\n<b>Allow discussion?</b><br>\r\nChecking this box will enable responses to your article much like Articles on Slashdot.org.\r\n<p>\r\n\r\n\r\n', 1070199700,NULL);
INSERT INTO template VALUES (1,'Default Login Box','<div class=\"loginBox\">\n<tmpl_if user.isVisitor>\n <tmpl_var form.header>\n <span><tmpl_var username.label><br></span>\n <tmpl_var username.form>\n <span><br><tmpl_var password.label><br></span>\n <tmpl_var password.form>\n <span><br></span>\n <tmpl_var form.login>\n <tmpl_var form.footer>\n <tmpl_if session.setting.anonymousRegistration>\n <p><a href=\"account.create.url\"><tmpl_var account.create.label></a></p>\n </tmpl_if> \n<tmpl_else>\n <tmpl_unless customText>\n <tmpl_var hello.label> <a href=\"<tmpl_var account.display.url>\"><tmpl_var session.user.username></a>.\n <tmpl_var logout.label>\n <tmpl_else>\n <tmpl_var customText>\n </tmpl_unless>\n</tmpl_if>\n</div>\n','Macro/L_loginBox');
INSERT INTO template VALUES (2,'Horizontal Login Box','<div class=\"loginBox\">\n<tmpl_if user.isVisitor>\n <tmpl_var form.header>\n <table border=\"0\" class=\"loginBox\" cellpadding=\"1\" cellspacing=\"0\">\n <tr>\n <td><tmpl_var username.form></td>\n <td><tmpl_var password.form></td>\n <td><tmpl_var form.login></td>\n </tr>\n <tr>\n <td><tmpl_var username.label></td>\n <td><tmpl_var password.label></td>\n <td></td>\n </tr>\n </table> \n <tmpl_var form.footer>\n <tmpl_if session.setting.anonymousRegistration>\n <a href=\"account.create.url\"><tmpl_var account.create.label></a>\n </tmpl_if> \n<tmpl_else>\n <tmpl_unless customText>\n <tmpl_var hello.label> <a href=\"<tmpl_var account.display.url>\"><tmpl_var session.user.username></a>.\n <tmpl_var logout.label><br />\n <tmpl_else>\n <tmpl_var customText>\n </tmpl_unless>\n</tmpl_if>\n</div>\n','Macro/L_loginBox');

View file

@ -11,10 +11,11 @@ package WebGUI::Macro::L_loginBox;
#-------------------------------------------------------------------
use strict;
use WebGUI::HTMLForm;
use WebGUI::Form;
use WebGUI::International;
use WebGUI::Macro;
use WebGUI::Session;
use WebGUI::Template;
use WebGUI::URL;
#-------------------------------------------------------------------
@ -24,44 +25,45 @@ sub _createURL {
#-------------------------------------------------------------------
sub process {
my ($temp,$boxSize,@param,$text,$f);
my $debug;
@param = WebGUI::Macro::getParams($_[0]);
$temp = '<div class="loginBox">';
if ($session{user}{userId} != 1) {
$text = $param[1];
if (not defined $text){
$temp .= WebGUI::International::get(48);
$temp .= ' <a href="'.WebGUI::URL::page('op=displayAccount').
'">'.$session{user}{username}.'</a>. ';
$temp .= WebGUI::International::get(49);
} else {
$text =~ s/%(.*?)%/_createURL($1)/ge;
$temp .= $text;
}
} else {
$boxSize = $param[0];
if (not defined $boxSize) {
$boxSize = 12;
}
if (index(lc($ENV{HTTP_USER_AGENT}),"msie") < 0) {
$boxSize = int($boxSize=$boxSize*2/3);
}
$f = WebGUI::HTMLForm->new(1);
$f->hidden("op","login");
$f->raw('<span class="formSubtext">'.WebGUI::International::get(50).'<br></span>');
$f->text("username",'','','','','',$boxSize);
$f->raw('<span class="formSubtext"><br>'.WebGUI::International::get(51).'<br></span>');
$f->password("identifier",'','','','','',$boxSize);
$f->raw('<span class="formSubtext"><br></span>');
$f->submit(WebGUI::International::get(52));
$temp .= $f->print;
if ($session{setting}{anonymousRegistration}) {
$temp .= '<a href="'.WebGUI::URL::page('op=createAccount').'">'.WebGUI::International::get(407).'</a>';
}
my @param = WebGUI::Macro::getParams($_[0]);
my $templateId = $param[2] || 1;
my %var;
$var{'user.isVisitor'} = ($session{user}{userId} == 1);
$var{'customText'} = $param[1];
$var{'customText'} =~ s/%(.*?)%/_createURL($1)/ge;
$var{'hello.label'} = WebGUI::International::get(48);
$var{'logout.url'} = WebGUI::URL::page("op=logout");
$var{'account.display.url'} = WebGUI::URL::page('op=displayAccount');
$var{'logout.label'} = WebGUI::International::get(49);
my $boxSize = $param[0];
$boxSize = 12 if (not defined $boxSize);
if (index(lc($ENV{HTTP_USER_AGENT}),"msie") < 0) {
$boxSize = int($boxSize=$boxSize*2/3);
}
$temp .= '</div>';
return $temp;
$var{'form.header'} = WebGUI::Form::formHeader()
.WebGUI::Form::hidden({
name=>"op",
value=>"login"
});
$var{'username.label'} = WebGUI::International::get(50);
$var{'username.form'} = WebGUI::Form::text({
name=>"username",
size=>$boxSize,
extras=>'class="loginBoxField"'
});
$var{'password.label'} = WebGUI::International::get(51);
$var{'password.form'} = WebGUI::Form::password({
name=>"identifier",
size=>$boxSize,
extras=>'class="loginBoxField"'
});
$var{'form.login'} = WebGUI::Form::submit({
value=>WebGUI::International::get(52),
extras=>'class="loginBoxButton"'
});
$var{'account.create.url'} = WebGUI::URL::page('op=createAccount');
$var{'account.create.label'} = WebGUI::International::get(407);
return WebGUI::Template::process(WebGUI::Template::get($templateId,"Macro/L_loginBox"),\%var);
}
1;