|
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
|
3 |
|
public function __construct($AppName, IRequest $request, Config $config, |
|
30
|
|
|
ItemService $itemService, $configFile){ |
|
31
|
3 |
|
parent::__construct($AppName, $request); |
|
32
|
3 |
|
$this->config = $config; |
|
33
|
3 |
|
$this->configPath = $configFile; |
|
34
|
3 |
|
$this->itemService = $itemService; |
|
35
|
3 |
|
} |
|
36
|
|
|
|
|
37
|
|
|
// There are no checks for the index method since the output is rendered |
|
38
|
|
|
// in admin/admin.php |
|
39
|
1 |
|
public function index() { |
|
40
|
|
|
$data = [ |
|
41
|
|
|
'autoPurgeMinimumInterval' => |
|
42
|
1 |
|
$this->config->getAutoPurgeMinimumInterval(), |
|
43
|
1 |
|
'autoPurgeCount' => $this->config->getAutoPurgeCount(), |
|
44
|
1 |
|
'maxRedirects' => $this->config->getMaxRedirects(), |
|
45
|
1 |
|
'feedFetcherTimeout' => $this->config->getFeedFetcherTimeout(), |
|
46
|
1 |
|
'useCronUpdates' => $this->config->getUseCronUpdates(), |
|
47
|
1 |
|
'maxSize' => $this->config->getMaxSize(), |
|
48
|
1 |
|
'exploreUrl' => $this->config->getExploreUrl(), |
|
49
|
1 |
|
]; |
|
50
|
1 |
|
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
|
1 |
|
public function update($autoPurgeMinimumInterval, $autoPurgeCount, |
|
65
|
|
|
$maxRedirects, $feedFetcherTimeout, $maxSize, |
|
66
|
|
|
$useCronUpdates, $exploreUrl) { |
|
67
|
1 |
|
$this->config->setAutoPurgeMinimumInterval($autoPurgeMinimumInterval); |
|
68
|
1 |
|
$this->config->setAutoPurgeCount($autoPurgeCount); |
|
69
|
1 |
|
$this->config->setMaxRedirects($maxRedirects); |
|
70
|
1 |
|
$this->config->setMaxSize($maxSize); |
|
71
|
1 |
|
$this->config->setFeedFetcherTimeout($feedFetcherTimeout); |
|
72
|
1 |
|
$this->config->setUseCronUpdates($useCronUpdates); |
|
73
|
1 |
|
$this->config->setExploreUrl($exploreUrl); |
|
74
|
1 |
|
$this->config->write($this->configPath); |
|
75
|
|
|
|
|
76
|
|
|
return [ |
|
77
|
|
|
'autoPurgeMinimumInterval' => |
|
78
|
1 |
|
$this->config->getAutoPurgeMinimumInterval(), |
|
79
|
1 |
|
'autoPurgeCount' => $this->config->getAutoPurgeCount(), |
|
80
|
1 |
|
'maxRedirects' => $this->config->getMaxRedirects(), |
|
81
|
1 |
|
'maxSize' => $this->config->getMaxSize(), |
|
82
|
1 |
|
'feedFetcherTimeout' => $this->config->getFeedFetcherTimeout(), |
|
83
|
1 |
|
'useCronUpdates' => $this->config->getUseCronUpdates(), |
|
84
|
1 |
|
'exploreUrl' => $this->config->getExploreUrl(), |
|
85
|
1 |
|
]; |
|
86
|
|
|
} |
|
87
|
|
|
|
|
88
|
|
|
/** |
|
89
|
|
|
* Generates indices |
|
90
|
|
|
*/ |
|
91
|
1 |
|
public function migrate() { |
|
92
|
1 |
|
$this->itemService->generateSearchIndices(); |
|
93
|
1 |
|
return []; |
|
94
|
|
|
} |
|
95
|
|
|
|
|
96
|
|
|
} |
|
97
|
|
|
|