1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* ownCloud - News |
4
|
|
|
* |
5
|
|
|
* This file is licensed under the Affero General Public License version 3 or |
6
|
|
|
* later. See the COPYING file. |
7
|
|
|
* |
8
|
|
|
* @author Alessandro Cosentino <[email protected]> |
9
|
|
|
* @author Bernhard Posselt <[email protected]> |
10
|
|
|
* @copyright Alessandro Cosentino 2012 |
11
|
|
|
* @copyright Bernhard Posselt 2012, 2014 |
12
|
|
|
*/ |
13
|
|
|
|
14
|
|
|
namespace OCA\News\Controller; |
15
|
|
|
|
16
|
|
|
use OCP\AppFramework\Http\TemplateResponse; |
17
|
|
|
use OCP\IRequest; |
18
|
|
|
use OCP\AppFramework\Controller; |
19
|
|
|
|
20
|
|
|
use OCA\News\Config\Config; |
21
|
|
|
use OCA\News\Service\itemService; |
22
|
|
|
|
23
|
|
|
class AdminController extends Controller { |
24
|
|
|
|
25
|
|
|
private $config; |
26
|
|
|
private $configPath; |
27
|
|
|
private $itemService; |
28
|
|
|
|
29
|
|
|
public function __construct($AppName, IRequest $request, Config $config, |
30
|
|
|
ItemService $itemService, $configFile){ |
31
|
|
|
parent::__construct($AppName, $request); |
32
|
|
|
$this->config = $config; |
33
|
|
|
$this->configPath = $configFile; |
34
|
|
|
$this->itemService = $itemService; |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
// There are no checks for the index method since the output is rendered |
38
|
|
|
// in admin/admin.php |
39
|
|
|
public function index() { |
40
|
|
|
$data = [ |
41
|
|
|
'autoPurgeMinimumInterval' => |
42
|
|
|
$this->config->getAutoPurgeMinimumInterval(), |
43
|
|
|
'autoPurgeCount' => $this->config->getAutoPurgeCount(), |
44
|
|
|
'maxRedirects' => $this->config->getMaxRedirects(), |
45
|
|
|
'feedFetcherTimeout' => $this->config->getFeedFetcherTimeout(), |
46
|
|
|
'useCronUpdates' => $this->config->getUseCronUpdates(), |
47
|
|
|
'maxSize' => $this->config->getMaxSize(), |
48
|
|
|
'exploreUrl' => $this->config->getExploreUrl(), |
49
|
|
|
]; |
50
|
|
|
return new TemplateResponse($this->appName, 'admin', $data, 'blank'); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* @param int $autoPurgeMinimumInterval |
56
|
|
|
* @param int $autoPurgeCount |
57
|
|
|
* @param int $maxRedirects |
58
|
|
|
* @param int $feedFetcherTimeout |
59
|
|
|
* @param int $maxSize |
60
|
|
|
* @param bool $useCronUpdates |
61
|
|
|
* @param string $exploreUrl |
62
|
|
|
* @return array with the updated values |
63
|
|
|
*/ |
64
|
|
|
public function update($autoPurgeMinimumInterval, $autoPurgeCount, |
65
|
|
|
$maxRedirects, $feedFetcherTimeout, $maxSize, |
66
|
|
|
$useCronUpdates, $exploreUrl) { |
67
|
|
|
$this->config->setAutoPurgeMinimumInterval($autoPurgeMinimumInterval); |
68
|
|
|
$this->config->setAutoPurgeCount($autoPurgeCount); |
69
|
|
|
$this->config->setMaxRedirects($maxRedirects); |
70
|
|
|
$this->config->setMaxSize($maxSize); |
71
|
|
|
$this->config->setFeedFetcherTimeout($feedFetcherTimeout); |
72
|
|
|
$this->config->setUseCronUpdates($useCronUpdates); |
73
|
|
|
$this->config->setExploreUrl($exploreUrl); |
74
|
|
|
$this->config->write($this->configPath); |
75
|
|
|
|
76
|
|
|
return [ |
77
|
|
|
'autoPurgeMinimumInterval' => |
78
|
|
|
$this->config->getAutoPurgeMinimumInterval(), |
79
|
|
|
'autoPurgeCount' => $this->config->getAutoPurgeCount(), |
80
|
|
|
'maxRedirects' => $this->config->getMaxRedirects(), |
81
|
|
|
'maxSize' => $this->config->getMaxSize(), |
82
|
|
|
'feedFetcherTimeout' => $this->config->getFeedFetcherTimeout(), |
83
|
|
|
'useCronUpdates' => $this->config->getUseCronUpdates(), |
84
|
|
|
'exploreUrl' => $this->config->getExploreUrl(), |
85
|
|
|
]; |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
} |
89
|
|
|
|