Skip to content

Commit

Permalink
Версия 1.1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitriitux committed Jun 30, 2019
1 parent 95ede62 commit f3845b5
Show file tree
Hide file tree
Showing 16 changed files with 204 additions and 36 deletions.
2 changes: 1 addition & 1 deletion administrator/components/com_quantummanager/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
label="COM_QUANTUMMANAGER_CONFIG_GENERAL_METAFILE_LABEL"
required="true"
class="btn-group"
default="0">
default="1">
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,26 @@ public function getDirectories()
{
$app = Factory::getApplication();
$data = $app->input->getArray();

if(!isset($data['path']))
{
$app->close();
}

$path = $data['path'];
$rootSplit = explode('/', $data['root']);

if(isset($rootSplit[0]))
{
$root = $rootSplit[0];
}
else
{
$root = '';
}

JLoader::register('QuantummanagerFileSystemLocal', JPATH_ROOT . '/administrator/components/com_quantummanager/filesystem/local.php');
echo QuantummanagerFileSystemLocal::getDirectories($path);
echo QuantummanagerFileSystemLocal::getDirectories($path, $root);

$app->close();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ public function createDirectory()
$app = Factory::getApplication();
$data = $app->input->getArray();

if(!isset($data['path']) || !isset($data['name']))
{
$app->close();
}

JLoader::register('QuantummanagerFileSystemLocal', JPATH_ROOT . '/administrator/components/com_quantummanager/filesystem/local.php');
echo QuantummanagerFileSystemLocal::createDirectory($data['path'], $data['name']);

Expand All @@ -41,6 +46,11 @@ public function getFiles()
$app = Factory::getApplication();
$data = $app->input->getArray();

if(!isset($data['path']))
{
$app->close();
}

JLoader::register('QuantummanagerFileSystemLocal', JPATH_ROOT . '/administrator/components/com_quantummanager/filesystem/local.php');
echo QuantummanagerFileSystemLocal::getFiles($data['path']);

Expand All @@ -53,6 +63,11 @@ public function getMetaFile()
$app = Factory::getApplication();
$data = $app->input->getArray();

if(!isset($data['path']) || !isset($data['name']))
{
$app->close();
}

JLoader::register('QuantummanagerFileSystemLocal', JPATH_ROOT . '/administrator/components/com_quantummanager/filesystem/local.php');
echo QuantummanagerFileSystemLocal::getMetaFile($data['path'], $data['name']);

Expand All @@ -64,6 +79,12 @@ public function delete()
{
$app = Factory::getApplication();
$data = $app->input->getArray();

if(!isset($data['path']) || !isset($data['list']))
{
$app->close();
}

$path = $data['path'];
$list = json_decode($data['list']);

Expand All @@ -80,6 +101,12 @@ public function getParsePath()
try {
$app = Factory::getApplication();
$data = $app->input->getArray();

if(!isset($data['path']))
{
$app->close();
}

$path = $data['path'];

JLoader::register('QuantummanagerHelper', JPATH_ROOT . '/administrator/components/com_quantummanager/helpers/quantummanager.php');
Expand All @@ -101,6 +128,12 @@ public function generatePreviewImage()
try {
$app = Factory::getApplication();
$data = $app->input->getArray();

if(!isset($data['path']) || !isset($data['file']))
{
$app->close();
}

$path = $data['path'];
$file = $data['file'];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public function getInput()

$this->__set('standalone', $this->getAttribute('standalone', true));
$this->__set('cssClass', $this->getAttribute('cssClass', ''));
$this->__set('metafile', $this->getAttribute('metafile', '0'));
$this->__set('metafile', $this->getAttribute('metafile', '1'));
$this->directory = $this->getAttribute('directory', 'images');
$this->onlyfiles = $this->getAttribute('onlyfiles', '0');

Expand Down
45 changes: 37 additions & 8 deletions administrator/components/com_quantummanager/filesystem/local.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Uri\Uri;
use Joomla\Filesystem\File;
use Joomla\Filesystem\Folder;

Expand Down Expand Up @@ -49,14 +50,18 @@ public static function createDirectory($path, $name)

/**
* @param $path
* @param $root
*
* @return string
*
* @since version
*/
public static function getDirectories($path)
public static function getDirectories($path, $root)
{
JLoader::register('QuantummanagerHelper', JPATH_SITE . '/administrator/components/com_quantummanager/helpers/quantummanager.php');
$path = JPATH_ROOT . DIRECTORY_SEPARATOR . QuantummanagerHelper::preparePath($path);
$directories = [];
$directories = self::showdir($path, true, true);
$directories = self::showdir($path, $root,true, true);

return json_encode([
'directories' => $directories
Expand All @@ -75,12 +80,14 @@ public static function getDirectories($path)
protected static function showdir
(
$dir,
$root = '',
$folderOnly = false,
$showRoot = false,
$level = 0, // do not use!!!
$ef = '' // do not use!!!
)
{

$html = '';
if ((int)$level == 0)
{
Expand All @@ -95,10 +102,10 @@ protected static function showdir
if ($showRoot && (int)$level == 0)
{
JLoader::register('QuantummanagerHelper', JPATH_SITE . '/administrator/components/com_quantummanager/helpers/quantummanager.php');
$subdir = self::showdir($dir, $folderOnly, $showRoot, $level + 1, $ef);
$subdir = self::showdir($dir, $root, $folderOnly, $showRoot, $level + 1, $ef);
return [
//'path' => QuantummanagerHelper::getFolderRoot(),
'path' => 'root',
'path' => $root,
'subpath' => $subdir
];
}
Expand All @@ -122,7 +129,7 @@ protected static function showdir

$folders[] = [
'path' => $name,
'subpath' => self::showdir($dir . DIRECTORY_SEPARATOR . $name, $folderOnly, $showRoot, $level + 1, $ef)
'subpath' => self::showdir($dir . DIRECTORY_SEPARATOR . $name, $root, $folderOnly, $showRoot, $level + 1, $ef)
];
}
else
Expand Down Expand Up @@ -236,10 +243,20 @@ public static function upload()
*/
public static function getMetaFile($path, $file)
{
$sourcePath = $path;
$path = QuantummanagerHelper::preparePath($path);
$directory = JPATH_ROOT . DIRECTORY_SEPARATOR . $path;
$filePath = $directory . DIRECTORY_SEPARATOR . $file;
$meta = [
'preview' => [
'link' => 'index.php?' . http_build_query([
'option' => 'com_quantummanager',
'task' => 'quantumviewfiles.generatePreviewImage',
'file' => $file,
'path' => $sourcePath,
'v' => rand(111111, 999999),
])
],
'global' => [],
'find' => [],
];
Expand All @@ -248,6 +265,7 @@ public static function getMetaFile($path, $file)
{
$splitFile = explode('.', $file);
$exs = mb_strtolower(array_pop($splitFile));

$globalInfo[] = [
'key' => Text::_('COM_QUANTUMMANAGER_FILE_METAINFO_FILENAME'),
'value' => implode('.', $splitFile),
Expand Down Expand Up @@ -275,7 +293,6 @@ public static function getMetaFile($path, $file)

}


if(in_array($exs, ['jpg', 'jpeg', 'png', 'gif']))
{
list($width, $height, $type, $attr) = getimagesize($filePath);
Expand All @@ -284,6 +301,11 @@ public static function getMetaFile($path, $file)
'key' => Text::_('COM_QUANTUMMANAGER_FILE_METAINFO_RESOLUTION'),
'value' => $width . ' x ' . $height
];
}

if(in_array($exs, ['jpg', 'jpeg']))
{


$tmp = exif_read_data($filePath);
foreach ($tmp as $key => $section)
Expand Down Expand Up @@ -571,6 +593,8 @@ public static function generatePreviewImage($path, $file)
$app = Factory::getApplication();
$splitFile = explode('.', $file);
$exs = mb_strtolower(array_pop($splitFile));
$mediaIconsPath = 'media/com_quantummanager/images/icons/';
$siteUrl = Uri::root();

if(in_array($exs, ['jpg', 'jpeg', 'png', 'gif']))
{
Expand Down Expand Up @@ -598,16 +622,21 @@ public static function generatePreviewImage($path, $file)
})->save($cache . DIRECTORY_SEPARATOR . $file);
}

$app->redirect(DIRECTORY_SEPARATOR . 'images/com_quantummanager/cache' . DIRECTORY_SEPARATOR . $path . DIRECTORY_SEPARATOR . $file . '?=' . rand(111111, 999999));
$app->redirect($siteUrl . 'images/com_quantummanager/cache' . DIRECTORY_SEPARATOR . $path . DIRECTORY_SEPARATOR . $file . '?=' . rand(111111, 999999));
}

if(in_array($exs, ['svg']))
{
$path = QuantummanagerHelper::preparePath($path);
$app->redirect(DIRECTORY_SEPARATOR . $path . DIRECTORY_SEPARATOR . $file . '?=' . rand(111111, 999999));
$app->redirect($siteUrl . $path . DIRECTORY_SEPARATOR . $file . '?=' . rand(111111, 999999));
}

if(in_array($exs, ['doc', 'docx', 'ppt', 'pptx', 'xls', 'xlsx', 'mp3', 'ogg', 'flac', 'pdf', 'zip', 'txt', 'html', 'css', 'js', 'webp']))
{
$app->redirect( $siteUrl . $mediaIconsPath . $exs . '.svg');
}

$app->redirect($siteUrl . $mediaIconsPath . 'other.svg');

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@
class QuantummanagerHelper
{

/**
* @var string
* @since version
*/
public static $cachePathRoot = '';

/**
* @var string
* @since version
Expand Down Expand Up @@ -135,9 +141,28 @@ public static function getActions()
*/
public static function preparePath($path)
{
$session = Factory::getSession();
$path = trim($path);
$componentParams = ComponentHelper::getParams('com_quantummanager');
$pathConfig = self::getParamsComponentValue('path', 'images');
$pathConfig = '';

if(empty(static::$cachePathRoot))
{
$pathConfig = static::getParamsComponentValue('path', 'images');
$pathSession = $session->get('quantummanagerroot', '');
static::$cachePathRoot = $pathConfig;

if(!empty($pathSession))
{
$pathConfig = $pathSession;
static::$cachePathRoot = $pathSession;
}

}
else
{
$pathConfig = static::$cachePathRoot;
}

$path = str_replace(DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR, $path);
$path = preg_replace("#" . JPATH_ROOT . "\/root?#", $pathConfig, $path);
Expand Down Expand Up @@ -208,7 +233,7 @@ public static function preparePath($path)
], $pathConfig);

//если пытаются выйти за пределы папки, то не даем этого сделать
if(!preg_match("/^" . str_replace("/", "\/", "(" . JPATH_ROOT . DIRECTORY_SEPARATOR . ")?" . $pathConfigParse) .".*?/", $path))
if(!preg_match("/^" . str_replace("/", "\/", "\(" . JPATH_ROOT . DIRECTORY_SEPARATOR . "\)?" . $pathConfigParse) .".*?/", $path))
{
if(preg_match("/.*?" . str_replace("/", "\/", JPATH_ROOT . DIRECTORY_SEPARATOR . $pathConfigParse) .".*?/", $path))
{
Expand Down Expand Up @@ -272,12 +297,15 @@ public static function getParamsComponentValue($name, $default = '')
$value = $componentParams->get($name, $default);
$groups = Factory::getUser()->groups;

foreach ($profiles as $key => $profile)
if(!empty($profiles))
{
if(in_array((int)$profile->group, $groups) && ($name === $profile->config))
foreach ($profiles as $key => $profile)
{
$value = trim($profile->value);
break;
if(in_array((int)$profile->group, $groups) && ($name === $profile->config))
{
$value = trim($profile->value);
break;
}
}
}

Expand All @@ -294,6 +322,7 @@ public static function loadLang()
$lang->load($extension, $base_dir, $language_tag, true);
}


/**
* @param $size
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ COM_QUANTUMMANAGER_CONFIG_GENERAL_PATH_DESC="Укажите здесь путь
COM_QUANTUMMANAGER_CONFIG_GENERAL_MAXSIZE_LABEL="Максимальный размер файла для загрузки <br /> в мегабайтах"
COM_QUANTUMMANAGER_CONFIG_GENERAL_POSTFIX_LABEL="Добавлять постфикс к именам файлов"
COM_QUANTUMMANAGER_CONFIG_GENERAL_POSTFIX_DESC=""
COM_QUANTUMMANAGER_CONFIG_GENERAL_METAFILE_LABEL="Метатеги для файлов"
COM_QUANTUMMANAGER_CONFIG_GENERAL_METAFILE_LABEL="Метаинформация для файлов"
COM_QUANTUMMANAGER_CONFIG_GENERAL_HELP_LABEL="Показывать ссылки на обратную связь"
COM_QUANTUMMANAGER_CONFIG_GENERAL_MIMETYPE_LABEL="Разрешенные mime типы файлов"
COM_QUANTUMMANAGER_CONFIG_GENERAL_MIMETYPE_DESC="1"
Expand Down Expand Up @@ -111,5 +111,5 @@ COM_QUANTUMMANAGER_FILE_METAINFO_WIDTH="Ширина"
COM_QUANTUMMANAGER_FILE_METAINFO_HEIGHT="Высота"
COM_QUANTUMMANAGER_FILE_METAINFO_MIMETYPE="Mime тип"
COM_QUANTUMMANAGER_FILE_METAINFO_SECTIONSFOUND="Найдена секция"
COM_QUANTUMMANAGER_FILE_METAINFO_SHOW="Просмотреть все теги"
COM_QUANTUMMANAGER_FILE_METAINFO_HIDE="Скрыть теги"
COM_QUANTUMMANAGER_FILE_METAINFO_SHOW="Просмотреть всю информацию"
COM_QUANTUMMANAGER_FILE_METAINFO_HIDE="Скрыть информацию"
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ COM_QUANTUMMANAGER_CONFIG_GENERAL_PATH_DESC="Укажите здесь путь
COM_QUANTUMMANAGER_CONFIG_GENERAL_MAXSIZE_LABEL="Максимальный размер файла для загрузки <br /> в мегабайтах"
COM_QUANTUMMANAGER_CONFIG_GENERAL_POSTFIX_LABEL="Добавлять постфикс к именам файлов"
COM_QUANTUMMANAGER_CONFIG_GENERAL_POSTFIX_DESC=""
COM_QUANTUMMANAGER_CONFIG_GENERAL_METAFILE_LABEL="Метатеги для файлов"
COM_QUANTUMMANAGER_CONFIG_GENERAL_METAFILE_LABEL="Метаинформация для файлов"
COM_QUANTUMMANAGER_CONFIG_GENERAL_HELP_LABEL="Показывать ссылки на обратную связь"
COM_QUANTUMMANAGER_CONFIG_GENERAL_MIMETYPE_LABEL="Разрешенные mime типы файлов"
COM_QUANTUMMANAGER_CONFIG_GENERAL_MIMETYPE_DESC=""
COM_QUANTUMMANAGER_CONFIG_GENERAL_MIMETYPE_DESC="1"

COM_QUANTUMMANAGER_CONFIG_IMAGE="Изображения"
COM_QUANTUMMANAGER_CONFIG_IMAGE_DESC="Здесь Вы можете настроить автоматический ресайзинг картинок, а так же наложение водяного знака и обрезки изображений"
Expand Down Expand Up @@ -111,5 +111,5 @@ COM_QUANTUMMANAGER_FILE_METAINFO_WIDTH="Ширина"
COM_QUANTUMMANAGER_FILE_METAINFO_HEIGHT="Высота"
COM_QUANTUMMANAGER_FILE_METAINFO_MIMETYPE="Mime тип"
COM_QUANTUMMANAGER_FILE_METAINFO_SECTIONSFOUND="Найдена секция"
COM_QUANTUMMANAGER_FILE_METAINFO_SHOW="Просмотреть все теги"
COM_QUANTUMMANAGER_FILE_METAINFO_HIDE="Скрыть теги"
COM_QUANTUMMANAGER_FILE_METAINFO_SHOW="Просмотреть всю информацию"
COM_QUANTUMMANAGER_FILE_METAINFO_HIDE="Скрыть информацию"
Loading

0 comments on commit f3845b5

Please sign in to comment.