* 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
*/
class ConversationAction extends ManagedAction
{
- var $conv = null;
- var $page = null;
- var $notices = null;
+ public $conv = null;
+ public $page = null;
+ public $notices = null;
protected function doPreparation()
{
*
* @return string page title
*/
- function title()
+ public function title()
{
// TRANS: Title for page with a conversion (multiple notices in context).
return _('Conversation');
*
* @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);
$nl = new FullThreadedNoticeList($notices, $this, $this->scoped);
$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;
}
- function getFeeds()
+ public function getFeeds()
{
-
- return array(new Feed(Feed::JSON,
- common_local_url('apiconversation',
- array(
- 'id' => $this->conv->getID(),
- 'format' => 'as')),
- // TRANS: Title for link to notice feed.
- // TRANS: %s is a user nickname.
- _('Conversation feed (Activity Streams JSON)')),
- new Feed(Feed::RSS2,
- common_local_url('apiconversation',
- array(
- 'id' => $this->conv->getID(),
- 'format' => 'rss')),
- // TRANS: Title for link to notice feed.
- // TRANS: %s is a user nickname.
- _('Conversation feed (RSS 2.0)')),
- new Feed(Feed::ATOM,
- common_local_url('apiconversation',
- array(
- 'id' => $this->conv->getID(),
- 'format' => 'atom')),
- // TRANS: Title for link to notice feed.
- // TRANS: %s is a user nickname.
- _('Conversation feed (Atom)')));
+ return [
+ new Feed(Feed::JSON,
+ common_local_url('apiconversation',
+ ['id' => $this->conv->getID(),
+ 'format' => 'as']),
+ // TRANS: Title for link to notice feed.
+ // TRANS: %s is a user nickname.
+ _('Conversation feed (Activity Streams JSON)')
+ ),
+ new Feed(Feed::RSS2,
+ common_local_url('apiconversation',
+ ['id' => $this->conv->getID(),
+ 'format' => 'rss']),
+ // TRANS: Title for link to notice feed.
+ // TRANS: %s is a user nickname.
+ _('Conversation feed (RSS 2.0)')
+ ),
+ new Feed(Feed::ATOM,
+ common_local_url('apiconversation',
+ ['id' => $this->conv->getID(),
+ 'format' => 'atom']),
+ // TRANS: Title for link to notice feed.
+ // TRANS: %s is a user nickname.
+ _('Conversation feed (Atom)')
+ )
+ ];
}
}
-
* @link http://status.net/
*/
-if (!defined('GNUSOCIAL')) { exit(1); }
+if (!defined('GNUSOCIAL')) {
+ exit(1);
+}
require_once INSTALLDIR.'/lib/noticelist.php';
/**
* Notice object to show
*/
- var $notice = null;
+ public $notice = null;
/**
* Profile of the notice object
*/
- var $profile = null;
+ public $profile = null;
/**
* Avatar of the profile of the notice object
*/
- var $avatar = null;
+ public $avatar = null;
/**
* Load attributes based on database arguments
*
* @return success flag
*/
- protected function prepare(array $args=array())
+ protected function prepare(array $args=[])
{
parent::prepare($args);
if ($this->boolean('ajax')) {
} catch (NoResultException $e) {
// Hm, not found.
$deleted = null;
- Event::handle('IsNoticeDeleted', array($id, &$deleted));
+ Event::handle('IsNoticeDeleted', [$id, &$deleted]);
if ($deleted === true) {
// TRANS: Client error displayed trying to show a deleted notice.
throw new ClientException(_('Notice deleted.'), 410);
*
* @return boolean true
*/
- function isReadOnly($args)
+ public function isReadOnly($args)
{
return true;
}
*
* @return int last-modified date as unix timestamp
*/
- function lastModified()
+ public function lastModified()
{
return max(strtotime($this->notice->modified),
strtotime($this->profile->modified),
*
* @return string etag
*/
- function etag()
+ public function etag()
{
$avtime = ($this->avatar) ?
strtotime($this->avatar->modified) : 0;
- return 'W/"' . implode(':', array($this->arg('action'),
- common_user_cache_hash(),
- common_language(),
- $this->notice->id,
- strtotime($this->notice->created),
- strtotime($this->profile->modified),
- $avtime)) . '"';
+ return 'W/"' . implode(':', [$this->arg('action'),
+ common_user_cache_hash(),
+ common_language(),
+ $this->notice->id,
+ strtotime($this->notice->created),
+ strtotime($this->profile->modified),
+ $avtime]) . '"';
}
/**
*
* @return string title of the page
*/
- function title()
+ public function title()
{
return $this->notice->getTitle();
}
*
* @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->show();
$this->elementEnd('ol');
*
* @return void
*/
- function showPageNoticeBlock()
+ public function showPageNoticeBlock()
{
}
- function getFeeds()
+ public function getFeeds()
{
- return array(new Feed(Feed::JSON,
- common_local_url('ApiStatusesShow',
- array(
- 'id' => $this->target->getID(),
- 'format' => 'json')),
- // TRANS: Title for link to single notice representation.
- // TRANS: %s is a user nickname.
- sprintf(_('Single notice (JSON)'))),
- new Feed(Feed::ATOM,
- common_local_url('ApiStatusesShow',
- array(
- 'id' => $this->target->getID(),
- 'format' => 'atom')),
- // TRANS: Title for link to notice feed.
- // TRANS: %s is a user nickname.
- sprintf(_('Single notice (Atom)'))));
+ return [
+ new Feed(Feed::JSON,
+ common_local_url('ApiStatusesShow',
+ ['id' => $this->target->getID(),
+ 'format' => 'json']),
+ // TRANS: Title for link to single notice representation.
+ // TRANS: %s is a user nickname.
+ sprintf(_('Single notice (JSON)'))
+ ),
+ new Feed(Feed::ATOM,
+ common_local_url('ApiStatusesShow',
+ ['id' => $this->target->getID(),
+ 'format' => 'atom']),
+ // TRANS: Title for link to notice feed.
+ // TRANS: %s is a user nickname.
+ sprintf(_('Single notice (Atom)'))
+ )
+ ];
}
/**
*
* @return void
*/
- function extraHead()
+ public function extraHead()
{
// Extras to aid in sharing notices to Facebook
$avatarUrl = $this->profile->avatarUrl(AVATAR_PROFILE_SIZE);
- $this->element('meta', array('property' => 'og:image',
- 'content' => $avatarUrl));
- $this->element('meta', array('property' => 'og:description',
- 'content' => $this->notice->content));
+ $this->element('meta', ['property' => 'og:image',
+ 'content' => $avatarUrl]);
+ $this->element('meta', ['property' => 'og:description',
+ 'content' => $this->notice->content]);
}
}
* @link http://status.net/
*/
-if (!defined('GNUSOCIAL')) { exit(1); }
+if (!defined('GNUSOCIAL')) {
+ exit(1);
+}
/**
* Group directory
*
* @return string Title of the page
*/
- function title()
+ public function title()
{
// @fixme: This looks kinda gross
}
// TRANS: Title for group directory page.
return _m('Group directory');
- } else if ($this->page == 1) {
+ } elseif ($this->page == 1) {
return sprintf(
// TRANS: Title for group directory page when it is filtered.
// TRANS: %s is the filter string.
*
* @return instructions for use
*/
- function getInstructions()
+ public function getInstructions()
{
// TRANS: Page instructions.
return _m("After you join a group you can send messages to all other members\n".
*
* @return boolean true
*/
- function isReadOnly($args)
+ public function isReadOnly($args)
{
return true;
}
*
* @return void
*/
- function showPageNotice()
+ public function showPageNotice()
{
$instr = $this->getInstructions();
$output = common_markup_to_html($instr);
*
* @return void
*/
- function showContent()
+ public function showContent()
{
if (common_logged_in()) {
- $this->elementStart(
- 'p',
- array(
- 'id' => 'new_group'
- )
- );
- $this->element(
- '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->elementStart('p',
+ ['id' => 'new_group']);
+ $this->element('a',
+ ['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->showForm();
- $this->elementStart('div', array('id' => 'profile_directory'));
+ $this->elementStart('div', ['id' => 'profile_directory']);
// @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();
$group = null;
}
}
- $args = array();
+ $args = [];
if (isset($this->q)) {
$args['q'] = $this->q;
} else {
$this->elementEnd('div');
}
- function showForm($error=null)
+ public function showForm($error=null)
{
- $this->elementStart(
- 'form',
- array(
- 'method' => 'get',
- 'id' => 'form_search',
- 'class' => 'form_settings',
- 'action' => common_local_url('groupdirectory')
- )
- );
+ $this->elementStart('form',
+ ['method' => 'get',
+ 'id' => 'form_search',
+ 'class' => 'form_settings',
+ 'action' => common_local_url('groupdirectory')]);
$this->elementStart('fieldset');
$this->input('q', _m('Keyword(s)'), $this->q);
// TRANS: Button text for searching group directory.
- $this->submit('search', _m('BUTTON','Search'));
+ $this->submit('search', _m('BUTTON', 'Search'));
$this->elementEnd('li');
$this->elementEnd('ul');
$this->elementEnd('fieldset');
* Get groups filtered by the current filter, sort key,
* sort order, and page
*/
- function getGroups()
+ public function getGroups()
{
$group = new User_group();
// Disable this to get global group searches
- $group->joinAdd(array('id', 'local_group:group_id'));
+ $group->joinAdd(['id', 'local_group:group_id']);
$order = false;
if (!empty($this->q)) {
- $wheres = array('nickname', 'fullname', 'homepage', 'description', 'location');
+ $wheres = ['nickname', 'fullname', 'homepage', 'description', 'location'];
foreach ($wheres as $where) {
// Double % because of sprintf
$group->whereAdd(sprintf('LOWER(%1$s.%2$s) LIKE LOWER("%%%3$s%%")',
- $group->escapedTableName(), $where,
- $group->escape($this->q)),
- 'OR');
+ $group->escapedTableName(),
+ $where,
+ $group->escape($this->q)),
+ 'OR');
}
$order = sprintf('%1$s.%2$s %3$s',
- $group->escapedTableName(),
- $this->getSortKey('created'),
- $this->reverse ? 'DESC' : 'ASC');
+ $group->escapedTableName(),
+ $this->getSortKey('created'),
+ $this->reverse ? 'DESC' : 'ASC');
} else {
// User is browsing via AlphaNav
- switch($this->filter) {
+ switch ($this->filter) {
case 'all':
// NOOP
break;
case '0-9':
$group->whereAdd(sprintf('LEFT(%1$s.%2$s, 1) BETWEEN %3$s AND %4$s',
- $group->escapedTableName(),
- 'nickname',
- $group->_quote("0"),
- $group->_quote("9")));
+ $group->escapedTableName(),
+ 'nickname',
+ $group->_quote("0"),
+ $group->_quote("9")));
break;
default:
$group->whereAdd(sprintf('LEFT(LOWER(%1$s.%2$s), 1) = %3$s',
- $group->escapedTableName(),
- 'nickname',
- $group->_quote($this->filter)));
+ $group->escapedTableName(),
+ 'nickname',
+ $group->_quote($this->filter)));
}
$order = sprintf('%1$s.%2$s %3$s, %1$s.%4$s ASC',
- $group->escapedTableName(),
- $this->getSortKey('nickname'),
- $this->reverse ? 'DESC' : 'ASC',
- 'nickname');
+ $group->escapedTableName(),
+ $this->getSortKey('nickname'),
+ $this->reverse ? 'DESC' : 'ASC',
+ 'nickname');
}
$offset = ($this->page-1) * PROFILES_PER_PAGE;
*
* @return string a column name for sorting
*/
- function getSortKey($def='created')
+ public function getSortKey($def='created')
{
switch ($this->sort) {
case 'nickname':
/**
* Show a nice message when there's no search results
*/
- function showEmptyListMessage()
+ public function showEmptyListMessage()
{
if (!empty($this->filter) && ($this->filter != 'all')) {
- $this->element(
- 'p',
- 'error',
- sprintf(
- // TRANS: Empty list message for searching group directory.
- // TRANS: %s is the search string.
- _m('No groups starting with %s.'),
- $this->filter
- )
- );
+ $this->element('p',
+ 'error',
+ sprintf(
+ // TRANS: Empty list message for searching group directory.
+ // TRANS: %s is the search string.
+ _m('No groups starting with %s.'),
+ $this->filter));
} else {
// TRANS: Empty list message for searching group directory.
$this->element('p', 'error', _m('No results.'));
}
}
- function showSections()
+ public function showSections()
{
$gbp = new GroupsByPostsSection($this);
$gbp->show();
* @link http://status.net/
*/
-if (!defined('GNUSOCIAL')) { exit(1); }
+if (!defined('GNUSOCIAL')) {
+ exit(1);
+}
/**
* User directory
*
* @return string Title of the page
*/
- function title()
+ public function title()
{
// @todo fixme: This looks kinda gross
}
// TRANS: Page title for user directory.
return _m('User directory');
- } else if ($this->page == 1) {
+ } elseif ($this->page == 1) {
return sprintf(
// TRANS: Page title for user directory. %s is the applied filter.
_m('User directory - %s'),
*
* @return instructions for use
*/
- function getInstructions()
+ public function getInstructions()
{
// TRANS: %%site.name%% is the name of the StatusNet site.
return _m('Search for people on %%site.name%% by their name, '
- . 'location, or interests. Separate the terms by spaces; '
- . ' they must be 3 characters or more.'
- );
+ . 'location, or interests. Separate the terms by spaces; '
+ . ' they must be 3 characters or more.');
}
/**
*
* @return boolean true
*/
- function isReadOnly($args)
+ public function isReadOnly($args)
{
return true;
}
*
* @return void
*/
- function showPageNotice()
+ public function showPageNotice()
{
$instr = $this->getInstructions();
$output = common_markup_to_html($instr);
*
* @return void
*/
- function showContent()
+ public function showContent()
{
$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();
$profile = null;
}
}
- $args = array();
+ $args = [];
if (isset($this->q)) {
$args['q'] = $this->q;
} elseif (isset($this->filter) && $this->filter != 'all') {
if (isset($this->sort)) {
$args['sort'] = $this->sort;
- }
+ }
if (!empty($this->reverse)) {
$args['reverse'] = $this->reverse;
}
);
$this->elementEnd('div');
-
}
- function showForm($error=null)
+ public function showForm($error=null)
{
- $this->elementStart(
- 'form',
- array(
- 'method' => 'get',
- 'id' => 'form_search',
- 'class' => 'form_settings',
- 'action' => common_local_url('userdirectory')
- )
- );
+ $this->elementStart('form',
+ ['method' => 'get',
+ 'id' => 'form_search',
+ 'class' => 'form_settings',
+ 'action' => common_local_url('userdirectory')]);
$this->elementStart('fieldset');
$this->input('q', _m('Keyword(s)'), $this->q);
// TRANS: Button text.
- $this->submit('search', _m('BUTTON','Search'));
+ $this->submit('search', _m('BUTTON', 'Search'));
$this->elementEnd('li');
$this->elementEnd('ul');
$this->elementEnd('fieldset');
* Get users filtered by the current filter, sort key,
* sort order, and page
*/
- function getUsers()
+ public function getUsers()
{
$profile = new Profile();
// 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;
$limit = PROFILES_PER_PAGE + 1;
if (!empty($this->q)) {
- // User is searching via query
- $search_engine = $profile->getSearchEngine('profile');
-
- $mode = 'reverse_chron';
-
- if ($this->sort == 'nickname') {
- if ($this->reverse) {
- $mode = 'nickname_desc';
- } else {
- $mode = 'nickname_asc';
- }
- } else {
- if ($this->reverse) {
- $mode = 'chron';
- }
- }
-
- $search_engine->set_sort_mode($mode);
- $search_engine->limit($offset, $limit);
- $search_engine->query($this->q);
-
- $profile->find();
+ // User is searching via query
+ $search_engine = $profile->getSearchEngine('profile');
+
+ $mode = 'reverse_chron';
+
+ if ($this->sort == 'nickname') {
+ if ($this->reverse) {
+ $mode = 'nickname_desc';
+ } else {
+ $mode = 'nickname_asc';
+ }
+ } else {
+ if ($this->reverse) {
+ $mode = 'chron';
+ }
+ }
+
+ $search_engine->set_sort_mode($mode);
+ $search_engine->limit($offset, $limit);
+ $search_engine->query($this->q);
+
+ $profile->find();
} else {
// User is browsing via AlphaNav
break;
case '0-9':
$profile->whereAdd(sprintf('LEFT(%1$s.%2$s, 1) BETWEEN %3$s AND %4$s',
- $profile->escapedTableName(),
- 'nickname',
- $profile->_quote("0"),
- $profile->_quote("9")));
+ $profile->escapedTableName(),
+ 'nickname',
+ $profile->_quote("0"),
+ $profile->_quote("9")));
break;
default:
$profile->whereAdd(sprintf('LEFT(LOWER(%1$s.%2$s), 1) = %3$s',
- $profile->escapedTableName(),
- 'nickname',
- $profile->_quote($this->filter)));
+ $profile->escapedTableName(),
+ 'nickname',
+ $profile->_quote($this->filter)));
}
$order = sprintf('%1$s.%2$s %3$s, %1$s.%4$s ASC',
- $profile->escapedTableName(),
- $this->getSortKey('nickname'),
- $this->reverse ? 'DESC' : 'ASC',
- 'nickname');
+ $profile->escapedTableName(),
+ $this->getSortKey('nickname'),
+ $this->reverse ? 'DESC' : 'ASC',
+ 'nickname');
$profile->orderBy($order);
$profile->limit($offset, $limit);
*
* @return string a column name for sorting
*/
- function getSortKey($def='nickname')
+ public function getSortKey($def='nickname')
{
switch ($this->sort) {
case 'nickname':
/**
* Show a nice message when there's no search results
*/
- function showEmptyListMessage()
+ public function showEmptyListMessage()
{
if (!empty($this->filter) && ($this->filter != 'all')) {
- $this->element(
- 'p',
- 'error',
- sprintf(
- // TRANS: Empty list message for user directory.
- _m('No users starting with %s'),
- $this->filter
- )
- );
+ $this->element('p',
+ 'error',
+ sprintf(
+ // TRANS: Empty list message for user directory.
+ _m('No users starting with %s'),
+ $this->filter));
} else {
// TRANS: Empty list message for user directory.
$this->element('p', 'error', _m('No results.'));