[DATABASE] Consistently use the "LIMIT $limit OFFSET $offset" syntax
The "LIMIT $offset, $limit" syntax is only supported by MySQL and MariaDB.
This commit is contained in:
parent
60ada8ae65
commit
9d87c37ac1
|
@ -1,55 +1,45 @@
|
||||||
<?php
|
<?php
|
||||||
|
// This file is part of GNU social - https://www.gnu.org/software/social
|
||||||
|
//
|
||||||
|
// GNU social is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// GNU social is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with GNU social. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* StatusNet, the distributed open-source microblogging tool
|
|
||||||
*
|
|
||||||
* Show the newest groups
|
* Show the newest groups
|
||||||
*
|
*
|
||||||
* PHP version 5
|
|
||||||
*
|
|
||||||
* LICENCE: This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Affero General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Affero General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
* @category API
|
* @category API
|
||||||
* @package StatusNet
|
* @package GNUsocial
|
||||||
* @author Craig Andrews <candrews@integralblue.com>
|
* @author Craig Andrews <candrews@integralblue.com>
|
||||||
* @author Evan Prodromou <evan@status.net>
|
* @author Evan Prodromou <evan@status.net>
|
||||||
* @author Jeffery To <jeffery.to@gmail.com>
|
* @author Jeffery To <jeffery.to@gmail.com>
|
||||||
* @author Zach Copley <zach@status.net>
|
* @author Zach Copley <zach@status.net>
|
||||||
* @copyright 2009 StatusNet, Inc.
|
* @copyright 2009 StatusNet, Inc.
|
||||||
* @copyright 2009 Free Software Foundation, Inc http://www.fsf.org
|
* @copyright 2009 Free Software Foundation, Inc http://www.fsf.org
|
||||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||||
* @link http://status.net/
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('STATUSNET')) {
|
defined('GNUSOCIAL') || die();
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns of the lastest 20 groups for the site
|
* Returns of the lastest 20 groups for the site
|
||||||
*
|
*
|
||||||
* @category API
|
* @copyright 2009 StatusNet, Inc.
|
||||||
* @package StatusNet
|
* @copyright 2009 Free Software Foundation, Inc http://www.fsf.org
|
||||||
* @author Craig Andrews <candrews@integralblue.com>
|
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||||
* @author Evan Prodromou <evan@status.net>
|
|
||||||
* @author Jeffery To <jeffery.to@gmail.com>
|
|
||||||
* @author Zach Copley <zach@status.net>
|
|
||||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
|
||||||
* @link http://status.net/
|
|
||||||
*/
|
*/
|
||||||
class ApiGroupListAllAction extends ApiPrivateAuthAction
|
class ApiGroupListAllAction extends ApiPrivateAuthAction
|
||||||
{
|
{
|
||||||
var $groups = null;
|
public $groups = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Take arguments for running
|
* Take arguments for running
|
||||||
|
@ -58,7 +48,7 @@ class ApiGroupListAllAction extends ApiPrivateAuthAction
|
||||||
*
|
*
|
||||||
* @return boolean success flag
|
* @return boolean success flag
|
||||||
*/
|
*/
|
||||||
function prepare(array $args = array())
|
public function prepare(array $args = [])
|
||||||
{
|
{
|
||||||
parent::prepare($args);
|
parent::prepare($args);
|
||||||
|
|
||||||
|
@ -77,7 +67,7 @@ class ApiGroupListAllAction extends ApiPrivateAuthAction
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
parent::handle();
|
parent::handle();
|
||||||
|
|
||||||
|
@ -90,7 +80,7 @@ class ApiGroupListAllAction extends ApiPrivateAuthAction
|
||||||
// TRANS: Message is used as a subtitle when listing the latest 20 groups. %s is a site name.
|
// TRANS: Message is used as a subtitle when listing the latest 20 groups. %s is a site name.
|
||||||
$subtitle = sprintf(_("groups on %s"), $sitename);
|
$subtitle = sprintf(_("groups on %s"), $sitename);
|
||||||
|
|
||||||
switch($this->format) {
|
switch ($this->format) {
|
||||||
case 'xml':
|
case 'xml':
|
||||||
$this->showXmlGroups($this->groups);
|
$this->showXmlGroups($this->groups);
|
||||||
break;
|
break;
|
||||||
|
@ -128,21 +118,20 @@ class ApiGroupListAllAction extends ApiPrivateAuthAction
|
||||||
*
|
*
|
||||||
* @return array groups
|
* @return array groups
|
||||||
*/
|
*/
|
||||||
function getGroups()
|
public function getGroups()
|
||||||
{
|
{
|
||||||
$qry = 'SELECT user_group.* '.
|
|
||||||
'from user_group join local_group on user_group.id = local_group.group_id '.
|
|
||||||
'order by created desc ';
|
|
||||||
$offset = intval($this->page - 1) * intval($this->count);
|
|
||||||
$limit = intval($this->count);
|
|
||||||
if (common_config('db', 'type') == 'pgsql') {
|
|
||||||
$qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset;
|
|
||||||
} else {
|
|
||||||
$qry .= ' LIMIT ' . $offset . ', ' . $limit;
|
|
||||||
}
|
|
||||||
$group = new User_group();
|
$group = new User_group();
|
||||||
|
|
||||||
$group->query($qry);
|
$offset = intval($this->page - 1) * intval($this->count);
|
||||||
|
$limit = intval($this->count);
|
||||||
|
|
||||||
|
$group->query(
|
||||||
|
'SELECT user_group.* '.
|
||||||
|
'FROM user_group INNER JOIN local_group ' .
|
||||||
|
'ON user_group.id = local_group.group_id '.
|
||||||
|
'ORDER BY created DESC ' .
|
||||||
|
'LIMIT ' . $limit . ' OFFSET ' . $offset
|
||||||
|
);
|
||||||
|
|
||||||
$groups = array();
|
$groups = array();
|
||||||
while ($group->fetch()) {
|
while ($group->fetch()) {
|
||||||
|
@ -159,7 +148,7 @@ class ApiGroupListAllAction extends ApiPrivateAuthAction
|
||||||
*
|
*
|
||||||
* @return boolean true
|
* @return boolean true
|
||||||
*/
|
*/
|
||||||
function isReadOnly($args)
|
public function isReadOnly($args)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -169,7 +158,7 @@ class ApiGroupListAllAction extends ApiPrivateAuthAction
|
||||||
*
|
*
|
||||||
* @return string datestamp of the site's latest group
|
* @return string datestamp of the site's latest group
|
||||||
*/
|
*/
|
||||||
function lastModified()
|
public function lastModified()
|
||||||
{
|
{
|
||||||
if (!empty($this->groups) && (count($this->groups) > 0)) {
|
if (!empty($this->groups) && (count($this->groups) > 0)) {
|
||||||
return strtotime($this->groups[0]->created);
|
return strtotime($this->groups[0]->created);
|
||||||
|
@ -186,10 +175,9 @@ class ApiGroupListAllAction extends ApiPrivateAuthAction
|
||||||
*
|
*
|
||||||
* @return string etag
|
* @return string etag
|
||||||
*/
|
*/
|
||||||
function etag()
|
public function etag()
|
||||||
{
|
{
|
||||||
if (!empty($this->groups) && (count($this->groups) > 0)) {
|
if (!empty($this->groups) && (count($this->groups) > 0)) {
|
||||||
|
|
||||||
$last = count($this->groups) - 1;
|
$last = count($this->groups) - 1;
|
||||||
|
|
||||||
return '"' . implode(
|
return '"' . implode(
|
||||||
|
|
|
@ -1,53 +1,45 @@
|
||||||
<?php
|
<?php
|
||||||
|
// This file is part of GNU social - https://www.gnu.org/software/social
|
||||||
|
//
|
||||||
|
// GNU social is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// GNU social is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with GNU social. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* StatusNet, the distributed open-source microblogging tool
|
|
||||||
*
|
|
||||||
* Action for showing profiles self-tagged with a given tag
|
* Action for showing profiles self-tagged with a given tag
|
||||||
*
|
*
|
||||||
* PHP version 5
|
|
||||||
*
|
|
||||||
* LICENCE: This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Affero General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Affero General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
* @category Action
|
* @category Action
|
||||||
* @package StatusNet
|
* @package GNUsocial
|
||||||
* @author Evan Prodromou <evan@status.net>
|
* @author Evan Prodromou <evan@status.net>
|
||||||
* @author Zach Copley <zach@status.net>
|
* @author Zach Copley <zach@status.net>
|
||||||
* @copyright 2009 StatusNet, Inc.
|
* @copyright 2009 StatusNet, Inc.
|
||||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||||
* @link http://status.net/
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('STATUSNET') && !defined('LACONICA')) {
|
defined('GNUSOCIAL') || die();
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class outputs a paginated list of profiles self-tagged with a given tag
|
* This class outputs a paginated list of profiles self-tagged with a given tag
|
||||||
*
|
*
|
||||||
* @category Output
|
* @category Output
|
||||||
* @package StatusNet
|
* @copyright 2009 StatusNet, Inc.
|
||||||
* @author Evan Prodromou <evan@status.net>
|
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||||
* @author Zach Copley <zach@status.net>
|
|
||||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
|
||||||
* @link http://status.net/
|
|
||||||
*
|
*
|
||||||
* @see Action
|
* @see Action
|
||||||
*/
|
*/
|
||||||
class SelftagAction extends Action
|
class SelftagAction extends Action
|
||||||
{
|
{
|
||||||
var $tag = null;
|
public $tag = null;
|
||||||
var $page = null;
|
public $page = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* For initializing members of the class.
|
* For initializing members of the class.
|
||||||
|
@ -57,7 +49,7 @@ class SelftagAction extends Action
|
||||||
* @return boolean true
|
* @return boolean true
|
||||||
* @throws ClientException
|
* @throws ClientException
|
||||||
*/
|
*/
|
||||||
function prepare(array $args = [])
|
public function prepare(array $args = [])
|
||||||
{
|
{
|
||||||
parent::prepare($args);
|
parent::prepare($args);
|
||||||
|
|
||||||
|
@ -66,8 +58,10 @@ class SelftagAction extends Action
|
||||||
if (!common_valid_profile_tag($this->tag)) {
|
if (!common_valid_profile_tag($this->tag)) {
|
||||||
// TRANS: Client error displayed when trying to list a profile with an invalid list.
|
// TRANS: Client error displayed when trying to list a profile with an invalid list.
|
||||||
// TRANS: %s is the invalid list name.
|
// TRANS: %s is the invalid list name.
|
||||||
$this->clientError(sprintf(_('Not a valid list: %s.'),
|
$this->clientError(sprintf(
|
||||||
$this->tag));
|
_('Not a valid list: %s.'),
|
||||||
|
$this->tag
|
||||||
|
));
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,7 +77,7 @@ class SelftagAction extends Action
|
||||||
*
|
*
|
||||||
* @return void is read only action?
|
* @return void is read only action?
|
||||||
*/
|
*/
|
||||||
function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
parent::handle();
|
parent::handle();
|
||||||
$this->showPage();
|
$this->showPage();
|
||||||
|
@ -94,19 +88,13 @@ class SelftagAction extends Action
|
||||||
* people tag and page, initalizes a ProfileList widget, and displays
|
* people tag and page, initalizes a ProfileList widget, and displays
|
||||||
* it to the user.
|
* it to the user.
|
||||||
*/
|
*/
|
||||||
function showContent()
|
public function showContent()
|
||||||
{
|
{
|
||||||
$profile = new Profile();
|
$profile = new Profile();
|
||||||
|
|
||||||
$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 (common_config('db', 'type') == 'pgsql') {
|
|
||||||
$lim = ' LIMIT ' . $limit . ' OFFSET ' . $offset;
|
|
||||||
} else {
|
|
||||||
$lim = ' LIMIT ' . $offset . ', ' . $limit;
|
|
||||||
}
|
|
||||||
|
|
||||||
// XXX: memcached this
|
// XXX: memcached this
|
||||||
|
|
||||||
$qry = 'SELECT profile.* ' .
|
$qry = 'SELECT profile.* ' .
|
||||||
|
@ -125,18 +113,21 @@ class SelftagAction extends Action
|
||||||
' OR profile_list.private = false) ';
|
' OR profile_list.private = false) ';
|
||||||
}
|
}
|
||||||
|
|
||||||
$qry .= 'ORDER BY profile_tag.modified DESC%s';
|
$qry .= 'ORDER BY profile_tag.modified DESC ' .
|
||||||
|
'LIMIT ' . $limit . ' OFFSET ' . $offset;
|
||||||
|
|
||||||
$profile->query(sprintf($qry, $this->tag, $lim));
|
$profile->query(sprintf($qry, $this->tag));
|
||||||
|
|
||||||
$ptl = new SelfTagProfileList($profile, $this); // pass the ammunition
|
$ptl = new SelfTagProfileList($profile, $this); // pass the ammunition
|
||||||
$cnt = $ptl->show();
|
$cnt = $ptl->show();
|
||||||
|
|
||||||
$this->pagination($this->page > 1,
|
$this->pagination(
|
||||||
$cnt > PROFILES_PER_PAGE,
|
$this->page > 1,
|
||||||
$this->page,
|
$cnt > PROFILES_PER_PAGE,
|
||||||
'selftag',
|
$this->page,
|
||||||
array('tag' => $this->tag));
|
'selftag',
|
||||||
|
['tag' => $this->tag]
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -144,18 +135,21 @@ class SelftagAction extends Action
|
||||||
*
|
*
|
||||||
* @return string page title
|
* @return string page title
|
||||||
*/
|
*/
|
||||||
function title()
|
public function title()
|
||||||
{
|
{
|
||||||
// TRANS: Page title for page showing self tags.
|
// TRANS: Page title for page showing self tags.
|
||||||
// TRANS: %1$s is a tag, %2$d is a page number.
|
// TRANS: %1$s is a tag, %2$d is a page number.
|
||||||
return sprintf(_('Users self-tagged with %1$s, page %2$d'),
|
return sprintf(
|
||||||
$this->tag, $this->page);
|
_('Users self-tagged with %1$s, page %2$d'),
|
||||||
|
$this->tag,
|
||||||
|
$this->page
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class SelfTagProfileList extends ProfileList
|
class SelfTagProfileList extends ProfileList
|
||||||
{
|
{
|
||||||
function newListItem(Profile $target)
|
public function newListItem(Profile $target)
|
||||||
{
|
{
|
||||||
return new SelfTagProfileListItem($target, $this->action);
|
return new SelfTagProfileListItem($target, $this->action);
|
||||||
}
|
}
|
||||||
|
@ -163,7 +157,7 @@ class SelfTagProfileList extends ProfileList
|
||||||
|
|
||||||
class SelfTagProfileListItem extends ProfileListItem
|
class SelfTagProfileListItem extends ProfileListItem
|
||||||
{
|
{
|
||||||
function linkAttributes()
|
public function linkAttributes()
|
||||||
{
|
{
|
||||||
$aAttrs = parent::linkAttributes();
|
$aAttrs = parent::linkAttributes();
|
||||||
|
|
||||||
|
@ -174,7 +168,7 @@ class SelfTagProfileListItem extends ProfileListItem
|
||||||
return $aAttrs;
|
return $aAttrs;
|
||||||
}
|
}
|
||||||
|
|
||||||
function homepageAttributes()
|
public function homepageAttributes()
|
||||||
{
|
{
|
||||||
$aAttrs = parent::linkAttributes();
|
$aAttrs = parent::linkAttributes();
|
||||||
|
|
||||||
|
@ -185,7 +179,7 @@ class SelfTagProfileListItem extends ProfileListItem
|
||||||
return $aAttrs;
|
return $aAttrs;
|
||||||
}
|
}
|
||||||
|
|
||||||
function showTags()
|
public function showTags()
|
||||||
{
|
{
|
||||||
$selftags = new SelfTagsWidget($this->out, $this->profile, $this->profile);
|
$selftags = new SelfTagsWidget($this->out, $this->profile, $this->profile);
|
||||||
$selftags->show();
|
$selftags->show();
|
||||||
|
|
|
@ -848,11 +848,7 @@ class User extends Managed_DataObject
|
||||||
'ORDER BY u.created DESC ';
|
'ORDER BY u.created DESC ';
|
||||||
|
|
||||||
if ($offset > 0) {
|
if ($offset > 0) {
|
||||||
if (common_config('db','type') == 'pgsql') {
|
$qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset;
|
||||||
$qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset;
|
|
||||||
} else {
|
|
||||||
$qry .= ' LIMIT ' . $offset . ', ' . $limit;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$apps = new Oauth_application_user();
|
$apps = new Oauth_application_user();
|
||||||
|
|
|
@ -1,77 +1,60 @@
|
||||||
<?php
|
<?php
|
||||||
|
// This file is part of GNU social - https://www.gnu.org/software/social
|
||||||
|
//
|
||||||
|
// GNU social is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// GNU social is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with GNU social. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* StatusNet, the distributed open-source microblogging tool
|
|
||||||
*
|
|
||||||
* Groups with the most members section
|
* Groups with the most members section
|
||||||
*
|
*
|
||||||
* PHP version 5
|
|
||||||
*
|
|
||||||
* LICENCE: This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Affero General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Affero General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
* @category Widget
|
* @category Widget
|
||||||
* @package StatusNet
|
* @package GNUsocial
|
||||||
* @author Evan Prodromou <evan@status.net>
|
* @author Evan Prodromou <evan@status.net>
|
||||||
* @copyright 2009 StatusNet, Inc.
|
* @copyright 2009 StatusNet, Inc.
|
||||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||||
* @link http://status.net/
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('STATUSNET') && !defined('LACONICA')) {
|
defined('GNUSOCIAL') || die();
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Groups with the most members section
|
* Groups with the most members section
|
||||||
*
|
*
|
||||||
* @category Widget
|
* @copyright 2019 Free Software Foundation, Inc http://www.fsf.org
|
||||||
* @package StatusNet
|
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||||
* @author Evan Prodromou <evan@status.net>
|
|
||||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
|
||||||
* @link http://status.net/
|
|
||||||
*/
|
*/
|
||||||
class GroupsByMembersSection extends GroupSection
|
class GroupsByMembersSection extends GroupSection
|
||||||
{
|
{
|
||||||
function getGroups()
|
public function getGroups()
|
||||||
{
|
{
|
||||||
$qry = 'SELECT user_group.*, count(*) as value ' .
|
|
||||||
'FROM user_group JOIN group_member '.
|
|
||||||
'ON user_group.id = group_member.group_id ' .
|
|
||||||
'GROUP BY user_group.id,user_group.nickname,user_group.fullname,user_group.homepage,user_group.description,user_group.location,user_group.original_logo,user_group.homepage_logo,user_group.stream_logo,user_group.mini_logo,user_group.created,user_group.modified ' .
|
|
||||||
'ORDER BY value DESC ';
|
|
||||||
|
|
||||||
$limit = GROUPS_PER_SECTION;
|
$limit = GROUPS_PER_SECTION;
|
||||||
$offset = 0;
|
|
||||||
|
|
||||||
if (common_config('db','type') == 'pgsql') {
|
$qry = 'SELECT user_group.*, COUNT(*) AS value ' .
|
||||||
$qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset;
|
'FROM user_group INNER JOIN group_member '.
|
||||||
} else {
|
'ON user_group.id = group_member.group_id ' .
|
||||||
$qry .= ' LIMIT ' . $offset . ', ' . $limit;
|
'GROUP BY user_group.id, user_group.nickname, user_group.fullname, user_group.homepage, user_group.description, user_group.location, user_group.original_logo, user_group.homepage_logo, user_group.stream_logo, user_group.mini_logo, user_group.created, user_group.modified ' .
|
||||||
}
|
'ORDER BY value DESC LIMIT ' . $limit;
|
||||||
|
|
||||||
$group = Memcached_DataObject::cachedQuery('User_group',
|
$group = Memcached_DataObject::cachedQuery('User_group', $qry, 3600);
|
||||||
$qry,
|
|
||||||
3600);
|
|
||||||
return $group;
|
return $group;
|
||||||
}
|
}
|
||||||
|
|
||||||
function title()
|
public function title()
|
||||||
{
|
{
|
||||||
// TRANS: Title for groups with the most members section.
|
// TRANS: Title for groups with the most members section.
|
||||||
return _('Popular groups');
|
return _('Popular groups');
|
||||||
}
|
}
|
||||||
|
|
||||||
function divId()
|
public function divId()
|
||||||
{
|
{
|
||||||
return 'top_groups_by_member';
|
return 'top_groups_by_member';
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,20 +44,13 @@ class GroupsByPostsSection extends GroupSection
|
||||||
{
|
{
|
||||||
function getGroups()
|
function getGroups()
|
||||||
{
|
{
|
||||||
|
$limit = GROUPS_PER_SECTION;
|
||||||
|
|
||||||
$qry = 'SELECT user_group.*, count(*) as value ' .
|
$qry = 'SELECT user_group.*, count(*) as value ' .
|
||||||
'FROM user_group JOIN group_inbox '.
|
'FROM user_group JOIN group_inbox '.
|
||||||
'ON user_group.id = group_inbox.group_id ' .
|
'ON user_group.id = group_inbox.group_id ' .
|
||||||
'GROUP BY user_group.id,user_group.nickname,user_group.fullname,user_group.homepage,user_group.description,user_group.location,user_group.original_logo,user_group.homepage_logo,user_group.stream_logo,user_group.mini_logo,user_group.created,user_group.modified ' .
|
'GROUP BY user_group.id,user_group.nickname,user_group.fullname,user_group.homepage,user_group.description,user_group.location,user_group.original_logo,user_group.homepage_logo,user_group.stream_logo,user_group.mini_logo,user_group.created,user_group.modified ' .
|
||||||
'ORDER BY value DESC ';
|
'ORDER BY value DESC LIMIT ' . $limit;
|
||||||
|
|
||||||
$limit = GROUPS_PER_SECTION;
|
|
||||||
$offset = 0;
|
|
||||||
|
|
||||||
if (common_config('db','type') == 'pgsql') {
|
|
||||||
$qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset;
|
|
||||||
} else {
|
|
||||||
$qry .= ' LIMIT ' . $offset . ', ' . $limit;
|
|
||||||
}
|
|
||||||
|
|
||||||
$group = Memcached_DataObject::cachedQuery('User_group',
|
$group = Memcached_DataObject::cachedQuery('User_group',
|
||||||
$qry,
|
$qry,
|
||||||
|
|
|
@ -1,65 +1,49 @@
|
||||||
<?php
|
<?php
|
||||||
|
// This file is part of GNU social - https://www.gnu.org/software/social
|
||||||
|
//
|
||||||
|
// GNU social is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// GNU social is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with GNU social. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* StatusNet, the distributed open-source microblogging tool
|
|
||||||
*
|
|
||||||
* Peopletags with the most subscribers section
|
* Peopletags with the most subscribers section
|
||||||
*
|
*
|
||||||
* PHP version 5
|
|
||||||
*
|
|
||||||
* LICENCE: This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Affero General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Affero General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
* @category Widget
|
* @category Widget
|
||||||
* @package StatusNet
|
* @package GNUsocial
|
||||||
* @author Evan Prodromou <evan@status.net>
|
* @author Evan Prodromou <evan@status.net>
|
||||||
* @copyright 2009 StatusNet, Inc.
|
* @copyright 2009 StatusNet, Inc.
|
||||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||||
* @link http://status.net/
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('STATUSNET') && !defined('LACONICA')) {
|
defined('GNUSOCIAL') || die();
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Peopletags with the most subscribers section
|
* Peopletags with the most subscribers section
|
||||||
*
|
*
|
||||||
* @category Widget
|
* @copyright 2009 StatusNet, Inc.
|
||||||
* @package StatusNet
|
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||||
* @author Evan Prodromou <evan@status.net>
|
|
||||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
|
||||||
* @link http://status.net/
|
|
||||||
*/
|
*/
|
||||||
class PeopletagsBySubsSection extends PeopletagSection
|
class PeopletagsBySubsSection extends PeopletagSection
|
||||||
{
|
{
|
||||||
function getPeopletags()
|
function getPeopletags()
|
||||||
{
|
{
|
||||||
$qry = 'SELECT profile_list.*, subscriber_count as value ' .
|
|
||||||
'FROM profile_list WHERE profile_list.private = false ' .
|
|
||||||
'ORDER BY value DESC ';
|
|
||||||
|
|
||||||
$limit = PEOPLETAGS_PER_SECTION;
|
$limit = PEOPLETAGS_PER_SECTION;
|
||||||
$offset = 0;
|
|
||||||
|
|
||||||
if (common_config('db','type') == 'pgsql') {
|
$qry = 'SELECT profile_list.*, subscriber_count AS value ' .
|
||||||
$qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset;
|
'FROM profile_list WHERE profile_list.private = FALSE ' .
|
||||||
} else {
|
'ORDER BY value DESC ' .
|
||||||
$qry .= ' LIMIT ' . $offset . ', ' . $limit;
|
'LIMIT ' . $limit;
|
||||||
}
|
|
||||||
|
|
||||||
$peopletag = Memcached_DataObject::cachedQuery('Profile_list',
|
$peopletag = Memcached_DataObject::cachedQuery('Profile_list', $qry, 3600);
|
||||||
$qry,
|
|
||||||
3600);
|
|
||||||
return $peopletag;
|
return $peopletag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,35 +1,30 @@
|
||||||
<?php
|
<?php
|
||||||
|
// This file is part of GNU social - https://www.gnu.org/software/social
|
||||||
|
//
|
||||||
|
// GNU social is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// GNU social is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with GNU social. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* StatusNet, the distributed open-source microblogging tool
|
|
||||||
*
|
|
||||||
* Base class for sections showing lists of people
|
* Base class for sections showing lists of people
|
||||||
*
|
*
|
||||||
* PHP version 5
|
|
||||||
*
|
|
||||||
* LICENCE: This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Affero General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Affero General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
* @category Widget
|
* @category Widget
|
||||||
* @package StatusNet
|
* @package GNUsocial
|
||||||
* @author Evan Prodromou <evan@status.net>
|
* @author Evan Prodromou <evan@status.net>
|
||||||
* @copyright 2009 StatusNet, Inc.
|
* @copyright 2009 StatusNet, Inc.
|
||||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||||
* @link http://status.net/
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('STATUSNET') && !defined('LACONICA')) {
|
defined('GNUSOCIAL') || die();
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base class for sections
|
* Base class for sections
|
||||||
|
@ -37,44 +32,32 @@ if (!defined('STATUSNET') && !defined('LACONICA')) {
|
||||||
* These are the widgets that show interesting data about a person
|
* These are the widgets that show interesting data about a person
|
||||||
* group, or site.
|
* group, or site.
|
||||||
*
|
*
|
||||||
* @category Widget
|
* @copyright 2009 StatusNet, Inc.
|
||||||
* @package StatusNet
|
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||||
* @author Evan Prodromou <evan@status.net>
|
|
||||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
|
||||||
* @link http://status.net/
|
|
||||||
*/
|
*/
|
||||||
class TopPostersSection extends ProfileSection
|
class TopPostersSection extends ProfileSection
|
||||||
{
|
{
|
||||||
function getProfiles()
|
public function getProfiles()
|
||||||
{
|
{
|
||||||
$qry = 'SELECT profile.*, count(*) as value ' .
|
|
||||||
'FROM profile JOIN notice ON profile.id = notice.profile_id ' .
|
|
||||||
(common_config('public', 'localonly') ? 'WHERE is_local = 1 ' : '') .
|
|
||||||
'GROUP BY profile.id,nickname,fullname,profileurl,homepage,bio,location,profile.created,profile.modified,textsearch ' .
|
|
||||||
'ORDER BY value DESC ';
|
|
||||||
|
|
||||||
$limit = PROFILES_PER_SECTION;
|
$limit = PROFILES_PER_SECTION;
|
||||||
$offset = 0;
|
|
||||||
|
|
||||||
if (common_config('db','type') == 'pgsql') {
|
$qry = 'SELECT profile.*, COUNT(*) AS value ' .
|
||||||
$qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset;
|
'FROM profile JOIN notice ON profile.id = notice.profile_id ' .
|
||||||
} else {
|
(common_config('public', 'localonly') ? 'WHERE is_local = 1 ' : '') .
|
||||||
$qry .= ' LIMIT ' . $offset . ', ' . $limit;
|
'GROUP BY profile.id, nickname, fullname, profileurl, homepage, bio, location, profile.created, profile.modified ' .
|
||||||
}
|
'ORDER BY value DESC LIMIT ' . $limit;
|
||||||
|
|
||||||
$profile = Memcached_DataObject::cachedQuery('Profile',
|
$profile = Memcached_DataObject::cachedQuery('Profile', $qry, 6 * 3600);
|
||||||
$qry,
|
|
||||||
6 * 3600);
|
|
||||||
return $profile;
|
return $profile;
|
||||||
}
|
}
|
||||||
|
|
||||||
function title()
|
public function title()
|
||||||
{
|
{
|
||||||
// TRANS: Title for top posters section.
|
// TRANS: Title for top posters section.
|
||||||
return _('Top posters');
|
return _('Top posters');
|
||||||
}
|
}
|
||||||
|
|
||||||
function divId()
|
public function divId()
|
||||||
{
|
{
|
||||||
return 'top_posters';
|
return 'top_posters';
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,36 +1,30 @@
|
||||||
<?php
|
<?php
|
||||||
|
// This file is part of GNU social - https://www.gnu.org/software/social
|
||||||
|
//
|
||||||
|
// GNU social is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// GNU social is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with GNU social. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* StatusNet, the distributed open-source microblogging tool
|
|
||||||
*
|
|
||||||
* Action for showing Twitter-like JSON search results
|
* Action for showing Twitter-like JSON search results
|
||||||
*
|
*
|
||||||
* PHP version 5
|
|
||||||
*
|
|
||||||
* LICENCE: This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Affero General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Affero General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
* @category Search
|
* @category Search
|
||||||
* @package StatusNet
|
* @package GNUsocial
|
||||||
* @author Zach Copley <zach@status.net>
|
* @author Zach Copley <zach@status.net>
|
||||||
* @copyright 2011 StatusNet, Inc.
|
* @copyright 2011 StatusNet, Inc.
|
||||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||||
* @link http://status.net/
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('STATUSNET')) {
|
defined('GNUSOCIAL') || die();
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class UserautocompleteAction extends Action
|
class UserautocompleteAction extends Action
|
||||||
{
|
{
|
||||||
|
@ -44,7 +38,7 @@ class UserautocompleteAction extends Action
|
||||||
* @return boolean true if nothing goes wrong
|
* @return boolean true if nothing goes wrong
|
||||||
* @throws ClientException
|
* @throws ClientException
|
||||||
*/
|
*/
|
||||||
public function prepare(array $args = array())
|
public function prepare(array $args = [])
|
||||||
{
|
{
|
||||||
parent::prepare($args);
|
parent::prepare($args);
|
||||||
$this->query = $this->trimmed('term');
|
$this->query = $this->trimmed('term');
|
||||||
|
@ -87,7 +81,7 @@ class UserautocompleteAction extends Action
|
||||||
. ' AND LEFT(LOWER(profile.nickname), '
|
. ' AND LEFT(LOWER(profile.nickname), '
|
||||||
. strlen($this->query)
|
. strlen($this->query)
|
||||||
. ') = \'%s\' '
|
. ') = \'%s\' '
|
||||||
. ' LIMIT 0, 10';
|
. ' LIMIT 10';
|
||||||
|
|
||||||
$profile->query(sprintf($sql, $this->query));
|
$profile->query(sprintf($sql, $this->query));
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,33 +62,22 @@ class GroupFavoritedAction extends ShowgroupAction
|
||||||
$groupId = (int)$this->group->id;
|
$groupId = (int)$this->group->id;
|
||||||
$weightexpr = common_sql_weight('fave.modified', common_config('popular', 'dropoff'));
|
$weightexpr = common_sql_weight('fave.modified', common_config('popular', 'dropoff'));
|
||||||
$cutoff = sprintf(
|
$cutoff = sprintf(
|
||||||
"fave.modified > '%s'",
|
"fave.modified > TIMESTAMP '%s'",
|
||||||
common_sql_date(time() - common_config('popular', 'cutoff'))
|
common_sql_date(time() - common_config('popular', 'cutoff'))
|
||||||
);
|
);
|
||||||
|
|
||||||
$qry = 'SELECT notice.*, ' .
|
|
||||||
$weightexpr . ' as weight ' .
|
|
||||||
'FROM notice ' .
|
|
||||||
"JOIN group_inbox ON notice.id = group_inbox.notice_id " .
|
|
||||||
'JOIN fave ON notice.id = fave.notice_id ' .
|
|
||||||
"WHERE $cutoff AND group_id = $groupId " .
|
|
||||||
'GROUP BY id,profile_id,uri,content,rendered,url,created,notice.modified,reply_to,is_local,source,notice.conversation ' .
|
|
||||||
'ORDER BY weight DESC';
|
|
||||||
|
|
||||||
$offset = ($this->page - 1) * NOTICES_PER_PAGE;
|
$offset = ($this->page - 1) * NOTICES_PER_PAGE;
|
||||||
$limit = NOTICES_PER_PAGE + 1;
|
$limit = NOTICES_PER_PAGE + 1;
|
||||||
|
|
||||||
if (common_config('db', 'type') == 'pgsql') {
|
$qry = 'SELECT notice.*, ' . $weightexpr . ' AS weight ' .
|
||||||
$qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset;
|
'FROM notice ' .
|
||||||
} else {
|
'INNER JOIN group_inbox ON notice.id = group_inbox.notice_id ' .
|
||||||
$qry .= ' LIMIT ' . $offset . ', ' . $limit;
|
'INNER JOIN fave ON notice.id = fave.notice_id ' .
|
||||||
}
|
'WHERE ' . $cutoff . ' AND group_id = ' . $groupId . ' ' .
|
||||||
|
'GROUP BY id, profile_id, uri, content, rendered, url, created, notice.modified, reply_to, is_local, source, notice.conversation ' .
|
||||||
|
'ORDER BY weight DESC LIMIT ' . $limit . ' OFFSET ' . $offset;
|
||||||
|
|
||||||
$notice = Memcached_DataObject::cachedQuery(
|
$notice = Memcached_DataObject::cachedQuery('Notice', $qry, 600);
|
||||||
'Notice',
|
|
||||||
$qry,
|
|
||||||
600
|
|
||||||
);
|
|
||||||
|
|
||||||
$nl = new NoticeList($notice, $this);
|
$nl = new NoticeList($notice, $this);
|
||||||
|
|
||||||
|
|
|
@ -1,40 +1,36 @@
|
||||||
<?php
|
<?php
|
||||||
|
// This file is part of GNU social - https://www.gnu.org/software/social
|
||||||
|
//
|
||||||
|
// GNU social is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// GNU social is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with GNU social. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* StatusNet, the distributed open-source microblogging tool
|
|
||||||
*
|
|
||||||
* List of popular notices
|
* List of popular notices
|
||||||
*
|
*
|
||||||
* PHP version 5
|
|
||||||
*
|
|
||||||
* LICENCE: This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Affero General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Affero General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
* @category Public
|
* @category Public
|
||||||
* @package StatusNet
|
* @package GNUsocial
|
||||||
* @author Zach Copley <zach@status.net>
|
* @author Zach Copley <zach@status.net>
|
||||||
* @author Evan Prodromou <evan@status.net>
|
* @author Evan Prodromou <evan@status.net>
|
||||||
* @copyright 2008-2009 StatusNet, Inc.
|
* @copyright 2008-2009 StatusNet, Inc.
|
||||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||||
* @link http://status.net/
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('STATUSNET') && !defined('LACONICA')) {
|
defined('GNUSOCIAL') || die();
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
class FavoritedSliceAction extends FavoritedAction
|
class FavoritedSliceAction extends FavoritedAction
|
||||||
{
|
{
|
||||||
private $includeUsers = array(), $excludeUsers = array();
|
private $includeUsers = [];
|
||||||
|
private $excludeUsers = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Take arguments for running
|
* Take arguments for running
|
||||||
|
@ -45,7 +41,7 @@ class FavoritedSliceAction extends FavoritedAction
|
||||||
*
|
*
|
||||||
* @todo move queries from showContent() to here
|
* @todo move queries from showContent() to here
|
||||||
*/
|
*/
|
||||||
function prepare(array $args = array())
|
public function prepare(array $args = [])
|
||||||
{
|
{
|
||||||
parent::prepare($args);
|
parent::prepare($args);
|
||||||
|
|
||||||
|
@ -72,7 +68,7 @@ class FavoritedSliceAction extends FavoritedAction
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function showContent()
|
public function showContent()
|
||||||
{
|
{
|
||||||
$slice = $this->sliceWhereClause();
|
$slice = $this->sliceWhereClause();
|
||||||
if (!$slice) {
|
if (!$slice) {
|
||||||
|
@ -80,28 +76,21 @@ class FavoritedSliceAction extends FavoritedAction
|
||||||
}
|
}
|
||||||
|
|
||||||
$weightexpr = common_sql_weight('fave.modified', common_config('popular', 'dropoff'));
|
$weightexpr = common_sql_weight('fave.modified', common_config('popular', 'dropoff'));
|
||||||
$cutoff = sprintf("fave.modified > '%s'",
|
$cutoff = sprintf(
|
||||||
common_sql_date(time() - common_config('popular', 'cutoff')));
|
"fave.modified > TIMESTAMP '%s'",
|
||||||
|
common_sql_date(time() - common_config('popular', 'cutoff'))
|
||||||
$qry = 'SELECT notice.*, '.
|
);
|
||||||
$weightexpr . ' as weight ' .
|
|
||||||
'FROM notice JOIN fave ON notice.id = fave.notice_id ' .
|
|
||||||
"WHERE $cutoff AND $slice " .
|
|
||||||
'GROUP BY id,profile_id,uri,content,rendered,url,created,notice.modified,reply_to,is_local,source,notice.conversation ' .
|
|
||||||
'ORDER BY weight DESC';
|
|
||||||
|
|
||||||
$offset = ($this->page - 1) * NOTICES_PER_PAGE;
|
$offset = ($this->page - 1) * NOTICES_PER_PAGE;
|
||||||
$limit = NOTICES_PER_PAGE + 1;
|
$limit = NOTICES_PER_PAGE + 1;
|
||||||
|
|
||||||
if (common_config('db', 'type') == 'pgsql') {
|
$qry = 'SELECT notice.*, ' . $weightexpr . ' AS weight ' .
|
||||||
$qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset;
|
'FROM notice INNER JOIN fave ON notice.id = fave.notice_id ' .
|
||||||
} else {
|
'WHERE ' . $cutoff . ' AND ' . $slice . ' ' .
|
||||||
$qry .= ' LIMIT ' . $offset . ', ' . $limit;
|
'GROUP BY id, profile_id, uri, content, rendered, url, created, notice.modified, reply_to, is_local, source, notice.conversation ' .
|
||||||
}
|
'ORDER BY weight DESC LIMIT ' . $limit . ' OFFSET ' . $offset;
|
||||||
|
|
||||||
$notice = Memcached_DataObject::cachedQuery('Notice',
|
$notice = Memcached_DataObject::cachedQuery('Notice', $qry, 600);
|
||||||
$qry,
|
|
||||||
600);
|
|
||||||
|
|
||||||
$nl = new NoticeList($notice, $this);
|
$nl = new NoticeList($notice, $this);
|
||||||
|
|
||||||
|
@ -111,8 +100,12 @@ class FavoritedSliceAction extends FavoritedAction
|
||||||
$this->showEmptyList();
|
$this->showEmptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->pagination($this->page > 1, $cnt > NOTICES_PER_PAGE,
|
$this->pagination(
|
||||||
$this->page, 'favorited');
|
$this->page > 1,
|
||||||
|
$cnt > NOTICES_PER_PAGE,
|
||||||
|
$this->page,
|
||||||
|
'favorited'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function sliceWhereClause()
|
private function sliceWhereClause()
|
||||||
|
@ -122,11 +115,11 @@ class FavoritedSliceAction extends FavoritedAction
|
||||||
|
|
||||||
if (count($include) == 1) {
|
if (count($include) == 1) {
|
||||||
return "profile_id = " . intval($include[0]);
|
return "profile_id = " . intval($include[0]);
|
||||||
} else if (count($include) > 1) {
|
} elseif (count($include) > 1) {
|
||||||
return "profile_id IN (" . implode(',', $include) . ")";
|
return "profile_id IN (" . implode(',', $include) . ")";
|
||||||
} else if (count($exclude) == 1) {
|
} elseif (count($exclude) === 1) {
|
||||||
return "profile_id != " . intval($exclude[0]);
|
return "profile_id != " . intval($exclude[0]);
|
||||||
} else if (count($exclude) > 1) {
|
} elseif (count($exclude) > 1) {
|
||||||
return "profile_id NOT IN (" . implode(',', $exclude) . ")";
|
return "profile_id NOT IN (" . implode(',', $exclude) . ")";
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -1,35 +1,30 @@
|
||||||
<?php
|
<?php
|
||||||
|
// This file is part of GNU social - https://www.gnu.org/software/social
|
||||||
|
//
|
||||||
|
// GNU social is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// GNU social is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with GNU social. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* StatusNet, the distributed open-source microblogging tool
|
|
||||||
*
|
|
||||||
* Personal tag cloud section
|
* Personal tag cloud section
|
||||||
*
|
*
|
||||||
* PHP version 5
|
|
||||||
*
|
|
||||||
* LICENCE: This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Affero General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Affero General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
* @category Widget
|
* @category Widget
|
||||||
* @package StatusNet
|
* @package GNUsocial
|
||||||
* @author Evan Prodromou <evan@status.net>
|
* @author Evan Prodromou <evan@status.net>
|
||||||
* @copyright 2009 StatusNet, Inc.
|
* @copyright 2009 StatusNet, Inc.
|
||||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||||
* @link http://status.net/
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('STATUSNET') && !defined('LACONICA')) {
|
defined('GNUSOCIAL') || die();
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Group tag cloud section
|
* Group tag cloud section
|
||||||
|
@ -42,22 +37,22 @@ if (!defined('STATUSNET') && !defined('LACONICA')) {
|
||||||
*/
|
*/
|
||||||
class GroupTagCloudSection extends TagCloudSection
|
class GroupTagCloudSection extends TagCloudSection
|
||||||
{
|
{
|
||||||
var $group = null;
|
public $group = null;
|
||||||
|
|
||||||
function __construct($out=null, $group=null)
|
public function __construct($out = null, $group = null)
|
||||||
{
|
{
|
||||||
parent::__construct($out);
|
parent::__construct($out);
|
||||||
$this->group = $group;
|
$this->group = $group;
|
||||||
}
|
}
|
||||||
|
|
||||||
function title()
|
public function title()
|
||||||
{
|
{
|
||||||
// TRANS: Title for group tag cloud section.
|
// TRANS: Title for group tag cloud section.
|
||||||
// TRANS: %s is a group name.
|
// TRANS: %s is a group name.
|
||||||
return _('Tags');
|
return _('Tags');
|
||||||
}
|
}
|
||||||
|
|
||||||
function getTags()
|
public function getTags()
|
||||||
{
|
{
|
||||||
$weightexpr = common_sql_weight('notice_tag.created', common_config('tag', 'dropoff'));
|
$weightexpr = common_sql_weight('notice_tag.created', common_config('tag', 'dropoff'));
|
||||||
// @fixme should we use the cutoff too? Doesn't help with indexing per-group.
|
// @fixme should we use the cutoff too? Doesn't help with indexing per-group.
|
||||||
|
@ -75,31 +70,22 @@ class GroupTagCloudSection extends TagCloudSection
|
||||||
}
|
}
|
||||||
|
|
||||||
$namestring = implode(',', $quoted);
|
$namestring = implode(',', $quoted);
|
||||||
|
|
||||||
$qry = 'SELECT notice_tag.tag, '.
|
|
||||||
$weightexpr . ' as weight ' .
|
|
||||||
'FROM notice_tag JOIN notice ' .
|
|
||||||
'ON notice_tag.notice_id = notice.id ' .
|
|
||||||
'JOIN group_inbox on group_inbox.notice_id = notice.id ' .
|
|
||||||
'WHERE group_inbox.group_id = %d ' .
|
|
||||||
'AND notice_tag.tag not in (%s) '.
|
|
||||||
'GROUP BY notice_tag.tag ' .
|
|
||||||
'ORDER BY weight DESC ';
|
|
||||||
|
|
||||||
$limit = TAGS_PER_SECTION;
|
$limit = TAGS_PER_SECTION;
|
||||||
$offset = 0;
|
|
||||||
|
|
||||||
if (common_config('db','type') == 'pgsql') {
|
$qry = 'SELECT notice_tag.tag, ' . $weightexpr . ' AS weight ' .
|
||||||
$qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset;
|
'FROM notice_tag INNER JOIN notice ' .
|
||||||
} else {
|
'ON notice_tag.notice_id = notice.id ' .
|
||||||
$qry .= ' LIMIT ' . $offset . ', ' . $limit;
|
'INNER JOIN group_inbox ON group_inbox.notice_id = notice.id ' .
|
||||||
}
|
'WHERE group_inbox.group_id = %d ' .
|
||||||
|
'AND notice_tag.tag NOT IN (%s) '.
|
||||||
|
'GROUP BY notice_tag.tag ' .
|
||||||
|
'ORDER BY weight DESC LIMIT ' . $limit;
|
||||||
|
|
||||||
$tag = Memcached_DataObject::cachedQuery('Notice_tag',
|
$tag = Memcached_DataObject::cachedQuery(
|
||||||
sprintf($qry,
|
'Notice_tag',
|
||||||
$this->group->id,
|
sprintf($qry, $this->group->id, $namestring),
|
||||||
$namestring),
|
3600
|
||||||
3600);
|
);
|
||||||
return $tag;
|
return $tag;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,42 +1,36 @@
|
||||||
<?php
|
<?php
|
||||||
|
// This file is part of GNU social - https://www.gnu.org/software/social
|
||||||
|
//
|
||||||
|
// GNU social is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// GNU social is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with GNU social. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* StatusNet, the distributed open-source microblogging tool
|
|
||||||
*
|
|
||||||
* Personal tag cloud section
|
* Personal tag cloud section
|
||||||
*
|
*
|
||||||
* PHP version 5
|
|
||||||
*
|
|
||||||
* LICENCE: This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Affero General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Affero General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
* @category Widget
|
* @category Widget
|
||||||
* @package StatusNet
|
* @package GNUsocial
|
||||||
* @author Evan Prodromou <evan@status.net>
|
* @author Evan Prodromou <evan@status.net>
|
||||||
* @copyright 2009 StatusNet, Inc.
|
* @copyright 2009 StatusNet, Inc.
|
||||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||||
* @link http://status.net/
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('GNUSOCIAL')) { exit(1); }
|
defined('GNUSOCIAL') || die();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Personal tag cloud section
|
* Personal tag cloud section
|
||||||
*
|
*
|
||||||
* @category Widget
|
* @copyright 2009 StatusNet, Inc.
|
||||||
* @package StatusNet
|
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||||
* @author Evan Prodromou <evan@status.net>
|
|
||||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
|
||||||
* @link http://status.net/
|
|
||||||
*/
|
*/
|
||||||
class InboxTagCloudSection extends TagCloudSection
|
class InboxTagCloudSection extends TagCloudSection
|
||||||
{
|
{
|
||||||
|
@ -44,19 +38,19 @@ class InboxTagCloudSection extends TagCloudSection
|
||||||
|
|
||||||
protected $target = null;
|
protected $target = null;
|
||||||
|
|
||||||
function __construct($out=null, Profile $target)
|
public function __construct($out = null, Profile $target)
|
||||||
{
|
{
|
||||||
parent::__construct($out);
|
parent::__construct($out);
|
||||||
$this->target = $target;
|
$this->target = $target;
|
||||||
}
|
}
|
||||||
|
|
||||||
function title()
|
public function title()
|
||||||
{
|
{
|
||||||
// TRANS: Title for inbox tag cloud section.
|
// TRANS: Title for inbox tag cloud section.
|
||||||
return _m('TITLE', 'Trends');
|
return _m('TITLE', 'Trends');
|
||||||
}
|
}
|
||||||
|
|
||||||
function getTags()
|
public function getTags()
|
||||||
{
|
{
|
||||||
// FIXME: Get the Profile::current() value some other way
|
// FIXME: Get the Profile::current() value some other way
|
||||||
// to avoid confusion between background stuff and session.
|
// to avoid confusion between background stuff and session.
|
||||||
|
@ -70,22 +64,15 @@ class InboxTagCloudSection extends TagCloudSection
|
||||||
$weightexpr = common_sql_weight('notice_tag.created', common_config('tag', 'dropoff'));
|
$weightexpr = common_sql_weight('notice_tag.created', common_config('tag', 'dropoff'));
|
||||||
// @fixme should we use the cutoff too? Doesn't help with indexing per-user.
|
// @fixme should we use the cutoff too? Doesn't help with indexing per-user.
|
||||||
|
|
||||||
|
$limit = TAGS_PER_SECTION;
|
||||||
|
|
||||||
$qry = 'SELECT notice_tag.tag, '.
|
$qry = 'SELECT notice_tag.tag, '.
|
||||||
$weightexpr . ' as weight ' .
|
$weightexpr . ' as weight ' .
|
||||||
'FROM notice_tag JOIN notice ' .
|
'FROM notice_tag JOIN notice ' .
|
||||||
'ON notice_tag.notice_id = notice.id ' .
|
'ON notice_tag.notice_id = notice.id ' .
|
||||||
'WHERE notice.id in (' . implode(',', $ids) . ')'.
|
'WHERE notice.id in (' . implode(',', $ids) . ')'.
|
||||||
'GROUP BY notice_tag.tag ' .
|
'GROUP BY notice_tag.tag ' .
|
||||||
'ORDER BY weight DESC ';
|
'ORDER BY weight DESC LIMIT ' . $limit;
|
||||||
|
|
||||||
$limit = TAGS_PER_SECTION;
|
|
||||||
$offset = 0;
|
|
||||||
|
|
||||||
if (common_config('db','type') == 'pgsql') {
|
|
||||||
$qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset;
|
|
||||||
} else {
|
|
||||||
$qry .= ' LIMIT ' . $offset . ', ' . $limit;
|
|
||||||
}
|
|
||||||
|
|
||||||
$t = new Notice_tag();
|
$t = new Notice_tag();
|
||||||
|
|
||||||
|
@ -101,7 +88,7 @@ class InboxTagCloudSection extends TagCloudSection
|
||||||
return new ArrayWrapper($tag);
|
return new ArrayWrapper($tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
function showMore()
|
public function showMore()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,85 +1,72 @@
|
||||||
<?php
|
<?php
|
||||||
|
// This file is part of GNU social - https://www.gnu.org/software/social
|
||||||
|
//
|
||||||
|
// GNU social is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// GNU social is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with GNU social. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* StatusNet, the distributed open-source microblogging tool
|
|
||||||
*
|
|
||||||
* Personal tag cloud section
|
* Personal tag cloud section
|
||||||
*
|
*
|
||||||
* PHP version 5
|
|
||||||
*
|
|
||||||
* LICENCE: This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Affero General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Affero General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
* @category Widget
|
* @category Widget
|
||||||
* @package StatusNet
|
* @package GNUsocial
|
||||||
* @author Evan Prodromou <evan@status.net>
|
* @author Evan Prodromou <evan@status.net>
|
||||||
* @copyright 2009 StatusNet, Inc.
|
* @copyright 2009 StatusNet, Inc.
|
||||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||||
* @link http://status.net/
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('GNUSOCIAL')) { exit(1); }
|
defined('GNUSOCIAL') || die();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Personal tag cloud section
|
* Personal tag cloud section
|
||||||
*
|
*
|
||||||
* @category Widget
|
* @copyright 2009 StatusNet, Inc.
|
||||||
* @package StatusNet
|
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||||
* @author Evan Prodromou <evan@status.net>
|
|
||||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
|
||||||
* @link http://status.net/
|
|
||||||
*/
|
*/
|
||||||
class PersonalTagCloudSection extends TagCloudSection
|
class PersonalTagCloudSection extends TagCloudSection
|
||||||
{
|
{
|
||||||
protected $profile = null;
|
protected $profile = null;
|
||||||
|
|
||||||
function __construct(HTMLOutputter $out, Profile $profile)
|
public function __construct(HTMLOutputter $out, Profile $profile)
|
||||||
{
|
{
|
||||||
parent::__construct($out);
|
parent::__construct($out);
|
||||||
$this->profile = $profile;
|
$this->profile = $profile;
|
||||||
}
|
}
|
||||||
|
|
||||||
function title()
|
public function title()
|
||||||
{
|
{
|
||||||
// TRANS: Title for personal tag cloud section.
|
// TRANS: Title for personal tag cloud section.
|
||||||
return _m('TITLE','Tags');
|
return _m('TITLE', 'Tags');
|
||||||
}
|
}
|
||||||
|
|
||||||
function getTags()
|
public function getTags()
|
||||||
{
|
{
|
||||||
$weightexpr = common_sql_weight('notice_tag.created', common_config('tag', 'dropoff'));
|
$weightexpr = common_sql_weight('notice_tag.created', common_config('tag', 'dropoff'));
|
||||||
// @fixme should we use the cutoff too? Doesn't help with indexing per-user.
|
// @fixme should we use the cutoff too? Doesn't help with indexing per-user.
|
||||||
|
|
||||||
$qry = 'SELECT notice_tag.tag, '.
|
|
||||||
$weightexpr . ' as weight ' .
|
|
||||||
'FROM notice_tag JOIN notice ' .
|
|
||||||
'ON notice_tag.notice_id = notice.id ' .
|
|
||||||
'WHERE notice.profile_id = %d ' .
|
|
||||||
'GROUP BY notice_tag.tag ' .
|
|
||||||
'ORDER BY weight DESC ';
|
|
||||||
|
|
||||||
$limit = TAGS_PER_SECTION;
|
$limit = TAGS_PER_SECTION;
|
||||||
$offset = 0;
|
|
||||||
|
|
||||||
if (common_config('db','type') == 'pgsql') {
|
$qry = 'SELECT notice_tag.tag, ' . $weightexpr . ' AS weight ' .
|
||||||
$qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset;
|
'FROM notice_tag INNER JOIN notice ' .
|
||||||
} else {
|
'ON notice_tag.notice_id = notice.id ' .
|
||||||
$qry .= ' LIMIT ' . $offset . ', ' . $limit;
|
'WHERE notice.profile_id = %d ' .
|
||||||
}
|
'GROUP BY notice_tag.tag ' .
|
||||||
|
'ORDER BY weight DESC LIMIT ' . $limit;
|
||||||
|
|
||||||
$tag = Memcached_DataObject::cachedQuery('Notice_tag',
|
$tag = Memcached_DataObject::cachedQuery(
|
||||||
sprintf($qry,
|
'Notice_tag',
|
||||||
$this->profile->getID()),
|
sprintf($qry, $this->profile->getID()),
|
||||||
3600);
|
3600
|
||||||
|
);
|
||||||
return $tag;
|
return $tag;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,59 +1,51 @@
|
||||||
<?php
|
<?php
|
||||||
|
// This file is part of GNU social - https://www.gnu.org/software/social
|
||||||
|
//
|
||||||
|
// GNU social is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// GNU social is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with GNU social. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* StatusNet, the distributed open-source microblogging tool
|
|
||||||
*
|
|
||||||
* Public tag cloud section
|
* Public tag cloud section
|
||||||
*
|
*
|
||||||
* PHP version 5
|
|
||||||
*
|
|
||||||
* LICENCE: This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Affero General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Affero General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
* @category Widget
|
* @category Widget
|
||||||
* @package StatusNet
|
* @package GNUsocial
|
||||||
* @author Evan Prodromou <evan@status.net>
|
* @author Evan Prodromou <evan@status.net>
|
||||||
* @copyright 2009 StatusNet, Inc.
|
* @copyright 2009 StatusNet, Inc.
|
||||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||||
* @link http://status.net/
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('STATUSNET') && !defined('LACONICA')) {
|
defined('GNUSOCIAL') || die();
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Public tag cloud section
|
* Public tag cloud section
|
||||||
*
|
*
|
||||||
* @category Widget
|
* @copyright 2009 StatusNet, Inc.
|
||||||
* @package StatusNet
|
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||||
* @author Evan Prodromou <evan@status.net>
|
|
||||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
|
||||||
* @link http://status.net/
|
|
||||||
*/
|
*/
|
||||||
class PublicTagCloudSection extends TagCloudSection
|
class PublicTagCloudSection extends TagCloudSection
|
||||||
{
|
{
|
||||||
function __construct($out=null)
|
public function __construct($out = null)
|
||||||
{
|
{
|
||||||
parent::__construct($out);
|
parent::__construct($out);
|
||||||
}
|
}
|
||||||
|
|
||||||
function title()
|
public function title()
|
||||||
{
|
{
|
||||||
// TRANS: Title for inbox tag cloud section.
|
// TRANS: Title for inbox tag cloud section.
|
||||||
return _m('TITLE', 'Trends');
|
return _m('TITLE', 'Trends');
|
||||||
}
|
}
|
||||||
|
|
||||||
function getTags()
|
public function getTags()
|
||||||
{
|
{
|
||||||
$profile = Profile::current();
|
$profile = Profile::current();
|
||||||
|
|
||||||
|
@ -66,7 +58,6 @@ class PublicTagCloudSection extends TagCloudSection
|
||||||
$tag = Memcached_DataObject::cacheGet($keypart);
|
$tag = Memcached_DataObject::cacheGet($keypart);
|
||||||
|
|
||||||
if ($tag === false) {
|
if ($tag === false) {
|
||||||
|
|
||||||
$stream = new PublicNoticeStream($profile);
|
$stream = new PublicNoticeStream($profile);
|
||||||
|
|
||||||
$ids = $stream->getNoticeIds(0, 500, null, null);
|
$ids = $stream->getNoticeIds(0, 500, null, null);
|
||||||
|
@ -77,22 +68,14 @@ class PublicTagCloudSection extends TagCloudSection
|
||||||
$weightexpr = common_sql_weight('notice_tag.created', common_config('tag', 'dropoff'));
|
$weightexpr = common_sql_weight('notice_tag.created', common_config('tag', 'dropoff'));
|
||||||
// @fixme should we use the cutoff too? Doesn't help with indexing per-user.
|
// @fixme should we use the cutoff too? Doesn't help with indexing per-user.
|
||||||
|
|
||||||
$qry = 'SELECT notice_tag.tag, '.
|
$limit = TAGS_PER_SECTION;
|
||||||
$weightexpr . ' as weight ' .
|
|
||||||
|
$qry = 'SELECT notice_tag.tag, ' . $weightexpr . ' AS weight ' .
|
||||||
'FROM notice_tag JOIN notice ' .
|
'FROM notice_tag JOIN notice ' .
|
||||||
'ON notice_tag.notice_id = notice.id ' .
|
'ON notice_tag.notice_id = notice.id ' .
|
||||||
'WHERE notice.id in (' . implode(',', $ids) . ') '.
|
'WHERE notice.id in (' . implode(',', $ids) . ') '.
|
||||||
'GROUP BY notice_tag.tag ' .
|
'GROUP BY notice_tag.tag ' .
|
||||||
'ORDER BY weight DESC ';
|
'ORDER BY weight DESC LIMIT ' . $limit;
|
||||||
|
|
||||||
$limit = TAGS_PER_SECTION;
|
|
||||||
$offset = 0;
|
|
||||||
|
|
||||||
if (common_config('db','type') == 'pgsql') {
|
|
||||||
$qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset;
|
|
||||||
} else {
|
|
||||||
$qry .= ' LIMIT ' . $offset . ', ' . $limit;
|
|
||||||
}
|
|
||||||
|
|
||||||
$t = new Notice_tag();
|
$t = new Notice_tag();
|
||||||
|
|
||||||
|
@ -111,7 +94,7 @@ class PublicTagCloudSection extends TagCloudSection
|
||||||
return new ArrayWrapper($tag);
|
return new ArrayWrapper($tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
function showMore()
|
public function showMore()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,77 +1,64 @@
|
||||||
<?php
|
<?php
|
||||||
|
// This file is part of GNU social - https://www.gnu.org/software/social
|
||||||
|
//
|
||||||
|
// GNU social is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// GNU social is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with GNU social. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* StatusNet, the distributed open-source microblogging tool
|
|
||||||
*
|
|
||||||
* Personal tag cloud section
|
* Personal tag cloud section
|
||||||
*
|
*
|
||||||
* PHP version 5
|
|
||||||
*
|
|
||||||
* LICENCE: This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Affero General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Affero General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
* @category Widget
|
* @category Widget
|
||||||
* @package StatusNet
|
* @package GNUsocial
|
||||||
* @author Evan Prodromou <evan@status.net>
|
* @author Evan Prodromou <evan@status.net>
|
||||||
* @copyright 2009 StatusNet, Inc.
|
* @copyright 2009 StatusNet, Inc.
|
||||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||||
* @link http://status.net/
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('STATUSNET') && !defined('LACONICA')) {
|
defined('GNUSOCIAL') || die();
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Personal tag cloud section
|
* Personal tag cloud section
|
||||||
*
|
*
|
||||||
* @category Widget
|
* @copyright 2009 StatusNet, Inc.
|
||||||
* @package StatusNet
|
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||||
* @author Evan Prodromou <evan@status.net>
|
|
||||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
|
||||||
* @link http://status.net/
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class SubPeopleTagCloudSection extends TagCloudSection
|
class SubPeopleTagCloudSection extends TagCloudSection
|
||||||
{
|
{
|
||||||
function getTags()
|
public function getTags()
|
||||||
{
|
{
|
||||||
$qry = $this->query();
|
$qry = $this->query();
|
||||||
$limit = TAGS_PER_SECTION;
|
$qry .= ' LIMIT ' . TAGS_PER_SECTION;
|
||||||
$offset = 0;
|
|
||||||
|
|
||||||
if (common_config('db','type') == 'pgsql') {
|
$profile_tag = Memcached_DataObject::cachedQuery(
|
||||||
$qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset;
|
'Profile_tag',
|
||||||
} else {
|
sprintf($qry, $this->out->user->id)
|
||||||
$qry .= ' LIMIT ' . $offset . ', ' . $limit;
|
);
|
||||||
}
|
|
||||||
|
|
||||||
$profile_tag = Memcached_DataObject::cachedQuery('Profile_tag',
|
|
||||||
sprintf($qry,
|
|
||||||
$this->out->user->id));
|
|
||||||
return $profile_tag;
|
return $profile_tag;
|
||||||
}
|
}
|
||||||
|
|
||||||
function tagUrl($tag) {
|
public function tagUrl($tag)
|
||||||
|
{
|
||||||
return common_local_url('peopletag', array('tag' => $tag));
|
return common_local_url('peopletag', array('tag' => $tag));
|
||||||
}
|
}
|
||||||
|
|
||||||
function showTag($tag, $weight, $relative) {
|
public function showTag($tag, $weight, $relative)
|
||||||
|
{
|
||||||
$rel = 'tag-cloud-';
|
$rel = 'tag-cloud-';
|
||||||
$rel .= 1+intval(7 * $relative * $weight - 0.01);
|
$rel .= 1 + (int) (7 * $relative * $weight - 0.01);
|
||||||
|
|
||||||
$this->out->elementStart('li', $rel);
|
$this->out->elementStart('li', $rel);
|
||||||
$this->out->element('a', array('href' => $this->tagUrl($tag)), $tag);
|
$this->out->element('a', array('href' => $this->tagUrl($tag)), $tag);
|
||||||
$this->out->elementEnd('li');
|
$this->out->elementEnd('li');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user