From 8942e3a445d6e4965fc46e08cb90bbfed17cd56a Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Fri, 23 Jan 2009 03:00:51 +0100 Subject: Add an action to show the list of the latest groups --- actions/groups.php | 117 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 117 insertions(+) create mode 100644 actions/groups.php (limited to 'actions/groups.php') diff --git a/actions/groups.php b/actions/groups.php new file mode 100644 index 000000000..154976f21 --- /dev/null +++ b/actions/groups.php @@ -0,0 +1,117 @@ +. + * + * @category Personal + * @package Laconica + * @author Evan Prodromou + * @author Sarven Capadisli + * @copyright 2008-2009 Control Yourself, Inc. + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://laconi.ca/ + */ + +if (!defined('LACONICA')) { + exit(1); +} + +require_once INSTALLDIR.'/lib/grouplist.php'; + +/** + * Latest groups + * + * Show the latest groups on the site + * + * @category Personal + * @package Laconica + * @author Evan Prodromou + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://laconi.ca/ + */ + +class GroupsAction extends Action +{ + var $page = null; + var $profile = null; + + function title() + { + if ($this->page == 1) { + return _("Groups"); + } else { + return sprintf(_("Groups, page %d"), $this->page); + } + } + + function prepare($args) + { + parent::prepare($args); + $this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1; + return true; + } + + function handle($args) + { + parent::handle($args); + $this->showPage(); + } + + function showLocalNav() + { + $nav = new PublicGroupNav($this); + $nav->show(); + } + + function showPageNotice() + { + $notice = + sprintf(_('%%%%site.name%%%% groups let you find and talk with ' . + 'people of similar interests. After you join a group ' . + 'you can send messages to all other members using the ' . + 'syntax "!groupname". Don\'t see a group you like? Try ' . + '[searching for one](%%%%action.groupsearch%%%%) or ' . + '[start your own!](%%%%action.newgroup%%%%)')); + $this->elementStart('div', 'instructions'); + $this->raw(common_markup_to_html($notice)); + $this->elementEnd('div'); + } + + function showContent() + { + $this->element('a', array('href' => common_local_url('newgroup'), + 'id' => 'new_group'), + _('Create a new group')); + + $offset = ($this->page-1) * GROUPS_PER_PAGE; + $limit = GROUPS_PER_PAGE + 1; + + $groups = new User_group(); + $groups->orderBy('created DESC'); + $groups->limit($offset, $limit); + + if ($groups->find()) { + $gl = new GroupList($groups, null, $this); + $cnt = $gl->show(); + } + + $this->pagination($this->page > 1, $cnt > GROUPS_PER_PAGE, + $this->page, 'groups'); + } +} -- cgit v1.2.3-54-g00ecf