Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug #181411 fix: BE>Field>After select category of field UI not well joomla 4 #359

Open
wants to merge 2 commits into
base: j4x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
276 changes: 173 additions & 103 deletions administrator/models/fields/fieldcategory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}
15 changes: 6 additions & 9 deletions administrator/models/fields/jsfunction.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -123,19 +121,18 @@ protected function getInput()

function fetchJsfunction($fieldName, $value, &$node, $control_name,$j)
{
return $Jsfunction = '<input type="text" id="tjfields_jsoptions_'.$j.'" name="tjfieldsJs['.$j.'][jsoptions]" class="tjfields_jsoptions " placeholder="Events" value="'.$value.'">';
return $Jsfunction = '<input type="text" id="tjfields_jsoptions_'.$j.'" name="tjfieldsJs['.$j.'][jsoptions]" class="tjfields_jsoptions form-control" placeholder="Events" value="'.$value.'">';
}

function fetchJsfunctionName($fieldName, $value, &$node, $control_name,$j)
{
return $JsfunctionName = '<input type="text" id="tjfields_jsfunctionname_'.$j.'" name="tjfieldsJs['.$j.'][jsfunctionname]" class="tjfields_jsfunctionname " placeholder="Function name" value="'.$value.'">';
return $JsfunctionName = '<input type="text" id="tjfields_jsfunctionname_'.$j.'" name="tjfieldsJs['.$j.'][jsfunctionname]" class="tjfields_jsfunctionname form-control" placeholder="Function name" value="'.$value.'">';
}
}
?>
<script type="text/javascript">
function addClonejsOption(rId,rClass)
{
//window.js_lenght=f_lenght;
var pre=js_lenght;
js_lenght++;

Expand Down
Loading