drg_elfinder 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +28 -0
- data/Rakefile +8 -0
- data/app/assets/config/drg_elfinder_manifest.js +1 -0
- data/app/assets/javascripts/drg_elfinder.js +15 -0
- data/app/assets/javascripts/elfinder/Changelog +1283 -0
- data/app/assets/javascripts/elfinder/LICENSE.md +15 -0
- data/app/assets/javascripts/elfinder/README.md +216 -0
- data/app/assets/javascripts/elfinder/bower.json +28 -0
- data/app/assets/javascripts/elfinder/composer.json +39 -0
- data/app/assets/javascripts/elfinder/css/elfinder.full.css +5350 -0
- data/app/assets/javascripts/elfinder/css/elfinder.min.css +9 -0
- data/app/assets/javascripts/elfinder/css/theme.css +430 -0
- data/app/assets/javascripts/elfinder/elfinder.html +74 -0
- data/app/assets/javascripts/elfinder/elfinder.legacy.html +94 -0
- data/app/assets/javascripts/elfinder/img/arrows-active.png +0 -0
- data/app/assets/javascripts/elfinder/img/arrows-normal.png +0 -0
- data/app/assets/javascripts/elfinder/img/crop.gif +0 -0
- data/app/assets/javascripts/elfinder/img/dialogs.png +0 -0
- data/app/assets/javascripts/elfinder/img/edit_aceeditor.png +0 -0
- data/app/assets/javascripts/elfinder/img/edit_ckeditor.png +0 -0
- data/app/assets/javascripts/elfinder/img/edit_ckeditor5.png +0 -0
- data/app/assets/javascripts/elfinder/img/edit_codemirror.png +0 -0
- data/app/assets/javascripts/elfinder/img/edit_creativecloud.png +0 -0
- data/app/assets/javascripts/elfinder/img/edit_onlineconvert.png +0 -0
- data/app/assets/javascripts/elfinder/img/edit_pixlreditor.png +0 -0
- data/app/assets/javascripts/elfinder/img/edit_pixlrexpress.png +0 -0
- data/app/assets/javascripts/elfinder/img/edit_simplemde.png +0 -0
- data/app/assets/javascripts/elfinder/img/edit_tinymce.png +0 -0
- data/app/assets/javascripts/elfinder/img/edit_tuiimgedit.png +0 -0
- data/app/assets/javascripts/elfinder/img/edit_zohooffice.png +0 -0
- data/app/assets/javascripts/elfinder/img/editor-icons.png +0 -0
- data/app/assets/javascripts/elfinder/img/icons-big.png +0 -0
- data/app/assets/javascripts/elfinder/img/icons-big.svg +1 -0
- data/app/assets/javascripts/elfinder/img/icons-small.png +0 -0
- data/app/assets/javascripts/elfinder/img/logo.png +0 -0
- data/app/assets/javascripts/elfinder/img/progress.gif +0 -0
- data/app/assets/javascripts/elfinder/img/quicklook-bg.png +0 -0
- data/app/assets/javascripts/elfinder/img/quicklook-icons.png +0 -0
- data/app/assets/javascripts/elfinder/img/resize.png +0 -0
- data/app/assets/javascripts/elfinder/img/spinner-mini.gif +0 -0
- data/app/assets/javascripts/elfinder/img/toolbar.png +0 -0
- data/app/assets/javascripts/elfinder/img/trashmesh.png +0 -0
- data/app/assets/javascripts/elfinder/img/tui-icon-a.svg +235 -0
- data/app/assets/javascripts/elfinder/img/tui-icon-b.svg +224 -0
- data/app/assets/javascripts/elfinder/img/tui-icon-c.svg +224 -0
- data/app/assets/javascripts/elfinder/img/tui-icon-d.svg +224 -0
- data/app/assets/javascripts/elfinder/img/ui-icons_ffffff_256x240.png +0 -0
- data/app/assets/javascripts/elfinder/img/volume_icon_box.png +0 -0
- data/app/assets/javascripts/elfinder/img/volume_icon_box.svg +1 -0
- data/app/assets/javascripts/elfinder/img/volume_icon_dropbox.png +0 -0
- data/app/assets/javascripts/elfinder/img/volume_icon_dropbox.svg +1 -0
- data/app/assets/javascripts/elfinder/img/volume_icon_ftp.png +0 -0
- data/app/assets/javascripts/elfinder/img/volume_icon_ftp.svg +1 -0
- data/app/assets/javascripts/elfinder/img/volume_icon_googledrive.png +0 -0
- data/app/assets/javascripts/elfinder/img/volume_icon_googledrive.svg +1 -0
- data/app/assets/javascripts/elfinder/img/volume_icon_local.png +0 -0
- data/app/assets/javascripts/elfinder/img/volume_icon_local.svg +1 -0
- data/app/assets/javascripts/elfinder/img/volume_icon_network.png +0 -0
- data/app/assets/javascripts/elfinder/img/volume_icon_network.svg +1 -0
- data/app/assets/javascripts/elfinder/img/volume_icon_onedrive.png +0 -0
- data/app/assets/javascripts/elfinder/img/volume_icon_onedrive.svg +1 -0
- data/app/assets/javascripts/elfinder/img/volume_icon_sql.png +0 -0
- data/app/assets/javascripts/elfinder/img/volume_icon_sql.svg +1 -0
- data/app/assets/javascripts/elfinder/img/volume_icon_trash.png +0 -0
- data/app/assets/javascripts/elfinder/img/volume_icon_trash.svg +1 -0
- data/app/assets/javascripts/elfinder/img/volume_icon_zip.png +0 -0
- data/app/assets/javascripts/elfinder/img/volume_icon_zip.svg +1 -0
- data/app/assets/javascripts/elfinder/js/elfinder.full.js +36019 -0
- data/app/assets/javascripts/elfinder/js/elfinder.min.js +25 -0
- data/app/assets/javascripts/elfinder/js/extras/editors.default.js +2643 -0
- data/app/assets/javascripts/elfinder/js/extras/editors.default.min.js +2 -0
- data/app/assets/javascripts/elfinder/js/extras/quicklook.googledocs.js +75 -0
- data/app/assets/javascripts/elfinder/js/extras/quicklook.googledocs.min.js +1 -0
- data/app/assets/javascripts/elfinder/js/i18n/elfinder.LANG.js +587 -0
- data/app/assets/javascripts/elfinder/js/i18n/elfinder.ar.js +580 -0
- data/app/assets/javascripts/elfinder/js/i18n/elfinder.bg.js +559 -0
- data/app/assets/javascripts/elfinder/js/i18n/elfinder.ca.js +375 -0
- data/app/assets/javascripts/elfinder/js/i18n/elfinder.cs.js +581 -0
- data/app/assets/javascripts/elfinder/js/i18n/elfinder.da.js +580 -0
- data/app/assets/javascripts/elfinder/js/i18n/elfinder.de.js +582 -0
- data/app/assets/javascripts/elfinder/js/i18n/elfinder.el.js +374 -0
- data/app/assets/javascripts/elfinder/js/i18n/elfinder.es.js +546 -0
- data/app/assets/javascripts/elfinder/js/i18n/elfinder.fa.js +580 -0
- data/app/assets/javascripts/elfinder/js/i18n/elfinder.fallback.js +11 -0
- data/app/assets/javascripts/elfinder/js/i18n/elfinder.fo.js +419 -0
- data/app/assets/javascripts/elfinder/js/i18n/elfinder.fr.js +578 -0
- data/app/assets/javascripts/elfinder/js/i18n/elfinder.fr_CA.js +580 -0
- data/app/assets/javascripts/elfinder/js/i18n/elfinder.he.js +375 -0
- data/app/assets/javascripts/elfinder/js/i18n/elfinder.hr.js +434 -0
- data/app/assets/javascripts/elfinder/js/i18n/elfinder.hu.js +580 -0
- data/app/assets/javascripts/elfinder/js/i18n/elfinder.id.js +498 -0
- data/app/assets/javascripts/elfinder/js/i18n/elfinder.it.js +552 -0
- data/app/assets/javascripts/elfinder/js/i18n/elfinder.ja.js +581 -0
- data/app/assets/javascripts/elfinder/js/i18n/elfinder.ko.js +582 -0
- data/app/assets/javascripts/elfinder/js/i18n/elfinder.nl.js +581 -0
- data/app/assets/javascripts/elfinder/js/i18n/elfinder.no.js +374 -0
- data/app/assets/javascripts/elfinder/js/i18n/elfinder.pl.js +580 -0
- data/app/assets/javascripts/elfinder/js/i18n/elfinder.pt_BR.js +580 -0
- data/app/assets/javascripts/elfinder/js/i18n/elfinder.ro.js +417 -0
- data/app/assets/javascripts/elfinder/js/i18n/elfinder.ru.js +582 -0
- data/app/assets/javascripts/elfinder/js/i18n/elfinder.si.js +537 -0
- data/app/assets/javascripts/elfinder/js/i18n/elfinder.sk.js +581 -0
- data/app/assets/javascripts/elfinder/js/i18n/elfinder.sl.js +374 -0
- data/app/assets/javascripts/elfinder/js/i18n/elfinder.sr.js +374 -0
- data/app/assets/javascripts/elfinder/js/i18n/elfinder.sv.js +375 -0
- data/app/assets/javascripts/elfinder/js/i18n/elfinder.tr.js +583 -0
- data/app/assets/javascripts/elfinder/js/i18n/elfinder.ug_CN.js +374 -0
- data/app/assets/javascripts/elfinder/js/i18n/elfinder.uk.js +580 -0
- data/app/assets/javascripts/elfinder/js/i18n/elfinder.vi.js +579 -0
- data/app/assets/javascripts/elfinder/js/i18n/elfinder.zh_CN.js +585 -0
- data/app/assets/javascripts/elfinder/js/i18n/elfinder.zh_TW.js +582 -0
- data/app/assets/javascripts/elfinder/js/i18n/help/cs.html.js +10 -0
- data/app/assets/javascripts/elfinder/js/i18n/help/de.html.js +15 -0
- data/app/assets/javascripts/elfinder/js/i18n/help/en.html.js +10 -0
- data/app/assets/javascripts/elfinder/js/i18n/help/es.html.js +10 -0
- data/app/assets/javascripts/elfinder/js/i18n/help/ja.html.js +10 -0
- data/app/assets/javascripts/elfinder/js/i18n/help/ko.html.js +10 -0
- data/app/assets/javascripts/elfinder/js/i18n/help/pl.html.js +10 -0
- data/app/assets/javascripts/elfinder/js/i18n/help/ru.html.js +10 -0
- data/app/assets/javascripts/elfinder/js/i18n/help/sk.html.js +10 -0
- data/app/assets/javascripts/elfinder/js/i18n/help/tr.html.js +10 -0
- data/app/assets/javascripts/elfinder/js/proxy/elFinderSupportVer1.js +408 -0
- data/app/assets/javascripts/elfinder/js/worker/calcfilehash.js +20 -0
- data/app/assets/javascripts/elfinder/js/worker/quicklook.tiff.js +7 -0
- data/app/assets/javascripts/elfinder/js/worker/quicklook.unzip.js +55 -0
- data/app/assets/javascripts/elfinder/main.default.js +175 -0
- data/app/assets/javascripts/elfinder/package.json +13 -0
- data/app/assets/javascripts/elfinder/php/MySQLStorage.sql +47 -0
- data/app/assets/javascripts/elfinder/php/autoload.php +56 -0
- data/app/assets/javascripts/elfinder/php/connector.maximal.php-dist +449 -0
- data/app/assets/javascripts/elfinder/php/connector.minimal.php-dist +180 -0
- data/app/assets/javascripts/elfinder/php/editors/OnlineConvert/editor.php +113 -0
- data/app/assets/javascripts/elfinder/php/editors/ZipArchive/editor.php +12 -0
- data/app/assets/javascripts/elfinder/php/editors/ZohoOffice/editor.php +206 -0
- data/app/assets/javascripts/elfinder/php/editors/editor.php +79 -0
- data/app/assets/javascripts/elfinder/php/elFinder.class.php +5401 -0
- data/app/assets/javascripts/elfinder/php/elFinderConnector.class.php +380 -0
- data/app/assets/javascripts/elfinder/php/elFinderFlysystemGoogleDriveNetmount.php +380 -0
- data/app/assets/javascripts/elfinder/php/elFinderPlugin.php +113 -0
- data/app/assets/javascripts/elfinder/php/elFinderSession.php +335 -0
- data/app/assets/javascripts/elfinder/php/elFinderSessionInterface.php +57 -0
- data/app/assets/javascripts/elfinder/php/elFinderVolumeBox.class.php +1972 -0
- data/app/assets/javascripts/elfinder/php/elFinderVolumeDriver.class.php +7651 -0
- data/app/assets/javascripts/elfinder/php/elFinderVolumeDropbox.class.php +1464 -0
- data/app/assets/javascripts/elfinder/php/elFinderVolumeDropbox2.class.php +1516 -0
- data/app/assets/javascripts/elfinder/php/elFinderVolumeFTP.class.php +1810 -0
- data/app/assets/javascripts/elfinder/php/elFinderVolumeGoogleDrive.class.php +2163 -0
- data/app/assets/javascripts/elfinder/php/elFinderVolumeGroup.class.php +315 -0
- data/app/assets/javascripts/elfinder/php/elFinderVolumeLocalFileSystem.class.php +1477 -0
- data/app/assets/javascripts/elfinder/php/elFinderVolumeMySQL.class.php +1022 -0
- data/app/assets/javascripts/elfinder/php/elFinderVolumeOneDrive.class.php +2131 -0
- data/app/assets/javascripts/elfinder/php/elFinderVolumeSFTPphpseclib.class.php +838 -0
- data/app/assets/javascripts/elfinder/php/elFinderVolumeTrash.class.php +51 -0
- data/app/assets/javascripts/elfinder/php/elFinderVolumeTrashMySQL.class.php +51 -0
- data/app/assets/javascripts/elfinder/php/libs/GdBmp.php +473 -0
- data/app/assets/javascripts/elfinder/php/mime.types +781 -0
- data/app/assets/javascripts/elfinder/php/plugins/AutoResize/plugin.php +151 -0
- data/app/assets/javascripts/elfinder/php/plugins/AutoRotate/plugin.php +148 -0
- data/app/assets/javascripts/elfinder/php/plugins/Normalizer/plugin.php +204 -0
- data/app/assets/javascripts/elfinder/php/plugins/Sanitizer/plugin.php +157 -0
- data/app/assets/javascripts/elfinder/php/plugins/Watermark/logo.png +0 -0
- data/app/assets/javascripts/elfinder/php/plugins/Watermark/plugin.php +432 -0
- data/app/assets/javascripts/elfinder/php/plugins/WinRemoveTailDots/plugin.php +114 -0
- data/app/assets/javascripts/elfinder/php/resources/image.png +0 -0
- data/app/assets/javascripts/elfinder/php/resources/video.png +0 -0
- data/app/assets/javascripts/elfinder/sounds/rm.wav +0 -0
- data/app/controllers/dc_elfinder_controller.rb +63 -0
- data/app/models/drgcms_form_fields/elfinder.rb +85 -0
- data/changelog.md +0 -0
- data/lib/drg_elfinder/engine.rb +5 -0
- data/lib/drg_elfinder/version.rb +3 -0
- data/lib/drg_elfinder.rb +9 -0
- data/lib/el_finder/action.rb +19 -0
- data/lib/el_finder/base64.rb +24 -0
- data/lib/el_finder/connector.rb +625 -0
- data/lib/el_finder/image.rb +33 -0
- data/lib/el_finder/mime_type.rb +86 -0
- data/lib/el_finder/pathname.rb +185 -0
- data/lib/el_finder/version.rb +5 -0
- data/lib/el_finder.rb +8 -0
- data/lib/patches/patch_for_elfinder.rb +115 -0
- data/lib/tasks/drg_elfinder_tasks.rake +10 -0
- metadata +245 -0
@@ -0,0 +1,113 @@
|
|
1
|
+
<?php
|
2
|
+
|
3
|
+
class elFinderEditorOnlineConvert extends elFinderEditor
|
4
|
+
{
|
5
|
+
protected $allowed = array('init', 'api');
|
6
|
+
|
7
|
+
public function enabled()
|
8
|
+
{
|
9
|
+
return defined('ELFINDER_ONLINE_CONVERT_APIKEY') && ELFINDER_ONLINE_CONVERT_APIKEY && (!defined('ELFINDER_DISABLE_ONLINE_CONVERT') || !ELFINDER_DISABLE_ONLINE_CONVERT);
|
10
|
+
}
|
11
|
+
|
12
|
+
public function init()
|
13
|
+
{
|
14
|
+
return array('api' => defined('ELFINDER_ONLINE_CONVERT_APIKEY') && ELFINDER_ONLINE_CONVERT_APIKEY && function_exists('curl_init'));
|
15
|
+
}
|
16
|
+
|
17
|
+
public function api()
|
18
|
+
{
|
19
|
+
// return array('apires' => array('message' => 'Currently disabled for developping...'));
|
20
|
+
$endpoint = 'https://api2.online-convert.com/jobs';
|
21
|
+
$category = $this->argValue('category');
|
22
|
+
$convert = $this->argValue('convert');
|
23
|
+
$options = $this->argValue('options');
|
24
|
+
$source = $this->argValue('source');
|
25
|
+
$filename = $this->argValue('filename');
|
26
|
+
$mime = $this->argValue('mime');
|
27
|
+
$jobid = $this->argValue('jobid');
|
28
|
+
$string_method = '';
|
29
|
+
$options = array();
|
30
|
+
// Currently these converts are make error with API call. I don't know why.
|
31
|
+
$nonApi = array('android', 'blackberry', 'dpg', 'ipad', 'iphone', 'ipod', 'nintendo-3ds', 'nintendo-ds', 'ps3', 'psp', 'wii', 'xbox');
|
32
|
+
if (in_array($convert, $nonApi)) {
|
33
|
+
return array('apires' => array());
|
34
|
+
}
|
35
|
+
$ch = null;
|
36
|
+
if ($convert && $source) {
|
37
|
+
$request = array(
|
38
|
+
'input' => array(array(
|
39
|
+
'type' => 'remote',
|
40
|
+
'source' => $source
|
41
|
+
)),
|
42
|
+
'conversion' => array(array(
|
43
|
+
'target' => $convert
|
44
|
+
))
|
45
|
+
);
|
46
|
+
|
47
|
+
if ($filename !== '') {
|
48
|
+
$request['input'][0]['filename'] = $filename;
|
49
|
+
}
|
50
|
+
|
51
|
+
if ($mime !== '') {
|
52
|
+
$request['input'][0]['content_type'] = $mime;
|
53
|
+
}
|
54
|
+
|
55
|
+
if ($category) {
|
56
|
+
$request['conversion'][0]['category'] = $category;
|
57
|
+
}
|
58
|
+
|
59
|
+
if ($options && $options !== 'null') {
|
60
|
+
$options = json_decode($options, true);
|
61
|
+
}
|
62
|
+
if (!is_array($options)) {
|
63
|
+
$options = array();
|
64
|
+
}
|
65
|
+
if ($options) {
|
66
|
+
$request['conversion'][0]['options'] = $options;
|
67
|
+
}
|
68
|
+
|
69
|
+
$ch = curl_init($endpoint);
|
70
|
+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
|
71
|
+
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($request));
|
72
|
+
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
|
73
|
+
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
|
74
|
+
'X-Oc-Api-Key: ' . ELFINDER_ONLINE_CONVERT_APIKEY,
|
75
|
+
'Content-Type: application/json',
|
76
|
+
'cache-control: no-cache'
|
77
|
+
));
|
78
|
+
} else if ($jobid) {
|
79
|
+
$ch = curl_init($endpoint . '/' . $jobid);
|
80
|
+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
|
81
|
+
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
|
82
|
+
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
|
83
|
+
'X-Oc-Api-Key: ' . ELFINDER_ONLINE_CONVERT_APIKEY,
|
84
|
+
'cache-control: no-cache'
|
85
|
+
));
|
86
|
+
}
|
87
|
+
|
88
|
+
if ($ch) {
|
89
|
+
$response = curl_exec($ch);
|
90
|
+
$info = curl_getinfo($ch);
|
91
|
+
$error = curl_error($ch);
|
92
|
+
curl_close($ch);
|
93
|
+
|
94
|
+
if (!empty($error)) {
|
95
|
+
$res = array('error' => $error);
|
96
|
+
} else {
|
97
|
+
$data = json_decode($response, true);
|
98
|
+
if (isset($data['status']) && isset($data['status']['code']) && $data['status']['code'] === 'completed') {
|
99
|
+
/** @var elFinderSession $session */
|
100
|
+
$session = $this->elfinder->getSession();
|
101
|
+
$urlContentSaveIds = $session->get('urlContentSaveIds', array());
|
102
|
+
$urlContentSaveIds['OnlineConvert-' . $data['id']] = true;
|
103
|
+
$session->set('urlContentSaveIds', $urlContentSaveIds);
|
104
|
+
}
|
105
|
+
$res = array('apires' => $data);
|
106
|
+
}
|
107
|
+
|
108
|
+
return $res;
|
109
|
+
} else {
|
110
|
+
return array('error' => array('errCmdParams', 'editor.OnlineConvert.api'));
|
111
|
+
}
|
112
|
+
}
|
113
|
+
}
|
@@ -0,0 +1,12 @@
|
|
1
|
+
<?php
|
2
|
+
|
3
|
+
class elFinderEditorZipArchive extends elFinderEditor
|
4
|
+
{
|
5
|
+
public function enabled()
|
6
|
+
{
|
7
|
+
return (!defined('ELFINDER_DISABLE_ZIPEDITOR') || !ELFINDER_DISABLE_ZIPEDITOR) &&
|
8
|
+
class_exists('Barryvdh\elFinderFlysystemDriver\Driver') &&
|
9
|
+
class_exists('League\Flysystem\Filesystem') &&
|
10
|
+
class_exists('League\Flysystem\ZipArchive\ZipArchiveAdapter');
|
11
|
+
}
|
12
|
+
}
|
@@ -0,0 +1,206 @@
|
|
1
|
+
<?php
|
2
|
+
|
3
|
+
class elFinderEditorZohoOffice extends elFinderEditor
|
4
|
+
{
|
5
|
+
private static $curlTimeout = 20;
|
6
|
+
|
7
|
+
protected $allowed = array('init', 'save', 'chk');
|
8
|
+
|
9
|
+
protected $editor_settings = array(
|
10
|
+
'writer' => array(
|
11
|
+
'unit' => 'mm',
|
12
|
+
'view' => 'pageview'
|
13
|
+
),
|
14
|
+
'sheet' => array(
|
15
|
+
'country' => 'US'
|
16
|
+
),
|
17
|
+
'show' => array()
|
18
|
+
);
|
19
|
+
|
20
|
+
private $urls = array(
|
21
|
+
'writer' => 'https://writer.zoho.com/writer/officeapi/v1/document',
|
22
|
+
'sheet' => 'https://sheet.zoho.com/sheet/officeapi/v1/spreadsheet',
|
23
|
+
'show' => 'https://show.zoho.com/show/officeapi/v1/presentation',
|
24
|
+
);
|
25
|
+
|
26
|
+
private $srvs = array(
|
27
|
+
'application/msword' => 'writer',
|
28
|
+
'application/vnd.openxmlformats-officedocument.wordprocessingml.document' => 'writer',
|
29
|
+
'application/pdf' => 'writer',
|
30
|
+
'application/vnd.oasis.opendocument.text' => 'writer',
|
31
|
+
'application/rtf' => 'writer',
|
32
|
+
'text/html' => 'writer',
|
33
|
+
'application/vnd.ms-excel' => 'sheet',
|
34
|
+
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' => 'sheet',
|
35
|
+
'application/vnd.oasis.opendocument.spreadsheet' => 'sheet',
|
36
|
+
'application/vnd.sun.xml.calc' => 'sheet',
|
37
|
+
'text/csv' => 'sheet',
|
38
|
+
'text/tab-separated-values' => 'sheet',
|
39
|
+
'application/vnd.ms-powerpoint' => 'show',
|
40
|
+
'application/vnd.openxmlformats-officedocument.presentationml.presentation' => 'show',
|
41
|
+
'application/vnd.openxmlformats-officedocument.presentationml.slideshow' => 'show',
|
42
|
+
'application/vnd.oasis.opendocument.presentation' => 'show',
|
43
|
+
'application/vnd.sun.xml.impress' => 'show',
|
44
|
+
);
|
45
|
+
|
46
|
+
private $myName = '';
|
47
|
+
|
48
|
+
public function __construct($elfinder, $args)
|
49
|
+
{
|
50
|
+
parent::__construct($elfinder, $args);
|
51
|
+
$this->myName = preg_replace('/^elFinderEditor/i', '', get_class($this));
|
52
|
+
}
|
53
|
+
|
54
|
+
public function enabled()
|
55
|
+
{
|
56
|
+
return defined('ELFINDER_ZOHO_OFFICE_APIKEY') && ELFINDER_ZOHO_OFFICE_APIKEY && function_exists('curl_init');
|
57
|
+
}
|
58
|
+
|
59
|
+
public function init()
|
60
|
+
{
|
61
|
+
if (!defined('ELFINDER_ZOHO_OFFICE_APIKEY') || !function_exists('curl_init')) {
|
62
|
+
return array('error', array(elFinder::ERROR_CONF, '`ELFINDER_ZOHO_OFFICE_APIKEY` or curl extension'));
|
63
|
+
}
|
64
|
+
if (!empty($this->args['target'])) {
|
65
|
+
$fp = $cfile = null;
|
66
|
+
$hash = $this->args['target'];
|
67
|
+
/** @var elFinderVolumeDriver $srcVol */
|
68
|
+
if (($srcVol = $this->elfinder->getVolume($hash)) && ($file = $srcVol->file($hash))) {
|
69
|
+
$cdata = empty($this->args['cdata']) ? '' : $this->args['cdata'];
|
70
|
+
$cookie = $this->elfinder->getFetchCookieFile();
|
71
|
+
$save = false;
|
72
|
+
$ch = curl_init();
|
73
|
+
$conUrl = elFinder::getConnectorUrl();
|
74
|
+
curl_setopt($ch, CURLOPT_URL, $conUrl . (strpos($conUrl, '?') !== false? '&' : '?') . 'cmd=editor&name=' . $this->myName . '&method=chk&args[target]=' . rawurlencode($hash) . $cdata);
|
75
|
+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
76
|
+
if ($cookie) {
|
77
|
+
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie);
|
78
|
+
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie);
|
79
|
+
}
|
80
|
+
$res = curl_exec($ch);
|
81
|
+
curl_close($ch);
|
82
|
+
if ($res) {
|
83
|
+
if ($data = json_decode($res, true)) {
|
84
|
+
$save = !empty($data['cansave']);
|
85
|
+
}
|
86
|
+
}
|
87
|
+
|
88
|
+
if ($size = $file['size']) {
|
89
|
+
$src = $srcVol->open($hash);
|
90
|
+
$fp = tmpfile();
|
91
|
+
stream_copy_to_stream($src, $fp);
|
92
|
+
$srcVol->close($src, $hash);
|
93
|
+
$info = stream_get_meta_data($fp);
|
94
|
+
if ($info && !empty($info['uri'])) {
|
95
|
+
$srcFile = $info['uri'];
|
96
|
+
if (class_exists('CURLFile')) {
|
97
|
+
$cfile = new CURLFile($srcFile);
|
98
|
+
$cfile->setPostFilename($file['name']);
|
99
|
+
$cfile->setMimeType($file['mime']);
|
100
|
+
} else {
|
101
|
+
$cfile = '@' . $srcFile;
|
102
|
+
}
|
103
|
+
}
|
104
|
+
}
|
105
|
+
//$srv = $this->args['service'];
|
106
|
+
$format = $srcVol->getExtentionByMime($file['mime']);
|
107
|
+
if (!$format) {
|
108
|
+
$format = substr($file['name'], strrpos($file['name'], '.') * -1);
|
109
|
+
}
|
110
|
+
$lang = $this->args['lang'];
|
111
|
+
if ($lang === 'jp') {
|
112
|
+
$lang = 'ja';
|
113
|
+
}
|
114
|
+
$srvsName = $this->srvs[$file['mime']];
|
115
|
+
$data = array(
|
116
|
+
'apikey' => ELFINDER_ZOHO_OFFICE_APIKEY,
|
117
|
+
'callback_settings' => array(
|
118
|
+
'save_format' => $format,
|
119
|
+
'context_info' => array(
|
120
|
+
'hash' => $hash
|
121
|
+
)
|
122
|
+
),
|
123
|
+
'editor_settings' => $this->editor_settings[$srvsName],
|
124
|
+
'document_info' => array(
|
125
|
+
'document_name' => substr($file['name'], 0, strlen($file['name']) - strlen($format)- 1)
|
126
|
+
)
|
127
|
+
);
|
128
|
+
$data['editor_settings']['language'] = $lang;
|
129
|
+
if ($save) {
|
130
|
+
$conUrl = elFinder::getConnectorUrl();
|
131
|
+
$data['callback_settings']['save_url'] = $conUrl . (strpos($conUrl, '?') !== false? '&' : '?') . 'cmd=editor&name=' . $this->myName . '&method=save' . $cdata;
|
132
|
+
}
|
133
|
+
foreach($data as $_k => $_v) {
|
134
|
+
if (is_array($_v)){
|
135
|
+
$data[$_k] = json_encode($_v);
|
136
|
+
}
|
137
|
+
}
|
138
|
+
if ($cfile) {
|
139
|
+
$data['document'] = $cfile;
|
140
|
+
}
|
141
|
+
$ch = curl_init();
|
142
|
+
curl_setopt($ch, CURLOPT_URL, $this->urls[$srvsName]);
|
143
|
+
curl_setopt($ch, CURLOPT_TIMEOUT, self::$curlTimeout);
|
144
|
+
curl_setopt($ch, CURLOPT_HEADER, 0);
|
145
|
+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
146
|
+
curl_setopt($ch, CURLOPT_POST, 1);
|
147
|
+
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
148
|
+
$res = curl_exec($ch);
|
149
|
+
$error = curl_error($ch);
|
150
|
+
curl_close($ch);
|
151
|
+
|
152
|
+
$fp && fclose($fp);
|
153
|
+
|
154
|
+
if ($res && $res = @json_decode($res, true)) {
|
155
|
+
if (!empty($res['document_url'])) {
|
156
|
+
$ret = array('zohourl' => $res['document_url']);
|
157
|
+
if (!$save) {
|
158
|
+
$ret['warning'] = 'exportToSave';
|
159
|
+
}
|
160
|
+
return $ret;
|
161
|
+
} else {
|
162
|
+
$error = $res;
|
163
|
+
}
|
164
|
+
}
|
165
|
+
|
166
|
+
if ($error) {
|
167
|
+
return array('error' => is_string($error)? preg_split('/[\r\n]+/', $error) : 'Error code: ' . $error);
|
168
|
+
}
|
169
|
+
}
|
170
|
+
}
|
171
|
+
|
172
|
+
return array('error' => array('errCmdParams', 'editor.' . $this->myName . '.init'));
|
173
|
+
}
|
174
|
+
|
175
|
+
public function save()
|
176
|
+
{
|
177
|
+
if (!empty($_POST) && !empty($_POST['id']) && !empty($_FILES) && !empty($_FILES['content'])) {
|
178
|
+
$data = @json_decode(str_replace('"', '"', $_POST['id']), true);
|
179
|
+
if (!empty($data['hash'])) {
|
180
|
+
$hash = $data['hash'];
|
181
|
+
/** @var elFinderVolumeDriver $volume */
|
182
|
+
if ($volume = $this->elfinder->getVolume($hash)) {
|
183
|
+
if ($content = file_get_contents($_FILES['content']['tmp_name'])) {
|
184
|
+
if ($volume->putContents($hash, $content)) {
|
185
|
+
return array('raw' => true, 'error' => '', 'header' => 'HTTP/1.1 200 OK');
|
186
|
+
}
|
187
|
+
}
|
188
|
+
}
|
189
|
+
}
|
190
|
+
}
|
191
|
+
return array('raw' => true, 'error' => '', 'header' => 'HTTP/1.1 500 Internal Server Error');
|
192
|
+
}
|
193
|
+
|
194
|
+
public function chk()
|
195
|
+
{
|
196
|
+
$hash = $this->args['target'];
|
197
|
+
$res = false;
|
198
|
+
/** @var elFinderVolumeDriver $volume */
|
199
|
+
if ($volume = $this->elfinder->getVolume($hash)) {
|
200
|
+
if ($file = $volume->file($hash)) {
|
201
|
+
$res = (bool)$file['write'];
|
202
|
+
}
|
203
|
+
}
|
204
|
+
return array('cansave' => $res);
|
205
|
+
}
|
206
|
+
}
|
@@ -0,0 +1,79 @@
|
|
1
|
+
<?php
|
2
|
+
|
3
|
+
/**
|
4
|
+
* Abstract class of editor plugins.
|
5
|
+
*
|
6
|
+
* @author Naoki Sawada
|
7
|
+
*/
|
8
|
+
class elFinderEditor
|
9
|
+
{
|
10
|
+
/**
|
11
|
+
* Array of allowed method by request from client side.
|
12
|
+
*
|
13
|
+
* @var array
|
14
|
+
*/
|
15
|
+
protected $allowed = array();
|
16
|
+
|
17
|
+
/**
|
18
|
+
* elFinder instance
|
19
|
+
*
|
20
|
+
* @var object elFinder instance
|
21
|
+
*/
|
22
|
+
protected $elfinder;
|
23
|
+
|
24
|
+
/**
|
25
|
+
* Arguments
|
26
|
+
*
|
27
|
+
* @var array argValues
|
28
|
+
*/
|
29
|
+
protected $args;
|
30
|
+
|
31
|
+
/**
|
32
|
+
* Constructor.
|
33
|
+
*
|
34
|
+
* @param object $elfinder
|
35
|
+
* @param array $args
|
36
|
+
*/
|
37
|
+
public function __construct($elfinder, $args)
|
38
|
+
{
|
39
|
+
$this->elfinder = $elfinder;
|
40
|
+
$this->args = $args;
|
41
|
+
}
|
42
|
+
|
43
|
+
/**
|
44
|
+
* Return boolean that this plugin is enabled.
|
45
|
+
*
|
46
|
+
* @return bool
|
47
|
+
*/
|
48
|
+
public function enabled()
|
49
|
+
{
|
50
|
+
return true;
|
51
|
+
}
|
52
|
+
|
53
|
+
/**
|
54
|
+
* Return boolean that $name method is allowed.
|
55
|
+
*
|
56
|
+
* @param string $name
|
57
|
+
*
|
58
|
+
* @return bool
|
59
|
+
*/
|
60
|
+
public function isAllowedMethod($name)
|
61
|
+
{
|
62
|
+
$checker = array_flip($this->allowed);
|
63
|
+
|
64
|
+
return isset($checker[$name]);
|
65
|
+
}
|
66
|
+
|
67
|
+
/**
|
68
|
+
* Return $this->args value of the key
|
69
|
+
*
|
70
|
+
* @param string $key target key
|
71
|
+
* @param string $empty empty value
|
72
|
+
*
|
73
|
+
* @return mixed
|
74
|
+
*/
|
75
|
+
public function argValue($key, $empty = '')
|
76
|
+
{
|
77
|
+
return isset($this->args[$key]) ? $this->args[$key] : $empty;
|
78
|
+
}
|
79
|
+
}
|