first commit
This commit is contained in:
@@ -0,0 +1,103 @@
|
||||
<?php
|
||||
/**
|
||||
* @package quantummanagerbutton
|
||||
* @author Dmitry Tsymbal <cymbal@delo-design.ru>
|
||||
* @copyright Copyright © 2019 Delo Design & NorrNext. All rights reserved.
|
||||
* @license GNU General Public License version 3 or later; see license.txt
|
||||
* @link https://www.norrnext.com
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Filter\OutputFilter;
|
||||
use Joomla\CMS\HTML\HTMLHelper;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Layout\FileLayout;
|
||||
|
||||
|
||||
JFormHelper::loadFieldClass('subform');
|
||||
|
||||
/**
|
||||
* @package ${NAMESPACE}
|
||||
*
|
||||
* @since version
|
||||
*/
|
||||
class JFormFieldQuantummanagerscopesinsert extends JFormFieldSubform
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $type = 'QuantumManagerScopesInsert';
|
||||
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getInput()
|
||||
{
|
||||
$lang = Factory::getLanguage()->load('com_quantummanager', JPATH_ROOT . '/administrator/components/com_quantummanager');
|
||||
JLoader::register('QuantummanagerHelper', JPATH_ROOT . '/administrator/components/com_quantummanager/helpers/quantummanager.php');
|
||||
JLoader::register('QuantummanagerbuttonHelper', JPATH_ROOT . '/plugins/editors-xtd/quantummanagerbutton/helper.php');
|
||||
$scopesForInput = [];
|
||||
$currentValue = $this->value;
|
||||
$scopes = QuantummanagerHelper::getAllScope('all');
|
||||
$defaultValues = QuantummanagerbuttonHelper::defaultValues();
|
||||
$i = 0;
|
||||
foreach ($scopes as $scope)
|
||||
{
|
||||
|
||||
if($scope->id === 'sessionroot')
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$findValue = null;
|
||||
|
||||
if(is_array($currentValue) && count($currentValue) > 0)
|
||||
{
|
||||
foreach ($currentValue as $value)
|
||||
{
|
||||
if ($value['id'] === $scope->id)
|
||||
{
|
||||
$findValue = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$title = '';
|
||||
|
||||
if (substr_count($scope->title, 'COM_QUANTUMMANAGER'))
|
||||
{
|
||||
$title = Text::_($scope->title);
|
||||
}
|
||||
|
||||
$defaultTemplateList = '';
|
||||
$defaultFieldsform = '';
|
||||
|
||||
if (isset($defaultValues[$scope->id]))
|
||||
{
|
||||
$defaultTemplateList = $defaultValues[$scope->id]->templatelist;
|
||||
$defaultFieldsform = json_encode($defaultValues[$scope->id]->fieldsform);
|
||||
}
|
||||
|
||||
$scopesForInput['scopes' . $i] = [
|
||||
'title' => $scope->title,
|
||||
'titleLabel' => $scope->title,
|
||||
'id' => $scope->id,
|
||||
'fieldsform' => $findValue !== null ? $findValue['fieldsform'] : $defaultFieldsform,
|
||||
'templatelist' => $findValue !== null ? $findValue['templatelist'] : $defaultTemplateList,
|
||||
];
|
||||
|
||||
$i++;
|
||||
}
|
||||
|
||||
$this->value = $scopesForInput;
|
||||
$html = parent::getInput();
|
||||
return $html;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
324
plugins/editors-xtd/quantummanagerbutton/helper.php
Normal file
324
plugins/editors-xtd/quantummanagerbutton/helper.php
Normal file
@@ -0,0 +1,324 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package quantummanagerbutton
|
||||
* @author Dmitry Tsymbal <cymbal@delo-design.ru>
|
||||
* @copyright Copyright © 2019 Delo Design & NorrNext. All rights reserved.
|
||||
* @license GNU General Public License version 3 or later; see license.txt
|
||||
* @link https://www.norrnext.com
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\Layout\FileLayout;
|
||||
|
||||
class QuantummanagerbuttonHelper
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @var
|
||||
* @since version
|
||||
*/
|
||||
public static $template;
|
||||
|
||||
|
||||
public static function loadLang()
|
||||
{
|
||||
Factory::getLanguage()->load('plg_editors-xtd_quantummanagerbutton', JPATH_ADMINISTRATOR);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @since version
|
||||
*/
|
||||
public static function getFieldsForScopes()
|
||||
{
|
||||
|
||||
$db = Factory::getDbo();
|
||||
$query = $db->getQuery(true)
|
||||
->select($db->quoteName(array('params')))
|
||||
->from('#__extensions')
|
||||
->where('element=' . $db->quote('quantummanagerbutton'));
|
||||
$extension = $db->setQuery($query)->loadObject();
|
||||
$params = json_decode($extension->params, JSON_OBJECT_AS_ARRAY);
|
||||
|
||||
if (!isset($params['scopes']) || empty($params['scopes']) || count((array) $params['scopes']) === 0)
|
||||
{
|
||||
$scopes = self::defaultValues();
|
||||
$scopes_custom = [];
|
||||
}
|
||||
else
|
||||
{
|
||||
$scopes = $params['scopes'];
|
||||
$scopes_custom = $params['customscopes'] ?? [];
|
||||
}
|
||||
|
||||
$output = [];
|
||||
|
||||
foreach ($scopes as $scope)
|
||||
{
|
||||
$scope = (array) $scope;
|
||||
$output[$scope['id']] = [
|
||||
'title' => $scope['title'],
|
||||
'fieldsform' => $scope['fieldsform']
|
||||
];
|
||||
}
|
||||
|
||||
foreach ($scopes_custom as $scope)
|
||||
{
|
||||
$scope = (array) $scope;
|
||||
$output[$scope['id']] = [
|
||||
'title' => $scope['title'],
|
||||
'fieldsform' => $scope['fieldsform']
|
||||
];
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @since version
|
||||
*/
|
||||
public static function getTemplateListForScopes()
|
||||
{
|
||||
$db = Factory::getDbo();
|
||||
$query = $db->getQuery(true)
|
||||
->select($db->quoteName(array('params')))
|
||||
->from('#__extensions')
|
||||
->where('element=' . $db->quote('quantummanagerbutton'));
|
||||
$extension = $db->setQuery($query)->loadObject();
|
||||
$params = json_decode($extension->params, JSON_OBJECT_AS_ARRAY);
|
||||
|
||||
if (!isset($params['scopes']) || empty($params['scopes']) || count((array) $params['scopes']) === 0)
|
||||
{
|
||||
$scopes = self::defaultValues();
|
||||
$scopes_custom = [];
|
||||
}
|
||||
else
|
||||
{
|
||||
$scopes = $params['scopes'];
|
||||
$scopes_custom = $params['customscopes'] ?? [];
|
||||
}
|
||||
|
||||
foreach ($scopes_custom as $scope)
|
||||
{
|
||||
$scopes[count($scopes)] = $scope;
|
||||
}
|
||||
|
||||
$output = [];
|
||||
|
||||
foreach ($scopes as $scope)
|
||||
{
|
||||
$scope = (array) $scope;
|
||||
|
||||
$templatelist = [];
|
||||
$templatelistFromScope = $scope['templatelist'];
|
||||
|
||||
if (!is_array($templatelistFromScope))
|
||||
{
|
||||
$templatelistFromScope = [
|
||||
[
|
||||
'templatename' => Text::_('PLG_BUTTON_QUANTUMMANAGERBUTTON_SCOPES_NAME_DEFAULT'),
|
||||
'template' => '<a href="{file}" target="_blank">{name}</a>'
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
foreach ($templatelistFromScope as $keyTemplate => $template)
|
||||
{
|
||||
$templateItem = '';
|
||||
if (preg_match("#^\{\{.*?\}\}$#isu", trim($template['template'])))
|
||||
{
|
||||
$layoutId = str_replace(['{', '}'], '', $template['template']);
|
||||
$templateItem = self::renderLayout($layoutId);
|
||||
}
|
||||
else
|
||||
{
|
||||
$templateItem = $template['template'];
|
||||
}
|
||||
|
||||
$enablefields = [];
|
||||
$matches = [];
|
||||
preg_match_all("#\{(.*?)\}#isu", $templateItem, $matches);
|
||||
|
||||
if (isset($matches[1]))
|
||||
{
|
||||
foreach ($matches[1] as $findField)
|
||||
{
|
||||
if (!in_array($findField, $enablefields))
|
||||
{
|
||||
$enablefields[] = $findField;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$templatelist[] = [
|
||||
'name' => $template['templatename'],
|
||||
'enablefields' => $enablefields,
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
$output[$scope['id']] = [
|
||||
'title' => $scope['title'],
|
||||
'templatelist' => $templatelist
|
||||
];
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $layoutId
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @throws Exception
|
||||
* @since version
|
||||
*/
|
||||
public static function renderLayout($layoutId)
|
||||
{
|
||||
$app = Factory::getApplication();
|
||||
$template = $app->getTemplate();
|
||||
|
||||
if (empty(self::$template))
|
||||
{
|
||||
$db = Factory::getDbo();
|
||||
$query = $db->getQuery(true);
|
||||
$query->select('template')
|
||||
->from('#__template_styles as e')
|
||||
->where('e.client_id = 0')
|
||||
->where('e.home = 1')
|
||||
->setLimit(1);
|
||||
$db->setQuery($query);
|
||||
$template = $db->loadObject();
|
||||
if (isset($template->template))
|
||||
{
|
||||
self::$template = $template->template;
|
||||
}
|
||||
}
|
||||
|
||||
$layout = new FileLayout($layoutId);
|
||||
$layout->addIncludePath([
|
||||
JPATH_ROOT . DIRECTORY_SEPARATOR . implode(DIRECTORY_SEPARATOR, ['templates', self::$template, 'layouts', 'plg_quantummanagcontent']),
|
||||
JPATH_ROOT . DIRECTORY_SEPARATOR . implode(DIRECTORY_SEPARATOR, ['templates', self::$template, 'html', 'layouts', 'plg_quantummanagcontent']),
|
||||
JPATH_ROOT . DIRECTORY_SEPARATOR . implode(DIRECTORY_SEPARATOR, ['templates', self::$template, 'html', 'layouts', 'plg_content_quantummanagercontent']),
|
||||
JPATH_ROOT . DIRECTORY_SEPARATOR . implode(DIRECTORY_SEPARATOR, ['templates', self::$template, 'html', 'plg_content_quantummanagercontent']),
|
||||
JPATH_ROOT . DIRECTORY_SEPARATOR . implode(DIRECTORY_SEPARATOR, ['templates', self::$template, 'html', 'plg_quantummanagcontent']),
|
||||
JPATH_ROOT . DIRECTORY_SEPARATOR . implode(DIRECTORY_SEPARATOR, ['templates', self::$template, 'html', 'plg_button_quantummanagerbutton']),
|
||||
]);
|
||||
|
||||
$output = $layout->render();
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @since version
|
||||
*/
|
||||
public static function defaultValues()
|
||||
{
|
||||
$lang = Factory::getLanguage();
|
||||
$lang->load('plg_editors-xtd_quantummanagerbutton', JPATH_ADMINISTRATOR);
|
||||
$lang->load('com_quantummanager', JPATH_ROOT . '/administrator/components/com_quantummanager');
|
||||
|
||||
return [
|
||||
'images' => (object) [
|
||||
'id' => 'images',
|
||||
'title' => Text::_('COM_QUANTUMMANAGER_SCOPE_IMAGES'),
|
||||
'templatelist' => [
|
||||
'templatelist0' => [
|
||||
'templatename' => Text::_('PLG_BUTTON_QUANTUMMANAGERBUTTON_SCOPES_NAME_IMAGE'),
|
||||
'templatebefore' => '',
|
||||
'template' => '<img src="{file}" alt="{alt}" width="{width}" height="{height}" />',
|
||||
'templateafter' => '',
|
||||
]
|
||||
],
|
||||
'fieldsform' => [
|
||||
'fieldsform0' => [
|
||||
'nametemplate' => 'width',
|
||||
'name' => Text::_('PLG_BUTTON_QUANTUMMANAGERBUTTON_SCOPES_IMAGES_FIELDSFORM_WIDTH_NAME'),
|
||||
'default' => '',
|
||||
'type' => 'number',
|
||||
],
|
||||
'fieldsform1' => [
|
||||
'nametemplate' => 'height',
|
||||
'name' => Text::_('PLG_BUTTON_QUANTUMMANAGERBUTTON_SCOPES_IMAGES_FIELDSFORM_HEIGHT_NAME'),
|
||||
'default' => '',
|
||||
'type' => 'number',
|
||||
],
|
||||
'fieldsform3' => [
|
||||
'nametemplate' => 'alt',
|
||||
'name' => Text::_('PLG_BUTTON_QUANTUMMANAGERBUTTON_SCOPES_IMAGES_FIELDSFORM_ALT_NAME'),
|
||||
'default' => '',
|
||||
'type' => 'text',
|
||||
]
|
||||
]
|
||||
],
|
||||
'docs' => (object) [
|
||||
'id' => 'docs',
|
||||
'title' => Text::_('COM_QUANTUMMANAGER_SCOPE_DOCS'),
|
||||
'templatelist' => [
|
||||
'templatelist0' => [
|
||||
'templatename' => Text::_('PLG_BUTTON_QUANTUMMANAGERBUTTON_SCOPES_NAME_DOC'),
|
||||
'templatebefore' => '',
|
||||
'template' => '<a href="{file}" target="_blank">{name}</a>',
|
||||
'templateafter' => '',
|
||||
]
|
||||
],
|
||||
'fieldsform' => [
|
||||
'fieldsform0' => [
|
||||
'nametemplate' => 'name',
|
||||
'name' => Text::_('PLG_BUTTON_QUANTUMMANAGERBUTTON_SCOPES_DOCS_FIELDSFORM_NAME_NAME'),
|
||||
'default' => Text::_('PLG_BUTTON_QUANTUMMANAGERBUTTON_SCOPES_IMAGES_FIELDSFORM_DEFAULT_NAME'),
|
||||
'type' => 'text',
|
||||
],
|
||||
]
|
||||
],
|
||||
'music' => (object) [
|
||||
'id' => 'music',
|
||||
'title' => Text::_('COM_QUANTUMMANAGER_SCOPE_MUSIC'),
|
||||
'templatelist' => [
|
||||
'templatelist0' => [
|
||||
'templatename' => Text::_('PLG_BUTTON_QUANTUMMANAGERBUTTON_SCOPES_NAME_AUDIO'),
|
||||
'templatebefore' => '',
|
||||
'template' => '<audio controls src="{file}"> ' . Text::_('PLG_BUTTON_QUANTUMMANAGERBUTTON_SCOPES_MUSIC_TEMPLATE_TEXT') . '</audio>',
|
||||
'templateafter' => '',
|
||||
]
|
||||
],
|
||||
'fieldsform' => '',
|
||||
],
|
||||
'videos' => (object) [
|
||||
'id' => 'videos',
|
||||
'title' => Text::_('COM_QUANTUMMANAGER_SCOPE_VIDEOS'),
|
||||
'templatelist' => [
|
||||
'templatelist0' => [
|
||||
'templatename' => Text::_('PLG_BUTTON_QUANTUMMANAGERBUTTON_SCOPES_NAME_VIDEO'),
|
||||
'templatebefore' => '',
|
||||
'template' => '<video src="{file}" autoplay>' . Text::_('PLG_BUTTON_QUANTUMMANAGERBUTTON_SCOPES_VIDEOS_TEMPLATE_TEXT') . '</video>',
|
||||
'templateafter' => '',
|
||||
]
|
||||
],
|
||||
'fieldsform' => '',
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,462 @@
|
||||
<?php
|
||||
/**
|
||||
* @package quantummanagerbutton
|
||||
* @author Dmitry Tsymbal <cymbal@delo-design.ru>
|
||||
* @copyright Copyright © 2019 Delo Design & NorrNext. All rights reserved.
|
||||
* @license GNU General Public License version 3 or later; see license.txt
|
||||
* @link https://www.norrnext.com
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\Layout\FileLayout;
|
||||
use Joomla\CMS\Object\CMSObject;
|
||||
use Joomla\CMS\Plugin\CMSPlugin;
|
||||
use Joomla\CMS\Session\Session;
|
||||
|
||||
class PlgButtonQuantummanagerbutton extends CMSPlugin
|
||||
{
|
||||
|
||||
/**
|
||||
* Application object
|
||||
*
|
||||
* @var CMSApplication
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected $app;
|
||||
|
||||
|
||||
/**
|
||||
* Load the language file on instantiation.
|
||||
*
|
||||
* @var boolean
|
||||
*
|
||||
* @since 1.1.0
|
||||
*/
|
||||
protected $autoloadLanguage = true;
|
||||
|
||||
|
||||
protected $install_quantummanager = false;
|
||||
|
||||
|
||||
public function __construct(&$subject, $config = array())
|
||||
{
|
||||
parent::__construct($subject, $config);
|
||||
|
||||
if(file_exists(JPATH_SITE . '/administrator/components/com_quantummanager/quantummanager.php'))
|
||||
{
|
||||
$this->install_quantummanager = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Display the button.
|
||||
*
|
||||
* @param string $name The name of the button to add.
|
||||
*
|
||||
* @return CMSObject The button options as CMSObject.
|
||||
*
|
||||
* @throws Exception
|
||||
*
|
||||
* @since 1.1.0
|
||||
*/
|
||||
public function onDisplay($name, $asset, $author)
|
||||
{
|
||||
|
||||
if(!$this->install_quantummanager)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!$this->accessCheck())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
JLoader::register('QuantummanagerHelper', JPATH_ROOT . '/administrator/components/com_quantummanager/helpers/quantummanager.php');
|
||||
$function = 'function(){}';
|
||||
$isJoomla4 = QuantummanagerHelper::isJoomla4();
|
||||
|
||||
$link = 'index.php?option=com_ajax&plugin=quantummanagerbutton&group=editors-xtd&format=html&tmpl=component&plugin.task=getmodal&e_name=' . $name . '&asset=com_content&author='
|
||||
. Session::getFormToken() . '=1&function=' . $function . '&isjoomla4=' . ($isJoomla4 ? '1' : '0');
|
||||
|
||||
$button = new CMSObject();
|
||||
$button->modal = true;
|
||||
$button->class = 'btn';
|
||||
$button->link = $link;
|
||||
$button->text = Text::_('PLG_BUTTON_QUANTUMMANAGERBUTTON_BUTTON');
|
||||
|
||||
if ($isJoomla4)
|
||||
{
|
||||
$button->name = $this->_type . '_' . $this->_name;
|
||||
$button->icon = 'pictures';
|
||||
$button->iconSVG = '<svg width="24" height="24" viewBox="0 0 512 512"><path d="M464 64H48C21.49 64 0 85.49 0 112v288c0 26.51 21.49 48'
|
||||
. ' 48 48h416c26.51 0 48-21.49 48-48V112c0-26.51-21.49-48-48-48zm-6 336H54a6 6 0 0 1-6-6V118a6 6 0 0 1 6-6h404a6 6'
|
||||
. ' 0 0 1 6 6v276a6 6 0 0 1-6 6zM128 152c-22.091 0-40 17.909-40 40s17.909 40 40 40 40-17.909 40-40-17.909-40-40-40'
|
||||
. 'zM96 352h320v-80l-87.515-87.515c-4.686-4.686-12.284-4.686-16.971 0L192 304l-39.515-39.515c-4.686-4.686-12.284-4'
|
||||
. '.686-16.971 0L96 304v48z"></path></svg>';
|
||||
$button->options = [
|
||||
'height' => '400px',
|
||||
'width' => '800px',
|
||||
'bodyHeight' => '70',
|
||||
'modalWidth' => '80',
|
||||
'tinyPath' => $link,
|
||||
'confirmCallback' => 'Joomla.getImage(Joomla.selectedMediaFile, \'' . $name . '\', this)',
|
||||
];
|
||||
|
||||
return $button;
|
||||
}
|
||||
|
||||
$button->name = 'file-add';
|
||||
$button->options = "{handler: 'iframe', size: {x: 1450, y: 700}, classWindow: 'quantummanager-modal-sbox-window'}";
|
||||
|
||||
$label = Text::_('PLG_BUTTON_QUANTUMMANAGERBUTTON_BUTTON');
|
||||
|
||||
Factory::getDocument()->addStyleDeclaration(<<<EOT
|
||||
@media screen and (max-width: 1540px) {
|
||||
.mce-window[aria-label="{$label}"] {
|
||||
left: 2% !important;
|
||||
right: 0 !important;
|
||||
width: 95% !important;
|
||||
}
|
||||
|
||||
.mce-window[aria-label="{$label}"] .mce-reset
|
||||
{
|
||||
width: 100% !important;
|
||||
height: 100% !important;
|
||||
}
|
||||
|
||||
.mce-window[aria-label="{$label}"] .mce-window-body {
|
||||
width: 100% !important;
|
||||
height: calc(100% - 96px) !important;
|
||||
}
|
||||
|
||||
.mce-window[aria-label="{$label}"] .mce-foot {
|
||||
width: 100% !important;
|
||||
}
|
||||
|
||||
.mce-window[aria-label="{$label}"] .mce-foot .mce-container-body {
|
||||
width: 100% !important;
|
||||
}
|
||||
|
||||
.mce-window[aria-label="{$label}"] .mce-foot .mce-container-body .mce-widget {
|
||||
left: auto !important;
|
||||
right: 18px !important;
|
||||
}
|
||||
}
|
||||
|
||||
@media screen and (max-height: 700px) {
|
||||
|
||||
.mce-window[aria-label="{$label}"] {
|
||||
top: 2% !important;
|
||||
height: 95% !important;
|
||||
}
|
||||
|
||||
.mce-window[aria-label="{$label}"] .mce-window-body {
|
||||
height: calc(100% - 96px) !important;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
EOT
|
||||
);
|
||||
|
||||
return $button;
|
||||
}
|
||||
|
||||
|
||||
public function onAjaxQuantummanagerbutton()
|
||||
{
|
||||
|
||||
if(!$this->install_quantummanager)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
JLoader::register('QuantummanagerHelper', JPATH_ROOT . '/administrator/components/com_quantummanager/helpers/quantummanager.php');
|
||||
JLoader::register('QuantummanagerbuttonHelper', JPATH_ROOT . '/plugins/editors-xtd/quantummanagerbutton/helper.php');
|
||||
|
||||
$app = Factory::getApplication();
|
||||
$data = $app->input->getArray();
|
||||
$task = $app->input->get('plugin_task');
|
||||
$html = '';
|
||||
|
||||
if (!$this->accessCheck())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if ($task === 'getmodal')
|
||||
{
|
||||
QuantummanagerHelper::loadlang();
|
||||
$layout = new FileLayout('default', JPATH_ROOT . DIRECTORY_SEPARATOR . implode(DIRECTORY_SEPARATOR, [
|
||||
'plugins', 'editors-xtd', 'quantummanagerbutton', 'tmpl'
|
||||
]));
|
||||
echo $layout->render();
|
||||
}
|
||||
|
||||
if ($task === 'prepareforcontent')
|
||||
{
|
||||
if (!isset($data['params'], $data['scope']))
|
||||
{
|
||||
$app->close();
|
||||
}
|
||||
|
||||
$scope = $data['scope'];
|
||||
$params = json_decode($data['params'], JSON_OBJECT_AS_ARRAY);
|
||||
$file = QuantummanagerHelper::preparePath($data['path'], false, $scope, true);
|
||||
$name = explode('/', $file);
|
||||
$filename = end($name);
|
||||
$type = explode('.', $file);
|
||||
$filetype = end($type);
|
||||
$filesize = filesize(JPATH_ROOT . '/' . $file);
|
||||
$scopesTemplate = $this->params->get('scopes', QuantummanagerbuttonHelper::defaultValues());
|
||||
$scopesCustom = $this->params->get('customscopes', []);
|
||||
$variables = [];
|
||||
$variablesParams = [];
|
||||
$html = '';
|
||||
|
||||
$shortCode = false;
|
||||
$template = '<a href="{file}" target="_blank">{name}</a>';
|
||||
|
||||
if(is_array($scopesCustom))
|
||||
{
|
||||
$scopesCustom = [];
|
||||
}
|
||||
|
||||
foreach ($scopesCustom as $scopeCustom)
|
||||
{
|
||||
$nameTmp = 'scopes' . count($scopesTemplate);
|
||||
$scopesTemplate->$nameTmp = $scopeCustom;
|
||||
}
|
||||
|
||||
foreach ($scopesTemplate as $scopesTemplateCurrent)
|
||||
{
|
||||
|
||||
$scopesTemplateCurrent = (object) $scopesTemplateCurrent;
|
||||
|
||||
if ($scopesTemplateCurrent->id === $scope)
|
||||
{
|
||||
|
||||
if (empty($scopesTemplateCurrent->templatelist))
|
||||
{
|
||||
foreach ($params['files'] as $item)
|
||||
{
|
||||
$file = QuantummanagerHelper::preparePath($data['path'], false, $scope, true) . DIRECTORY_SEPARATOR . $item['file'];
|
||||
$name = explode('/', $file);
|
||||
$filename = end($name);
|
||||
$type = explode('.', $file);
|
||||
$filetype = mb_strtolower(end($type));
|
||||
$filesize = filesize(JPATH_ROOT . '/' . $file);
|
||||
|
||||
$variables = [
|
||||
'{file}' => $file,
|
||||
'{filename}' => $filename,
|
||||
'{type}' => $filetype,
|
||||
'{size}' => QuantummanagerHelper::formatFileSize($filesize),
|
||||
];
|
||||
|
||||
if (file_exists(JPATH_ROOT . DIRECTORY_SEPARATOR . $file))
|
||||
{
|
||||
if (in_array($filetype, ['jpg', 'jpeg', 'png']))
|
||||
{
|
||||
list($width, $height, $type, $attr) = getimagesize(JPATH_ROOT . DIRECTORY_SEPARATOR . $file);
|
||||
$variables['{imagewidth}'] = $width;
|
||||
$variables['{imageheight}'] = $height;
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($item['fields'] as $key => $value)
|
||||
{
|
||||
if (preg_match("#^\{.*?\}$#isu", $key))
|
||||
{
|
||||
$variables[$key] = trim($value);
|
||||
}
|
||||
}
|
||||
|
||||
$template = '<a href="{file}" target="_blank">{name}</a>';
|
||||
$variablesFind = [];
|
||||
$variablesReplace = [];
|
||||
|
||||
foreach ($variables as $key => $value)
|
||||
{
|
||||
$variablesFind[] = $key;
|
||||
$variablesReplace[] = $value;
|
||||
}
|
||||
|
||||
$template = str_replace($variablesFind, $variablesReplace, $template);
|
||||
$html .= preg_replace("#[\s\040]?[a-zA-Z0-9]{1,}\=\"\"#isu", '', $template);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach ($scopesTemplateCurrent->templatelist as $templateList)
|
||||
{
|
||||
$templateList = (object) $templateList;
|
||||
if (isset($params['template']) && $templateList->templatename === $params['template'])
|
||||
{
|
||||
//собираем по выбранному шаблону
|
||||
$templatebefore = '';
|
||||
$templateitems = '';
|
||||
$templateafter = '';
|
||||
$shortCode = false;
|
||||
|
||||
if (preg_match("#^\{\{.*?\}\}$#isu", trim($templateList->templatebefore)))
|
||||
{
|
||||
$templatebefore = '[before]' . $templateList->templatebefore . '[/before]';
|
||||
$shortCode = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$templatebefore = $templateList->templatebefore;
|
||||
}
|
||||
|
||||
$variablesForTemplate = [];
|
||||
foreach ($params['files'] as $item)
|
||||
{
|
||||
$file = QuantummanagerHelper::preparePath($data['path'], false, $scope, true) . DIRECTORY_SEPARATOR . $item['file'];
|
||||
$name = explode('/', $file);
|
||||
$filename = end($name);
|
||||
$type = explode('.', $file);
|
||||
$filetype = end($type);
|
||||
$filesize = filesize(JPATH_ROOT . '/' . $file);
|
||||
|
||||
$variables = [
|
||||
'{file}' => $file,
|
||||
'{filename}' => $filename,
|
||||
'{type}' => $filetype,
|
||||
'{size}' => QuantummanagerHelper::formatFileSize($filesize),
|
||||
];
|
||||
|
||||
if (file_exists(JPATH_ROOT . DIRECTORY_SEPARATOR . $file))
|
||||
{
|
||||
if (in_array($filetype, ['jpg', 'jpeg', 'png']))
|
||||
{
|
||||
list($width, $height, $type, $attr) = getimagesize(JPATH_ROOT . DIRECTORY_SEPARATOR . $file);
|
||||
$variables['{imagewidth}'] = $width;
|
||||
$variables['{imageheight}'] = $height;
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($item['fields'] as $key => $value)
|
||||
{
|
||||
if (preg_match("#^\{.*?\}$#isu", $key))
|
||||
{
|
||||
$variables[$key] = trim($value);
|
||||
}
|
||||
}
|
||||
|
||||
$variablesFind = [];
|
||||
$variablesReplace = [];
|
||||
|
||||
foreach ($variables as $key => $value)
|
||||
{
|
||||
$variablesFind[] = $key;
|
||||
$variablesReplace[] = $value;
|
||||
}
|
||||
|
||||
foreach ($variables as $key => $value)
|
||||
{
|
||||
$variables[$key] = str_replace($variablesFind, $variablesReplace, $value);
|
||||
}
|
||||
|
||||
$variablesFind = [];
|
||||
$variablesReplace = [];
|
||||
|
||||
foreach ($variables as $key => $value)
|
||||
{
|
||||
$variablesFind[] = $key;
|
||||
$variablesReplace[] = $value;
|
||||
}
|
||||
|
||||
if (preg_match("#^\{\{.*?\}\}$#isu", trim($templateList->template)) || $shortCode)
|
||||
{
|
||||
$shortCode = true;
|
||||
$variablesForTemplate[] = $variables;
|
||||
}
|
||||
else
|
||||
{
|
||||
$item = str_replace($variablesFind, $variablesReplace, $templateList->template);
|
||||
$item = preg_replace("#[\s\040]?[a-zA-Z0-9]{1,}\=\"\"#isu", '', $item);
|
||||
$templateitems .= $item;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ($shortCode)
|
||||
{
|
||||
$templateitems = '[item][variables]' . json_encode($variablesForTemplate) . '[/variables][template]' . $templateList->template . '[/template][/item]';
|
||||
}
|
||||
|
||||
if (preg_match("#^\{\{.*?\}\}$#isu", trim($templateList->templateafter)))
|
||||
{
|
||||
$templateafter = '[after]' . $templateList->templateafter . '[/after]';
|
||||
$shortCode = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$templateafter = $templateList->templateafter;
|
||||
}
|
||||
|
||||
if ($shortCode)
|
||||
{
|
||||
$html = '[qmcontent]' . $templatebefore . $templateitems . $templateafter . '[/qmcontent]';
|
||||
}
|
||||
else
|
||||
{
|
||||
$html = $templatebefore . $templateitems . $templateafter;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
echo $html;
|
||||
|
||||
$app->close();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
protected function accessCheck()
|
||||
{
|
||||
|
||||
if ($this->app->isClient('administrator'))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// проверяем на включенность параметра
|
||||
JLoader::register('QuantummanagerHelper', JPATH_ADMINISTRATOR . '/components/com_quantummanager/helpers/quantummanager.php');
|
||||
|
||||
if (!(int) QuantummanagerHelper::getParamsComponentValue('front', 0))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// проверяем что пользователь авторизован
|
||||
if (Factory::getUser()->id === 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
$actions = QuantummanagerHelper::getActions();
|
||||
|
||||
if (!$actions->get('core.create'))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,279 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<extension version="3.9" type="plugin" group="editors-xtd" method="upgrade">
|
||||
<name>PLG_BUTTON_QUANTUMMANAGERBUTTON</name>
|
||||
<author>Tsymbal</author>
|
||||
<creationDate>02.02.2020</creationDate>
|
||||
<copyright>Copyright © 2020 Delo Design & NorrNext. All rights reserved.</copyright>
|
||||
<license>https://www.gnu.org/copyleft/gpl.html GNU/GPL</license>
|
||||
<authorEmail>cymbal@delo-design.ru</authorEmail>
|
||||
<authorUrl>https://www.norrnext.com</authorUrl>
|
||||
<version>1.4</version>
|
||||
<description>PLG_BUTTON_QUANTUMMANAGERBUTTON_DESCRIPTION</description>
|
||||
<scriptfile>script.php</scriptfile>
|
||||
<languages folder="language">
|
||||
<language tag="en-GB">en-GB/en-GB.plg_editors-xtd_quantummanagerbutton.ini</language>
|
||||
<language tag="en-GB">en-GB/en-GB.plg_editors-xtd_quantummanagerbutton.sys.ini</language>
|
||||
<language tag="ru-RU">ru-RU/ru-RU.plg_editors-xtd_quantummanagerbutton.ini</language>
|
||||
<language tag="ru-RU">ru-RU/ru-RU.plg_editors-xtd_quantummanagerbutton.sys.ini</language>
|
||||
</languages>
|
||||
<media folder="media" destination="plg_button_quantummanagerbutton">
|
||||
<folder>css</folder>
|
||||
<folder>js</folder>
|
||||
</media>
|
||||
<files>
|
||||
<filename plugin="quantummanagerbutton">quantummanagerbutton.php</filename>
|
||||
<filename plugin="quantummanagerbutton">helper.php</filename>
|
||||
<folder>fields</folder>
|
||||
<folder>tmpl</folder>
|
||||
</files>
|
||||
<config>
|
||||
<fields name="params" addfieldpath="/plugins/editors-xtd/quantummanagerbutton/fields">
|
||||
<fieldset name="basic">
|
||||
|
||||
<field type="note"
|
||||
label="PLG_BUTTON_QUANTUMMANAGERBUTTON_CONFIG_DOCS_LABEL"
|
||||
description="PLG_BUTTON_QUANTUMMANAGERBUTTON_CONFIG_DOCS"
|
||||
class="alert alert-info"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="scopes"
|
||||
type="quantummanagerscopesinsert"
|
||||
label="PLG_BUTTON_QUANTUMMANAGERBUTTON_CONFIG_SCOPES"
|
||||
required="true"
|
||||
buttons=" "
|
||||
multiple="true">
|
||||
<form>
|
||||
<field
|
||||
name="titleLabel"
|
||||
type="text"
|
||||
default=""
|
||||
label="PLG_BUTTON_QUANTUMMANAGERBUTTON_CONFIG_SCOPES_TITLE"
|
||||
disabled="disabled"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="title"
|
||||
type="hidden"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="id"
|
||||
type="hidden"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="fieldsform"
|
||||
type="subform"
|
||||
label="PLG_BUTTON_QUANTUMMANAGERBUTTON_CONFIG_SCOPES_FIELDSFORM"
|
||||
required="true"
|
||||
multiple="true">
|
||||
<form>
|
||||
<field
|
||||
name="nametemplate"
|
||||
type="text"
|
||||
label="PLG_BUTTON_QUANTUMMANAGERBUTTON_CONFIG_SCOPES_FIELDSFORM_NAMETEMPLATE"
|
||||
/>
|
||||
<field
|
||||
name="name"
|
||||
type="text"
|
||||
label="PLG_BUTTON_QUANTUMMANAGERBUTTON_CONFIG_SCOPES_FIELDSFORM_NAME"
|
||||
/>
|
||||
<field
|
||||
name="default"
|
||||
type="text"
|
||||
label="PLG_BUTTON_QUANTUMMANAGERBUTTON_CONFIG_SCOPES_FIELDSFORM_DEFAULT"
|
||||
/>
|
||||
<field
|
||||
name="type"
|
||||
type="list"
|
||||
default="text"
|
||||
label="PLG_BUTTON_QUANTUMMANAGERBUTTON_CONFIG_SCOPES_FIELDSFORM_TYPE">
|
||||
<option value="text">Text</option>
|
||||
<option value="number">Number</option>
|
||||
<option value="list">List</option>
|
||||
<option value="color">Color</option>
|
||||
<option value="email">Email</option>
|
||||
<option value="url">Url</option>
|
||||
<option value="date">Date</option>
|
||||
<option value="time">Time</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="forlist"
|
||||
type="textarea"
|
||||
default=""
|
||||
label="PLG_BUTTON_QUANTUMMANAGERBUTTON_CONFIG_SCOPES_FIELDSFORM_FORLIST"
|
||||
showon="type:list"
|
||||
/>
|
||||
</form>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="templatelist"
|
||||
type="subform"
|
||||
label="PLG_BUTTON_QUANTUMMANAGERBUTTON_CONFIG_SCOPES_TEMPLATE_LIST"
|
||||
required="true"
|
||||
multiple="true">
|
||||
<form>
|
||||
<field
|
||||
name="templatename"
|
||||
type="text"
|
||||
label="PLG_BUTTON_QUANTUMMANAGERBUTTON_CONFIG_SCOPES_TEMPLATE_NAME"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="templatebefore"
|
||||
type="textarea"
|
||||
label="PLG_BUTTON_QUANTUMMANAGERBUTTON_CONFIG_SCOPES_TEMPLATE_BEFORE"
|
||||
rows="10"
|
||||
cols="10"
|
||||
filter="raw"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="template"
|
||||
type="textarea"
|
||||
label="PLG_BUTTON_QUANTUMMANAGERBUTTON_CONFIG_SCOPES_TEMPLATE_ITEM"
|
||||
rows="10"
|
||||
cols="10"
|
||||
filter="raw"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="templateafter"
|
||||
type="textarea"
|
||||
label="PLG_BUTTON_QUANTUMMANAGERBUTTON_CONFIG_SCOPES_TEMPLATE_AFTER"
|
||||
rows="10"
|
||||
cols="10"
|
||||
filter="raw"
|
||||
/>
|
||||
</form>
|
||||
</field>
|
||||
|
||||
</form>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="customscopes"
|
||||
type="subform"
|
||||
label="PLG_BUTTON_QUANTUMMANAGERBUTTON_CONFIG_SCOPES_CUSTOM"
|
||||
multiple="true"
|
||||
>
|
||||
<form>
|
||||
<field
|
||||
name="titleLabel"
|
||||
type="text"
|
||||
default=""
|
||||
label="PLG_BUTTON_QUANTUMMANAGERBUTTON_CONFIG_SCOPES_TITLE"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="id"
|
||||
type="text"
|
||||
default=""
|
||||
label="PLG_BUTTON_QUANTUMMANAGERBUTTON_CONFIG_SCOPES_ID"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="title"
|
||||
type="text"
|
||||
default=""
|
||||
label="PLG_BUTTON_QUANTUMMANAGERBUTTON_CONFIG_SCOPES_TITLE"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="fieldsform"
|
||||
type="subform"
|
||||
label="PLG_BUTTON_QUANTUMMANAGERBUTTON_CONFIG_SCOPES_FIELDSFORM"
|
||||
required="true"
|
||||
multiple="true">
|
||||
<form>
|
||||
<field
|
||||
name="nametemplate"
|
||||
type="text"
|
||||
label="PLG_BUTTON_QUANTUMMANAGERBUTTON_CONFIG_SCOPES_FIELDSFORM_NAMETEMPLATE"
|
||||
/>
|
||||
<field
|
||||
name="name"
|
||||
type="text"
|
||||
label="PLG_BUTTON_QUANTUMMANAGERBUTTON_CONFIG_SCOPES_FIELDSFORM_NAME"
|
||||
/>
|
||||
<field
|
||||
name="default"
|
||||
type="text"
|
||||
label="PLG_BUTTON_QUANTUMMANAGERBUTTON_CONFIG_SCOPES_FIELDSFORM_DEFAULT"
|
||||
/>
|
||||
<field
|
||||
name="type"
|
||||
type="list"
|
||||
default="text"
|
||||
label="PLG_BUTTON_QUANTUMMANAGERBUTTON_CONFIG_SCOPES_FIELDSFORM_TYPE">
|
||||
<option value="text">Text</option>
|
||||
<option value="number">Number</option>
|
||||
<option value="list">List</option>
|
||||
<option value="color">Color</option>
|
||||
<option value="email">Email</option>
|
||||
<option value="url">Url</option>
|
||||
<option value="date">Date</option>
|
||||
<option value="time">Time</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="forlist"
|
||||
type="textarea"
|
||||
default=""
|
||||
label="PLG_BUTTON_QUANTUMMANAGERBUTTON_CONFIG_SCOPES_FIELDSFORM_FORLIST"
|
||||
showon="type:list"
|
||||
/>
|
||||
</form>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="templatelist"
|
||||
type="subform"
|
||||
label="PLG_BUTTON_QUANTUMMANAGERBUTTON_CONFIG_SCOPES_TEMPLATE_LIST"
|
||||
required="true"
|
||||
multiple="true">
|
||||
<form>
|
||||
<field
|
||||
name="templatename"
|
||||
type="text"
|
||||
label="PLG_BUTTON_QUANTUMMANAGERBUTTON_CONFIG_SCOPES_TEMPLATE_NAME"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="templatebefore"
|
||||
type="textarea"
|
||||
label="PLG_BUTTON_QUANTUMMANAGERBUTTON_CONFIG_SCOPES_TEMPLATE_BEFORE"
|
||||
rows="10"
|
||||
cols="10"
|
||||
filter="raw"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="template"
|
||||
type="textarea"
|
||||
label="PLG_BUTTON_QUANTUMMANAGERBUTTON_CONFIG_SCOPES_TEMPLATE_ITEM"
|
||||
rows="10"
|
||||
cols="10"
|
||||
filter="raw"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="templateafter"
|
||||
type="textarea"
|
||||
label="PLG_BUTTON_QUANTUMMANAGERBUTTON_CONFIG_SCOPES_TEMPLATE_AFTER"
|
||||
rows="10"
|
||||
cols="10"
|
||||
filter="raw"
|
||||
/>
|
||||
</form>
|
||||
</field>
|
||||
|
||||
</form>
|
||||
</field>
|
||||
</fieldset>
|
||||
</fields>
|
||||
</config>
|
||||
</extension>
|
||||
52
plugins/editors-xtd/quantummanagerbutton/script.php
Normal file
52
plugins/editors-xtd/quantummanagerbutton/script.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
/**
|
||||
* @package quantummanagercontent
|
||||
* @author Dmitry Tsymbal <cymbal@delo-design.ru>
|
||||
* @copyright Copyright © 2019 Delo Design & NorrNext. All rights reserved.
|
||||
* @license GNU General Public License version 3 or later; see license.txt
|
||||
* @link https://www.norrnext.com
|
||||
*/
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Installer\InstallerAdapter;
|
||||
|
||||
class plgEditorsXTDQuantummanagerbuttonInstallerScript
|
||||
{
|
||||
/**
|
||||
* Runs right after any installation action.
|
||||
*
|
||||
* @param string $type Type of PostFlight action. Possible values are:
|
||||
* @param InstallerAdapter $parent Parent object calling object.
|
||||
*
|
||||
* @since 1.1.0
|
||||
*/
|
||||
function postflight($type, $parent)
|
||||
{
|
||||
// Enable plugin
|
||||
if ($type == 'install')
|
||||
{
|
||||
$this->enablePlugin($parent);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable plugin after installation.
|
||||
*
|
||||
* @param InstallerAdapter $parent Parent object calling object.
|
||||
*
|
||||
* @since 1.1.0
|
||||
*/
|
||||
protected function enablePlugin($parent)
|
||||
{
|
||||
// Prepare plugin object
|
||||
$plugin = new stdClass();
|
||||
$plugin->type = 'plugin';
|
||||
$plugin->element = $parent->getElement();
|
||||
$plugin->folder = (string) $parent->getParent()->manifest->attributes()['group'];
|
||||
$plugin->enabled = 1;
|
||||
|
||||
// Update record
|
||||
Factory::getDbo()->updateObject('#__extensions', $plugin, array('type', 'element', 'folder'));
|
||||
}
|
||||
}
|
||||
191
plugins/editors-xtd/quantummanagerbutton/tmpl/default.php
Normal file
191
plugins/editors-xtd/quantummanagerbutton/tmpl/default.php
Normal file
@@ -0,0 +1,191 @@
|
||||
<?php
|
||||
/**
|
||||
* @package quantummanager
|
||||
* @author Dmitry Tsymbal <cymbal@delo-design.ru>
|
||||
* @copyright Copyright © 2019 Delo Design & NorrNext. All rights reserved.
|
||||
* @license GNU General Public License version 3 or later; see license.txt
|
||||
* @link https://www.norrnext.com
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\HTML\HTMLHelper;
|
||||
use Joomla\CMS\Language\Text;
|
||||
|
||||
$app = Factory::getApplication();
|
||||
$folder = $app->input->get('folder', '', 'string');
|
||||
$app->getSession()->clear('quantummanageraddscripts');
|
||||
|
||||
if(!empty($folder))
|
||||
{
|
||||
$app->getSession()->set('quantummanagerroot', 'images/' . $folder);
|
||||
}
|
||||
else
|
||||
{
|
||||
$app->getSession()->clear('quantummanagerroot');
|
||||
}
|
||||
|
||||
HTMLHelper::_('stylesheet', 'com_quantummanager/modal.css', [
|
||||
'version' => filemtime(__FILE__),
|
||||
'relative' => true
|
||||
]);
|
||||
|
||||
HTMLHelper::_('stylesheet', 'plg_button_quantummanagerbutton/modal.css', [
|
||||
'version' => filemtime(__FILE__),
|
||||
'relative' => true
|
||||
]);
|
||||
|
||||
HTMLHelper::_('jquery.framework');
|
||||
|
||||
HTMLHelper::_('script', 'com_quantummanager/sortable.min.js', [
|
||||
'version' => filemtime(__FILE__),
|
||||
'relative' => true
|
||||
]);
|
||||
|
||||
HTMLHelper::_('script', 'plg_button_quantummanagerbutton/modal.js', [
|
||||
'version' => filemtime(__FILE__),
|
||||
'relative' => true
|
||||
]);
|
||||
|
||||
?>
|
||||
|
||||
<?php
|
||||
|
||||
JLoader::register('JFormFieldQuantumCombine', JPATH_ROOT . '/administrator/components/com_quantummanager/fields/quantumcombine.php');
|
||||
JLoader::register('QuantummanagerHelper', JPATH_SITE . '/administrator/components/com_quantummanager/helpers/quantummanager.php');
|
||||
JLoader::register('QuantummanagerbuttonHelper', JPATH_ROOT . '/plugins/editors-xtd/quantummanagerbutton/helper.php');
|
||||
|
||||
QuantummanagerbuttonHelper::loadLang();
|
||||
$fieldsForContentPlugin = QuantummanagerbuttonHelper::getFieldsForScopes();
|
||||
$templatelistForContentPlugin = QuantummanagerbuttonHelper::getTemplateListForScopes();
|
||||
$groups = Factory::getUser()->groups;
|
||||
|
||||
try {
|
||||
|
||||
$folderRoot = 'root';
|
||||
|
||||
$buttonsBun = [];
|
||||
$fields = [
|
||||
'quantumtreecatalogs' => [
|
||||
'label' => '',
|
||||
'directory' => $folderRoot,
|
||||
'position' => 'container-left',
|
||||
],
|
||||
'quantumtoolbar' => [
|
||||
'label' => '',
|
||||
'position' => 'container-center-top',
|
||||
'buttons' => 'all',
|
||||
'buttonsBun' => '',
|
||||
'cssClass' => 'qm-padding-small-left qm-padding-small-right qm-padding-small-top qm-padding-small-bottom',
|
||||
],
|
||||
'quantumupload' => [
|
||||
'label' => '',
|
||||
'position' => 'container-center-top',
|
||||
'maxsize' => QuantummanagerHelper::getParamsComponentValue('maxsize', '10'),
|
||||
'dropAreaHidden' => QuantummanagerHelper::getParamsComponentValue('dropareahidden', '0'),
|
||||
'directory' => $folderRoot,
|
||||
'cssClass' => 'qm-padding-small-left qm-padding-small-right qm-padding-small-bottom',
|
||||
],
|
||||
'quantumviewfiles' => [
|
||||
'label' => '',
|
||||
'position' => 'container-center-center',
|
||||
'directory' => $folderRoot,
|
||||
'view' => 'list-grid',
|
||||
'onlyfiles' => '0',
|
||||
'watermark' => QuantummanagerHelper::getParamsComponentValue('overlay' , 0) > 0 ? '1' : '0',
|
||||
'help' => QuantummanagerHelper::getParamsComponentValue('help' , '1'),
|
||||
'metafile' => QuantummanagerHelper::getParamsComponentValue('metafile' , '1'),
|
||||
],
|
||||
'quantumcropperjs' => [
|
||||
'label' => '',
|
||||
'position' => 'bottom'
|
||||
],
|
||||
];
|
||||
|
||||
/*
|
||||
if((int)QuantummanagerHelper::getParamsComponentValue('unsplash', '1'))
|
||||
{
|
||||
$fields['quantumunsplash'] = [
|
||||
'position' => 'bottom'
|
||||
];
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
if ((int) QuantummanagerHelper::getParamsComponentValue('pexels', '1'))
|
||||
{
|
||||
$fields['quantumpexels'] = [
|
||||
'label' => '',
|
||||
'position' => 'bottom'
|
||||
];
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
if((int)QuantummanagerHelper::getParamsComponentValue('pixabay', '1'))
|
||||
{
|
||||
$fields['quantumpixabay'] = [
|
||||
'position' => 'bottom'
|
||||
];
|
||||
}
|
||||
*/
|
||||
|
||||
$actions = QuantummanagerHelper::getActions();
|
||||
if (!$actions->get('core.create'))
|
||||
{
|
||||
$buttonsBun[] = 'viewfilesCreateDirectory';
|
||||
unset($fields['quantumupload']);
|
||||
}
|
||||
|
||||
if (!$actions->get('core.delete'))
|
||||
{
|
||||
unset($fields['quantumcropperjs']);
|
||||
}
|
||||
|
||||
if (!$actions->get('core.delete'))
|
||||
{
|
||||
$buttonsBun[] = 'viewfilesDelete';
|
||||
}
|
||||
|
||||
$optionsForField = [
|
||||
'name' => 'filemanager',
|
||||
'label' => '',
|
||||
'fields' => json_encode($fields)
|
||||
];
|
||||
|
||||
$field = new JFormFieldQuantumCombine();
|
||||
foreach ($optionsForField as $name => $value)
|
||||
{
|
||||
$field->__set($name, $value);
|
||||
}
|
||||
echo $field->getInput();
|
||||
}
|
||||
catch (Exception $e) {
|
||||
echo $e->getMessage();
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
window.QuantumButtonPlugin = {
|
||||
templatelist: '<?php echo QuantummanagerHelper::escapeJsonString(json_encode($templatelistForContentPlugin)) ?>',
|
||||
fields: '<?php echo QuantummanagerHelper::escapeJsonString(json_encode($fieldsForContentPlugin)) ?>'
|
||||
};
|
||||
|
||||
window.QuantumwindowLang = {
|
||||
'buttonInsert': '<?php echo Text::_('COM_QUANTUMMANAGER_WINDOW_INSERT'); ?>',
|
||||
'inputAlt': '<?php echo Text::_('COM_QUANTUMMANAGER_WINDOW_ALT'); ?>',
|
||||
'inputWidth': '<?php echo Text::_('COM_QUANTUMMANAGER_WINDOW_WIDTH'); ?>',
|
||||
'defaultScope': '<?php echo Text::_('PLG_BUTTON_QUANTUMMANAGERBUTTON_SCOPES_NAME_DEFAULT'); ?>',
|
||||
'defaultName': '<?php echo Text::_('PLG_BUTTON_QUANTUMMANAGERBUTTON_SCOPES_DOCS_FIELDSFORM_NAME_NAME'); ?>',
|
||||
'defaultNameValue': '<?php echo Text::_('PLG_BUTTON_QUANTUMMANAGERBUTTON_SCOPES_IMAGES_FIELDSFORM_DEFAULT_NAME'); ?>',
|
||||
'insertFile': '<?php echo Text::_('PLG_BUTTON_QUANTUMMANAGERBUTTON_INSERT_FILE'); ?>',
|
||||
'helpSettings': '<?php echo in_array('2', $groups) || in_array('8', $groups) ? Text::sprintf('PLG_BUTTON_QUANTUMMANAGERBUTTON_HELP_SETTINGS', 'index.php?' . http_build_query(['option' => 'com_plugins', 'view' => 'plugins', (QuantummanagerHelper::isJoomla4() ? 'filter[search]' : 'filter.search') => Text::_('PLG_BUTTON_QUANTUMMANAGERBUTTON')])) : '' ?>',
|
||||
};
|
||||
</script>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user