Skip to content

Commit f13af53

Browse files
committed
Версия 1.1
1 parent 16f00d6 commit f13af53

22 files changed

Lines changed: 559 additions & 166 deletions

administrator/components/com_quantummanager/config.xml

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,7 @@
44
<fieldset name="general" label="COM_QUANTUMMANAGER_CONFIG_GENERAL" description="COM_QUANTUMMANAGER_CONFIG_GENERAL_DESC">
55

66
<field name="path"
7-
type="folderlist"
8-
directory=""
9-
filter=""
10-
exclude=""
11-
stripext=""
7+
type="text"
128
label="COM_QUANTUMMANAGER_CONFIG_GENERAL_PATH_LABEL"
139
description="COM_QUANTUMMANAGER_CONFIG_GENERAL_PATH_DESC"
1410
required="true"
@@ -188,6 +184,41 @@
188184

189185
</fieldset>
190186

187+
<fieldset name="profiles" label="COM_QUANTUMMANAGER_CONFIG_PROFILES" description="COM_QUANTUMMANAGER_CONFIG_PROFILES_DESC">
188+
189+
<field name="profiles"
190+
type="subform"
191+
label="COM_QUANTUMMANAGER_CONFIG_PROFILES_VARIABLES"
192+
multiple="true">
193+
<form>
194+
195+
<field
196+
name="group"
197+
type="sql"
198+
label="COM_QUANTUMMANAGER_CONFIG_PROFILES_GROUP"
199+
query="SELECT id, title FROM #__usergroups"
200+
key_field="id"
201+
value_field="title"
202+
/>
203+
204+
<field
205+
name="config"
206+
type="text"
207+
label="COM_QUANTUMMANAGER_CONFIG_PROFILES_CONFIG"
208+
/>
209+
210+
<field
211+
name="value"
212+
type="textarea"
213+
label="COM_QUANTUMMANAGER_CONFIG_PROFILES_VALUE"
214+
cols="40"
215+
rows="8"
216+
/>
217+
218+
</form>
219+
</field>
220+
221+
</fieldset>
191222

192223
<fieldset name="permissions" label="JCONFIG_PERMISSIONS_LABEL" description="JCONFIG_PERMISSIONS_DESC">
193224

administrator/components/com_quantummanager/controllers/quantumviewfiles.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,27 @@ public function delete()
7575
}
7676

7777

78+
public function getParsePath()
79+
{
80+
try {
81+
$app = Factory::getApplication();
82+
$data = $app->input->getArray();
83+
$path = $data['path'];
84+
85+
JLoader::register('QuantummanagerHelper', JPATH_ROOT . '/administrator/components/com_quantummanager/helpers/quantummanager.php');
86+
echo json_encode([
87+
'path' => QuantummanagerHelper::preparePath($path)
88+
]);
89+
90+
$app->close();
91+
}
92+
catch (Exception $e)
93+
{
94+
echo $e->getMessage();
95+
}
96+
}
97+
98+
7899
public function generatePreviewImage()
79100
{
80101
try {

administrator/components/com_quantummanager/filesystem/local.php

Lines changed: 128 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)