-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathhelper.php
74 lines (66 loc) · 1.92 KB
/
helper.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<?php
/**
* This file is part of the NV Newspage Extension package.
*
* @copyright (c) nickvergessen <https://github.com/nickvergessen>
* @license GNU General Public License, version 2 (GPL-2.0)
*
* For full copyright and license information, please see
* the license.txt file.
*/
namespace nickvergessen\newspage;
/**
* Class helper
*
* @package nickvergessen\newspage
*/
class helper
{
/** @var \phpbb\controller\helper */
protected $helper;
/** @var \phpbb\config\config */
protected $config;
/**
* Constructor
*
* @param \phpbb\controller\helper $helper
* @param \phpbb\config\config $config
*/
public function __construct(\phpbb\controller\helper $helper, \phpbb\config\config $config)
{
$this->helper = $helper;
$this->config = $config;
}
/**
* Generate the pagination for the news list
*
* @param mixed $force_category Overwrites the category, false for disabled, integer otherwise
* @param mixed $force_archive Overwrites the archive, false for disabled, string otherwise
* @param mixed $force_page Overwrites the page, false for disabled, string otherwise
* @return \nickvergessen\newspage\route Full URL with append_sid performed on it
*/
public function generate_route($force_category = false, $force_archive = false, $force_page = false)
{
$route = new route($this->helper, $this->config);
if ($this->config['news_cat_show'] && $force_category)
{
$route->set_category($force_category);
}
if ($this->config['news_archive_show'] && is_array($force_archive))
{
$route->set_archive_year($force_archive['y'])
->set_archive_month($force_archive['m']);
}
else if ($this->config['news_archive_show'] && is_string($force_archive))
{
list($archive_year, $archive_month) = explode('/', $force_archive, 2);
$route->set_archive_year($archive_year)
->set_archive_month($archive_month);
}
if ($force_page)
{
$route->set_page($force_page);
}
return $route;
}
}