X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=plugins%2FSphinxSearch%2Fsphinxsearch.php;h=46b5e3e28aa58830a599cb4e3a5e8b337c29e5a3;hb=527ed62f3f1a26ff8abfce26c4fb9d6429e374d4;hp=71f3308281163b9338efc660c3f156e986e61bd1;hpb=1455d60b06df11f7b765040a4195ded288711ae0;p=quix0rs-gnu-social.git diff --git a/plugins/SphinxSearch/sphinxsearch.php b/plugins/SphinxSearch/sphinxsearch.php index 71f3308281..46b5e3e28a 100644 --- a/plugins/SphinxSearch/sphinxsearch.php +++ b/plugins/SphinxSearch/sphinxsearch.php @@ -73,9 +73,39 @@ class SphinxSearch extends SearchEngine function set_sort_mode($mode) { - if ('chron' === $mode) { + switch ($mode) { + case 'chron': $this->sphinx->SetSortMode(SPH_SORT_ATTR_DESC, 'created_ts'); - return $this->target->orderBy('created desc'); + return $this->target->orderBy('id desc'); + break; + case 'reverse_chron': + $this->sphinx->SetSortMode(SPH_SORT_ATTR_ASC, 'created_ts'); + return $this->target->orderBy('id asc'); + break; + case 'nickname_desc': + if ($this->table != 'profile') { + throw new Exception( + 'nickname_desc sort mode can only be use when searching profile.' + ); + } else { + $this->sphinx->SetSortMode(SPH_SORT_ATTR_DESC, 'nickname'); + return $this->target->orderBy('id desc'); + } + break; + case 'nickname_asc': + if ($this->table != 'profile') { + throw new Exception( + 'nickname_desc sort mode can only be use when searching profile.' + ); + } else { + $this->sphinx->SetSortMode(SPH_SORT_ATTR_ASC, 'nickname'); + return $this->target->orderBy('id asc'); + } + break; + default: + $this->sphinx->SetSortMode(SPH_SORT_ATTR_DESC, 'created_ts'); + return $this->target->orderBy('id desc'); + break; } } @@ -91,6 +121,8 @@ class SphinxSearch extends SearchEngine if (preg_match('!^.*?://.*?:.*?@.*?/(.*?)$!', common_config('db', 'database'), $matches)) { return $matches[1]; } - throw new ServerException("Sphinx search could not identify database name"); + + // TRANS: Server exception thrown when a database name cannot be identified. + throw new ServerException(_m("Sphinx search could not identify database name.")); } }