[Cpan-forum-commit] rev 67 - in trunk: lib/CPAN templates

svn at pti.co.il svn at pti.co.il
Wed Feb 2 21:07:28 IST 2005


Author: gabor
Date: 2005-02-02 21:07:28 +0200 (Wed, 02 Feb 2005)
New Revision: 67

Modified:
   trunk/lib/CPAN/Forum.pm
   trunk/templates/search.tmpl
Log:
make the full text search clearer and provide separate boxes for subject and body

Modified: trunk/lib/CPAN/Forum.pm
===================================================================
--- trunk/lib/CPAN/Forum.pm	2005-02-02 17:45:01 UTC (rev 66)
+++ trunk/lib/CPAN/Forum.pm	2005-02-02 19:07:28 UTC (rev 67)
@@ -1773,12 +1773,36 @@
 Search form and processor.
 
 =cut
+# not in use
+sub small_search {
+	my $self = shift;
+	my $q       = $self->query;
+	my $name    = $q->param("name")    || '';
 
+	if ($name    =~ /(.*)/) { $name    = $1; }
+	
+	my $t = $self->load_tmpl("search.tmpl",
+		associate => $q,
+		loop_context_vars => 1,
+	);
+
+	if ($name) {
+		my $it =  CPAN::Forum::Groups->search_like(name => $name . '%');
+		my $cnt = CPAN::Forum::Groups->sql_count_like("name" =>  $name . '%')->select_val;
+		$t->param(messages => $self->build_listing($it,$cnt));
+	}
+
+	$t->output;
+}
+
+
+# not yet in use
 sub search {
 	my $self = shift;
 
-	my $q = $self->query;
-	my $txt = $q->param("q");
+	my $q       = $self->query;
+	my $subject = $q->param("subject") || '' ;
+	my $text    = $q->param("text")    || '';
 	
 	my $t = $self->load_tmpl("search.tmpl",
 		associate => $q,
@@ -1786,13 +1810,17 @@
 	);
 
 	# kill the taint checking (why do I use taint checking if I kill it then ?)
-	if ($txt =~ /(.*)/) {
-		$txt = $1;
-	}
+	if ($text    =~ /(.*)/) { $text    = $1; }
+	if ($subject =~ /(.*)/) { $subject = $1; }
 
-	if ($txt) {
-		my $it =  CPAN::Forum::Posts->search_like(text => '%' . $txt . '%');
-		my $cnt = CPAN::Forum::Posts->sql_count_like("text", '%' . $txt . '%')->select_val;
+	my %search;
+
+	if ($text)    { $search{text}    = '%' . $text    . '%'; }
+	if ($subject) { $search{subject} = '%' . $subject . '%'; }
+
+	if (%search) {
+		my $it =  CPAN::Forum::Posts->search_like(%search);
+		my $cnt = CPAN::Forum::Posts->sql_count_like(%search)->select_val;
 		$t->param(messages => $self->build_listing($it,$cnt));
 	}
 

Modified: trunk/templates/search.tmpl
===================================================================
--- trunk/templates/search.tmpl	2005-02-02 17:45:01 UTC (rev 66)
+++ trunk/templates/search.tmpl	2005-02-02 19:07:28 UTC (rev 67)
@@ -6,9 +6,14 @@
 <form method="post" action="/search/">
 <p>
 <input type="hidden" name="rm" value="search" />
-<input name="q" value="<TMPL_VAR q>" />
-<input type="submit" value="Search" />
 </p>
+<table>
+<tr><td>Subject:</td><td><input name="subject" value="<TMPL_VAR subject>" /></td></tr>
+<tr><td>Text:</td><td><input name="text" value="<TMPL_VAR text>" /></td></tr>
+</table>
+<p>
+<input type="submit" value="Search Posts" />
+</p>
 </form>
 
 <TMPL_IF q>



More information about the Cpan-forum-commit mailing list