summaryrefslogtreecommitdiff
path: root/lib/search_engines.php
diff options
context:
space:
mode:
authorEvan Prodromou <evan@prodromou.name>2008-12-23 14:33:23 -0500
committerEvan Prodromou <evan@prodromou.name>2008-12-23 14:33:23 -0500
commit04ef1ba8eee7a9e2a565d7b4b747ef607665d562 (patch)
treed56ac33bd6bfb8f8641cc9f63b0f6af52b6edfb9 /lib/search_engines.php
parenteb2f9c98ac115ce67e9a740b200c832153ffa05c (diff)
change function headers to K&R style
Another huge change, for PEAR code standards compliance. Function headers have to be in K&R style (opening brace on its own line), instead of having the opening brace on the same line as the function and parameters. So, a little perl magic found all the function definitions and move the opening brace to the next line (properly indented... usually). darcs-hash:20081223193323-84dde-a28e36ecc66672c783c2842d12fc11043c13ab28.gz
Diffstat (limited to 'lib/search_engines.php')
-rw-r--r--lib/search_engines.php33
1 files changed, 22 insertions, 11 deletions
diff --git a/lib/search_engines.php b/lib/search_engines.php
index d53d7d8d8..e96570d63 100644
--- a/lib/search_engines.php
+++ b/lib/search_engines.php
@@ -23,19 +23,23 @@ class SearchEngine {
protected $target;
protected $table;
- function __construct($target, $table) {
+ function __construct($target, $table)
+ {
$this->target = $target;
$this->table = $table;
}
- function query($q) {
+ function query($q)
+ {
}
- function limit($offset, $count, $rss = false) {
+ function limit($offset, $count, $rss = false)
+ {
return $this->target->limit($offset, $count);
}
- function set_sort_mode($mode) {
+ function set_sort_mode($mode)
+ {
if ('chron' === $mode)
return $this->target->orderBy('created desc');
}
@@ -45,7 +49,8 @@ class SphinxSearch extends SearchEngine {
private $sphinx;
private $connected;
- function __construct($target, $table) {
+ function __construct($target, $table)
+ {
$fp = @fsockopen(common_config('sphinx', 'server'), common_config('sphinx', 'port'));
if (!$fp) {
$this->connected = false;
@@ -58,11 +63,13 @@ class SphinxSearch extends SearchEngine {
$this->connected = true;
}
- function is_connected() {
+ function is_connected()
+ {
return $this->connected;
}
- function limit($offset, $count, $rss = false) {
+ function limit($offset, $count, $rss = false)
+ {
//FIXME without LARGEST_POSSIBLE, the most recent results aren't returned
// this probably has a large impact on performance
$LARGEST_POSSIBLE = 1e6;
@@ -78,7 +85,8 @@ class SphinxSearch extends SearchEngine {
return $this->target->limit(0, $count);
}
- function query($q) {
+ function query($q)
+ {
$result = $this->sphinx->query($q, $this->table);
if (!isset($result['matches'])) return false;
$id_set = join(', ', array_keys($result['matches']));
@@ -86,7 +94,8 @@ class SphinxSearch extends SearchEngine {
return true;
}
- function set_sort_mode($mode) {
+ function set_sort_mode($mode)
+ {
if ('chron' === $mode) {
$this->sphinx->SetSortMode(SPH_SORT_ATTR_DESC, 'created_ts');
return $this->target->orderBy('created desc');
@@ -95,7 +104,8 @@ class SphinxSearch extends SearchEngine {
}
class MySQLSearch extends SearchEngine {
- function query($q) {
+ function query($q)
+ {
if ('identica_people' === $this->table)
return $this->target->whereAdd('MATCH(nickname, fullname, location, bio, homepage) ' .
'against (\''.addslashes($q).'\')');
@@ -106,7 +116,8 @@ class MySQLSearch extends SearchEngine {
}
class PGSearch extends SearchEngine {
- function query($q) {
+ function query($q)
+ {
if ('identica_people' === $this->table)
return $this->target->whereAdd('textsearch @@ plainto_tsquery(\''.addslashes($q).'\')');
if ('identica_notices' === $this->table)