remove dead code (from Collabora Online perspective)
This commit is contained in:
parent
664a564ee4
commit
f0f3e42c0e
258
appinfo/app.php
258
appinfo/app.php
@ -23,7 +23,6 @@
|
||||
|
||||
namespace OCA\Richdocuments\AppInfo;
|
||||
|
||||
use OCA\Richdocuments\Filter\Office;
|
||||
use OCA\Richdocuments\Config;
|
||||
|
||||
$app = new Application();
|
||||
@ -53,262 +52,5 @@ if (isset($request->server['REQUEST_URI'])) {
|
||||
}
|
||||
}
|
||||
|
||||
if ($c->query('AppConfig')->isConverterEnabled()){
|
||||
$odtFilter = new Office(
|
||||
[
|
||||
'read' =>
|
||||
[
|
||||
'target' => 'application/vnd.oasis.opendocument.text',
|
||||
'format' => 'odt:writer8',
|
||||
'extension' => 'odt'
|
||||
],
|
||||
'write' =>
|
||||
[
|
||||
'target' => 'application/msword',
|
||||
'format' => 'doc',
|
||||
'extension' => 'doc'
|
||||
]
|
||||
]
|
||||
);
|
||||
|
||||
$docxFilter = new Office(
|
||||
[
|
||||
'read' =>
|
||||
[
|
||||
'target' => 'application/vnd.oasis.opendocument.text',
|
||||
'format' => 'odt:writer8',
|
||||
'extension' => 'odt'
|
||||
],
|
||||
'write' =>
|
||||
[
|
||||
'target' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
||||
'format' => 'docx',
|
||||
'extension' => 'docx'
|
||||
]
|
||||
]
|
||||
);
|
||||
|
||||
$odpFilter = new Office(
|
||||
[
|
||||
'read' =>
|
||||
[
|
||||
'target' => 'application/vnd.oasis.opendocument.presentation',
|
||||
'format' => 'odp',
|
||||
'extension' => 'odp'
|
||||
],
|
||||
'write' =>
|
||||
[
|
||||
'target' => 'application/vnd.oasis.opendocument.presentation',
|
||||
'format' => 'dop',
|
||||
'extension' => 'odp'
|
||||
]
|
||||
]
|
||||
);
|
||||
|
||||
$odsFilter = new Office(
|
||||
[
|
||||
'read' =>
|
||||
[
|
||||
'target' => 'application/vnd.oasis.opendocument.spreadsheet',
|
||||
'format' => 'ods',
|
||||
'extension' => 'ods'
|
||||
],
|
||||
'write' =>
|
||||
[
|
||||
'target' => 'application/vnd.oasis.opendocument.spreadsheet',
|
||||
'format' => 'ods',
|
||||
'extension' => 'ods'
|
||||
]
|
||||
]
|
||||
);
|
||||
|
||||
$odgFilter = new Office(
|
||||
[
|
||||
'read' =>
|
||||
[
|
||||
'target' => 'application/vnd.oasis.opendocument.graphics',
|
||||
'format' => 'odg',
|
||||
'extension' => 'odg'
|
||||
],
|
||||
'write' =>
|
||||
[
|
||||
'target' => 'application/vnd.oasis.opendocument.graphics',
|
||||
'format' => 'odg',
|
||||
'extension' => 'odg'
|
||||
]
|
||||
]
|
||||
);
|
||||
|
||||
$docFilter = new Office(
|
||||
[
|
||||
'read' =>
|
||||
[
|
||||
'target' => 'application/msword',
|
||||
'format' => 'doc',
|
||||
'extension' => 'doc'
|
||||
],
|
||||
'write' =>
|
||||
[
|
||||
'target' => 'application/msword',
|
||||
'format' => 'doc',
|
||||
'extension' => 'doc'
|
||||
]
|
||||
]
|
||||
);
|
||||
|
||||
$lwpFilter = new Office(
|
||||
[
|
||||
'read' =>
|
||||
[
|
||||
'target' => 'application/vnd.lotus-wordpro',
|
||||
'format' => 'lwp',
|
||||
'extension' => 'lwp'
|
||||
],
|
||||
'write' =>
|
||||
[
|
||||
'target' => 'application/vnd.lotus-wordpro',
|
||||
'format' => 'lwp',
|
||||
'extension' => 'lwp'
|
||||
]
|
||||
]
|
||||
);
|
||||
|
||||
$svgFilter = new Office(
|
||||
[
|
||||
'read' =>
|
||||
[
|
||||
'target' => 'image/svg+xml',
|
||||
'format' => 'svg',
|
||||
'extension' => 'svg'
|
||||
],
|
||||
'write' =>
|
||||
[
|
||||
'target' => 'image/svg+xml',
|
||||
'format' => 'svg',
|
||||
'extension' => 'svg'
|
||||
]
|
||||
]
|
||||
);
|
||||
|
||||
$potFilter = new Office(
|
||||
[
|
||||
'read' =>
|
||||
[
|
||||
'target' => 'application/vnd.ms-powerpoint',
|
||||
'format' => 'pot',
|
||||
'extension' => 'pot'
|
||||
],
|
||||
'write' =>
|
||||
[
|
||||
'target' => 'application/vnd.ms-powerpoint',
|
||||
'format' => 'pot',
|
||||
'extension' => 'pot'
|
||||
]
|
||||
]
|
||||
);
|
||||
|
||||
$xlaFilter = new Office(
|
||||
[
|
||||
'read' =>
|
||||
[
|
||||
'target' => 'application/vnd.ms-excel',
|
||||
'format' => 'xla',
|
||||
'extension' => 'xla'
|
||||
],
|
||||
'write' =>
|
||||
[
|
||||
'target' => 'application/vnd.ms-excel',
|
||||
'format' => 'xla',
|
||||
'extension' => 'xla'
|
||||
]
|
||||
]
|
||||
);
|
||||
|
||||
$xlaFilter = new Office(
|
||||
[
|
||||
'read' =>
|
||||
[
|
||||
'target' => 'application/vnd.ms-excel',
|
||||
'format' => 'xla',
|
||||
'extension' => 'xla'
|
||||
],
|
||||
'write' =>
|
||||
[
|
||||
'target' => 'application/vnd.ms-excel',
|
||||
'format' => 'xla',
|
||||
'extension' => 'xla'
|
||||
]
|
||||
]
|
||||
);
|
||||
|
||||
$xlsxFilter = new Office(
|
||||
[
|
||||
'read' =>
|
||||
[
|
||||
'target' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
||||
'format' => 'xlsx',
|
||||
'extension' => 'xlsx'
|
||||
],
|
||||
'write' =>
|
||||
[
|
||||
'target' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
||||
'format' => 'xlsx',
|
||||
'extension' => 'xlsx'
|
||||
]
|
||||
]
|
||||
);
|
||||
|
||||
$vsdFilter = new Office(
|
||||
[
|
||||
'read' =>
|
||||
[
|
||||
'target' => 'application/vnd.visio',
|
||||
'format' => 'vsd',
|
||||
'extension' => 'vsd'
|
||||
],
|
||||
'write' =>
|
||||
[
|
||||
'target' => 'application/vnd.visio',
|
||||
'format' => 'vsd',
|
||||
'extension' => 'vsd'
|
||||
]
|
||||
]
|
||||
);
|
||||
|
||||
$wpdFilter = new Office(
|
||||
[
|
||||
'read' =>
|
||||
[
|
||||
'target' => 'application/vnd.wordperfect',
|
||||
'format' => 'wpd',
|
||||
'extension' => 'wpd'
|
||||
],
|
||||
'write' =>
|
||||
[
|
||||
'target' => 'application/vnd.wordperfect',
|
||||
'format' => 'wpd',
|
||||
'extension' => 'wpd'
|
||||
]
|
||||
]
|
||||
);
|
||||
|
||||
$wpdFilter = new Office(
|
||||
[
|
||||
'read' =>
|
||||
[
|
||||
'target' => 'application/vnd.wordperfect',
|
||||
'format' => 'wpd',
|
||||
'extension' => 'wpd'
|
||||
],
|
||||
'write' =>
|
||||
[
|
||||
'target' => 'application/vnd.wordperfect',
|
||||
'format' => 'wpd',
|
||||
'extension' => 'wpd'
|
||||
]
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
//Listen to delete file signal
|
||||
\OCP\Util::connectHook('OC_Filesystem', 'delete', "OCA\Richdocuments\Storage", "onDelete");
|
||||
|
@ -43,7 +43,7 @@ $application->registerRoutes($this, [
|
||||
//settings
|
||||
['name' => 'settings#savePersonal', 'url' => 'ajax/personal.php', 'verb' => 'POST'],
|
||||
['name' => 'settings#setUnstable', 'url' => 'ajax/config/unstable', 'verb' => 'POST'],
|
||||
['name' => 'settings#setConverter', 'url' => 'ajax/admin.php', 'verb' => 'POST'],
|
||||
['name' => 'settings#setSettings', 'url' => 'ajax/admin.php', 'verb' => 'POST'],
|
||||
['name' => 'settings#getSupportedMimes', 'url' => 'ajax/mimes.php', 'verb' => 'GET'],
|
||||
]
|
||||
]);
|
||||
|
@ -380,11 +380,9 @@ class DocumentController extends Controller{
|
||||
$fullPath = '/files' . $path;
|
||||
$fileInfo = \OC\Files\Filesystem::getFileInfo($path);
|
||||
if ($fileInfo){
|
||||
if($fileInfo->getMimeType() !== \OCA\Richdocuments\Filter\Office::NATIVE_MIMETYPE){
|
||||
$file = new File($fileInfo->getId());
|
||||
$genesis = new Genesis($file);
|
||||
$fullPath = $genesis->getPath();
|
||||
}
|
||||
$file = new File($fileInfo->getId());
|
||||
$genesis = new Genesis($file);
|
||||
$fullPath = $genesis->getPath();
|
||||
}
|
||||
return new DownloadResponse($this->request, $this->uid, $fullPath);
|
||||
}
|
||||
|
@ -18,7 +18,6 @@ use \OCP\AppFramework\Http\JSONResponse;
|
||||
use OCP\AppFramework\Http\TemplateResponse;
|
||||
|
||||
use OCA\Richdocuments\AppConfig;
|
||||
use OCA\Richdocuments\Converter;
|
||||
use OCA\Richdocuments\Filter;
|
||||
|
||||
class SettingsController extends Controller{
|
||||
@ -77,9 +76,7 @@ class SettingsController extends Controller{
|
||||
$this->appName,
|
||||
'admin',
|
||||
[
|
||||
'converter' => $this->appConfig->getAppValue('converter'),
|
||||
'wopi_url' => $this->appConfig->getAppValue('wopi_url'),
|
||||
'converter_url' => $this->appConfig->getAppValue('converter_url'),
|
||||
],
|
||||
'blank'
|
||||
);
|
||||
@ -121,54 +118,16 @@ class SettingsController extends Controller{
|
||||
return array('status' => 'success');
|
||||
}
|
||||
|
||||
public function setConverter($converter, $wopi_url, $url){
|
||||
if (!is_null($converter)){
|
||||
$this->appConfig->setAppValue('converter', $converter);
|
||||
}
|
||||
|
||||
public function setSettings($wopi_url){
|
||||
if (!is_null($wopi_url)){
|
||||
$this->appConfig->setAppValue('wopi_url', $wopi_url);
|
||||
}
|
||||
|
||||
if (!is_null($url)){
|
||||
$this->appConfig->setAppValue('converter_url', $url);
|
||||
}
|
||||
|
||||
$response = array(
|
||||
'status' => 'success',
|
||||
'data' => array('message' => (string) $this->l10n->t('Saved'))
|
||||
);
|
||||
|
||||
$currentConverter = $this->appConfig->getAppValue('converter');
|
||||
if ($currentConverter == 'external'){
|
||||
if (!Converter::checkConnection()){
|
||||
\OC::$server->getLogger()->warning(
|
||||
'Bad response from Format Filter Server',
|
||||
['app' => $this->appName]
|
||||
);
|
||||
$response = array(
|
||||
'status' => 'error',
|
||||
'data'=>
|
||||
array('message' => (string) $this->l10n->t('Format filter server is down or misconfigured') )
|
||||
);
|
||||
}
|
||||
} elseif ($currentConverter === 'local') {
|
||||
try {
|
||||
if (!Converter::testConversion()){
|
||||
$response = array(
|
||||
'status' => 'error',
|
||||
'data'=>
|
||||
array('message' => (string) $this->l10n->t('Conversion failed. Check log for details.') )
|
||||
);
|
||||
}
|
||||
} catch (\Exception $e){
|
||||
$response = array(
|
||||
'status' => 'error',
|
||||
'data'=> array('message' => $e->getMessage())
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
|
@ -6,14 +6,9 @@ $(document).ready(function(){
|
||||
save : function() {
|
||||
$('#docs_apply').attr('disabled', true);
|
||||
var data = {
|
||||
converter : $('[name="docs_converter"]:checked').val(),
|
||||
wopi_url : $('#wopi_url').val()
|
||||
};
|
||||
|
||||
if (data.converter === 'external'){
|
||||
data.url = $('#docs_url').val();
|
||||
}
|
||||
|
||||
OC.msg.startAction('#documents-admin-msg', t('richdocuments', 'Saving...'));
|
||||
$.post(
|
||||
OC.filePath('richdocuments', 'ajax', 'admin.php'),
|
||||
@ -28,8 +23,5 @@ $(document).ready(function(){
|
||||
}
|
||||
};
|
||||
|
||||
$('#docs_converter_external, #docs_converter_local, #docs_converter_off').on('click', function(){
|
||||
$('#docs_extra').toggle($('[name="docs_converter"]:checked').val() === 'external');
|
||||
});
|
||||
$('#docs_apply').on('click', documentsSettings.save);
|
||||
});
|
||||
|
@ -16,8 +16,6 @@ use \OCP\IConfig;
|
||||
class AppConfig{
|
||||
private $appName = 'richdocuments';
|
||||
private $defaults = [
|
||||
'converter' => 'off',
|
||||
'converter_url' => 'http://localhost:16080',
|
||||
'unstable' => 'false',
|
||||
'wopi_url' => 'htpp://localhost'
|
||||
];
|
||||
@ -28,14 +26,6 @@ use \OCP\IConfig;
|
||||
$this->config = $config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Can we convert anything to odt?
|
||||
* @return bool
|
||||
*/
|
||||
public function isConverterEnabled(){
|
||||
return $this->getAppValue('converter') !== 'off';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a value by key
|
||||
* @param string $key
|
||||
|
@ -1,147 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* ownCloud - Richdocuments App
|
||||
*
|
||||
* @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.
|
||||
*/
|
||||
|
||||
namespace OCA\Richdocuments;
|
||||
|
||||
use OCA\Richdocuments\AppInfo\Application;
|
||||
|
||||
class Converter {
|
||||
|
||||
const TEST_DOC_PATH = '/assets/test.doc';
|
||||
|
||||
public static function testConversion(){
|
||||
$targetFilter = 'odt:writer8';
|
||||
$targetExtension = 'odt';
|
||||
$input = file_get_contents(dirname(__DIR__) . self::TEST_DOC_PATH);
|
||||
$infile = \OC::$server->getTempManager()->getTemporaryFile();
|
||||
$outdir = \OC::$server->getTempManager()->getTemporaryFolder();
|
||||
$outfile = $outdir . '/' . basename($infile) . '.' . $targetExtension;
|
||||
$cmd = Helper::findOpenOffice();
|
||||
|
||||
$params = ' --headless --convert-to ' . escapeshellarg($targetFilter) . ' --outdir '
|
||||
. escapeshellarg($outdir)
|
||||
. ' --writer '. escapeshellarg($infile)
|
||||
. ' -env:UserInstallation=file://'
|
||||
. escapeshellarg(\OC::$server->getTempManager()->getTempBaseDir() . '/owncloud-' . \OC_Util::getInstanceId().'/') . ' 2>&1'
|
||||
;
|
||||
file_put_contents($infile, $input);
|
||||
|
||||
$result = shell_exec($cmd . $params);
|
||||
$exists = file_exists($outfile);
|
||||
|
||||
if (!$exists){
|
||||
\OC::$server->getLogger()->warn(
|
||||
'Conversion test failed. Raw output:' . $result,
|
||||
['app' => 'richdocuments']
|
||||
|
||||
);
|
||||
return false;
|
||||
} else {
|
||||
unlink($outfile);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function convert($input, $targetFilter, $targetExtension){
|
||||
if (self::getAppConfig()->getAppValue('converter') === 'local'){
|
||||
$output = self::convertLocal($input, $targetFilter, $targetExtension);
|
||||
} else {
|
||||
$output = self::convertExternal($input, $targetExtension);
|
||||
}
|
||||
|
||||
if (empty($output)){
|
||||
\OC::$server->getLogger()->warn(
|
||||
'Empty conversion output',
|
||||
['app' => 'richdocuments']
|
||||
|
||||
);
|
||||
throw new \RuntimeException('Empty conversion output');
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
public static function checkConnection(){
|
||||
$expected = file_get_contents(dirname(__DIR__) . '/assets/response.odt');
|
||||
$converted = self::convertExternal('', 'odt');
|
||||
|
||||
return $converted === $expected;
|
||||
}
|
||||
|
||||
/**
|
||||
* convert via openOffice hosted on the same server
|
||||
* @param string $input
|
||||
* @param string $targetFilter
|
||||
* @param string $targetExtension
|
||||
* @return string
|
||||
*/
|
||||
protected static function convertLocal($input, $targetFilter, $targetExtension){
|
||||
$infile = \OC::$server->getTempManager()->getTemporaryFile();
|
||||
$outdir = \OC::$server->getTempManager()->getTemporaryFolder();
|
||||
$cmd = Helper::findOpenOffice();
|
||||
$params = ' --headless --convert-to ' . $targetFilter . ' --outdir '
|
||||
. escapeshellarg($outdir)
|
||||
. ' --writer '. escapeshellarg($infile)
|
||||
. ' -env:UserInstallation=file://'
|
||||
. escapeshellarg(\OC::$server->getTempManager()->getTempBaseDir() . '/owncloud-' . \OC_Util::getInstanceId().'/')
|
||||
;
|
||||
|
||||
file_put_contents($infile, $input);
|
||||
shell_exec($cmd . $params);
|
||||
$output = file_get_contents($outdir . '/' . basename($infile) . '.' . $targetExtension);
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* convert via format-filter-server installed on the same host with openOffice
|
||||
* @param string $input
|
||||
* @return string
|
||||
*/
|
||||
protected static function convertExternal($input, $targetExtension){
|
||||
$options = array(
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_HEADER => false,
|
||||
CURLOPT_FOLLOWLOCATION => true,
|
||||
CURLOPT_ENCODING => "",
|
||||
CURLOPT_AUTOREFERER => true,
|
||||
CURLOPT_CONNECTTIMEOUT => 120,
|
||||
CURLOPT_TIMEOUT => 120,
|
||||
CURLOPT_MAXREDIRS => 2,
|
||||
CURLOPT_POST => 1,
|
||||
CURLOPT_POSTFIELDS => $input,
|
||||
CURLOPT_SSL_VERIFYHOST => 0,
|
||||
CURLOPT_SSL_VERIFYPEER => 0,
|
||||
CURLOPT_VERBOSE => 1
|
||||
);
|
||||
|
||||
$ch = curl_init(self::getAppConfig()->getAppValue('converter_url') . '?target_format=' . $targetExtension);
|
||||
curl_setopt_array($ch, $options);
|
||||
$content = curl_exec($ch);
|
||||
if (curl_errno($ch)){
|
||||
\OC::$server->getLogger()->debug(
|
||||
'cURL error' . curl_errno($ch) . ':' . curl_error($ch),
|
||||
['app' => 'richdocuments']
|
||||
|
||||
);
|
||||
}
|
||||
curl_close($ch);
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
protected static function getAppConfig(){
|
||||
$app = new Application();
|
||||
$c = $app->getContainer();
|
||||
return $c->query('AppConfig');
|
||||
}
|
||||
|
||||
}
|
@ -1,85 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* ownCloud - RichDocuments App
|
||||
*
|
||||
* @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.
|
||||
*/
|
||||
|
||||
namespace OCA\Richdocuments\Filter;
|
||||
|
||||
class Office {
|
||||
const NATIVE_MIMETYPE = 'application/vnd.oasis.opendocument.text';
|
||||
|
||||
private $readSpec;
|
||||
private $writeSpec;
|
||||
|
||||
/* sample mimespec
|
||||
array (
|
||||
'read' =>
|
||||
array (
|
||||
'target' => 'application/vnd.oasis.opendocument.text',
|
||||
'format' => 'odt:writer8',
|
||||
'extension' => 'odt'
|
||||
),
|
||||
'write' =>
|
||||
array (
|
||||
'target' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
||||
'format' => 'docx',
|
||||
'extension' => 'docx'
|
||||
)
|
||||
);
|
||||
|
||||
array(
|
||||
'read' =>
|
||||
array (
|
||||
'target' => 'application/vnd.oasis.opendocument.text',
|
||||
'format' => 'odt:writer8',
|
||||
'extension' => 'odt'
|
||||
),
|
||||
'write' =>
|
||||
array (
|
||||
'target' => 'application/msword',
|
||||
'format' => 'doc',
|
||||
'extension' => 'doc'
|
||||
)
|
||||
);
|
||||
|
||||
*/
|
||||
|
||||
public function __construct($mimeSpec){
|
||||
$this->readSpec = $mimeSpec['read'];
|
||||
$this->writeSpec = $mimeSpec['write'];
|
||||
|
||||
\OCA\Richdocuments\Filter::add($mimeSpec['write']['target'], $this);
|
||||
}
|
||||
|
||||
public function read($data){
|
||||
return array(
|
||||
'mimetype' => $this->readSpec['target'],
|
||||
'content' =>
|
||||
\OCA\Richdocuments\Converter::convert(
|
||||
$data['content'],
|
||||
$this->readSpec['format'],
|
||||
$this->readSpec['extension']
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function write($data){
|
||||
return array(
|
||||
'mimetype' => $this->writeSpec['target'],
|
||||
'content' =>
|
||||
\OCA\Richdocuments\Converter::convert(
|
||||
$data['content'],
|
||||
$this->writeSpec['format'],
|
||||
$this->writeSpec['extension']
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
@ -26,7 +26,7 @@ class Helper {
|
||||
|
||||
return $path;
|
||||
}
|
||||
|
||||
|
||||
public static function getArrayValueByKey($array, $key, $default=''){
|
||||
if (array_key_exists($key, $array)){
|
||||
return $array[$key];
|
||||
@ -141,39 +141,5 @@ class Helper {
|
||||
$dB = str_pad(dechex(round($dB)), 2, "0", STR_PAD_LEFT);
|
||||
return $dR.$dG.$dB;
|
||||
}
|
||||
|
||||
public static function findOpenOffice(){
|
||||
$config = \OC::$server->getConfig();
|
||||
$cmd = '';
|
||||
if (is_string($config->getSystemValue('preview_libreoffice_path', null))){
|
||||
$cmd = $config->getSystemValue('preview_libreoffice_path', null);
|
||||
}
|
||||
|
||||
$whichLibreOffice = shell_exec('which libreoffice');
|
||||
if ($cmd === '' && !empty($whichLibreOffice)){
|
||||
$cmd = 'libreoffice';
|
||||
}
|
||||
|
||||
$whichOpenOffice = shell_exec('which openoffice');
|
||||
if ($cmd === '' && !empty($whichOpenOffice)){
|
||||
$cmd = 'openoffice';
|
||||
}
|
||||
|
||||
if (empty($cmd)){
|
||||
\OC::$server->getLogger()->warn(
|
||||
'Pure configuration issue. Missing open office binary that is mandatory for conversion.',
|
||||
['app' => 'richdocuments']
|
||||
|
||||
);
|
||||
\OC::$server->getLogger()->debug(
|
||||
'If openoffice or libreoffice is already installed please specify the path to it using preview_libreoffice_path config. Refer to admin manual for details.',
|
||||
['app' => 'richdocuments']
|
||||
|
||||
);
|
||||
throw new \RuntimeException('Missing open office binary that is mandatory for conversion.');
|
||||
}
|
||||
|
||||
return $cmd;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,81 +0,0 @@
|
||||
#!/bin/bash
|
||||
# Copies the needed files from the build dir of the WebODF pullbox branch
|
||||
#
|
||||
# Prepare the webodf build dir by calling: make webodf-debug.js-target editor-compiled.js-target
|
||||
|
||||
if [ ! -e "README.md" ]; then
|
||||
echo "Call me in the toplevel dir of OwnCloud Documents."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ $# -lt 1 ]; then
|
||||
echo "Usage : $0 prepare|copy|patch"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
WEBODF_BUILDDIR='build/'
|
||||
WEBODF_SRCDIR='webodf/'
|
||||
|
||||
# create folders
|
||||
function prepare(){
|
||||
if [ ! -d "$WEBODF_SRCDIR" ]; then
|
||||
git clone git@github.com:kogmbh/WebODF.git "$WEBODF_SRCDIR"
|
||||
else
|
||||
pushd "$WEBODF_SRCDIR"
|
||||
git pull --rebase
|
||||
popd
|
||||
fi
|
||||
|
||||
if [ ! -d "$WEBODF_BUILDDIR" ]; then
|
||||
mkdir "$WEBODF_BUILDDIR"
|
||||
fi
|
||||
|
||||
pushd "$WEBODF_BUILDDIR"
|
||||
cmake "../${WEBODF_SRCDIR}"
|
||||
make all webodf-debug.js-target build-wodocollabtexteditor
|
||||
popd
|
||||
}
|
||||
|
||||
# copy sources
|
||||
function copy_sources(){
|
||||
# webodf.js
|
||||
cp "$WEBODF_BUILDDIR"/webodf/webodf.js ./js/3rdparty/webodf
|
||||
cp "$WEBODF_BUILDDIR"/webodf/webodf-debug.js ./js/3rdparty/webodf
|
||||
# dojo
|
||||
cp "$WEBODF_BUILDDIR"/programs/editor/dojo-amalgamation.js ./js/3rdparty/webodf
|
||||
|
||||
# Tools, Editor, EditorSession, MemberListView:
|
||||
cp "$WEBODF_BUILDDIR"/programs/editor/{Tools,Editor,EditorSession,MemberListView}.js ./js/3rdparty/webodf/editor
|
||||
cp "$WEBODF_BUILDDIR"/programs/editor/backend/pullbox/* ./js/3rdparty/webodf/editor/backend/pullbox -R
|
||||
cp "$WEBODF_BUILDDIR"/programs/editor/backend/ServerFactory.js ./js/3rdparty/webodf/editor/backend -R
|
||||
cp "$WEBODF_BUILDDIR"/programs/editor/widgets ./js/3rdparty/webodf/editor -R
|
||||
cp "$WEBODF_BUILDDIR"/wodocollabtexteditor/wodo/{wodotexteditor,wodocollabpane}.css ./css/3rdparty/webodf
|
||||
|
||||
cp "$WEBODF_BUILDDIR"/programs/editor/dojo/* ./js/3rdparty/resources/dojo -R
|
||||
cp "$WEBODF_BUILDDIR"/programs/editor/dojox/* ./js/3rdparty/resources/dojox -R
|
||||
cp "$WEBODF_BUILDDIR"/programs/editor/dijit/* ./js/3rdparty/resources/dijit -R
|
||||
|
||||
# files which need to be adapted manually:
|
||||
# "$WEBODF_BUILDDIR"/programs/editor/dojo-deps/src/app/resources/app.css -> ./css/3rdparty/webodf/dojo-app.css
|
||||
# dojo-app.css has other paths then upstream, needs to be manually adapted to changes
|
||||
# also is dojo.css is not imported here, other than in upstream
|
||||
}
|
||||
|
||||
# patches against upstream
|
||||
function patch_sources(){
|
||||
patch -p1 -i src/patches/Patch-EditorSession.patch
|
||||
patch -p1 -i src/patches/Patch-MemberListView.patch
|
||||
patch -p1 -i src/patches/Patch-Tools.patch
|
||||
|
||||
#Just for the record
|
||||
#patch -p1 -i src/patches/dojoStylesPill.patch
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
'prepare' )
|
||||
prepare ;;
|
||||
'copy' )
|
||||
copy_sources ;;
|
||||
'patch' )
|
||||
patch_sources ;;
|
||||
esac
|
@ -3,41 +3,10 @@ script('richdocuments', 'admin');
|
||||
?>
|
||||
<div class="section" id="documents">
|
||||
<h2><?php p($l->t('Documents')) ?></h2>
|
||||
<p><?php p($l->t('MS Word support (requires openOffice/libreOffice)')) ?></p>
|
||||
<p>
|
||||
<input type="radio" name="docs_converter" value="local" id="docs_converter_local"
|
||||
<?php print_unescaped($_['converter']=='local' ? 'checked="checked"' : '') ?>
|
||||
/>
|
||||
<label for="docs_converter_local"><?php p($l->t('Local')) ?></label><br>
|
||||
<em><?php p($l->t('openOffice/libreOffice is installed on this server. Path to binary is provided via preview_libreoffice_path in config.php')) ?></em>
|
||||
</p>
|
||||
<p>
|
||||
<input type="radio" name="docs_converter" value="external" id="docs_converter_external"
|
||||
<?php print_unescaped($_['converter']=='external' ? 'checked="checked"' : '') ?>
|
||||
/>
|
||||
<label for="docs_converter_external"><?php p($l->t('External')) ?></label><br>
|
||||
<em><?php p($l->t('openOffice/libreOffice is installed on external server running a format filter server')) ?></em>
|
||||
</p>
|
||||
<p>
|
||||
<input type="radio" name="docs_converter" value="off" id="docs_converter_off"
|
||||
<?php print_unescaped($_['converter']=='off' ? 'checked="checked"' : '') ?>
|
||||
/>
|
||||
<label for="docs_converter_off"><?php p($l->t('Disabled')) ?></label><br>
|
||||
<em><?php p($l->t('No MS Word support')) ?></em>
|
||||
</p>
|
||||
<div id="docs_extra" <?php print_unescaped($_['converter']!=='external' ? 'style="display:none"' : '') ?>>
|
||||
<input type="text" name="docs_url" id="docs_url"
|
||||
value="<?php p($_['converter_url'])?>"
|
||||
original-title="<?php p($l->t('scheme://domain.tld[:port]')) ?>"
|
||||
style="width:250px;"
|
||||
/>
|
||||
<br /><em><?php p($l->t('Server URL')) ?></em>
|
||||
</div>
|
||||
<br />
|
||||
<div id="wopi_client">
|
||||
<input type="text" name="wopi_url" id="wopi_url" value="<?php p($_['wopi_url'])?>" style="width:250px;">
|
||||
<br /><em><?php p($l->t('WOPI Client')) ?></em>
|
||||
</div>
|
||||
<br /><button type="button" id="docs_apply"><?php p($l->t('Apply and test')) ?></button>
|
||||
<br /><button type="button" id="docs_apply"><?php p($l->t('Apply')) ?></button>
|
||||
<span id="documents-admin-msg" class="msg"></span>
|
||||
</div>
|
||||
|
Loading…
x
Reference in New Issue
Block a user