Skip to content

Commit

Permalink
upgrade to 3.x
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitriitux committed Jan 17, 2021
1 parent ba277db commit d0c38c2
Show file tree
Hide file tree
Showing 53 changed files with 927 additions and 9,040 deletions.
17 changes: 0 additions & 17 deletions elements/tmpl/upload.php

This file was deleted.

100 changes: 47 additions & 53 deletions fields/radicalmultifield.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@
*/

use Joomla\CMS\Filter\OutputFilter;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Factory;
use Joomla\CMS\Layout\LayoutHelper;

defined('_JEXEC') or die;

Expand All @@ -23,6 +25,7 @@
class JFormFieldRadicalmultifield extends JFormFieldSubform
{


/**
* @var string
*/
Expand All @@ -44,6 +47,7 @@ protected function getLayoutPaths()
];
}


/**
* @return string
*/
Expand All @@ -59,13 +63,13 @@ public function getInput()

$db = Factory::getDBO();
$query = $db->getQuery(true)
->select($db->quoteName(array('params', 'fieldparams')))
->select($db->quoteName(['name', 'params', 'fieldparams']))
->from('#__fields')
->where( 'name=' . $db->quote($this->fieldname));
$field = $db->setQuery( $query )->loadObject();

$query = $db->getQuery(true)
->select($db->quoteName(array('params')))
->select($db->quoteName(['params']))
->from('#__extensions')
->where( 'element=' . $db->quote('radicalmultifield'));
$extension = $db->setQuery( $query )->loadObject();
Expand All @@ -83,7 +87,8 @@ public function getInput()
//подзагружаем кастомные поля
JLoader::import('radicalmultifieldhelper', JPATH_ROOT . '/plugins/fields/radicalmultifield');

if(isset($params['extendfield']))

if(isset($params['extendfield']) && !empty($params['extendfield']))
{

$extendField = explode("\n", $params['extendfield']);
Expand All @@ -94,6 +99,7 @@ public function getInput()

}


foreach ($fieldparams['listtype'] as $fieldparam)
{
switch ($fieldparam['type'])
Expand All @@ -107,7 +113,7 @@ public function getInput()
$this->formsource .= "<field name=\"{$fieldparam['name']}\" type=\"{$fieldparam['listview']}\" label=\"{$fieldparam['title']}\"{$required}{$multiple}{$class} {$attrs}>";
$options = explode( "\n", $fieldparam['options'] );

foreach ( $options as $option )
foreach ($options as $option)
{
$value = OutputFilter::stringURLSafe( $option );
$this->formsource .= "<option value=\"{$value}\">{$option}</option>";
Expand All @@ -121,72 +127,60 @@ public function getInput()
$this->formsource .= "<field name=\"{$fieldparam['name']}\" type=\"{$fieldparam['type']}\" label=\"{$fieldparam['title']}\" filter=\"raw\" {$attrs}/>";
break;

case 'custom':
if(!empty($fieldparam['customxml']))
{
$this->formsource .= $fieldparam['customxml'];
}
break;

default:
$attrs = trim( $fieldparam['attrs'] );
$this->formsource .= "<field name=\"{$fieldparam['name']}\" type=\"{$fieldparam['type']}\" label=\"{$fieldparam['title']}\" {$attrs}/>";
}
}

$this->formsource .= "</form>";

$html = parent::getInput();


if(isset($fieldparams['filesimport']))
if(isset($fieldparams['filesimport']) && RadicalmultifieldHelper::checkQuantumManager())
{

if((int)$fieldparams['filesimport'])
{
$allow = true;

$app = Factory::getApplication();
$admin = $app->isAdmin();

if((int)$fieldparams['filesimportadmin'] && !$admin)
{
$allow = false;
}

if($allow)
{
$folder = $fieldparams['filesimportpath'];
JLoader::register(
'FormFieldRadicalmultifieldtreecatalog',
JPATH_ROOT . DIRECTORY_SEPARATOR . implode(DIRECTORY_SEPARATOR, ['plugins', 'fields', 'radicalmultifield', 'elements', 'radicalmultifieldtreecatalog']) . '.php'
);

$treeCatalog = new FormFieldRadicalmultifieldtreecatalog;

$paramsForField = [
'name' => 'select-directory',
'label' => Text::_('PLG_RADICAL_MULTI_FIELD_FIELD_IMPORT_TREECATALOG_TITLE'),
'class' => '',
'type' => 'radicalmultifieldtreecatalog',
'folder' => $folder,
'folderonly' => 'true',
'showroot' => 'true',
'exs' => $fieldparams['filesimportexc'],
'maxsize' => $fieldparams['filesimportmaxsize'],
'namefield' => $fieldparams['filesimportname'],
'namefile' => $fieldparams['filesimportnamefile'],
'importfield' => $this->fieldname,
];

$dataAttributes = array_map(function($value, $key)
{
return $key.'="'.$value.'"';
}, array_values($paramsForField), array_keys($paramsForField));

$treeCatalog->setup(new SimpleXMLElement("<field " . implode(' ', $dataAttributes) . " />"), '');
$html = "<div style='margin-bottom: 15px'>" . $treeCatalog->getInput() . "</div>" . $html;

}
HTMLHelper::stylesheet('plg_fields_radicalmultifield/import.css', [
'version' => filemtime ( __FILE__ ),
'relative' => true,
]);

HTMLHelper::script('plg_fields_radicalmultifield/buttons.js', [
'version' => filemtime ( __FILE__ ),
'relative' => true,
]);

HTMLHelper::script('plg_fields_radicalmultifield/import.js', [
'version' => filemtime ( __FILE__ ),
'relative' => true,
]);

$field_path = !empty($fieldparams['filesimportpath']) ? $fieldparams['filesimportpath'] : 'images';
$params_for_field = [
'namefield' => $fieldparams['filesimportname'],
'namefile' => $fieldparams['filesimportnamefile'],
];
$html =
"<div class='radicalmultifield-import' data-options='" . json_encode($params_for_field) . "'>" .
LayoutHelper::render('import', [
'field_name' => $field->name,
'field_path' => $field_path
], JPATH_ROOT . '/plugins/fields/radicalmultifield/layouts')
. $html .
"</div>";

}

}

return $html;
}


}
Loading

0 comments on commit d0c38c2

Please sign in to comment.