summaryrefslogtreecommitdiffstats
path: root/lib/Controller/AdminController.php
blob: e3551a2a179bc76d67d18a2ea52ce1856f0d108d (plain)
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
pre { line-height: 125%; }
td.linenos .normal { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
span.linenos { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
td.linenos .special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
span.linenos.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
.highlight .hll { background-color: #ffffcc }
<?php
/**
 * Nextcloud - News
 *
 * This file is licensed under the Affero General Public License version 3 or
 * later. See the COPYING file.
 *
 * @author Alessandro Cosentino <cosenal@gmail.com>
 * @author Bernhard Posselt <dev@bernhard-posselt.com>
 *
 * @copyright 2012 Alessandro Cosentino
 * @copyright 2012-2014 Bernhard Posselt
 */

namespace OCA\News\Controller;

use OCA\News\AppInfo\Application;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\IConfig;
use OCP\IRequest;
use OCP\AppFramework\Controller;

use OCA\News\Service\ItemService;

/**
 * Class AdminController
 *
 * @package OCA\News\Controller
 */
class AdminController extends Controller
{

    /**
     * @var IConfig
     */
    private $config;

    /**
     * @var ItemService
     */
    private $itemService;

    /**
     * AdminController constructor.
     *
     * @param string      $appName     The name of the app
     * @param IRequest    $request     The request
     * @param IConfig     $config      Config for nextcloud
     * @param ItemService $itemService Service for items
     */
    public function __construct(
        string $appName,
        IRequest $request,
        IConfig $config,
        ItemService $itemService
    ) {
        parent::__construct($appName, $request);
        $this->config      = $config;
        $this->itemService = $itemService;
    }

    /**
     * Controller main entry.
     *
     * There are no checks for the index method since the output is
     * rendered in admin/admin.php
     *
     * @return TemplateResponse
     */
    public function index(): TemplateResponse
    {
        return new TemplateResponse($this->appName, 'admin', $this->getData(), 'blank');
    }

    /**
     * Get admin data.
     *
     * @return array
     */
    private function getData(): array
    {
        $data = [];

        foreach (array_keys(Application::DEFAULT_SETTINGS) as $setting) {
            $data[$setting] = $this->config->getAppValue(
                Application::NAME,
                $setting,
                Application::DEFAULT_SETTINGS[$setting]
            );
        }

        return $data;
    }

    /**
     * Update the app config.
     *
     * @param int    $autoPurgeMinimumInterval New minimum interval for auto-purge
     * @param int    $autoPurgeCount           New value of auto-purge count
     * @param int    $maxRedirects             New value for max amount of redirects
     * @param int    $feedFetcherTimeout       New timeout value for feed fetcher
     * @param bool   $useCronUpdates           Whether or not to use cron updates
     * @param string $exploreUrl               URL to use for the explore feed
     * @param int    $updateInterval           Interval in which the feeds will be updated
     *
     * @return array with the updated values
     */
    public function update(
        int $autoPurgeMinimumInterval,
        int $autoPurgeCount,
        int $maxRedirects,
        int $feedFetcherTimeout,
        bool $useCronUpdates,
        string $exploreUrl,
        int $updateInterval
    ): array {
        $this->config->setAppValue($this->appName, 'autoPurgeMinimumInterval', $autoPurgeMinimumInterval);
        $this->config->setAppValue($this->appName, 'autoPurgeCount', $autoPurgeCount);
        $this->config->setAppValue($this->appName, 'maxRedirects', $maxRedirects);
        $this->config->setAppValue($this->appName, 'feedFetcherTimeout', $feedFetcherTimeout);
        $this->config->setAppValue($this->appName, 'useCronUpdates', $useCronUpdates);
        $this->config->setAppValue($this->appName, 'exploreUrl', $exploreUrl);
        $this->config->setAppValue($this->appName, 'updateInterval', $updateInterval);

        return $this->getData();
    }
}
class="p">: "Non hai artigos sen ler dispoñíbeis", "Open website" : "Abrir o sitio web", "Star article" : "Marcar artigo", "Unstar article" : "Desmarcar artigo", "Keep article unread" : "Manter o artigo como non lido", "Remove keep article unread" : "Retirar a marca de artigo sen ler", "by" : "por", "from" : "dende", "Play audio" : "Reproducir son", "Download audio" : "Descargar son", "Download video" : "Descargar video", "Keyboard shortcut" : "Atallo de teclado", "Description" : "Descrición", "right" : "dereita", "Jump to next article" : "Ir ao seguinte artigo", "left" : "esquerda", "Jump to previous article" : "Saltar ao artigo anterior", "Toggle star article" : "Marcar/desmarcar os artigos con estrela", "Star article and jump to next one" : "Destacar o artigo e ir ao seguinte", "Toggle keep current article unread" : "Manter/retirar o artigo actual como non lido", "Open article in new tab" : "Abrir o artigo nunha nova lapela", "Toggle expand article in compact view" : "Expandir/contraer o artigo en vista compacta", "Refresh" : "Actualizar", "Load next feed" : "Cargar a seguinte fonte", "Load previous feed" : "Cargar a fonte anterior", "Load next folder" : "Cargar o seguinte cartafol", "Load previous folder" : "Cargar o cartafol anterior", "Scroll to active navigation entry" : "Desprazar ata a entrada de navegación activa", "Focus search field" : "Campo de busca en foco", "Mark current article's feed/folder read" : "Marcar o actual artigo de fonte/cartafol como lido", "Ajax or webcron mode detected! Your feeds will not be updated!" : "Detectouse o modo Ajax ou webcron! As súas fontes non van ser actualizadas!", "How to set up the operating system cron" : "Cómo configurar o cron do sistema operativo", "Install and set up a faster parallel updater that uses the News app's update API" : "Instala e configura un actualizador paralelo máis rápido que utiliza a API de actualización da aplicación Novas", "Web address" : "Enderezo web", "Feed exists already!" : "Esta fonte de novas xa existe!", "Folder" : "Cartafol", "No folder" : "Sen cartafol", "New folder" : "Novo cartafol", "Folder name" : "Nome do cartafol", "Go back" : "Volver", "Folder exists already!" : "Xa existe o cartafol!", "Credentials" : "Credenciais", "HTTP Basic Auth credentials must be stored unencrypted! Everyone with access to the server or database will be able to access them!" : "As credenciais para HTTP Basic Auth deben estar gardadas sen cifrar! Calquera persoa con acceso ao servidor poderá acceder a elas!", "Username" : "Nome de usuario", "Password" : "Contrasinal", "New Folder" : "Novo cartafol", "Create" : "Crear", "Explore" : "Examinar", "Update failed more than 50 times" : "A actualización fallou máis de 50 veces.", "Deleted feed" : "Fonte eliminada", "Undo delete feed" : "Desfacer a eliminación da fonte", "Rename" : "Renomear", "Menu" : "Menú", "Mark read" : "Marcar como lido", "Unpin from top" : "Soltar de enriba", "Pin to top" : "Fixar enriba", "Newest first" : "Primeiro o máis recente", "Oldest first" : "Primeiro o máis antigo", "Default order" : "Orde predeterminado", "Enable full text" : "Activar o texto completo", "Disable full text" : "Desactivar o texto completo", "Unread updated" : "Actualización non lida", "Ignore updated" : "Ignorar actualizados", "Open feed URL" : "Abrir o URL da fonte", "Delete" : "Eliminar", "Dismiss" : "Rexeitar", "Collapse" : "Contraer", "Deleted folder" : "Eliminar cartafol", "Undo delete folder" : "Desfacer a eliminación do cartafol", "Starred" : "Destacado", "Unread articles" : "Artigos sen ler", "All articles" : "Todos os artigos", "Settings" : "Axustes", "Disable mark read through scrolling" : "Desactivar o marcado como lido co desprazamento", "Compact view" : "Vista compacta", "Expand articles on key navigation" : "Expandir artigos na tecla de navegación", "Show all articles" : "Amosar todos os artigos", "Reverse ordering (oldest on top)" : "Ordenado inverso (máis vellos enriba)", "Subscriptions (OPML)" : "Subscricións (OPML)", "Import" : "Importar", "Export" : "Exportar", "Error when importing: File does not contain valid OPML" : "Erro durante a importación: O ficheiro non contén OPML correcto", "Error when importing: OPML is does neither contain feeds nor folders" : "Produciuse un erro ao importar: OPML non contén fontes ou cartafoles", "Unread/Starred Articles" : "Artigos destacados ou sen ler", "Error when importing: file does not contain valid JSON" : "Produciuse un erro ao importar: o ficheiro non contén un JSON correcto", "Help" : "Axuda", "Keyboard shortcuts" : "Atallos de teclado", "Documentation" : "Documentación", "Report a bug" : "Informar dun fallo" },"pluralForm" :"nplurals=2; plural=(n != 1);" }