Index: admin/comments.php
===================================================================
--- admin/comments.php	(revision 178)
+++ admin/comments.php	(revision 506)
@@ -17,7 +17,5 @@
 # Creating filter combo boxes
 # Filter form we'll put in html_block
-$status_combo = array(
-'-' => ''
-);
+$status_combo = array();
 foreach ($core->blog->getAllCommentStatus() as $k => $v) {
 	$status_combo[$v] = (string) $k;
@@ -25,7 +23,6 @@
 
 $type_combo = array(
-'-' => '',
-__('comment') => 'co',
-__('trackback') => 'tb'
+__('comment') => '0',
+__('trackback') => '1'
 );
 
@@ -43,16 +40,4 @@
 
 
-/* Get comments
--------------------------------------------------------- */
-$author = isset($_GET['author']) ?	$_GET['author'] : '';
-$status = isset($_GET['status']) ?		$_GET['status'] : '';
-$type = !empty($_GET['type']) ?		$_GET['type'] : '';
-$sortby = !empty($_GET['sortby']) ?	$_GET['sortby'] : 'comment_dt';
-$order = !empty($_GET['order']) ?		$_GET['order'] : 'desc';
-$ip = !empty($_GET['ip']) ?			$_GET['ip'] : '';
-
-$with_spam = $author || $status || $type || $sortby != 'comment_dt' || $order != 'desc' || $ip;
-
-$show_filters = false;
 
 $page = !empty($_GET['page']) ? (integer) $_GET['page'] : 1;
@@ -65,44 +50,7 @@
 	$nb_per_page = (integer) $_GET['nb'];
 }
-
+$params = new ArrayObject();
 $params['limit'] = array((($page-1)*$nb_per_page),$nb_per_page);
 $params['no_content'] = true;
-
-# Author filter
-if ($author !== '') {
-	$params['q_author'] = $author;
-	$show_filters = true;
-}
-
-# - Type filter
-if ($type == 'tb' || $type == 'co') {
-	$params['comment_trackback'] = ($type == 'tb');
-	$show_filters = true;
-}
-
-# - Status filter
-if ($status !== '' && in_array($status,$status_combo)) {
-	$params['comment_status'] = $status;
-	$show_filters = true;
-} elseif (!$with_spam) {
-	$params['comment_status_not'] = -2;
-}
-
-# - IP filter
-if ($ip) {
-	$params['comment_ip'] = $ip;
-	$show_filters = true;
-}
-
-# Sortby and order filter
-if ($sortby !== '' && in_array($sortby,$sortby_combo)) {
-	if ($order !== '' && in_array($order,$order_combo)) {
-		$params['order'] = $sortby.' '.$order;
-	}
-	
-	if ($sortby != 'comment_dt' || $order != 'desc') {
-		$show_filters = true;
-	}
-}
 
 # Actions combo box
@@ -123,20 +71,49 @@
 $core->callBehavior('adminCommentsActionsCombo',array(&$combo_action));
 
+$filterSet = new dcFilterSet('comments','comments.php');
+
+$authorFilter = new textFilter(
+		'author',__('Author'),'q_author',20,255);
+$filterSet
+	->addFilter(new comboFilter(
+		'status',__('Status'), 'comment_status', $status_combo))
+	->addFilter(new booleanFilter(
+		'type',__('Type'), 'comment_trackback', $type_combo))
+	->addFilter($authorFilter)
+	->addFilter(new textFilter(
+		'ip',__('IP address'),'comment_ip',20,39));
+		
+$core->callBehavior('adminCommentsFilters',$filterSet);
+
+$filterSet->setFormValues($_GET);
+if (isset($_GET['author'])) {
+	$authorFilter->add();
+	$authorFilter->setValue($_GET['author']);
+}
 /* Get comments
 -------------------------------------------------------- */
 try {
+	$nfparams = $params->getArrayCopy();
+	$filtered = $filterSet->applyFilters($params);
+	$core->callBehavior('adminCommentsParams',$params);
 	$comments = $core->blog->getComments($params);
 	$counter = $core->blog->getComments($params,true);
+	if ($filtered) {
+		$totalcounter = $core->blog->getComments($nfparams,true);
+		$page_title = sprintf(__('Comments and Trackacks / %s filtered out of %s'),$counter->f(0),$totalcounter->f(0));
+	} else {
+		$page_title = __('Comments and Trackacks');
+	}
+
 	$comment_list = new adminCommentList($core,$comments,$counter->f(0));
 } catch (Exception $e) {
 	$core->error->add($e->getMessage());
 }
+$filterSet->setColumnsForm($comment_list->getColumnsForm());
 
 /* DISPLAY
 -------------------------------------------------------- */
-$starting_script = dcPage::jsLoad('js/_comments.js');
-if (!$show_filters) {
-	$starting_script .= dcPage::jsLoad('js/filter-controls.js');
-}
+$starting_script = dcPage::jsLoad('js/_comments.js').$filterSet->header();;
+
 # --BEHAVIOR-- adminCommentsHeaders
 $starting_script .= $core->callBehavior('adminCommentsHeaders');
@@ -144,5 +121,5 @@
 dcPage::open(__('Comments and trackbacks'),$starting_script);
 
-echo '<h2>'.html::escapeHTML($core->blog->name).' &rsaquo; '.__('Comments and trackbacks').'</h2>';
+echo '<h2>'.html::escapeHTML($core->blog->name).' &rsaquo; '.$page_title.'</h2>';
 
 if (!$core->error->flag())
