diff --git a/docs/changelog/6.x.x.txt b/docs/changelog/6.x.x.txt
index 0109cbe51..d9f8ef9e5 100644
--- a/docs/changelog/6.x.x.txt
+++ b/docs/changelog/6.x.x.txt
@@ -5,6 +5,8 @@
- Added a new pluggable templating system. (Thanks to Misja Op de Coul /
E-Wise)
- Added "201" http status to various entity creation responses.
+ - Replaced the old search engine system with a brand new one, that is more
+ powerful, easier to use, and more flexible.
6.8.6
- Added logic to deal with case sensitivity and whitespace problems in LDAP
diff --git a/etc/WebGUI.conf.original b/etc/WebGUI.conf.original
index ea1109d5b..f5a5e19b1 100644
--- a/etc/WebGUI.conf.original
+++ b/etc/WebGUI.conf.original
@@ -138,7 +138,6 @@ assets = WebGUI::Asset::Snippet, \
WebGUI::Asset::Wobject::DataForm, \
WebGUI::Asset::Wobject::EventsCalendar, \
WebGUI::Asset::Wobject::HttpProxy, \
- WebGUI::Asset::Wobject::IndexedSearch, \
WebGUI::Asset::Wobject::MessageBoard, \
WebGUI::Asset::Wobject::Navigation, \
WebGUI::Asset::Wobject::Matrix, \
diff --git a/lib/WebGUI/Asset.pm b/lib/WebGUI/Asset.pm
index bdb0229cf..fd0b783a6 100644
--- a/lib/WebGUI/Asset.pm
+++ b/lib/WebGUI/Asset.pm
@@ -28,6 +28,7 @@ use WebGUI::AdminConsole;
use WebGUI::Cache;
use WebGUI::Form;
use WebGUI::HTMLForm;
+use WebGUI::Search;
use WebGUI::Search::Index;
use WebGUI::TabForm;
use WebGUI::Utility;
@@ -999,6 +1000,247 @@ sub indexContent {
}
+#-------------------------------------------------------------------
+
+=head2 manageAssets ( )
+
+Main page to manage assets. Renders an AdminConsole with a list of assets. If canEdit returns False, renders an insufficient privilege page. Is called by www_manageAssets
+
+=cut
+
+sub manageAssets {
+ my $self = shift;
+ my $i18n = WebGUI::International->new($self->session, "Asset");
+ my $ancestors = $self->getLineage(["self","ancestors"],{returnObjects=>1});
+ my @crumbtrail;
+ foreach my $ancestor (@{$ancestors}) {
+ push(@crumbtrail,''.$ancestor->getTitle.'');
+ }
+ my $output = '
+ ';
+ return $output;
+}
+
+#-------------------------------------------------------------------
+
+=head2 manageAssetsSearch ( )
+
+Returns the interface for searching within the asset manager.
+
+=cut
+
+sub manageAssetsSearch {
+ my $self = shift;
+ my $i18n = WebGUI::International->new($self->session, "Asset");
+ my $output = WebGUI::Form::formHeader($self->session);
+ $output .= WebGUI::Form::text($self->session, { name=>"keywords", value=>$self->session->form->get("keywords")});
+ my %classes = ();
+ tie %classes, "Tie::IxHash";
+ %classes = ("any"=>"Any Class", $self->session->db->buildHash("select distinct(className) from asset"));
+ delete $classes{"WebGUI::Asset"}; # don't want to search for the root asset
+ $output .= WebGUI::Form::selectBox($self->session, {name=>"class", value=>$self->session->form->get("class","selectBox"), defaultValue=>"any", options=>\%classes});
+ $output .= WebGUI::Form::hidden($self->session, {name=>"func", value=>"manageAssets"});
+ $output .= WebGUI::Form::hidden($self->session, {name=>"doit", value=>"1"});
+ $output .= WebGUI::Form::submit($self->session, {value=>"Search"});
+ $output .= WebGUI::Form::formFooter($self->session);
+ return $output unless ($self->session->form->get("doit"));
+ my $class = $self->session->form->get("class") eq "any" ? undef : $self->session->form->get("class");
+ my $assets = WebGUI::Search->new($self->session,0)->search({
+ keywords=>{terms=>[$self->session->form->get("keywords")]},
+ classes=>{terms=>[$class]}
+ })->getAssets;
+ $output .= "
';
+ return $output;
+}
+
#-------------------------------------------------------------------
=head2 new ( session, assetId [, className, revisionDate ] )
@@ -1552,7 +1794,7 @@ sub www_editSave {
=head2 www_manageAssets ( )
-Main page to manage assets. Renders an AdminConsole with a list of assets. If canEdit returns False, renders an insufficient privilege page.
+Main page to manage/search assets. Renders an AdminConsole with a list of assets. If canEdit returns False, renders an insufficient privilege page. Is called by www_manageAssets
=cut
@@ -1563,151 +1805,20 @@ sub www_manageAssets {
$self->session->style->setScript($self->session->config->get("extrasURL").'/contextMenu/contextMenu.js', {type=>"text/javascript"});
$self->session->style->setLink($self->session->config->get("extrasURL").'/assetManager/assetManager.css', {rel=>"stylesheet",type=>"text/css"});
$self->session->style->setScript($self->session->config->get("extrasURL").'/assetManager/assetManager.js', {type=>"text/javascript"});
- my $i18n = WebGUI::International->new($self->session, "Asset");
- my $ancestors = $self->getLineage(["self","ancestors"],{returnObjects=>1});
- my @crumbtrail;
- foreach my $ancestor (@{$ancestors}) {
- push(@crumbtrail,''.$ancestor->getTitle.'');
- }
- my $output = '
- ';
return $self->getAdminConsole->render($output);
}
-
-
#-------------------------------------------------------------------
=head2 www_view ( )
diff --git a/lib/WebGUI/SQL.pm b/lib/WebGUI/SQL.pm
index e8d0fa373..032ebccb8 100644
--- a/lib/WebGUI/SQL.pm
+++ b/lib/WebGUI/SQL.pm
@@ -135,7 +135,7 @@ Builds a hash of data from a series of rows.
=head3 sql
-An SQL query. The query must select at least two columns of data, the first being the key for the hash, the second being the value. If the query selects more than two columns, then the last column will be the value and the remaining columns will be joined together by a colon ":" to form a complex key.
+An SQL query. The query must select at least two columns of data, the first being the key for the hash, the second being the value. If the query selects more than two columns, then the last column will be the value and the remaining columns will be joined together by a colon ":" to form a complex key. If the query selects only one column, then the key and value will be the same.
=cut
@@ -147,7 +147,8 @@ sub buildHash {
$sth = $self->read($sql);
while (@data = $sth->array) {
my $value = pop @data;
- my $key = join(":",@data);
+ my $key = join(":",@data); # if more than two columns is selected, join them together with :
+ $key = $value unless ($key); # if only one column is selected, then it is both the key and the value
$hash{$key} = $value;
}
$sth->finish;
@@ -163,7 +164,7 @@ Builds a hash reference of data from a series of rows.
=head3 sql
-An SQL query. The query must select at least two columns of data, the first being the key for the hash, the second being the value. If the query selects more than two columns, then the last column will be the value and the remaining columns will be joined together by an underscore "_" to form a complex key.
+An SQL query. The query must select at least two columns of data, the first being the key for the hash, the second being the value. If the query selects more than two columns, then the last column will be the value and the remaining columns will be joined together by a colon ":" to form a complex key. If the query selects only one column, then the key and the value will be the same.
=cut
diff --git a/lib/WebGUI/Search.pm b/lib/WebGUI/Search.pm
index d7d00a9e7..b5f7a3d9f 100644
--- a/lib/WebGUI/Search.pm
+++ b/lib/WebGUI/Search.pm
@@ -75,9 +75,10 @@ sub getAssets {
$query .= "(".$self->{_query}.")";
my $rs = $self->session->db->prepare($query);
$rs->execute($self->{_params});
- my @assets;
+ my @assets = ();
while (my ($id, $class, $version) = $rs->array) {
- push(@assets, WebGUI::Asset->new($id, $class, $version));
+ my $asset = WebGUI::Asset->new($self->session, $id, $class, $version);
+ push(@assets, $asset);
}
return \@assets;
}
@@ -237,18 +238,20 @@ sub search {
if ($rules->{lineage}) {
my @phrases = ();
foreach my $lineage (@{$rules->{lineage}{terms}}) {
+ next unless defined $lineage;
push(@params, $lineage."%");
push(@phrases, "lineage like ?");
}
- push(@clauses, join(" or ", @phrases));
+ push(@clauses, join(" or ", @phrases)) if (scalar(@phrases));
}
if ($rules->{classes}) {
my @phrases = ();
foreach my $class (@{$rules->{classes}{terms}}) {
+ next unless defined $class;
push(@params, $class);
push(@phrases, "className=?");
}
- push(@clauses, join(" or ", @phrases));
+ push(@clauses, join(" or ", @phrases)) if (scalar(@phrases));
}
if ($rules->{creationDate}) {
my $start = $rules->{creationDate}{start} || 0;