feat(php): creating and editing pdf instead docxf

This commit is contained in:
sshakndr
2024-07-11 16:47:05 +07:00
parent 1936274a13
commit 597b3dfac7
10 changed files with 29 additions and 18 deletions

View File

@ -1,7 +1,9 @@
# Change Log
- php: filling by default
- python: filling by default
- ruby: filling by default
- php: creating and editing pdf instead docxf
- python: creating and editing pdf instead docxf
- ruby: creating and editing pdf instead docxf
- nodejs: tabs menu

View File

@ -171,7 +171,7 @@ label .checkbox {
}
.try-editor.form {
background-image: url("/assets/images/file_docxf.svg");
background-image: url("/assets/images/file_pdf.svg");
}
.side-option {
@ -536,6 +536,11 @@ footer table tr td:first-child {
background-image: url("/assets/images/icon_pptx.svg");
}
.stored-edit.pdf,
.uploadFileName.pdf {
background-image: url("/assets/images/icon_pdf.svg");
}
.stored-edit span {
font-size: 12px;
line-height: 12px;

View File

@ -1 +0,0 @@
<svg width="30" height="40" viewBox="0 0 30 40" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M0 3c0-1.65685 1.34315-3 3-3h20l7 7v30c0 1.6569-1.3431 3-3 3H3c-1.65685 0-3-1.3431-3-3V3z" fill="#27ABA3"/><path d="M23 0l7 7h-4c-1.6569 0-3-1.34315-3-3V0z" fill="#008078"/><path fill-rule="evenodd" clip-rule="evenodd" d="M24 14H6v7h18v-7zm-.8182 5.9978H6.81818V15H23.1818v4.9978zM24 23H6v7h18v-7zm-.8182 5.9978H6.81818V24H23.1818v4.9978z" fill="#fff"/></svg>

Before

Width:  |  Height:  |  Size: 463 B

View File

@ -0,0 +1,5 @@
<svg width="30" height="40" viewBox="0 0 30 40" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M0 3C0 1.34315 1.34315 0 3 0H23L30 7V37C30 38.6569 28.6569 40 27 40H3C1.34315 40 0 38.6569 0 37V3Z" fill="#9E1919"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M17.0062 15V16.0065H24V15H17.0062ZM17.0062 19V20.0163H24V19H17.0062ZM24 23H17.0062V24.0261H24V23ZM6 28V27.0293H24V28H6ZM7 16H14V23H7V16ZM6 15H7H14H15V16V23V24H14H7H6V23V16V15Z" fill="white"/>
<path d="M23 0L30 7H26C24.3431 7 23 5.65685 23 4V0Z" fill="black" fill-opacity="0.25"/>
</svg>

After

Width:  |  Height:  |  Size: 558 B

View File

@ -0,0 +1 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M2 1h8l4 4v10H2V1z" fill="#fff"/><path fill-rule="evenodd" clip-rule="evenodd" d="M14 5l-4-4H2v14h12V5zm-4-5l5 5v11H1V0h9z" fill="#BFBFBF"/><path fill="#9E1919" d="M3 10h10v4H3z"/><path d="M7 7V2H3v5h4zM8 3V2h2v1H8zM8 5V4h5v1H8zM13 6H8v1h5V6zM13 8H3v1h10V8z" fill="#BFBFBF"/><path opacity=".3" d="M9 1h1v3h4l1 1H9V1z" fill="#333"/></svg>

After

Width:  |  Height:  |  Size: 441 B

View File

@ -63,7 +63,7 @@ final class DocEditorView extends View
$filename = tryGetDefaultByType($createExt, $user);
// create the demo file url
$newURL = "editor?fileID=" . $filename . "&user=" . $request["user"];
$newURL = "editor?action=edit&fileID=" . $filename . "&user=" . $request["user"];
header('Location: ' . $newURL, true);
exit;
}
@ -74,18 +74,16 @@ final class DocEditorView extends View
$filetype = mb_strtolower(pathinfo($filename, PATHINFO_EXTENSION));
$ext = mb_strtolower(pathinfo($filename, PATHINFO_EXTENSION));
$editorsMode = empty($request["action"]) ? "edit" : $request["action"]; // get the editors mode
$canFill = in_array($ext, $formatManager->fillableExtensions());
$editorsMode = empty($request["action"]) ? ($canFill ? "fillForms" : "edit") : $request["action"];
$canEdit = in_array($ext, $formatManager->editableExtensions()); // check if the file can be edited
if ((!$canEdit && $editorsMode == "edit"
|| $editorsMode == "fillForms")
&& in_array($ext, $formatManager->fillableExtensions())
) {
if ((!$canEdit && $editorsMode == "edit" || $editorsMode == "fillForms") && $canFill) {
$editorsMode = "fillForms";
$canEdit = true;
}
// check if the Submit form button is displayed or not
$submitForm = $editorsMode == "fillForms" && $user->id == "uid-1";
$submitForm = in_array($editorsMode, ["fillForms", "embedded"]) && $user->id == "uid-1";
$mode = $canEdit && $editorsMode != "view" ? "edit" : "view"; // define if the editing mode is edit or view
$type = empty($request["type"]) ? "desktop" : $request["type"];

View File

@ -44,6 +44,12 @@ class IndexStoredListView extends View
$directUrlArg = isset($this->request["directUrl"]) ? "&directUrl=" . $this->request["directUrl"] : "";
if (!empty($storedFiles)) {
foreach ($storedFiles as &$storeFile) {
$comment = $storeFile->documentType != "pdf" ?
' <td class="contentCells contentCells-icon"> <a href="editor?fileID='.
urlencode($storeFile->name).'&user='.htmlentities($user).$directUrlArg.
'&action=comment&type=desktop" target="_blank">'.
' <img src="assets/images/comment.svg" alt="Open in editor for comment"'.
' title="Open in editor for comment" /></a></td>' : '';
$layout .= '<tr class="tableRow" title="'.$storeFile->name.' ['.getFileVersion(
getHistoryDir(
getStoragePath($storeFile->name)
@ -64,12 +70,7 @@ class IndexStoredListView extends View
urlencode($storeFile->name).'&user=' . htmlentities($user).$directUrlArg.
'&action=edit&type=mobile" target="_blank">'.
'<img src="assets/images/mobile.svg" alt="Open in editor for mobile devices"'.
' title="Open in editor for mobile devices" /></a></td>'.
' <td class="contentCells contentCells-icon"> <a href="editor?fileID='.
urlencode($storeFile->name).'&user='.htmlentities($user).$directUrlArg.
'&action=comment&type=desktop" target="_blank">'.
' <img src="assets/images/comment.svg" alt="Open in editor for comment"'.
' title="Open in editor for comment" /></a></td>';
' title="Open in editor for mobile devices" /></a></td>'.$comment;
if ($storeFile->documentType == "word") {
$layout .= '<td class="contentCells contentCells-icon"> <a href="editor?fileID='.
urlencode($storeFile->name).'&user='.htmlentities($user).$directUrlArg.

View File

@ -60,7 +60,7 @@
</li>
<li>
<a class="try-editor form reload-page" target="_blank"
href="editor?fileExt=docxf&user={user}">PDF form</a>
href="editor?fileExt=pdf&user={user}">PDF form</a>
</li>
</ul>
<label class="side-option">