From aa39dc28821c9eb85f5e0944311d3da5162aa591 Mon Sep 17 00:00:00 2001 From: Deepa Gawade Date: Tue, 26 Jul 2022 17:32:18 +0530 Subject: [PATCH 1/2] Bug #181411 fix: BE>Field>After select category of field UI not well joomla 4 --- administrator/models/fields/fieldcategory.php | 276 +++++++++++------- administrator/models/forms/field.xml | 2 +- administrator/views/field/tmpl/edit_bs5.php | 81 +++-- 3 files changed, 212 insertions(+), 147 deletions(-) diff --git a/administrator/models/fields/fieldcategory.php b/administrator/models/fields/fieldcategory.php index 8666ae0c..9d25fe75 100644 --- a/administrator/models/fields/fieldcategory.php +++ b/administrator/models/fields/fieldcategory.php @@ -13,135 +13,205 @@ use Joomla\CMS\Form\FormField; use Joomla\CMS\Factory; use Joomla\CMS\HTML\HTMLHelper; - -jimport('joomla.form.formfield'); +use Joomla\CMS\Language\Text; +use Joomla\CMS\Layout\LayoutHelper; +use Joomla\CMS\Form\Field\ListField; /** * Class for custom gateway element * * @since 1.0.0 */ -class JFormFieldFieldcategory extends JFormField +if (JVERSION < '4.0') { - protected $type = 'Fieldcategory'; - - protected $name = 'Fieldcategory'; - - /** - * Function to genarate html of custom element - * - * @return HTML - * - * @since 1.0.0 - */ - public function getInput() + class JFormFieldFieldcategory extends FormField { - $this->value = $this->getSelectedCategories(); - $controlName = (isset($this->options['control'])) ? $this->options['control'] : ''; + protected $type = 'Fieldcategory'; + + protected $name = 'Fieldcategory'; + + /** + * Function to genarate html of custom element + * + * @return HTML + * + * @since 1.0.0 + */ + public function getInput() + { + $this->value = $this->getSelectedCategories(); + $controlName = (isset($this->options['control'])) ? $this->options['control'] : ''; - return $this->fetchElement($this->name, $this->value, $this->element, $controlName); - } + return $this->fetchElement($this->name, $this->value, $this->element, $controlName); + } - /** - * Function to fetch a tooltip - * - * @param string $name name of field - * @param string $value value of field - * @param string &$node node of field - * @param string $control_name control_name of field - * - * @return HTML - * - * @since 1.0.0 - */ - public function fetchElement($name, $value, &$node, $control_name) - { - $jinput = Factory::getApplication()->input; - $id = $jinput->get('id', '', 'int'); - $clientStr = $jinput->get("client"); - $ClientDetail = explode('.', $clientStr); - $client = $ClientDetail[0]; - $options = array(); + /** + * Function to fetch a tooltip + * + * @param string $name name of field + * @param string $value value of field + * @param string &$node node of field + * @param string $control_name control_name of field + * + * @return HTML + * + * @since 1.0.0 + */ + public function fetchElement($name, $value, &$node, $control_name) + { + $jinput = Factory::getApplication()->input; + $id = $jinput->get('id', '', 'int'); + $clientStr = $jinput->get("client"); + $ClientDetail = explode('.', $clientStr); + $client = $ClientDetail[0]; + $options = array(); + + // Fetch only published category. Static public function options($extension, $config = array('filter.published' => array(0,1))) + $categories = HTMLHelper::_('category.options', $client, array('filter.published' => array(1))); + $category_list = array_merge($options, $categories); + + foreach ($category_list as $category) + { + $options[] = HTMLHelper::_('select.option', $category->value, $category->text); + } - /*$options[] = HTMLHelper::_('select.option', '', JText::_('COM_TJFIELDS_FORM_SELECT_CLIENT_CATEGORY'));*/ + $fieldName = $name; + $disabled = ''; - // Fetch only published category. Static public function options($extension, $config = array('filter.published' => array(0,1))) - $categories = HTMLHelper::_('category.options', $client, array('filter.published' => array(1))); - $category_list = array_merge($options, $categories); + if (!empty($id)) + { + $disabled = 'disabled="true"'; + } - $options = array(); + $class = (JVERSION < '4.0.0') ? '' : 'form-select'; + $html = HTMLHelper::_('select.genericlist', $options, $fieldName, + 'class="inputbox ' . $class . '" multiple="multiple" size="5" ' . $disabled, 'value', 'text', $value, $control_name . $name + ); - foreach ($category_list as $category) - { - $options[] = HTMLHelper::_('select.option', $category->value, $category->text); + return $html; } - if (JVERSION >= 1.6) - { - $fieldName = $name; - } - else + /** + * Function to fetch a tooltip + * + * @param string $label label of field + * @param string $description description of field + * @param string &$node node of field + * @param string $control_name control_name of field + * @param string $name name of field + * + * @return HTML + * + * @since 1.0.0 + */ + public function fetchTooltip($label, $description, &$node, $control_name, $name) { - $fieldName = $control_name . '[' . $name . ']'; + return null; } - $disabled = ''; - - if (!empty($id)) + /** + * Fetch category list for field + * + * @return category array + * + * @since 1.0.0 + */ + public function getSelectedCategories() { - $disabled = 'disabled="true"'; + $catList = array(); + $jinput = Factory::getApplication()->input; + $fieldId = $jinput->get("id"); + + if (!empty($fieldId)) + { + $db = Factory::getDBO(); + $query = $db->getQuery(true) + ->select('category_id') + ->from($db->quoteName('#__tjfields_category_mapping')) + ->where('field_id=' . $fieldId); + $db->setQuery($query); + + return $db->loadColumn(); + } } - - $class = (JVERSION < '4.0.0') ? '' : 'form-select'; - - $html = HTMLHelper::_('select.genericlist', $options, $fieldName, - 'class="inputbox ' . $class . '" multiple="multiple" size="5" ' . $disabled, 'value', 'text', $value, $control_name . $name - ); - - return $html; } - - /** - * Function to fetch a tooltip - * - * @param string $label label of field - * @param string $description description of field - * @param string &$node node of field - * @param string $control_name control_name of field - * @param string $name name of field - * - * @return HTML - * - * @since 1.0.0 - */ - public function fetchTooltip($label, $description, &$node, $control_name, $name) +} +else +{ + class JFormFieldFieldcategory extends ListField { - return null; - } + /** + * Function to genarate html of custom element + * + * @return HTML + * + * @since 2.0.1 + */ + public function getInput() + { + $this->value = $this->getSelectedCategories(); + $controlName = (isset($this->options['control'])) ? $this->options['control'] : ''; + $html = parent::getInput(); - /** - * Fetch category list for field - * - * @return category array - * - * @since 1.0.0 - */ - public function getSelectedCategories() - { - $catList = array(); - $jinput = Factory::getApplication()->input; - $fieldId = $jinput->get("id"); + return $html; + } + + /** + * Function to fetch a tooltip + * + * @param string $name name of field + * @param string $value value of field + * @param string &$node node of field + * @param string $control_name control_name of field + * + * @return HTML + * + * @since 2.0.1 + */ + public function getOptions() + { + $jinput = Factory::getApplication()->input; + $clientStr = $jinput->get("client"); + $ClientDetail = explode('.', $clientStr); + $client = $ClientDetail[0]; + $options = array(); + + // Fetch only published category. Static public function options($extension, $config = array('filter.published' => array(0,1))) + $categories = HTMLHelper::_('category.options', $client, array('filter.published' => array(1))); + $category_list = array_merge($options, $categories); + + foreach ($category_list as $category) + { + $options[] = HTMLHelper::_('select.option', $category->value, $category->text); + } + + return $options; + } - if (!empty($fieldId)) + /** + * Fetch category list for field + * + * @return category list array + * + * @since 2.0.1 + */ + public function getSelectedCategories() { - $db = Factory::getDBO(); - $query = $db->getQuery(true) - ->select('category_id') - ->from($db->quoteName('#__tjfields_category_mapping')) - ->where('field_id=' . $fieldId); - $db->setQuery($query); - - return $db->loadColumn(); + $catList = array(); + $fieldId = Factory::getApplication()->input->get("id"); + + if (!empty($fieldId)) + { + $db = Factory::getDBO(); + $query = $db->getQuery(true) + ->select('category_id') + ->from($db->quoteName('#__tjfields_category_mapping')) + ->where('field_id=' . $fieldId); + $db->setQuery($query); + $catList = $db->loadColumn(); + } + + return $catList; } } } diff --git a/administrator/models/forms/field.xml b/administrator/models/forms/field.xml index dda20010..362c54aa 100755 --- a/administrator/models/forms/field.xml +++ b/administrator/models/forms/field.xml @@ -31,7 +31,7 @@ - + diff --git a/administrator/views/field/tmpl/edit_bs5.php b/administrator/views/field/tmpl/edit_bs5.php index 96e30f94..54bd586f 100644 --- a/administrator/views/field/tmpl/edit_bs5.php +++ b/administrator/views/field/tmpl/edit_bs5.php @@ -6,30 +6,31 @@ * @copyright Copyright (c) 2009-2016 TechJoomla. All rights reserved. * @license GNU General Public License version 2 or later. */ -// no direct access + +// No direct access defined('_JEXEC') or die; + use Joomla\CMS\HTML\HTMLHelper; use Joomla\CMS\Factory; use Joomla\CMS\Router\Route; use Joomla\CMS\Uri\Uri; use Joomla\CMS\Language\Text; -JHtml::addIncludePath(JPATH_COMPONENT . '/helpers/html'); +HTMLHelper::addIncludePath(JPATH_COMPONENT . '/helpers/html'); HTMLHelper::_('bootstrap.tooltip'); HTMLHelper::_('behavior.formvalidator'); HTMLHelper::_('behavior.keepalive'); -$input = Factory::getApplication()->input; +$input = Factory::getApplication()->input; $fullClient = $input->get('client', '', 'STRING'); $fullClient = explode('.', $fullClient); - -$client = $fullClient[0]; +$client = $fullClient[0]; $clientType = $fullClient[1]; - -$link = Route::_('index.php?option=com_tjfields&view=field&layout=edit&id=0&client=' . $input->get('client', '', 'STRING'), false); +$link = Route::_('index.php?option=com_tjfields&view=field&layout=edit&id=0&client=' . $input->get('client', '', 'STRING'), false); // Import helper for declaring language constant JLoader::import('TjfieldsHelper', Uri::root() . 'administrator/components/com_tjfields/helpers/tjfields.php'); + // Call helper function TjfieldsHelper::getLanguageConstant(); @@ -56,9 +57,7 @@
- +
form->getLabel('id'); ?>
@@ -70,10 +69,10 @@
form->getInput('label'); ?>
  - - - - + + + +
