[geeklog-cvs] geeklog: Don't display search result info when there is nothing ...

geeklog-cvs at lists.geeklog.net geeklog-cvs at lists.geeklog.net
Mon May 25 09:07:39 EDT 2009


details:   http://project.geeklog.net/cgi-bin/hgweb.cgi/rev/ad57bda59747
changeset: 7055:ad57bda59747
user:      Sami Barakat
date:      Mon May 25 14:06:13 2009 +0100
description:
Don't display search result info when there is nothing to show

diffstat:

 system/classes/listfactory.class.php |  19 +++++++++++++------
 system/classes/search.class.php      |  11 ++++++++---
 2 files changed, 21 insertions(+), 9 deletions(-)

diffs (72 lines):

diff -r 05a6c9cd2a64 -r ad57bda59747 system/classes/listfactory.class.php
--- a/system/classes/listfactory.class.php	Mon May 25 10:18:11 2009 +0200
+++ b/system/classes/listfactory.class.php	Mon May 25 14:06:13 2009 +0100
@@ -426,7 +426,11 @@
                 foreach ($this->_fields as $field)
                 {
                     if (!is_numeric($field['name']) && $field['name'][0] != '_') {
-                        $col[ $field['name'] ] = $A[ $field['name'] ];
+                        if (empty($A[ $field['name'] ])) {
+                            $col[ $field['name'] ] = 'LF_NULL';
+                        } else {
+                            $col[ $field['name'] ] = $A[ $field['name'] ];
+                        }
                     }
                 }
 
@@ -444,7 +448,8 @@
         $direction = $this->_sort_arr['direction'] == 'asc' ? SORT_ASC : SORT_DESC;
         $column = array();
         foreach ($rows_arr as $sortarray) {
-            $column[] = strip_tags($sortarray[ $this->_sort_arr['field'] ]);
+            $tmp = strip_tags($sortarray[ $this->_sort_arr['field'] ]);
+            $column[] = ($tmp == 'LF_NULL' ? 0 : $tmp);
         }
         array_multisort($column, $direction, $rows_arr);
 
@@ -598,11 +603,13 @@
                         $fieldvalue = $row[ $field['name'] ];
                     }
 
-                    $fieldvalue = sprintf($field['format'], $fieldvalue, $field['title']);
+                    if ($fieldvalue != 'LF_NULL') {
+                        $fieldvalue = sprintf($field['format'], $fieldvalue, $field['title']);
 
-                    // Write field
-                    $list_templates->set_var('field_text', $fieldvalue);
-                    $list_templates->parse('item_field', 'field', true);
+                        // Write field
+                        $list_templates->set_var('field_text', $fieldvalue);
+                        $list_templates->parse('item_field', 'field', true);
+                    }
                 }
             }
 
diff -r 05a6c9cd2a64 -r ad57bda59747 system/classes/search.class.php
--- a/system/classes/search.class.php	Mon May 25 10:18:11 2009 +0200
+++ b/system/classes/search.class.php	Mon May 25 14:06:13 2009 +0100
@@ -750,8 +750,13 @@
                 $row['description'] = stripslashes($this->_shortenText($this->_query, $row['description'], $this->_wordlength));
             }
 
-            $row['date'] = strftime($_CONF['daytime'], intval($row['date']));
-            $row['hits'] = COM_NumberFormat($row['hits']) . ' '; // simple solution to a silly problem!
+            if ($row['date'] != 'LF_NULL') {
+                $row['date'] = strftime($_CONF['daytime'], intval($row['date']));
+            }
+
+            if ($row['hits'] != 'LF_NULL') {
+                $row['hits'] = COM_NumberFormat($row['hits']) . ' '; // simple solution to a silly problem!
+            }
         }
 
         return $row;
@@ -894,7 +899,7 @@
     *
     * @param   string  $haystack  string to search in
     * @param   string  $needle    string to search for
-    * @return  mixed              first pos of $needle in $haystack, or false 
+    * @return  mixed              first pos of $needle in $haystack, or false
     *
     */
     function _stripos($haystack, $needle)



More information about the geeklog-cvs mailing list