1.1 --- a/system/classes/search.class.php Sun Oct 18 02:05:53 2009 +0100
1.2 +++ b/system/classes/search.class.php Sun Oct 25 22:01:38 2009 +0000
1.3 @@ -2,7 +2,7 @@
1.4
1.5 /* Reminder: always indent with 4 spaces (no tabs). */
1.6 // +---------------------------------------------------------------------------+
1.7 -// | Geeklog 1.6 |
1.8 +// | Geeklog 1.6.1 |
1.9 // +---------------------------------------------------------------------------+
1.10 // | search.class.php |
1.11 // | |
1.12 @@ -342,8 +342,6 @@
1.13 /**
1.14 * Performs search on all stories
1.15 *
1.16 - * @author Tony Bibbs, tony AT geeklog DOT net
1.17 - * @author Sami Barakat, s.m.barakat AT gmail DOT com
1.18 * @access private
1.19 * @return object plugin object
1.20 *
1.21 @@ -425,7 +423,6 @@
1.22 * in this function to allow legacy support to plugins using
1.23 * the old API calls defined versions prior to Geeklog 1.5.1
1.24 *
1.25 - * @author Sami Barakat, s.m.barakat AT gmail DOT com
1.26 * @access public
1.27 * @return string HTML output for search results
1.28 *
1.29 @@ -460,7 +457,7 @@
1.30
1.31 $url = "{$this->_searchURL}&type={$this->_type}&mode=";
1.32 $obj = new ListFactory($url.'search', $_CONF['search_limits'], $_CONF['num_search_results']);
1.33 - $obj->setRowFunction(array($this, 'searchFormatCallBack'));
1.34 + $obj->setRowFunction(array($this, 'searchFormatCallback'));
1.35 $obj->setField('ID', 'id', false);
1.36 $obj->setField('URL', 'url', false);
1.37
1.38 @@ -520,51 +517,62 @@
1.39 {
1.40 if (is_a($result, 'SearchCriteria'))
1.41 {
1.42 + $debug_info = $result->getName() . " using APIv2";
1.43 +
1.44 if ($this->_type != 'all' && $this->_type != $result->getName())
1.45 {
1.46 if ($this->_verbose) {
1.47 - COM_errorLog($result->getName() . " using APIv2. Skipped as type is not " . $this->_type);
1.48 + $new_api++;
1.49 + COM_errorLog("$debug_info. Skipped as type is not " . $this->_type);
1.50 }
1.51 continue;
1.52 }
1.53
1.54 - $debug_info = $result->getName() . " using APIv2 with ";
1.55 -
1.56 - if ($_CONF['search_use_fulltext'] == true && $result->getFTSQL() != '')
1.57 - {
1.58 - $debug_info .= "FULLTEXT. ";
1.59 - $sql = $result->getFTSQL();
1.60 - }
1.61 - else
1.62 - {
1.63 - $debug_info .= "LIKE. ";
1.64 - $sql = $result->getSQL();
1.65 - }
1.66 -
1.67 - $sql = $this->_convertsql($sql);
1.68 -
1.69 - $debug_info .= "SQL = " . print_r($sql,1);
1.70 - if ($this->_verbose) {
1.71 - COM_errorLog($debug_info);
1.72 - }
1.73 -
1.74 $api_results = $result->getResults();
1.75 if (!empty($api_results)) {
1.76 $obj->addResultArray($api_results);
1.77 }
1.78
1.79 - $obj->setQuery($result->getLabel(), $result->getName(), $sql, $result->getRank());
1.80 + $api_callback_func = $result->getCallback();
1.81 + if (!empty($api_callback_func))
1.82 + {
1.83 + $debug_info .= " with Callback Function " . $api_callback_func;
1.84 + $obj->setCallback($result->getLabel(), $result->getName(), $api_callback_func, $result->getRank(), $result->getTotal());
1.85 + }
1.86 + else
1.87 + {
1.88 + if ($_CONF['search_use_fulltext'] == true && $result->getFTSQL() != '')
1.89 + {
1.90 + $debug_info .= " with SQL FULLTEXT. ";
1.91 + $sql = $result->getFTSQL();
1.92 + }
1.93 + else
1.94 + {
1.95 + $debug_info .= " with SQL LIKE. ";
1.96 + $sql = $result->getSQL();
1.97 + }
1.98 +
1.99 + $sql = $this->_convertsql($sql);
1.100 + $debug_info .= "SQL = " . print_r($sql,1);
1.101 + $obj->setQuery($result->getLabel(), $result->getName(), $sql, $result->getRank());
1.102 + }
1.103 +
1.104 $this->_url_rewrite[ $result->getName() ] = $result->UrlRewriteEnable();
1.105 $this->_append_query[ $result->getName() ] = $result->AppendQueryEnable();
1.106 - $new_api++;
1.107 +
1.108 + if ($this->_verbose) {
1.109 + $new_api++;
1.110 + COM_errorLog($debug_info);
1.111 + }
1.112 }
1.113 else if (is_a($result, 'Plugin') && $result->num_searchresults != 0)
1.114 {
1.115 // Some backwards compatibility
1.116 - $debug_info = $result->plugin_name . " using APIv1 with backwards compatibility.";
1.117 - $debug_info .= " Count: " . $result->num_searchresults;
1.118 - $debug_info .= " Headings: " . implode(",", $result->searchheading);
1.119 if ($this->_verbose) {
1.120 + $old_api++;
1.121 + $debug_info = $result->plugin_name . " using APIv1 with backwards compatibility.";
1.122 + $debug_info .= " Count: " . $result->num_searchresults;
1.123 + $debug_info .= " Headings: " . implode(",", $result->searchheading);
1.124 COM_errorLog($debug_info);
1.125 }
1.126
1.127 @@ -617,7 +625,6 @@
1.128
1.129 $obj->addResult($api_results);
1.130 }
1.131 - $old_api++;
1.132 }
1.133 }
1.134
1.135 @@ -673,19 +680,18 @@
1.136 }
1.137
1.138 /**
1.139 - * CallBack function for the ListFactory class
1.140 + * Callback function for the ListFactory class
1.141 *
1.142 * This function gets called by the ListFactory class and formats
1.143 * each row accordingly for example pulling usernames from the
1.144 * users table and displaying a link to their profile.
1.145 *
1.146 - * @author Sami Barakat, s.m.barakat AT gmail DOT com
1.147 * @access public
1.148 * @param array $row An array of plain data to format
1.149 * @return array A reformatted version of the input array
1.150 *
1.151 */
1.152 - function searchFormatCallBack( $preSort, $row )
1.153 + function searchFormatCallback( $preSort, $row )
1.154 {
1.155 global $_CONF, $LANG09;
1.156
1.157 @@ -756,7 +762,6 @@
1.158 * version depending where the text was cut. Works on a
1.159 * word basis, so long words wont get cut.
1.160 *
1.161 - * @author Sami Barakat, s.m.barakat AT gmail DOT com
1.162 * @access private
1.163 * @param string $keyword The word to centre around
1.164 * @param string $text The complete text string
1.165 @@ -879,7 +884,6 @@
1.166 * number of similar heading names. Used for backwards
1.167 * compatibility in the doSearch() function.
1.168 *
1.169 - * @author Sami Barakat, s.m.barakat AT gmail DOT com
1.170 * @access private
1.171 * @param array $headings All the headings
1.172 * @param array $find An array of alternative headings to find
1.173 @@ -907,7 +911,6 @@
1.174 /**
1.175 * Converts the MySQL CONCAT function to the MSSQL equivalent
1.176 *
1.177 - * @author Sami Barakat, s.m.barakat AT gmail DOT com
1.178 * @access private
1.179 * @param string $sql The SQL to convert
1.180 * @return string MSSQL friendly SQL