Added Help, code cleanup, some template changes

This commit is contained in:
Yung Han Khoe 2008-05-19 18:24:27 +00:00
parent 4b120aed10
commit 9968a25729
3 changed files with 295 additions and 86 deletions

View file

@ -67,9 +67,9 @@ sub getAlphabetSearchLoop {
my $hasResults = $self->session->db->quickScalar("select if ("
."(select count(*) from userProfileData where lastName like '".$letter."%')<>0, 1, 0)");
push @alphabetLoop, {
label => $htmlEncodedLetter || $letter,
hasResults => $hasResults,
searchURL => $searchURL,
alphabetSearch_loop_label => $htmlEncodedLetter || $letter,
alphabetSearch_loop_hasResults => $hasResults,
alphabetSearch_loop_searchURL => $searchURL,
}
}
return \@alphabetLoop;
@ -88,56 +88,56 @@ A hash reference containing the properties of this wobject.
=cut
sub definition {
my $class = shift;
my $session = shift;
my $definition = shift;
my %properties;
my $i18n = WebGUI::International->new($session, 'Asset_UserList');
tie %properties, 'Tie::IxHash';
%properties = (
templateId =>{
fieldType=>"template",
defaultValue=>'UserListTmpl0000001',
namespace=>'UserList',
tab=>"display",
},
my $class = shift;
my $session = shift;
my $definition = shift;
my %properties;
my $i18n = WebGUI::International->new($session, 'Asset_UserList');
tie %properties, 'Tie::IxHash';
%properties = (
templateId =>{
fieldType=>"template",
defaultValue=>'UserListTmpl0000001',
namespace=>'UserList',
tab=>"display",
},
showGroupId=>{
fieldType=>"group",
defaultValue=>"7",
label=>$i18n->get("Group to show label"),
hoverHelp=>$i18n->get('Group to show description'),
tab=>"display",
},
hideGroupId=>{
fieldType=>"group",
defaultValue=>"3",
label=>$i18n->get("Group to hide label"),
hoverHelp=>$i18n->get('Group to hide description'),
tab=>"display",
},
usersPerPage=>{
fieldType=>"integer",
defaultValue=>"25",
tab=>"display",
hoverHelp=>$i18n->get('Users per page description'),
label=>$i18n->get("Users per page label"),
},
alphabet=>{
fieldType=>"text",
defaultValue=>"",
tab=>"display",
label=>$i18n->get("alphabet label"),
hoverHelp=>$i18n->get('alphabet description'),
},
showOnlyVisibleAsNamed=>{
fieldType=>"yesNo",
defaultValue=>"0",
tab=>"display",
label=>$i18n->get("showOnlyVisibleAsNamed label"),
hoverHelp=>$i18n->get('showOnlyVisibleAsNamed description'),
},
);
showGroupId=>{
fieldType=>"group",
defaultValue=>"7",
label=>$i18n->get("Group to show label"),
hoverHelp=>$i18n->get('Group to show description'),
tab=>"display",
},
hideGroupId=>{
fieldType=>"group",
defaultValue=>"3",
label=>$i18n->get("Group to hide label"),
hoverHelp=>$i18n->get('Group to hide description'),
tab=>"display",
},
usersPerPage=>{
fieldType=>"integer",
defaultValue=>"25",
tab=>"display",
hoverHelp=>$i18n->get('Users per page description'),
label=>$i18n->get("Users per page label"),
},
alphabet=>{
fieldType=>"text",
defaultValue=>"",
tab=>"display",
label=>$i18n->get("alphabet label"),
hoverHelp=>$i18n->get('alphabet description'),
},
showOnlyVisibleAsNamed=>{
fieldType=>"yesNo",
defaultValue=>"0",
tab=>"display",
label=>$i18n->get("showOnlyVisibleAsNamed label"),
hoverHelp=>$i18n->get('showOnlyVisibleAsNamed description'),
},
);
push(@{$definition}, {
assetName=>$i18n->get('assetName'),
@ -152,23 +152,6 @@ sub definition {
#-------------------------------------------------------------------
=head2 getEditForm ( )
Returns a tab form containing the properties of this wobject.
=cut
sub getEditForm {
my $self = shift;
my $tabform = $self->SUPER::getEditForm();
my $i18n = WebGUI::International->new($self->session, "Asset_UserList");
return $tabform;
}
#-------------------------------------------------------------------
=head2 isInGroup ( [ groupId ] )
Returns a boolean (0|1) value signifying that the user has the required privileges. Always returns true for Admins.
@ -187,8 +170,6 @@ sub isInGroup {
my ($self, $gid, $uid, $secondRun) = @_;
$gid = 3 unless (defined $gid);
### The following several checks are to increase performance. If this section were removed, everything would continue to work as normal.
#my $eh = $self->session->errorHandler;
#$eh->warn("Group Id is: $gid for ".$tgroup->name);
return 1 if ($gid eq '7'); # everyone is in the everyone group
return 1 if ($gid eq '1' && $uid eq '1'); # visitors are in the visitors group
return 1 if ($gid eq '2' && $uid ne '1'); # if you're not a visitor, then you're a registered user
@ -223,15 +204,17 @@ See WebGUI::Asset::prepareView() for details.
=cut
sub prepareView {
my $self = shift;
$self->SUPER::prepareView();
my $templateId = $self->get("templateId");
if ($self->session->form->process("overrideTemplateId") ne "") {
$templateId = $self->session->form->process("overrideTemplateId");
}
my $template = WebGUI::Asset::Template->new($self->session, $templateId);
$template->prepare;
$self->{_viewTemplate} = $template;
my $self = shift;
$self->SUPER::prepareView();
my $templateId = $self->get("templateId");
if ($self->session->form->process("overrideTemplateId") ne "") {
$templateId = $self->session->form->process("overrideTemplateId");
}
my $template = WebGUI::Asset::Template->new($self->session, $templateId);
$template->prepare;
$self->{_viewTemplate} = $template;
return undef;
}
#-------------------------------------------------------------------
@ -405,9 +388,9 @@ sub view {
$p->appendTemplateVars(\%var);
$var{searchFormHeader} = WebGUI::Form::formHeader($self->session,{action => $self->getUrl});
$var{'searchFormTypeOr'} = WebGUI::Form::hidden($self->session, {name=>'searchType', value=>'or'});
$var{'searchFormTypeAnd'} = WebGUI::Form::hidden($self->session, {name=>'searchType', value=>'and'});
$var{'searchFormTypeSelect'} = WebGUI::Form::selectBox($self->session,{
$var{searchFormTypeOr} = WebGUI::Form::hidden($self->session, {name=>'searchType', value=>'or'});
$var{searchFormTypeAnd} = WebGUI::Form::hidden($self->session, {name=>'searchType', value=>'and'});
$var{searchFormTypeSelect} = WebGUI::Form::selectBox($self->session,{
name=>'searchType',
value=>'or',
options=> {
@ -416,15 +399,15 @@ sub view {
}
});
$var{'searchFormQuery_label'} = $i18n->get('query label');
$var{'searchFormQuery_form'} = WebGUI::Form::text($self->session,{
$var{searchFormQuery_label} = $i18n->get('query label');
$var{searchFormQuery_form} = WebGUI::Form::text($self->session,{
name=>'search',
value=>$self->session->form->process("search"),
});
$var{searchFormSubmit} = WebGUI::Form::submit($self->session,{value => $i18n->get('submit search label')});
$var{searchFormFooter} = WebGUI::Form::formFooter($self->session);
$var{alphabetSearchLoop} = $self->getAlphabetSearchLoop("lastName",$self->get("alphabet"));
$var{alphabetSearch_loop} = $self->getAlphabetSearchLoop("lastName",$self->get("alphabet"));
# $error->info("global tmpl_vars created, time :".(time() - $start_time));
my $out = $self->processTemplate(\%var,$self->get("templateId"));

View file

@ -0,0 +1,81 @@
package WebGUI::Help::Asset_UserList;
our $HELP = {
'userlist template' => {
title => 'UserList Template',
body => 'UserList Template Help Body',
isa => [
{ namespace => "Asset_UserList",
tag => "userlist asset template variables"
},
{ namespace => "Asset_Template",
tag => "template variables"
},
{ namespace => "Asset",
tag => "asset template"
},
{ tag => 'pagination template variables',
namespace => 'WebGUI'
},
],
variables => [
{ 'name' => 'searchFormHeader' },
{ 'name' => 'searchFormSubmit' },
{ 'name' => 'searchFormFooter' },
{ 'name' => 'searchFormTypeOr' },
{ 'name' => 'searchFormTypeAnd' },
{ 'name' => 'searchFormTypeSelect' },
{ 'name' => 'searchFormQuery_form' },
{ 'name' => 'numberOfProfileFields' },
{ 'name' => 'profileField_loop',
'variables' => [
{ 'name' => 'profileField_label' },
],
},
{ 'name' => 'alphabetSearch_loop',
'variables' => [
{ 'name' => 'alphabetSearch_loop_label' },
{ 'name' => 'alphabetSearch_loop_hasResults' },
{ 'name' => 'alphabetSearch_loop_searchURL' },
],
},
{ 'name' => 'user_loop',
'variables' => [
{ 'name' => 'user_name' },
{ 'name' => 'user_id' },
{ 'name' => 'user_profile_PROFILEFIELDNAME_value' },
{ 'name' => 'user_profile_emailNotPublic' },
{ 'name' => 'user_profile_loop',
'variables' => [
{ 'name' => 'profile_emailNotPublic' },
{ 'name' => 'profile_value' },
],
},
],
},
],
related => []
},
'userlist asset template variables' => {
private => 1,
title => 'UserList Template',
body => 'UserList Template Help Body',
isa => [
{ namespace => "Asset_Wobject",
tag => "wobject template variables",
},
],
variables => [
{ 'name' => 'alphabet' },
{ 'name' => 'showGroupId' },
{ 'name' => 'hideGroupId' },
{ 'name' => 'usersPerPage' },
{ 'name' => 'templateId' },
{ 'name' => 'showOnlyVisibleAsNamed' },
],
related => []
},
};
1;

View file

@ -21,6 +21,16 @@ our $I18N = {
lastUpdated => 1081514049
},
'templateId' => {
message => q|The ID of the template used to display the UserList Asset.|,
lastUpdated => 1168897708,
},
'showGroupId' => {
message => q|Only users that are in this group will be shown.|,
lastUpdated => 1081514049
},
'Group to show label' => {
message => q|Group to show|,
lastUpdated => 1081514049
@ -32,6 +42,11 @@ our $I18N = {
lastUpdated => 1081514049
},
'hideGroupId' => {
message => q|Users in this group will be hidden.|,
lastUpdated => 1081514049
},
'Group to hide label' => {
message => q|Group to hide|,
lastUpdated => 1081514049
@ -42,6 +57,11 @@ our $I18N = {
lastUpdated => 1081514049
},
'usersPerPage' => {
message => q|The number of users per page|,
lastUpdated => 1081514049
},
'Users per page label' => {
message => q|Users per page|,
lastUpdated => 1081514049
@ -52,6 +72,12 @@ our $I18N = {
lastUpdated => 1081514049
},
'showOnlyVisibleAsNamed' => {
message => q|Boolean. If true then only fields that are set to 'visible' in the user profile settings
will be available as named tmpl_vars|,
lastUpdated => 1081514049
},
'showOnlyVisibleAsNamed label' => {
message => q|Show only visible fields as named tmpl_vars|,
lastUpdated => 1081514049
@ -63,6 +89,12 @@ will be available as named tmpl_vars|,
lastUpdated => 1081514049
},
'alphabet' => {
message => q|The alphabet that is used for the alphabet search. This is a string of comma
seperated values|,
lastUpdated => 1081514049
},
'alphabet label' => {
message => q|Alphabet|,
lastUpdated => 1081514049
@ -105,6 +137,119 @@ seperated values|,
},
'searchFormHeader' => {
message => q|The header tag for the search form.|,
lastUpdated => 1081514049
},
'searchFormSubmit' => {
message => q|The submit form element for the search form|,
lastUpdated => 1081514049
},
'searchFormFooter' => {
message => q|The footer tag for the search form|,
lastUpdated => 1081514049
},
'searchFormTypeOr' => {
message => q|A hidden form element to set the search type to 'or'.|,
lastUpdated => 1081514049
},
'searchFormTypeAnd' => {
message => q|A hidden form element to set the search type to 'and'.|,
lastUpdated => 1081514049
},
'searchFormTypeSelect' => {
message => q|A select box to let the user select the search type.|,
lastUpdated => 1081514049
},
'searchFormQuery_form' => {
message => q|A text input for the search query.|,
lastUpdated => 1081514049
},
'numberOfProfileFields' => {
message => q|The number of profile fields.|,
lastUpdated => 1081514049
},
'alphabetSearch_loop' => {
message => q|A loop that contains elements to create an alphabetical search.|,
lastUpdated => 1081514049
},
'alphabetSearch_loop_label' => {
message => q|The label for this alphabet search query. Usually one letter of the alphabet.|,
lastUpdated => 1081514049
},
'alphabetSearch_loop_hasResults' => {
message => q|A conditional that is true if there are any results for this alphabet query.|,
lastUpdated => 1081514049
},
'alphabetSearch_loop_searchURL' => {
message => q|The url to do an alphabet search on this query.|,
lastUpdated => 1081514049
},
'user_loop' => {
message => q|A loop containing the users that are listed by the UserList.|,
lastUpdated => 1081514049
},
'user_name' => {
message => q|The username of the user.|,
lastUpdated => 1081514049
},
'user_id' => {
message => q|The userId of the user|,
lastUpdated => 1081514049
},
'user_profile_PROFILEFIELDNAME_value' => {
message => q|The value of the profile field with the name PROFILEFIELDNAME in the users user
profile. Example &lt;tmpl_var user_profile_firstName_value&gt;|,
lastUpdated => 1081514049
},
'user_profile_emailNotPublic' => {
message => q|A conditional that is true if the users email address is not public.|,
lastUpdated => 1081514049
},
'user_profile_loop' => {
message => q|A loop containing the users profile fields.|,
lastUpdated => 1081514049
},
'profile_emailNotPublic' => {
message => q|A conditional that is true if the users email address is not public. It will only be
true for the 'email' profile field.|,
lastUpdated => 1081514049
},
'profile_value' => {
message => q|The value of the profile field for this user.|,
lastUpdated => 1081514049
},
'profileField_loop' => {
message => q|A loop contining profile fields|,
lastUpdated => 1081514049
},
'profileField_label' => {
message => q|The label for a profile field|,
lastUpdated => 1081514049
},
};
1;