. * */ namespace OCA\News\Controller; use \OCP\IRequest; use \OCP\AppFramework\Http\JSONResponse; use \OCP\AppFramework\Controller; use \OCA\News\Core\API; class PageController extends Controller { private $api; public function __construct(API $api, IRequest $request){ parent::__construct($api->getAppName(), $request); $this->api = $api; } /** * @NoAdminRequired * @NoCSRFRequired */ public function index() { return $this->render('main'); } /** * @NoAdminRequired */ public function settings() { $showAll = $this->api->getUserValue('showAll'); $compact = $this->api->getUserValue('compact'); $language = $this->api->getTrans()->findLanguage(); $settings = array( 'showAll' => $showAll === '1', 'compact' => $compact === '1', 'language' => $language ); return new JSONResponse($settings); } /** * @NoAdminRequired */ public function updateSettings() { $isShowAll = $this->params('showAll'); $isCompact = $this->params('compact'); $this->api->setUserValue('showAll', $isShowAll); $this->api->setUserValue('compact', $isCompact); return new JSONResponse(); } }