Files
crm.clientright.ru/crm_extensions/file_storage/api/get_edit_urls.php

54 lines
2.2 KiB
PHP
Raw Normal View History

<?php
/**
* API для получения различных вариантов URL для редактирования
*/
// Устанавливаем заголовки
header('Content-Type: application/json; charset=utf-8');
try {
// Получаем параметры
$recordId = $_GET['recordId'] ?? 'test';
$fileName = $_GET['fileName'] ?? 'test.docx';
// Декодируем URL-кодированное имя файла
if ($fileName) {
$fileName = urldecode($fileName);
}
// Используем хардкод базового URL для избежания проблем с конфигом
$baseUrl = 'https://office.clientright.ru';
// Отладочная информация
error_log("get_edit_urls.php: recordId=$recordId, fileName=$fileName");
// Создаем различные варианты URL
$urls = [
'direct_edit' => $baseUrl . '/apps/files/files/662?dir=/crm2/CRM_Active_Files/Documents/' . $recordId . '&openfile=' . urlencode($fileName) . '&action=edit',
'openfile_only' => $baseUrl . '/apps/files/files/662?dir=/crm2/CRM_Active_Files/Documents/' . $recordId . '&openfile=' . urlencode($fileName),
'edit_true' => $baseUrl . '/apps/files/files/662?dir=/crm2/CRM_Active_Files/Documents/' . $recordId . '&openfile=' . urlencode($fileName) . '&edit=true',
'richdocuments' => $baseUrl . '/apps/richdocuments/open?path=/crm2/CRM_Active_Files/Documents/' . $recordId . '/' . urlencode($fileName),
'onlyoffice' => $baseUrl . '/apps/onlyoffice/open?path=/crm2/CRM_Active_Files/Documents/' . $recordId . '/' . urlencode($fileName),
'files_app' => $baseUrl . '/apps/files/?dir=/crm2/CRM_Active_Files/Documents/' . $recordId . '&openfile=' . urlencode($fileName) . '&action=edit'
];
echo json_encode([
'success' => true,
'data' => [
'record_id' => $recordId,
'file_name' => $fileName,
'urls' => $urls,
'recommended' => 'direct_edit'
]
]);
} catch (Exception $e) {
http_response_code(500);
echo json_encode([
'success' => false,
'error' => $e->getMessage()
]);
}
?>