Added some UserList search form tmpl_vars
This commit is contained in:
parent
b398c902e6
commit
043daceb7c
3 changed files with 110 additions and 1 deletions
|
|
@ -70,6 +70,72 @@ sub getAlphabetSearchLoop {
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
|
=head2 getFormElement ( data )
|
||||||
|
|
||||||
|
Returns the form element tied to this field.
|
||||||
|
|
||||||
|
=head3 data
|
||||||
|
|
||||||
|
A hashref containing the properties of this field.
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
sub getFormElement {
|
||||||
|
|
||||||
|
my $self = shift;
|
||||||
|
my $data = shift;
|
||||||
|
my %param;
|
||||||
|
|
||||||
|
$param{name} = $data->{name};
|
||||||
|
my $name = $param{name};
|
||||||
|
$param{value} = $data->{value} || WebGUI::Operation::Shared::secureEval($self->session,$data->{dataDefault});
|
||||||
|
$param{fieldType} = $data->{fieldType};
|
||||||
|
|
||||||
|
if ($data->{fieldType} eq "Checkbox") {
|
||||||
|
$param{value} = ($data->{defaultValue} =~ /checked/xi) ? 1 : "";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (WebGUI::Utility::isIn($data->{fieldType},qw(SelectList CheckList SelectBox Attachments SelectSlider))) {
|
||||||
|
my @defaultValues;
|
||||||
|
if ($self->session->form->param($name)) {
|
||||||
|
@defaultValues = $self->session->form->selectList($name);
|
||||||
|
} else {
|
||||||
|
foreach (split(/\n/x, $data->{value})) {
|
||||||
|
s/\s+$//x; # remove trailing spaces
|
||||||
|
push(@defaultValues, $_);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$param{value} = \@defaultValues;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($data->{possibleValues}){
|
||||||
|
my $values = WebGUI::Operation::Shared::secureEval($self->session,$data->{possibleValues});
|
||||||
|
unless (ref $values eq 'HASH') {
|
||||||
|
if ($self->get('possibleValues') =~ /\S/) {
|
||||||
|
$self->session->errorHandler->warn("Could not get a hash out of possible values for profile field "
|
||||||
|
.$self->getId);
|
||||||
|
}
|
||||||
|
$values = {};
|
||||||
|
}
|
||||||
|
$param{options} = $values;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($data->{fieldType} eq "YesNo") {
|
||||||
|
if ($data->{defaultValue} =~ /yes/xi) {
|
||||||
|
$param{value} = 1;
|
||||||
|
} elsif ($data->{defaultValue} =~ /no/xi) {
|
||||||
|
$param{value} = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
my $formElement = eval { WebGUI::Pluggable::instanciate("WebGUI::Form::". ucfirst $param{fieldType}, "new",
|
||||||
|
[$self->session, \%param ])};
|
||||||
|
return $formElement->toHtml();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
=head2 definition ( properties )
|
=head2 definition ( properties )
|
||||||
|
|
||||||
Defines wobject properties for UserList instances.
|
Defines wobject properties for UserList instances.
|
||||||
|
|
@ -269,7 +335,8 @@ sub view {
|
||||||
}
|
}
|
||||||
|
|
||||||
$sth = $self->session->db->read(
|
$sth = $self->session->db->read(
|
||||||
"SELECT field.fieldName, field.label, field.sequenceNumber, field.visible, field.fieldType "
|
"SELECT field.fieldName, field.label, field.sequenceNumber, field.visible, field.fieldType, "
|
||||||
|
."field.dataDefault, field.possibleValues "
|
||||||
."FROM userProfileField as field "
|
."FROM userProfileField as field "
|
||||||
."left join userProfileCategory as category USING(profileCategoryId) "
|
."left join userProfileCategory as category USING(profileCategoryId) "
|
||||||
."ORDER BY category.sequenceNumber, field.sequenceNumber");
|
."ORDER BY category.sequenceNumber, field.sequenceNumber");
|
||||||
|
|
@ -301,18 +368,29 @@ sub view {
|
||||||
$var{'profileField_'.$fieldName.'_sortByURL'} = $sortByURL;
|
$var{'profileField_'.$fieldName.'_sortByURL'} = $sortByURL;
|
||||||
}
|
}
|
||||||
# create field specific templ_vars for search
|
# create field specific templ_vars for search
|
||||||
|
my %formElementProperties = %{$profileField};
|
||||||
|
|
||||||
|
$formElementProperties{value} = $form->process('search_'.$fieldName);
|
||||||
|
$formElementProperties{name} = 'search_'.$fieldName;
|
||||||
|
$var{'search_'.$fieldName.'_form'} = $self->getFormElement(\%formElementProperties);
|
||||||
$var{'search_'.$fieldName.'_text'} = WebGUI::Form::Text($self->session, {
|
$var{'search_'.$fieldName.'_text'} = WebGUI::Form::Text($self->session, {
|
||||||
-name => 'search_'.$fieldName,
|
-name => 'search_'.$fieldName,
|
||||||
-value => $form->process('search_'.$fieldName),
|
-value => $form->process('search_'.$fieldName),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$formElementProperties{value} = $form->process('search_Exact'.$fieldName);
|
||||||
|
$formElementProperties{name} = 'searchExact_'.$fieldName;
|
||||||
|
$var{'searchExact_'.$fieldName.'_form'} = $self->getFormElement(\%formElementProperties);
|
||||||
$var{'searchExact_'.$fieldName.'_text'} = WebGUI::Form::Text($self->session, {
|
$var{'searchExact_'.$fieldName.'_text'} = WebGUI::Form::Text($self->session, {
|
||||||
-name => 'searchExact_'.$fieldName,
|
-name => 'searchExact_'.$fieldName,
|
||||||
-value => $form->process('searchExact_'.$fieldName),
|
-value => $form->process('searchExact_'.$fieldName),
|
||||||
});
|
});
|
||||||
|
|
||||||
$var{'includeInSearch_'.$fieldName.'_hidden'} = WebGUI::Form::Hidden($self->session, {
|
$var{'includeInSearch_'.$fieldName.'_hidden'} = WebGUI::Form::Hidden($self->session, {
|
||||||
-name => 'includeInSearch_'.$fieldName,
|
-name => 'includeInSearch_'.$fieldName,
|
||||||
-value => '1',
|
-value => '1',
|
||||||
});
|
});
|
||||||
|
|
||||||
$var{'includeInSearch_'.$fieldName.'_checkBox'} = WebGUI::Form::Checkbox($self->session, {
|
$var{'includeInSearch_'.$fieldName.'_checkBox'} = WebGUI::Form::Checkbox($self->session, {
|
||||||
-name => 'includeInSearch_'.$fieldName,
|
-name => 'includeInSearch_'.$fieldName,
|
||||||
-value => '1',
|
-value => '1',
|
||||||
|
|
@ -526,6 +604,8 @@ $config);
|
||||||
showOnlyVisibleAsNamed int(11),
|
showOnlyVisibleAsNamed int(11),
|
||||||
sortBy varchar(128),
|
sortBy varchar(128),
|
||||||
sortOrder varchar(4),
|
sortOrder varchar(4),
|
||||||
|
overridePublicEmail int(11),
|
||||||
|
overridePublicProfile int(11),
|
||||||
PRIMARY KEY (`assetId`,`revisionDate`)
|
PRIMARY KEY (`assetId`,`revisionDate`)
|
||||||
)");
|
)");
|
||||||
my $import = WebGUI::Asset->getImportNode($session);
|
my $import = WebGUI::Asset->getImportNode($session);
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,9 @@ our $HELP = {
|
||||||
{ 'name' => 'searchFormTypeSelect' },
|
{ 'name' => 'searchFormTypeSelect' },
|
||||||
{ 'name' => 'searchFormQuery_form' },
|
{ 'name' => 'searchFormQuery_form' },
|
||||||
{ 'name' => 'search_PROFILEFIELDNAME_text' },
|
{ 'name' => 'search_PROFILEFIELDNAME_text' },
|
||||||
|
{ 'name' => 'search_PROFILEFIELDNAME_form' },
|
||||||
{ 'name' => 'searchExact_PROFILEFIELDNAME_text' },
|
{ 'name' => 'searchExact_PROFILEFIELDNAME_text' },
|
||||||
|
{ 'name' => 'searchExact_PROFILEFIELDNAME_form' },
|
||||||
{ 'name' => 'limitSearch' },
|
{ 'name' => 'limitSearch' },
|
||||||
{ 'name' => 'includeInSearch_PROFILEFIELDNAME_hidden' },
|
{ 'name' => 'includeInSearch_PROFILEFIELDNAME_hidden' },
|
||||||
{ 'name' => 'includeInSearch_PROFILEFIELDNAME_checkBox' },
|
{ 'name' => 'includeInSearch_PROFILEFIELDNAME_checkBox' },
|
||||||
|
|
|
||||||
|
|
@ -135,11 +135,26 @@ seperated values|,
|
||||||
lastUpdated => 1081514049
|
lastUpdated => 1081514049
|
||||||
},
|
},
|
||||||
|
|
||||||
|
'id label' => {
|
||||||
|
message => q|Id|,
|
||||||
|
lastUpdated => 1081514049
|
||||||
|
},
|
||||||
|
|
||||||
|
'username label' => {
|
||||||
|
message => q|Username|,
|
||||||
|
lastUpdated => 1081514049
|
||||||
|
},
|
||||||
|
|
||||||
'query label' => {
|
'query label' => {
|
||||||
message => q|Query|,
|
message => q|Query|,
|
||||||
lastUpdated => 1081514049
|
lastUpdated => 1081514049
|
||||||
},
|
},
|
||||||
|
|
||||||
|
'search in label' => {
|
||||||
|
message => q|Search in:|,
|
||||||
|
lastUpdated => 1081514049
|
||||||
|
},
|
||||||
|
|
||||||
'submit search label' => {
|
'submit search label' => {
|
||||||
message => q|Search|,
|
message => q|Search|,
|
||||||
lastUpdated => 1081514049
|
lastUpdated => 1081514049
|
||||||
|
|
@ -202,12 +217,24 @@ seperated values|,
|
||||||
lastUpdated => 1081514049
|
lastUpdated => 1081514049
|
||||||
},
|
},
|
||||||
|
|
||||||
|
'search_PROFILEFIELDNAME_form' => {
|
||||||
|
message => q|The form element tied to this field to do a normal search in profile field PROFILEFIELDNAME. Example:
|
||||||
|
<tmpl_var search_timeZone_form> will be a select box.|,
|
||||||
|
lastUpdated => 1081514049
|
||||||
|
},
|
||||||
|
|
||||||
'searchExact_PROFILEFIELDNAME_text' => {
|
'searchExact_PROFILEFIELDNAME_text' => {
|
||||||
message => q|A text input to do an exact search in profile field PROFILEFIELDNAME. Example:
|
message => q|A text input to do an exact search in profile field PROFILEFIELDNAME. Example:
|
||||||
<tmpl_var searchExact_email_text>.|,
|
<tmpl_var searchExact_email_text>.|,
|
||||||
lastUpdated => 1081514049
|
lastUpdated => 1081514049
|
||||||
},
|
},
|
||||||
|
|
||||||
|
'searchExact_PROFILEFIELDNAME_form' => {
|
||||||
|
message => q|The form element tied to this field to do an exact search in profile field PROFILEFIELDNAME. Example:
|
||||||
|
<tmpl_var searchExact_email_form>.|,
|
||||||
|
lastUpdated => 1081514049
|
||||||
|
},
|
||||||
|
|
||||||
'limitSearch' => {
|
'limitSearch' => {
|
||||||
message => q|A hidden form element to indicate that the search is limited to certain profile
|
message => q|A hidden form element to indicate that the search is limited to certain profile
|
||||||
fields. Use includeInSearch_PROFILEFIELDNAME_hidden or includeInSearch_PROFILEFIELDNAME_checkBox tmpl_vars to
|
fields. Use includeInSearch_PROFILEFIELDNAME_hidden or includeInSearch_PROFILEFIELDNAME_checkBox tmpl_vars to
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue