1
1
<?php
2
2
/**
3
- *
4
- * (c) Copyright Ascensio System SIA 2021
3
+ * (c) Copyright Ascensio System SIA 2021.
5
4
*
6
5
* Licensed under the Apache License, Version 2.0 (the "License");
7
6
* you may not use this file except in compliance with the License.
14
13
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
14
* See the License for the specific language governing permissions and
16
15
* limitations under the License.
17
- *
18
16
*/
19
-
20
17
require_once __DIR__ .'/../../main/inc/global.inc.php ' ;
21
18
22
19
use ChamiloSession as Session ;
23
20
24
21
$ plugin = OnlyofficePlugin::create ();
25
22
26
23
$ mapFileFormat = [
27
- "text " => $ plugin ->get_lang ("document " ),
24
+ "text " => $ plugin ->get_lang ("document " ),
28
25
"spreadsheet " => $ plugin ->get_lang ("spreadsheet " ),
29
- "presentation " => $ plugin ->get_lang ("presentation " )
26
+ "presentation " => $ plugin ->get_lang ("presentation " ),
30
27
];
31
28
32
29
$ userId = $ _GET ["userId " ];
48
45
49
46
$ form = new FormValidator ("doc_create " ,
50
47
"post " ,
51
- api_get_path (WEB_PLUGIN_PATH ) . "onlyoffice/create.php " );
48
+ api_get_path (WEB_PLUGIN_PATH ). "onlyoffice/create.php " );
52
49
53
50
$ form ->addText ("fileName " , $ plugin ->get_lang ("title " ), true );
54
51
$ form ->addSelect ("fileFormat " , $ plugin ->get_lang ("chooseFileFormat " ), $ mapFileFormat );
73
70
74
71
$ fileType = $ values ["fileFormat " ];
75
72
$ fileExt = FileUtility::getDocExt ($ fileType );
76
- $ fileTitle = $ values ["fileName " ] . ". " . $ fileExt ;
73
+ $ fileTitle = $ values ["fileName " ]. ". " . $ fileExt ;
77
74
78
75
$ courseInfo = api_get_course_info_by_id ($ courseId );
79
76
$ courseCode = $ courseInfo ["code " ];
80
-
77
+
81
78
$ fileNamePrefix = DocumentManager::getDocumentSuffix ($ courseInfo , $ sessionId , $ groupId );
82
- $ fileName = $ values ["fileName " ] . $ fileNamePrefix . ". " . $ fileExt ;
79
+ $ fileName = $ values ["fileName " ]. $ fileNamePrefix. ". " . $ fileExt ;
83
80
84
81
$ groupInfo = GroupManager::get_group_properties ($ groupId );
85
82
89
86
if (!empty ($ folderId )) {
90
87
$ document_data = DocumentManager::get_document_data_by_id ($ folderId , $ courseCode , true , $ sessionId );
91
88
$ folderPath = $ document_data ["absolute_path " ];
92
- $ fileRelatedPath = $ fileRelatedPath . substr ($ document_data ["absolute_path_from_document " ], 10 ) . "/ " . $ fileName ;
89
+ $ fileRelatedPath = $ fileRelatedPath. substr ($ document_data ["absolute_path_from_document " ], 10 ). "/ " . $ fileName ;
93
90
} else {
94
- $ folderPath = api_get_path (SYS_COURSE_PATH ) . api_get_course_path ($ courseCode ) . "/document " ;
91
+ $ folderPath = api_get_path (SYS_COURSE_PATH ). api_get_course_path ($ courseCode ). "/document " ;
95
92
if (!empty ($ groupId )) {
96
- $ folderPath = $ folderPath . "/ " . $ groupInfo ["directory " ];
97
- $ fileRelatedPath = $ groupInfo ["directory " ] . "/ " ;
93
+ $ folderPath = $ folderPath. "/ " . $ groupInfo ["directory " ];
94
+ $ fileRelatedPath = $ groupInfo ["directory " ]. "/ " ;
98
95
}
99
- $ fileRelatedPath = $ fileRelatedPath . $ fileName ;
96
+ $ fileRelatedPath = $ fileRelatedPath. $ fileName ;
100
97
}
101
- $ filePath = $ folderPath . "/ " . $ fileName ;
98
+ $ filePath = $ folderPath. "/ " . $ fileName ;
102
99
103
100
if (file_exists ($ filePath )) {
104
101
Display::addFlash (Display::return_message ($ plugin ->get_lang ("fileIsExist " ), "error " ));
131
128
null ,
132
129
$ sessionId );
133
130
134
- header ("Location: " . $ goBackUrl );
131
+ header ("Location: " . $ goBackUrl );
135
132
exit ();
136
133
}
137
-
138
134
} else {
139
135
Display::addFlash (Display::return_message ($ plugin ->get_lang ("impossibleCreateFile " ), "error " ));
140
136
}
141
137
}
142
138
143
139
display:
144
140
$ goBackUrl = $ goBackUrl ?: $ _SERVER ["HTTP_REFERER " ];
145
- $ actionsLeft = '<a href=" ' . $ goBackUrl . '"> ' . Display::return_icon ("back.png " , get_lang ("Back " ) . " " . get_lang ("To " ) . " " . get_lang ("DocumentsOverview " ), "" , ICON_SIZE_MEDIUM ) . "</a> " ;
141
+ $ actionsLeft = '<a href=" ' .$ goBackUrl. '"> ' . Display::return_icon ("back.png " , get_lang ("Back " ). " " . get_lang ("To " ). " " . get_lang ("DocumentsOverview " ), "" , ICON_SIZE_MEDIUM ). "</a> " ;
146
142
147
143
Display::display_header ($ plugin ->get_lang ("createNewDocument " ));
148
144
echo Display::toolbarAction ("actions-documents " , [$ actionsLeft ]);
149
145
echo $ form ->returnForm ();
150
146
Display::display_footer ();
151
- ?>
0 commit comments