@@ -3720,43 +3720,33 @@ public function get_link($type = 'http', $item_id = 0, $provided_toc = false)
3720
3720
'odt',
3721
3721
'dot',
3722
3722
];
3723
- $officeExtensions = [
3724
- 'ppt',
3725
- 'pptx',
3726
- 'odp',
3727
- 'xls',
3728
- 'xlsx',
3729
- 'ods',
3730
- 'csv',
3731
- 'doc',
3732
- 'docx',
3733
- 'odt',
3734
- ];
3735
3723
3736
- if (in_array($extension, $extensionsToDownload)) {
3737
- $found = false;
3738
- if (in_array($extension, $officeExtensions )) {
3739
- $onlyOffice = OnlyofficePlugin::create( );
3740
- if ($onlyOffice->isEnabled()) {
3741
- $lpItem = $this->getItem($item_id);
3742
- if ($lpItem->get_type() == 'document') {
3743
- $docId = $lpItem->get_path();
3744
- if (method_exists('OnlyofficeTools', 'getPathToView')) {
3745
- $pathToView = OnlyofficeTools::getPathToView($docId, false);
3746
- // getPathView returns empty on error, so if this is the case,
3747
- // fallback to normal viewer/downloader
3748
- if (!empty($pathToView)) {
3749
- $file = $pathToView;
3750
- $found = true;
3751
- }
3752
- }
3724
+ $onlyofficeEditable = false;
3725
+
3726
+ if (OnlyofficePlugin::create()->isEnabled( )) {
3727
+ $lpItem = $this->getItem($item_id );
3728
+
3729
+ if ( $lpItem->get_type() == 'document'
3730
+ && OnlyofficePlugin::isExtensionAllowed($extension)
3731
+ ) {
3732
+ $docId = $lpItem->get_path();
3733
+
3734
+ if (method_exists('OnlyofficeTools', 'getPathToView')) {
3735
+ $pathToView = OnlyofficeTools::getPathToView($docId, false);
3736
+ // getPathView returns empty on error, so if this is the case,
3737
+ // fallback to normal viewer/downloader
3738
+ if (!empty($pathToView)) {
3739
+ $file = $pathToView;
3740
+ $onlyofficeEditable = true;
3753
3741
}
3754
3742
}
3755
3743
}
3756
- if (false === $found) {
3757
- $file = api_get_path(WEB_CODE_PATH).
3758
- 'lp/embed.php?type=download&source=file&lp_item_id='.$item_id.'&'.api_get_cidreq();
3759
- }
3744
+ }
3745
+
3746
+ if (in_array($extension, $extensionsToDownload) && false === $onlyofficeEditable) {
3747
+ $file = api_get_path(WEB_CODE_PATH)
3748
+ .'lp/embed.php?type=download&source=file&lp_item_id='.$item_id.'&'
3749
+ .api_get_cidreq();
3760
3750
}
3761
3751
}
3762
3752
}
0 commit comments