@@ -31,12 +31,6 @@ class Versions extends \Controller
3131 */
3232 protected $ intPid ;
3333
34- /**
35- * File path
36- * @var string
37- */
38- protected $ strPath ;
39-
4034 /**
4135 * Edit URL
4236 * @var string
@@ -69,17 +63,6 @@ public function __construct($strTable, $intPid)
6963
7064 $ this ->strTable = $ strTable ;
7165 $ this ->intPid = $ intPid ;
72-
73- // Store the path if it is an editable file
74- if ($ strTable == 'tl_files ' )
75- {
76- $ objFile = \FilesModel::findByPk ($ intPid );
77-
78- if ($ objFile !== null && in_array ($ objFile ->extension , trimsplit (', ' , strtolower (\Config::get ('editableFiles ' )))))
79- {
80- $ this ->strPath = $ objFile ->path ;
81- }
82- }
8366 }
8467
8568
@@ -163,17 +146,23 @@ public function create()
163146 return ;
164147 }
165148
166- if ($ this ->strPath !== null )
149+ // Store the content if it is an editable file
150+ if ($ this ->strTable == 'tl_files ' )
167151 {
168- $ objFile = new \ File ($ this ->strPath , true );
152+ $ objModel = \FilesModel:: findByPk ($ this ->intPid );
169153
170- if ($ objFile ->extension == ' svgz ' )
154+ if ($ objModel !== null && in_array ( $ objModel ->extension , trimsplit ( ' , ' , strtolower (\Config:: get ( ' editableFiles ' )))) )
171155 {
172- $ objRecord ->content = gzdecode ($ objFile ->getContent ());
173- }
174- else
175- {
176- $ objRecord ->content = $ objFile ->getContent ();
156+ $ objFile = new \File ($ objModel ->path , true );
157+
158+ if ($ objFile ->extension == 'svgz ' )
159+ {
160+ $ objRecord ->content = gzdecode ($ objFile ->getContent ());
161+ }
162+ else
163+ {
164+ $ objRecord ->content = $ objFile ->getContent ();
165+ }
177166 }
178167 }
179168
@@ -278,12 +267,26 @@ public function restore($intVersion)
278267 return ;
279268 }
280269
281- // Restore the content
282- if ($ this ->strPath ! == null )
270+ // Restore the content if it is an editable file
271+ if ($ this ->strTable == ' tl_files ' )
283272 {
284- $ objFile = new \File ($ this ->strPath , true );
285- $ objFile ->write ($ data ['content ' ]);
286- $ objFile ->close ();
273+ $ objModel = \FilesModel::findByPk ($ this ->intPid );
274+
275+ if ($ objModel !== null && in_array ($ objModel ->extension , trimsplit (', ' , strtolower (\Config::get ('editableFiles ' )))))
276+ {
277+ $ objFile = new \File ($ objModel ->path , true );
278+
279+ if ($ objFile ->extension == 'svgz ' )
280+ {
281+ $ objFile ->write (gzencode ($ data ['content ' ]));
282+ }
283+ else
284+ {
285+ $ objFile ->write ($ data ['content ' ]);
286+ }
287+
288+ $ objFile ->close ();
289+ }
287290 }
288291
289292 // Get the currently available fields
0 commit comments