You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
88 lines
2.0 KiB
PHTML
88 lines
2.0 KiB
PHTML
10 years ago
|
<?php
|
||
|
/**
|
||
9 years ago
|
* ownCloud - Richdocuments App
|
||
10 years ago
|
*
|
||
|
* @author Victor Dubiniuk
|
||
|
* @copyright 2014 Victor Dubiniuk victor.dubiniuk@gmail.com
|
||
|
*
|
||
|
* This file is licensed under the Affero General Public License version 3 or
|
||
|
* later.
|
||
|
*/
|
||
|
|
||
9 years ago
|
namespace OCA\Richdocuments\Controller;
|
||
10 years ago
|
|
||
|
use \OCP\AppFramework\Controller;
|
||
8 years ago
|
use OCP\AppFramework\Http\JSONResponse;
|
||
10 years ago
|
use \OCP\IRequest;
|
||
|
use \OCP\IL10N;
|
||
|
|
||
9 years ago
|
use OCA\Richdocuments\AppConfig;
|
||
|
use OCA\Richdocuments\Filter;
|
||
10 years ago
|
|
||
|
class SettingsController extends Controller{
|
||
8 years ago
|
/** @var IL10N */
|
||
10 years ago
|
private $l10n;
|
||
8 years ago
|
/** @var AppConfig */
|
||
9 years ago
|
private $appConfig;
|
||
8 years ago
|
|
||
8 years ago
|
/**
|
||
|
* @param string $appName
|
||
|
* @param IRequest $request
|
||
|
* @param IL10N $l10n
|
||
|
* @param AppConfig $appConfig
|
||
|
* @param string $userId
|
||
|
*/
|
||
|
public function __construct($appName,
|
||
|
IRequest $request,
|
||
|
IL10N $l10n,
|
||
|
AppConfig $appConfig,
|
||
|
$userId) {
|
||
10 years ago
|
parent::__construct($appName, $request);
|
||
|
$this->l10n = $l10n;
|
||
9 years ago
|
$this->appConfig = $appConfig;
|
||
10 years ago
|
}
|
||
8 years ago
|
|
||
10 years ago
|
/**
|
||
|
* @NoAdminRequired
|
||
|
*/
|
||
|
public function getSupportedMimes(){
|
||
|
return array(
|
||
|
'status' => 'success',
|
||
|
'mimes' => Filter::getAll()
|
||
|
);
|
||
|
}
|
||
8 years ago
|
|
||
8 years ago
|
/**
|
||
|
* @param string $wopi_url
|
||
|
* @param string $doc_format
|
||
|
* @return JSONResponse
|
||
|
*/
|
||
|
public function setSettings($wopi_url,
|
||
|
$doc_format){
|
||
8 years ago
|
$message = $this->l10n->t('Saved');
|
||
|
|
||
8 years ago
|
if ($wopi_url !== null){
|
||
8 years ago
|
$this->appConfig->setAppValue('wopi_url', $wopi_url);
|
||
8 years ago
|
|
||
|
$colon = strpos($wopi_url, ':', 0);
|
||
|
if (\OC::$server->getRequest()->getServerProtocol() !== substr($wopi_url, 0, $colon)){
|
||
|
$message = $this->l10n->t('Saved with error: Collabora Online should use the same protocol as the server installation.');
|
||
|
}
|
||
8 years ago
|
}
|
||
|
|
||
8 years ago
|
if ($doc_format !== null) {
|
||
8 years ago
|
$this->appConfig->setAppValue('doc_format', $doc_format);
|
||
|
}
|
||
|
|
||
8 years ago
|
$richMemCache = \OC::$server->getMemCacheFactory()->create('richdocuments');
|
||
|
$richMemCache->clear('discovery.xml');
|
||
|
|
||
10 years ago
|
$response = array(
|
||
|
'status' => 'success',
|
||
8 years ago
|
'data' => array('message' => (string) $message)
|
||
10 years ago
|
);
|
||
8 years ago
|
|
||
8 years ago
|
return new JSONResponse($response);
|
||
10 years ago
|
}
|
||
|
}
|