PSR2-format

This commit is contained in:
brunoccast 2019-06-02 13:46:39 +01:00 committed by Diogo Cordeiro
parent ab24f59660
commit 691df04103
4 changed files with 203 additions and 215 deletions

View File

@ -28,7 +28,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
if (!defined('GNUSOCIAL')) { exit(1); } if (!defined('GNUSOCIAL')) {
exit(1);
}
/** /**
* Conversation tree in the browser * Conversation tree in the browser
@ -45,9 +47,9 @@ if (!defined('GNUSOCIAL')) { exit(1); }
*/ */
class ConversationAction extends ManagedAction class ConversationAction extends ManagedAction
{ {
var $conv = null; public $conv = null;
var $page = null; public $page = null;
var $notices = null; public $notices = null;
protected function doPreparation() protected function doPreparation()
{ {
@ -59,7 +61,7 @@ class ConversationAction extends ManagedAction
* *
* @return string page title * @return string page title
*/ */
function title() public function title()
{ {
// TRANS: Title for page with a conversion (multiple notices in context). // TRANS: Title for page with a conversion (multiple notices in context).
return _('Conversation'); return _('Conversation');
@ -72,48 +74,48 @@ class ConversationAction extends ManagedAction
* *
* @return void * @return void
*/ */
function showContent() public function showContent()
{ {
if (Event::handle('StartShowConversation', array($this, $this->conv, $this->scoped))) { if (Event::handle('StartShowConversation', [$this, $this->conv, $this->scoped])) {
$notices = $this->conv->getNotices($this->scoped); $notices = $this->conv->getNotices($this->scoped);
$nl = new FullThreadedNoticeList($notices, $this, $this->scoped); $nl = new FullThreadedNoticeList($notices, $this, $this->scoped);
$cnt = $nl->show(); $cnt = $nl->show();
} }
Event::handle('EndShowConversation', array($this, $this->conv, $this->scoped)); Event::handle('EndShowConversation', [$this, $this->conv, $this->scoped]);
} }
function isReadOnly($args) public function isReadOnly($args)
{ {
return true; return true;
} }
function getFeeds() public function getFeeds()
{ {
return [
return array(new Feed(Feed::JSON, new Feed(Feed::JSON,
common_local_url('apiconversation', common_local_url('apiconversation',
array( ['id' => $this->conv->getID(),
'id' => $this->conv->getID(), 'format' => 'as']),
'format' => 'as')), // TRANS: Title for link to notice feed.
// TRANS: Title for link to notice feed. // TRANS: %s is a user nickname.
// TRANS: %s is a user nickname. _('Conversation feed (Activity Streams JSON)')
_('Conversation feed (Activity Streams JSON)')), ),
new Feed(Feed::RSS2, new Feed(Feed::RSS2,
common_local_url('apiconversation', common_local_url('apiconversation',
array( ['id' => $this->conv->getID(),
'id' => $this->conv->getID(), 'format' => 'rss']),
'format' => 'rss')), // TRANS: Title for link to notice feed.
// TRANS: Title for link to notice feed. // TRANS: %s is a user nickname.
// TRANS: %s is a user nickname. _('Conversation feed (RSS 2.0)')
_('Conversation feed (RSS 2.0)')), ),
new Feed(Feed::ATOM, new Feed(Feed::ATOM,
common_local_url('apiconversation', common_local_url('apiconversation',
array( ['id' => $this->conv->getID(),
'id' => $this->conv->getID(), 'format' => 'atom']),
'format' => 'atom')), // TRANS: Title for link to notice feed.
// TRANS: Title for link to notice feed. // TRANS: %s is a user nickname.
// TRANS: %s is a user nickname. _('Conversation feed (Atom)')
_('Conversation feed (Atom)'))); )
];
} }
} }

View File

@ -27,7 +27,9 @@
* @link http://status.net/ * @link http://status.net/
*/ */
if (!defined('GNUSOCIAL')) { exit(1); } if (!defined('GNUSOCIAL')) {
exit(1);
}
require_once INSTALLDIR.'/lib/noticelist.php'; require_once INSTALLDIR.'/lib/noticelist.php';
@ -45,17 +47,17 @@ class ShownoticeAction extends ManagedAction
/** /**
* Notice object to show * Notice object to show
*/ */
var $notice = null; public $notice = null;
/** /**
* Profile of the notice object * Profile of the notice object
*/ */
var $profile = null; public $profile = null;
/** /**
* Avatar of the profile of the notice object * Avatar of the profile of the notice object
*/ */
var $avatar = null; public $avatar = null;
/** /**
* Load attributes based on database arguments * Load attributes based on database arguments
@ -66,7 +68,7 @@ class ShownoticeAction extends ManagedAction
* *
* @return success flag * @return success flag
*/ */
protected function prepare(array $args=array()) protected function prepare(array $args=[])
{ {
parent::prepare($args); parent::prepare($args);
if ($this->boolean('ajax')) { if ($this->boolean('ajax')) {
@ -122,7 +124,7 @@ class ShownoticeAction extends ManagedAction
} catch (NoResultException $e) { } catch (NoResultException $e) {
// Hm, not found. // Hm, not found.
$deleted = null; $deleted = null;
Event::handle('IsNoticeDeleted', array($id, &$deleted)); Event::handle('IsNoticeDeleted', [$id, &$deleted]);
if ($deleted === true) { if ($deleted === true) {
// TRANS: Client error displayed trying to show a deleted notice. // TRANS: Client error displayed trying to show a deleted notice.
throw new ClientException(_('Notice deleted.'), 410); throw new ClientException(_('Notice deleted.'), 410);
@ -137,7 +139,7 @@ class ShownoticeAction extends ManagedAction
* *
* @return boolean true * @return boolean true
*/ */
function isReadOnly($args) public function isReadOnly($args)
{ {
return true; return true;
} }
@ -150,7 +152,7 @@ class ShownoticeAction extends ManagedAction
* *
* @return int last-modified date as unix timestamp * @return int last-modified date as unix timestamp
*/ */
function lastModified() public function lastModified()
{ {
return max(strtotime($this->notice->modified), return max(strtotime($this->notice->modified),
strtotime($this->profile->modified), strtotime($this->profile->modified),
@ -166,18 +168,18 @@ class ShownoticeAction extends ManagedAction
* *
* @return string etag * @return string etag
*/ */
function etag() public function etag()
{ {
$avtime = ($this->avatar) ? $avtime = ($this->avatar) ?
strtotime($this->avatar->modified) : 0; strtotime($this->avatar->modified) : 0;
return 'W/"' . implode(':', array($this->arg('action'), return 'W/"' . implode(':', [$this->arg('action'),
common_user_cache_hash(), common_user_cache_hash(),
common_language(), common_language(),
$this->notice->id, $this->notice->id,
strtotime($this->notice->created), strtotime($this->notice->created),
strtotime($this->profile->modified), strtotime($this->profile->modified),
$avtime)) . '"'; $avtime]) . '"';
} }
/** /**
@ -185,7 +187,7 @@ class ShownoticeAction extends ManagedAction
* *
* @return string title of the page * @return string title of the page
*/ */
function title() public function title()
{ {
return $this->notice->getTitle(); return $this->notice->getTitle();
} }
@ -197,9 +199,9 @@ class ShownoticeAction extends ManagedAction
* *
* @return void * @return void
*/ */
function showContent() public function showContent()
{ {
$this->elementStart('ol', array('class' => 'notices xoxo')); $this->elementStart('ol', ['class' => 'notices xoxo']);
$nli = new NoticeListItem($this->notice, $this); $nli = new NoticeListItem($this->notice, $this);
$nli->show(); $nli->show();
$this->elementEnd('ol'); $this->elementEnd('ol');
@ -210,28 +212,30 @@ class ShownoticeAction extends ManagedAction
* *
* @return void * @return void
*/ */
function showPageNoticeBlock() public function showPageNoticeBlock()
{ {
} }
function getFeeds() public function getFeeds()
{ {
return array(new Feed(Feed::JSON, return [
common_local_url('ApiStatusesShow', new Feed(Feed::JSON,
array( common_local_url('ApiStatusesShow',
'id' => $this->target->getID(), ['id' => $this->target->getID(),
'format' => 'json')), 'format' => 'json']),
// TRANS: Title for link to single notice representation. // TRANS: Title for link to single notice representation.
// TRANS: %s is a user nickname. // TRANS: %s is a user nickname.
sprintf(_('Single notice (JSON)'))), sprintf(_('Single notice (JSON)'))
new Feed(Feed::ATOM, ),
common_local_url('ApiStatusesShow', new Feed(Feed::ATOM,
array( common_local_url('ApiStatusesShow',
'id' => $this->target->getID(), ['id' => $this->target->getID(),
'format' => 'atom')), 'format' => 'atom']),
// TRANS: Title for link to notice feed. // TRANS: Title for link to notice feed.
// TRANS: %s is a user nickname. // TRANS: %s is a user nickname.
sprintf(_('Single notice (Atom)')))); sprintf(_('Single notice (Atom)'))
)
];
} }
/** /**
@ -241,13 +245,13 @@ class ShownoticeAction extends ManagedAction
* *
* @return void * @return void
*/ */
function extraHead() public function extraHead()
{ {
// Extras to aid in sharing notices to Facebook // Extras to aid in sharing notices to Facebook
$avatarUrl = $this->profile->avatarUrl(AVATAR_PROFILE_SIZE); $avatarUrl = $this->profile->avatarUrl(AVATAR_PROFILE_SIZE);
$this->element('meta', array('property' => 'og:image', $this->element('meta', ['property' => 'og:image',
'content' => $avatarUrl)); 'content' => $avatarUrl]);
$this->element('meta', array('property' => 'og:description', $this->element('meta', ['property' => 'og:description',
'content' => $this->notice->content)); 'content' => $this->notice->content]);
} }
} }

View File

@ -27,7 +27,9 @@
* @link http://status.net/ * @link http://status.net/
*/ */
if (!defined('GNUSOCIAL')) { exit(1); } if (!defined('GNUSOCIAL')) {
exit(1);
}
/** /**
* Group directory * Group directory
@ -81,7 +83,7 @@ class GroupdirectoryAction extends ManagedAction
* *
* @return string Title of the page * @return string Title of the page
*/ */
function title() public function title()
{ {
// @fixme: This looks kinda gross // @fixme: This looks kinda gross
@ -92,7 +94,7 @@ class GroupdirectoryAction extends ManagedAction
} }
// TRANS: Title for group directory page. // TRANS: Title for group directory page.
return _m('Group directory'); return _m('Group directory');
} else if ($this->page == 1) { } elseif ($this->page == 1) {
return sprintf( return sprintf(
// TRANS: Title for group directory page when it is filtered. // TRANS: Title for group directory page when it is filtered.
// TRANS: %s is the filter string. // TRANS: %s is the filter string.
@ -115,7 +117,7 @@ class GroupdirectoryAction extends ManagedAction
* *
* @return instructions for use * @return instructions for use
*/ */
function getInstructions() public function getInstructions()
{ {
// TRANS: Page instructions. // TRANS: Page instructions.
return _m("After you join a group you can send messages to all other members\n". return _m("After you join a group you can send messages to all other members\n".
@ -129,7 +131,7 @@ class GroupdirectoryAction extends ManagedAction
* *
* @return boolean true * @return boolean true
*/ */
function isReadOnly($args) public function isReadOnly($args)
{ {
return true; return true;
} }
@ -152,7 +154,7 @@ class GroupdirectoryAction extends ManagedAction
* *
* @return void * @return void
*/ */
function showPageNotice() public function showPageNotice()
{ {
$instr = $this->getInstructions(); $instr = $this->getInstructions();
$output = common_markup_to_html($instr); $output = common_markup_to_html($instr);
@ -170,32 +172,25 @@ class GroupdirectoryAction extends ManagedAction
* *
* @return void * @return void
*/ */
function showContent() public function showContent()
{ {
if (common_logged_in()) { if (common_logged_in()) {
$this->elementStart( $this->elementStart('p',
'p', ['id' => 'new_group']);
array( $this->element('a',
'id' => 'new_group' ['href' => common_local_url('newgroup'),
) 'class' => 'more'],
); // TRANS: Link to create a new group on the group list page.
$this->element( _m('Create a new group'));
'a',
array(
'href' => common_local_url('newgroup'),
'class' => 'more'),
// TRANS: Link to create a new group on the group list page.
_m('Create a new group')
);
$this->elementEnd('p'); $this->elementEnd('p');
} }
$this->showForm(); $this->showForm();
$this->elementStart('div', array('id' => 'profile_directory')); $this->elementStart('div', ['id' => 'profile_directory']);
// @todo FIXME: Does "All" need i18n here? // @todo FIXME: Does "All" need i18n here?
$alphaNav = new AlphaNav($this, false, false, array('0-9', 'All')); $alphaNav = new AlphaNav($this, false, false, ['0-9', 'All']);
$alphaNav->show(); $alphaNav->show();
$group = null; $group = null;
@ -217,7 +212,7 @@ class GroupdirectoryAction extends ManagedAction
} }
} }
$args = array(); $args = [];
if (isset($this->q)) { if (isset($this->q)) {
$args['q'] = $this->q; $args['q'] = $this->q;
} else { } else {
@ -235,17 +230,13 @@ class GroupdirectoryAction extends ManagedAction
$this->elementEnd('div'); $this->elementEnd('div');
} }
function showForm($error=null) public function showForm($error=null)
{ {
$this->elementStart( $this->elementStart('form',
'form', ['method' => 'get',
array( 'id' => 'form_search',
'method' => 'get', 'class' => 'form_settings',
'id' => 'form_search', 'action' => common_local_url('groupdirectory')]);
'class' => 'form_settings',
'action' => common_local_url('groupdirectory')
)
);
$this->elementStart('fieldset'); $this->elementStart('fieldset');
@ -258,7 +249,7 @@ class GroupdirectoryAction extends ManagedAction
$this->input('q', _m('Keyword(s)'), $this->q); $this->input('q', _m('Keyword(s)'), $this->q);
// TRANS: Button text for searching group directory. // TRANS: Button text for searching group directory.
$this->submit('search', _m('BUTTON','Search')); $this->submit('search', _m('BUTTON', 'Search'));
$this->elementEnd('li'); $this->elementEnd('li');
$this->elementEnd('ul'); $this->elementEnd('ul');
$this->elementEnd('fieldset'); $this->elementEnd('fieldset');
@ -269,55 +260,56 @@ class GroupdirectoryAction extends ManagedAction
* Get groups filtered by the current filter, sort key, * Get groups filtered by the current filter, sort key,
* sort order, and page * sort order, and page
*/ */
function getGroups() public function getGroups()
{ {
$group = new User_group(); $group = new User_group();
// Disable this to get global group searches // Disable this to get global group searches
$group->joinAdd(array('id', 'local_group:group_id')); $group->joinAdd(['id', 'local_group:group_id']);
$order = false; $order = false;
if (!empty($this->q)) { if (!empty($this->q)) {
$wheres = array('nickname', 'fullname', 'homepage', 'description', 'location'); $wheres = ['nickname', 'fullname', 'homepage', 'description', 'location'];
foreach ($wheres as $where) { foreach ($wheres as $where) {
// Double % because of sprintf // Double % because of sprintf
$group->whereAdd(sprintf('LOWER(%1$s.%2$s) LIKE LOWER("%%%3$s%%")', $group->whereAdd(sprintf('LOWER(%1$s.%2$s) LIKE LOWER("%%%3$s%%")',
$group->escapedTableName(), $where, $group->escapedTableName(),
$group->escape($this->q)), $where,
'OR'); $group->escape($this->q)),
'OR');
} }
$order = sprintf('%1$s.%2$s %3$s', $order = sprintf('%1$s.%2$s %3$s',
$group->escapedTableName(), $group->escapedTableName(),
$this->getSortKey('created'), $this->getSortKey('created'),
$this->reverse ? 'DESC' : 'ASC'); $this->reverse ? 'DESC' : 'ASC');
} else { } else {
// User is browsing via AlphaNav // User is browsing via AlphaNav
switch($this->filter) { switch ($this->filter) {
case 'all': case 'all':
// NOOP // NOOP
break; break;
case '0-9': case '0-9':
$group->whereAdd(sprintf('LEFT(%1$s.%2$s, 1) BETWEEN %3$s AND %4$s', $group->whereAdd(sprintf('LEFT(%1$s.%2$s, 1) BETWEEN %3$s AND %4$s',
$group->escapedTableName(), $group->escapedTableName(),
'nickname', 'nickname',
$group->_quote("0"), $group->_quote("0"),
$group->_quote("9"))); $group->_quote("9")));
break; break;
default: default:
$group->whereAdd(sprintf('LEFT(LOWER(%1$s.%2$s), 1) = %3$s', $group->whereAdd(sprintf('LEFT(LOWER(%1$s.%2$s), 1) = %3$s',
$group->escapedTableName(), $group->escapedTableName(),
'nickname', 'nickname',
$group->_quote($this->filter))); $group->_quote($this->filter)));
} }
$order = sprintf('%1$s.%2$s %3$s, %1$s.%4$s ASC', $order = sprintf('%1$s.%2$s %3$s, %1$s.%4$s ASC',
$group->escapedTableName(), $group->escapedTableName(),
$this->getSortKey('nickname'), $this->getSortKey('nickname'),
$this->reverse ? 'DESC' : 'ASC', $this->reverse ? 'DESC' : 'ASC',
'nickname'); 'nickname');
} }
$offset = ($this->page-1) * PROFILES_PER_PAGE; $offset = ($this->page-1) * PROFILES_PER_PAGE;
@ -338,7 +330,7 @@ class GroupdirectoryAction extends ManagedAction
* *
* @return string a column name for sorting * @return string a column name for sorting
*/ */
function getSortKey($def='created') public function getSortKey($def='created')
{ {
switch ($this->sort) { switch ($this->sort) {
case 'nickname': case 'nickname':
@ -352,19 +344,16 @@ class GroupdirectoryAction extends ManagedAction
/** /**
* Show a nice message when there's no search results * Show a nice message when there's no search results
*/ */
function showEmptyListMessage() public function showEmptyListMessage()
{ {
if (!empty($this->filter) && ($this->filter != 'all')) { if (!empty($this->filter) && ($this->filter != 'all')) {
$this->element( $this->element('p',
'p', 'error',
'error', sprintf(
sprintf( // TRANS: Empty list message for searching group directory.
// TRANS: Empty list message for searching group directory. // TRANS: %s is the search string.
// TRANS: %s is the search string. _m('No groups starting with %s.'),
_m('No groups starting with %s.'), $this->filter));
$this->filter
)
);
} else { } else {
// TRANS: Empty list message for searching group directory. // TRANS: Empty list message for searching group directory.
$this->element('p', 'error', _m('No results.')); $this->element('p', 'error', _m('No results.'));
@ -379,7 +368,7 @@ class GroupdirectoryAction extends ManagedAction
} }
} }
function showSections() public function showSections()
{ {
$gbp = new GroupsByPostsSection($this); $gbp = new GroupsByPostsSection($this);
$gbp->show(); $gbp->show();

View File

@ -27,7 +27,9 @@
* @link http://status.net/ * @link http://status.net/
*/ */
if (!defined('GNUSOCIAL')) { exit(1); } if (!defined('GNUSOCIAL')) {
exit(1);
}
/** /**
* User directory * User directory
@ -80,7 +82,7 @@ class UserdirectoryAction extends ManagedAction
* *
* @return string Title of the page * @return string Title of the page
*/ */
function title() public function title()
{ {
// @todo fixme: This looks kinda gross // @todo fixme: This looks kinda gross
@ -91,7 +93,7 @@ class UserdirectoryAction extends ManagedAction
} }
// TRANS: Page title for user directory. // TRANS: Page title for user directory.
return _m('User directory'); return _m('User directory');
} else if ($this->page == 1) { } elseif ($this->page == 1) {
return sprintf( return sprintf(
// TRANS: Page title for user directory. %s is the applied filter. // TRANS: Page title for user directory. %s is the applied filter.
_m('User directory - %s'), _m('User directory - %s'),
@ -113,13 +115,12 @@ class UserdirectoryAction extends ManagedAction
* *
* @return instructions for use * @return instructions for use
*/ */
function getInstructions() public function getInstructions()
{ {
// TRANS: %%site.name%% is the name of the StatusNet site. // TRANS: %%site.name%% is the name of the StatusNet site.
return _m('Search for people on %%site.name%% by their name, ' return _m('Search for people on %%site.name%% by their name, '
. 'location, or interests. Separate the terms by spaces; ' . 'location, or interests. Separate the terms by spaces; '
. ' they must be 3 characters or more.' . ' they must be 3 characters or more.');
);
} }
/** /**
@ -127,7 +128,7 @@ class UserdirectoryAction extends ManagedAction
* *
* @return boolean true * @return boolean true
*/ */
function isReadOnly($args) public function isReadOnly($args)
{ {
return true; return true;
} }
@ -150,7 +151,7 @@ class UserdirectoryAction extends ManagedAction
* *
* @return void * @return void
*/ */
function showPageNotice() public function showPageNotice()
{ {
$instr = $this->getInstructions(); $instr = $this->getInstructions();
$output = common_markup_to_html($instr); $output = common_markup_to_html($instr);
@ -168,13 +169,13 @@ class UserdirectoryAction extends ManagedAction
* *
* @return void * @return void
*/ */
function showContent() public function showContent()
{ {
$this->showForm(); $this->showForm();
$this->elementStart('div', array('id' => 'profile_directory')); $this->elementStart('div', ['id' => 'profile_directory']);
$alphaNav = new AlphaNav($this, false, false, array('0-9', 'All')); $alphaNav = new AlphaNav($this, false, false, ['0-9', 'All']);
$alphaNav->show(); $alphaNav->show();
$profile = null; $profile = null;
@ -196,7 +197,7 @@ class UserdirectoryAction extends ManagedAction
} }
} }
$args = array(); $args = [];
if (isset($this->q)) { if (isset($this->q)) {
$args['q'] = $this->q; $args['q'] = $this->q;
} elseif (isset($this->filter) && $this->filter != 'all') { } elseif (isset($this->filter) && $this->filter != 'all') {
@ -205,7 +206,7 @@ class UserdirectoryAction extends ManagedAction
if (isset($this->sort)) { if (isset($this->sort)) {
$args['sort'] = $this->sort; $args['sort'] = $this->sort;
} }
if (!empty($this->reverse)) { if (!empty($this->reverse)) {
$args['reverse'] = $this->reverse; $args['reverse'] = $this->reverse;
} }
@ -219,20 +220,15 @@ class UserdirectoryAction extends ManagedAction
); );
$this->elementEnd('div'); $this->elementEnd('div');
} }
function showForm($error=null) public function showForm($error=null)
{ {
$this->elementStart( $this->elementStart('form',
'form', ['method' => 'get',
array( 'id' => 'form_search',
'method' => 'get', 'class' => 'form_settings',
'id' => 'form_search', 'action' => common_local_url('userdirectory')]);
'class' => 'form_settings',
'action' => common_local_url('userdirectory')
)
);
$this->elementStart('fieldset'); $this->elementStart('fieldset');
@ -245,7 +241,7 @@ class UserdirectoryAction extends ManagedAction
$this->input('q', _m('Keyword(s)'), $this->q); $this->input('q', _m('Keyword(s)'), $this->q);
// TRANS: Button text. // TRANS: Button text.
$this->submit('search', _m('BUTTON','Search')); $this->submit('search', _m('BUTTON', 'Search'));
$this->elementEnd('li'); $this->elementEnd('li');
$this->elementEnd('ul'); $this->elementEnd('ul');
$this->elementEnd('fieldset'); $this->elementEnd('fieldset');
@ -256,39 +252,39 @@ class UserdirectoryAction extends ManagedAction
* Get users filtered by the current filter, sort key, * Get users filtered by the current filter, sort key,
* sort order, and page * sort order, and page
*/ */
function getUsers() public function getUsers()
{ {
$profile = new Profile(); $profile = new Profile();
// Comment this out or disable to get global profile searches // Comment this out or disable to get global profile searches
$profile->joinAdd(array('id', 'user:id')); $profile->joinAdd(['id', 'user:id']);
$offset = ($this->page - 1) * PROFILES_PER_PAGE; $offset = ($this->page - 1) * PROFILES_PER_PAGE;
$limit = PROFILES_PER_PAGE + 1; $limit = PROFILES_PER_PAGE + 1;
if (!empty($this->q)) { if (!empty($this->q)) {
// User is searching via query // User is searching via query
$search_engine = $profile->getSearchEngine('profile'); $search_engine = $profile->getSearchEngine('profile');
$mode = 'reverse_chron'; $mode = 'reverse_chron';
if ($this->sort == 'nickname') { if ($this->sort == 'nickname') {
if ($this->reverse) { if ($this->reverse) {
$mode = 'nickname_desc'; $mode = 'nickname_desc';
} else { } else {
$mode = 'nickname_asc'; $mode = 'nickname_asc';
} }
} else { } else {
if ($this->reverse) { if ($this->reverse) {
$mode = 'chron'; $mode = 'chron';
} }
} }
$search_engine->set_sort_mode($mode); $search_engine->set_sort_mode($mode);
$search_engine->limit($offset, $limit); $search_engine->limit($offset, $limit);
$search_engine->query($this->q); $search_engine->query($this->q);
$profile->find(); $profile->find();
} else { } else {
// User is browsing via AlphaNav // User is browsing via AlphaNav
@ -298,23 +294,23 @@ class UserdirectoryAction extends ManagedAction
break; break;
case '0-9': case '0-9':
$profile->whereAdd(sprintf('LEFT(%1$s.%2$s, 1) BETWEEN %3$s AND %4$s', $profile->whereAdd(sprintf('LEFT(%1$s.%2$s, 1) BETWEEN %3$s AND %4$s',
$profile->escapedTableName(), $profile->escapedTableName(),
'nickname', 'nickname',
$profile->_quote("0"), $profile->_quote("0"),
$profile->_quote("9"))); $profile->_quote("9")));
break; break;
default: default:
$profile->whereAdd(sprintf('LEFT(LOWER(%1$s.%2$s), 1) = %3$s', $profile->whereAdd(sprintf('LEFT(LOWER(%1$s.%2$s), 1) = %3$s',
$profile->escapedTableName(), $profile->escapedTableName(),
'nickname', 'nickname',
$profile->_quote($this->filter))); $profile->_quote($this->filter)));
} }
$order = sprintf('%1$s.%2$s %3$s, %1$s.%4$s ASC', $order = sprintf('%1$s.%2$s %3$s, %1$s.%4$s ASC',
$profile->escapedTableName(), $profile->escapedTableName(),
$this->getSortKey('nickname'), $this->getSortKey('nickname'),
$this->reverse ? 'DESC' : 'ASC', $this->reverse ? 'DESC' : 'ASC',
'nickname'); 'nickname');
$profile->orderBy($order); $profile->orderBy($order);
$profile->limit($offset, $limit); $profile->limit($offset, $limit);
@ -329,7 +325,7 @@ class UserdirectoryAction extends ManagedAction
* *
* @return string a column name for sorting * @return string a column name for sorting
*/ */
function getSortKey($def='nickname') public function getSortKey($def='nickname')
{ {
switch ($this->sort) { switch ($this->sort) {
case 'nickname': case 'nickname':
@ -343,18 +339,15 @@ class UserdirectoryAction extends ManagedAction
/** /**
* Show a nice message when there's no search results * Show a nice message when there's no search results
*/ */
function showEmptyListMessage() public function showEmptyListMessage()
{ {
if (!empty($this->filter) && ($this->filter != 'all')) { if (!empty($this->filter) && ($this->filter != 'all')) {
$this->element( $this->element('p',
'p', 'error',
'error', sprintf(
sprintf( // TRANS: Empty list message for user directory.
// TRANS: Empty list message for user directory. _m('No users starting with %s'),
_m('No users starting with %s'), $this->filter));
$this->filter
)
);
} else { } else {
// TRANS: Empty list message for user directory. // TRANS: Empty list message for user directory.
$this->element('p', 'error', _m('No results.')); $this->element('p', 'error', _m('No results.'));