@@ -97,7 +97,8 @@ protected static function showdir
9797 JLoader::register ('QuantummanagerHelper ' , JPATH_SITE . '/administrator/components/com_quantummanager/helpers/quantummanager.php ' );
9898 $ subdir = self ::showdir ($ dir , $ folderOnly , $ showRoot , $ level + 1 , $ ef );
9999 return [
100- 'path ' => QuantummanagerHelper::getFolderRoot (),
100+ //'path' => QuantummanagerHelper::getFolderRoot(),
101+ 'path ' => 'root ' ,
101102 'subpath ' => $ subdir
102103 ];
103104 }
@@ -238,25 +239,87 @@ public static function getMetaFile($path, $file)
238239 $ path = QuantummanagerHelper::preparePath ($ path );
239240 $ directory = JPATH_ROOT . DIRECTORY_SEPARATOR . $ path ;
240241 $ filePath = $ directory . DIRECTORY_SEPARATOR . $ file ;
241- $ meta = [];
242+ $ meta = [
243+ 'global ' => [],
244+ 'find ' => [],
245+ ];
242246
243247 if (file_exists ($ filePath ))
244248 {
245- $ tmp = exif_read_data ($ filePath );
246- foreach ($ tmp as $ key => $ section )
249+ $ splitFile = explode ('. ' , $ file );
250+ $ exs = mb_strtolower (array_pop ($ splitFile ));
251+ $ globalInfo [] = [
252+ 'key ' => Text::_ ('COM_QUANTUMMANAGER_FILE_METAINFO_FILENAME ' ),
253+ 'value ' => implode ('. ' , $ splitFile ),
254+ ];
255+
256+ $ stat = stat ($ filePath );
257+
258+ if ($ stat !== false )
247259 {
248- if (is_array ( $ section ))
260+ if (isset ( $ stat [ ' mtime ' ] ))
249261 {
250- foreach ( $ section as $ name => $ val )
251- {
252- $ meta [] = " $ key . $ name : $ val " ;
253- }
262+ $ globalInfo [] = [
263+ ' key ' => Text:: _ ( ' COM_QUANTUMMANAGER_FILE_METAINFO_FILEDATETIME ' ),
264+ ' value ' => date (Text:: _ ( ' DATE_FORMAT_LC5 ' ), $ stat [ ' mtime ' ])
265+ ];
254266 }
255- else
267+
268+ if (isset ($ stat ['size ' ]))
256269 {
257- $ meta [] = "$ key: $ section " ;
270+ $ globalInfo [] = [
271+ 'key ' => Text::_ ('COM_QUANTUMMANAGER_FILE_METAINFO_FILESIZE ' ),
272+ 'value ' => QuantummanagerHelper::formatFileSize ((int )$ stat ['size ' ])
273+ ];
258274 }
275+
259276 }
277+
278+
279+ if (in_array ($ exs , ['jpg ' , 'jpeg ' , 'png ' , 'gif ' ]))
280+ {
281+ list ($ width , $ height , $ type , $ attr ) = getimagesize ($ filePath );
282+
283+ $ globalInfo [] = [
284+ 'key ' => Text::_ ('COM_QUANTUMMANAGER_FILE_METAINFO_RESOLUTION ' ),
285+ 'value ' => $ width . ' x ' . $ height
286+ ];
287+
288+ $ tmp = exif_read_data ($ filePath );
289+ foreach ($ tmp as $ key => $ section )
290+ {
291+ if (is_array ($ section ))
292+ {
293+ foreach ($ section as $ name => $ val )
294+ {
295+ $ meta ['find ' ][] = [
296+ 'key ' => $ key . '. ' . $ name ,
297+ 'value ' => $ val
298+ ];
299+ }
300+ }
301+ else
302+ {
303+
304+ if (!in_array (mb_strtolower ($ key ), [
305+ 'filename ' ,
306+ 'filedatetime ' ,
307+ 'filesize ' ,
308+ 'filetype ' ,
309+ 'mimetype ' ,
310+ ])) {
311+ $ meta ['find ' ][] = [
312+ 'key ' => $ key ,
313+ 'value ' => $ section ,
314+ ];
315+ }
316+
317+ }
318+ }
319+ }
320+
321+ $ meta ['global ' ] = array_merge ($ meta ['global ' ], $ globalInfo );
322+
260323 }
261324
262325 return json_encode ($ meta );
@@ -274,6 +337,16 @@ public static function getFiles($path)
274337 JLoader::register ('JInterventionimage ' , JPATH_LIBRARIES . DIRECTORY_SEPARATOR . 'jinterventionimage ' . DIRECTORY_SEPARATOR . 'jinterventionimage.php ' );
275338 $ path = QuantummanagerHelper::preparePath ($ path );
276339 $ directory = JPATH_ROOT . DIRECTORY_SEPARATOR . $ path ;
340+
341+ if (!file_exists ($ directory ))
342+ {
343+ return json_encode ([
344+ 'error ' => '0 ' ,
345+ 'message ' => 'folder not create ' ,
346+ ]);
347+ }
348+
349+
277350 $ filesOutput = [];
278351 $ files = Folder::files ($ directory );
279352 $ directories = Folder::folders ($ directory );
@@ -311,14 +384,15 @@ public static function getFiles($path)
311384 'dateM ' => filemtime ($ directory . DIRECTORY_SEPARATOR . $ file ),
312385 ];
313386
314- if (in_array (strtolower ($ exs ), ['jpg ' , 'png ' , 'jpeg ' , 'gif ' ]))
387+ if (in_array (strtolower ($ exs ), ['jpg ' , 'png ' , 'jpeg ' , 'gif ' , ' svg ' ]))
315388 {
316389 $ cacheSource = JPATH_ROOT . DIRECTORY_SEPARATOR . 'images/com_quantummanager/cache ' ;
390+ $ path = QuantummanagerHelper::preparePath ($ path );
317391 $ cache = $ cacheSource . DIRECTORY_SEPARATOR . $ path ;
318- if (!file_exists ($ cache . DIRECTORY_SEPARATOR . $ file ))
319- {
392+ // if (!file_exists($cache . DIRECTORY_SEPARATOR . $file))
393+ // {
320394 $ fileMeta ['fileP ' ] = 'index.php?option=com_quantummanager&task=quantumviewfiles.generatePreviewImage&file= ' . $ file ;
321- }
395+ // }
322396
323397 }
324398
@@ -484,34 +558,56 @@ public static function converterSave()
484558 }
485559
486560
561+ /**
562+ * @param $path
563+ * @param $file
564+ *
565+ *
566+ * @since version
567+ * @throws Exception
568+ */
487569 public static function generatePreviewImage ($ path , $ file )
488570 {
489- JLoader::register ('JInterventionimage ' , JPATH_LIBRARIES . DIRECTORY_SEPARATOR . 'jinterventionimage ' . DIRECTORY_SEPARATOR . 'jinterventionimage.php ' );
490- $ path = QuantummanagerHelper::preparePath ($ path );
491- $ directory = JPATH_ROOT . DIRECTORY_SEPARATOR . $ path ;
492- $ manager = JInterventionimage::getInstance ();
493- $ cacheSource = JPATH_ROOT . DIRECTORY_SEPARATOR . 'images/com_quantummanager/cache ' ;
494- $ cache = $ cacheSource ;
495- $ pathArr = explode ('/ ' , $ path );
571+ $ app = Factory::getApplication ();
572+ $ splitFile = explode ('. ' , $ file );
573+ $ exs = mb_strtolower (array_pop ($ splitFile ));
496574
497- for ( $ i = 0 ; $ i < count ( $ pathArr ); $ i ++ )
575+ if ( in_array ( $ exs , [ ' jpg ' , ' jpeg ' , ' png ' , ' gif ' ]) )
498576 {
499- $ cache .= DIRECTORY_SEPARATOR . $ pathArr [$ i ];
500- if (!file_exists ($ cache ))
577+ JLoader::register ('JInterventionimage ' , JPATH_LIBRARIES . DIRECTORY_SEPARATOR . 'jinterventionimage ' . DIRECTORY_SEPARATOR . 'jinterventionimage.php ' );
578+ $ path = QuantummanagerHelper::preparePath ($ path );
579+ $ directory = JPATH_ROOT . DIRECTORY_SEPARATOR . $ path ;
580+ $ manager = JInterventionimage::getInstance ();
581+ $ cacheSource = JPATH_ROOT . DIRECTORY_SEPARATOR . 'images/com_quantummanager/cache ' ;
582+ $ cache = $ cacheSource ;
583+ $ pathArr = explode ('/ ' , $ path );
584+
585+ for ($ i =0 ;$ i <count ($ pathArr );$ i ++)
501586 {
502- Folder::create ($ cache );
587+ $ cache .= DIRECTORY_SEPARATOR . $ pathArr [$ i ];
588+ if (!file_exists ($ cache ))
589+ {
590+ Folder::create ($ cache );
591+ }
503592 }
593+
594+ if (!file_exists ($ cache . DIRECTORY_SEPARATOR . $ file ))
595+ {
596+ $ manager ->make ($ directory . DIRECTORY_SEPARATOR . $ file )->resize (null , 320 , function ($ constraint ) {
597+ $ constraint ->aspectRatio ();
598+ })->save ($ cache . DIRECTORY_SEPARATOR . $ file );
599+ }
600+
601+ $ app ->redirect (DIRECTORY_SEPARATOR . 'images/com_quantummanager/cache ' . DIRECTORY_SEPARATOR . $ path . DIRECTORY_SEPARATOR . $ file . '?= ' . rand (111111 , 999999 ));
504602 }
505603
506- if (! file_exists ( $ cache . DIRECTORY_SEPARATOR . $ file ))
604+ if ( in_array ( $ exs , [ ' svg ' ] ))
507605 {
508- $ manager ->make ($ directory . DIRECTORY_SEPARATOR . $ file )->resize (null , 320 , function ($ constraint ) {
509- $ constraint ->aspectRatio ();
510- })->save ($ cache . DIRECTORY_SEPARATOR . $ file );
606+ $ path = QuantummanagerHelper::preparePath ($ path );
607+ $ app ->redirect (DIRECTORY_SEPARATOR . $ path . DIRECTORY_SEPARATOR . $ file . '?= ' . rand (111111 , 999999 ));
511608 }
512609
513- $ app = Factory::getApplication ();
514- $ app ->redirect (DIRECTORY_SEPARATOR . 'images/com_quantummanager/cache ' . DIRECTORY_SEPARATOR . $ path . DIRECTORY_SEPARATOR . $ file . '?= ' . rand (111111 , 999999 ));
610+
515611
516612 }
517613
0 commit comments