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/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 = ''; } } ?>