[feature/module_services] Move topposers to module services

This commit is contained in:
Marc Alexander
2013-11-17 01:17:23 +01:00
parent 8c66281379
commit 9131024585
3 changed files with 68 additions and 29 deletions

View File

@@ -90,6 +90,11 @@ services:
tags:
- { name: board3.module }
board3.module.clock:
class: \board3\portal\modules\clock
tags:
- { name: board3.module }
board3.module.custom:
class: \board3\portal\modules\custom
arguments:
@@ -102,6 +107,15 @@ services:
tags:
- { name: board3.module }
board3.module.donation:
class: \board3\portal\modules\donation
arguments:
- @config
- @template
- @user
tags:
- { name: board3.module }
board3.module.forumlist:
class: \board3\portal\modules\forumlist
arguments:
@@ -271,16 +285,13 @@ services:
tags:
- { name: board3.module }
board3.module.clock:
class: \board3\portal\modules\clock
tags:
- { name: board3.module }
board3.module.donation:
class: \board3\portal\modules\donation
board3.module.topposters:
class: \board3\portal\modules\topposters
arguments:
- @config
- @dbal.conn
- @template
- @user
- %core.root_path%
- %core.php_ext%
tags:
- { name: board3.module }

View File

@@ -369,7 +369,7 @@ class v210_beta1 extends \phpbb\db\migration\migration
'module_status' => 1,
),
array(
'module_classname' => 'topposters',
'module_classname' => '\board3\portal\modules\topposters',
'module_column' => 1,
'module_order' => 7,
'module_name' => 'TOPPOSTERS',

View File

@@ -1,24 +1,18 @@
<?php
/**
*
* @package Board3 Portal v2 - Topposters
* @package Board3 Portal v2.1
* @copyright (c) Board3 Group ( www.board3.de )
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
namespace board3\portal\modules;
/**
* @package Topposters
*/
class portal_topposters_module extends \board3\portal\modules\module_base
class topposters extends module_base
{
/**
* Allowed columns: Just sum up your options (Exp: left + right = 10)
@@ -47,37 +41,68 @@ class portal_topposters_module extends \board3\portal\modules\module_base
*/
public $language = 'portal_topposters_module';
public function get_template_center($module_id)
/** @var \phpbb\config\config */
protected $config;
/** @var \phpbb\db\driver */
protected $db;
/** @var \phpbb\template */
protected $template;
/** @var php file extension */
protected $php_ext;
/** @var phpbb root path */
protected $phpbb_root_path;
/**
* Construct a topposers object
*
* @param \phpbb\config\config $config phpBB config
* @param \phpbb\db\driver $db phpBB db driver
* @param \phpbb\template $template phpBB template
* @param string $phpbb_root_path phpBB root path
* @param string $phpEx php file extension
*/
public function __construct($config, $db, $template, $phpbb_root_path, $phpEx)
{
return false;
$this->config = $config;
$this->db = $db;
$this->template = $template;
$this->phpbb_root_path = $phpbb_root_path;
$this->php_ext = $phpEx;
}
/**
* @inheritdoc
*/
public function get_template_side($module_id)
{
global $config, $db, $template;
global $phpbb_root_path, $phpEx;
$sql = 'SELECT user_id, username, user_posts, user_colour
FROM ' . USERS_TABLE . '
WHERE user_type <> ' . USER_IGNORE . "
AND user_posts <> 0
AND username <> ''
ORDER BY user_posts DESC";
$result = $db->sql_query_limit($sql, $config['board3_topposters_' . $module_id]);
$result = $this->db->sql_query_limit($sql, $this->config['board3_topposters_' . $module_id]);
while (($row = $db->sql_fetchrow($result)))
while (($row = $this->db->sql_fetchrow($result)))
{
$template->assign_block_vars('topposters', array(
'S_SEARCH_ACTION' => append_sid("{$phpbb_root_path}search.$phpEx", 'author_id=' . $row['user_id'] . '&amp;sr=posts'),
$this->template->assign_block_vars('topposters', array(
'S_SEARCH_ACTION' => append_sid("{$this->phpbb_root_path}search.{$this->php_ext}", 'author_id=' . $row['user_id'] . '&amp;sr=posts'),
'USERNAME_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']),
'POSTER_POSTS' => $row['user_posts'],
));
}
$db->sql_freeresult($result);
$this->db->sql_freeresult($result);
return 'topposters_side.html';
}
/**
* @inheritdoc
*/
public function get_template_acp($module_id)
{
return array(
@@ -90,7 +115,7 @@ class portal_topposters_module extends \board3\portal\modules\module_base
}
/**
* API functions
* @inheritdoc
*/
public function install($module_id)
{
@@ -98,6 +123,9 @@ class portal_topposters_module extends \board3\portal\modules\module_base
return true;
}
/**
* @inheritdoc
*/
public function uninstall($module_id, $db)
{
$del_config = array(