@@ -87,7 +86,16 @@ { ?>
- +

- +

@@ -133,9 +139,7 @@
- +
form->getLabel('group_id'); ?>
@@ -163,9 +167,7 @@
form->getLabel('category') ; ?>
-
- form->getInput('category');?> -
+
form->getInput('category');?>
  @@ -173,12 +175,10 @@
form->getLabel('filterable'); ?>
-
- form->getInput('filterable'); ?> -
+
form->getInput('filterable'); ?>
  - +
@@ -187,9 +187,7 @@
form->getLabel('js_function'); ?>
-
- form->getInput('js_function'); ?> -
+
form->getInput('js_function'); ?>
form->getLabel('validation_class'); ?>
@@ -203,21 +201,18 @@
-
- - authorise('core.admin','com_tjfields')) : ?> - - form->getInput('rules'); ?> - - - + authorise('core.admin','com_tjfields')) : + echo HTMLHelper::_('bootstrap.addTab', 'myTab', 'permissions', Text::_('JGLOBAL_ACTION_PERMISSIONS_LABEL', true)); + echo $this->form->getInput('rules'); + echo HTMLHelper::_('bootstrap.endTab'); + endif; + echo HTMLHelper::_('bootstrap.endTabSet'); ?>
- -
- - + From 461c745bf67ef6bf265d5a1acdac05155a8b9edc Mon Sep 17 00:00:00 2001 From: Deepa Gawade Date: Tue, 26 Jul 2022 19:26:07 +0530 Subject: [PATCH 2/2] Bug #181408 fix: BE> Field> After select Field Type dropdown get save then field should be disabled joomla 4 --- administrator/models/fields/jsfunction.php | 15 +- administrator/models/forms/field.xml | 188 +++++++++++++++++--- administrator/views/field/tmpl/edit_bs5.php | 2 +- 3 files changed, 172 insertions(+), 33 deletions(-) diff --git a/administrator/models/fields/jsfunction.php b/administrator/models/fields/jsfunction.php index d01103d3..5c8737ae 100644 --- a/administrator/models/fields/jsfunction.php +++ b/administrator/models/fields/jsfunction.php @@ -25,18 +25,16 @@ class JFormFieldJsfunction extends FormField function __construct () { parent::__construct(); - $this->countoption=0; - $this->tjfield_icon_plus = "icon-plus-2 "; + $this->countoption = 0; + $this->tjfield_icon_plus = "icon-plus-2 "; $this->tjfield_icon_minus = "icon-minus-2 "; } protected function getInput() { - $jsarray = explode('||', $this->value); - //now we get array[0] = onclick-getfunction() - //remove the blank array element + $jsarray = explode('||', $this->value); $jsarray_removed_blank_element = array_filter($jsarray); - $countjs = empty($this->value) ? 0 : count($this->value); + $countjs = empty($this->value) ? 0 : count($this->value); if(empty($this->value)) $countjs = 0; @@ -123,19 +121,18 @@ protected function getInput() function fetchJsfunction($fieldName, $value, &$node, $control_name,$j) { - return $Jsfunction = ''; + return $Jsfunction = ''; } function fetchJsfunctionName($fieldName, $value, &$node, $control_name,$j) { - return $JsfunctionName = ''; + return $JsfunctionName = ''; } } ?>