@@ -153,43 +130,5 @@
 		__('Filters').'</a></p>';
 	}
-	
-	echo
-	'<form action="comments.php" method="get" id="filters-form">'.
-	'<fieldset><legend>'.__('Filters').'</legend>'.
-	'<div class="three-cols">'.
-	'<div class="col">'.
-	'<label for="type">'.__('Type:').' '.
-	form::combo('type',$type_combo,$type).
-	'</label> '.
-	'<label for="status">'.__('Status:').' '.
-	form::combo('status',$status_combo,$status).
-	'</label>'.
-	'</div>'.
-	
-	'<div class="col">'.
-	'<p><label for="sortby">'.__('Order by:').' '.
-	form::combo('sortby',$sortby_combo,$sortby).
-	'</label> '.
-	'<label for="order">'.__('Sort:').' '.
-	form::combo('order',$order_combo,$order).
-	'</label></p>'.
-	'<p><label for="nb" class="classic">'.	form::field('nb',3,3,$nb_per_page).' '.
-	__('Comments per page').'</label></p>'.
-	'</div>'.
-	
-	'<div class="col">'.
-	'<p><label for="author">'.__('Comment author:').' '.
-	form::field('author',20,255,html::escapeHTML($author)).
-	'</label>'.
-	'<label for="ip">'.__('IP address:').' '.
-	form::field('ip',20,39,html::escapeHTML($ip)).
-	'</label></p>'.
-	'<p><input type="submit" value="'.__('Apply filters').'" /></p>'.
-	'</div>'.
-	
-	'</div>'.
-	'<br class="clear" />'. //Opera sucks
-	'</fieldset>'.
-	'</form>';
+	$filterSet->display();
 	
 	if (!$with_spam) {
Index: admin/posts.php
===================================================================
--- admin/posts.php	(revision 508)
+++ admin/posts.php	(revision 509)
@@ -166,5 +166,5 @@
 $core->callBehavior('adminPostsFilters',$filterSet);
 
-$filterSet->setValues($_GET);
+$filterSet->setFormValues($_GET);
 
 # Get posts
Index: inc/admin/class.dc.filter.php
===================================================================
--- inc/admin/class.dc.filter.php	(revision 453)
+++ inc/admin/class.dc.filter.php	(revision 506)
@@ -91,5 +91,5 @@
 	@param	form_data	<b>array</b>	form values (usually $_GET or $_POST)
 	*/
-	public function setValues ($form_data) {
+	public function setFormValues ($form_data) {
 		$this->hideform = true;
 		if (isset($form_data['clear_filters'])) {
@@ -101,5 +101,5 @@
 		}
 		foreach ($this->filters as $filter) {
-			$filter->setValues ($form_data);
+			$filter->setFormValues ($form_data);
 			if ($filter->isEnabled()) {
 				$this->hideform=false;
@@ -337,5 +337,5 @@
 	@param	$form_data	<b>array</b>	form data
 	*/
-	public function setValues($form_data) {
+	public function setFormValues($form_data) {
 		$count=0;
 		while (isset($form_data[$this->getFieldId($count)])) {
@@ -389,4 +389,12 @@
 	}
 	
+	public function setValues($value) {
+		$this->values = $value;
+	}
+	
+	public function getValue() {
+		return $this->values;
+	}
+	
 }
 
@@ -436,6 +444,6 @@
 	}
 	
-	public function setValues($form_data) {
-		parent::setValues($form_data);
+	public function setFormValues($form_data) {
+		parent::setFormValues($form_data);
 		if (isset($form_data[$this->field_id."_v"])) {
 			$this->verb = ($form_data[$this->field_id."_v"] == 'is') ? 'is' : 'isnot';
@@ -514,3 +522,44 @@
 }
 
+
+class textFilter extends Filter {
+	protected $size;
+	protected $max;
+	
+	public function __construct($id,$desc,$request_param,$size,$max) {
+		parent::__construct($id,$desc,$request_param);
+		$this->options = $options;
+		$this->values=array();
+		$this->size = $size;
+		$this->max = $max;
+	}
+	
+	
+	public function getType() {
+		return "text";
+	}
+	public function add() {
+		parent::add();
+		$this->values[]='';
+	}
+
+	public function getFormFields($pos=0) {
+		return '<span class="'.$labelclass.'">'.$this->desc.'</span>'.
+			form::field($this->getFieldId($pos),$this->size,$this->max,html::escapeHTML($this->values[0]));
+	}
+	
+	public function applyFilter($params) {
+		$params[$this->request_param]=$this->values[0];
+	}
+	
+	public function setValues($value) {
+		parent::setValues(array($value));
+	}
+
+	public function getValue() {
+		$v = parent::getValue();
+		return $v[0];
+	}
+	
+}
 ?>
Index: inc/core/class.dc.blog.php
===================================================================
--- inc/core/class.dc.blog.php	(revision 504)
+++ inc/core/class.dc.blog.php	(revision 506)
@@ -1812,8 +1812,7 @@
 		
 		if (isset($params['comment_status'])) {
-			$strReq .= 'AND comment_status = '.(integer) $params['comment_status'].' ';
-		}
-		
-		if (!empty($params['comment_status_not']))
+			$strReq .= 'AND '.$this->getInParamStr($params,'comment_status','comment_status');
+		} 
+		elseif (!empty($params['comment_status_not'])) // older method, deprecated
 		{
 			$strReq .= 'AND comment_status <> '.(integer) $params['comment_status_not'].' ';
