| Server IP : 54.36.91.62 / Your IP : 216.73.217.112 Web Server : Apache System : Linux webm013.cluster127.gra.hosting.ovh.net 5.15.206-ovh-vps-grsec-zfs-classid #1 SMP Fri May 15 02:41:25 UTC 2026 x86_64 User : coopiak ( 151928) PHP Version : 8.3.23 Disable Function : _dyuweyrj4,_dyuweyrj4r,dl MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/coopiak/amisdesseniors-fr/administrator/components/com_djcatalog2/models/fields/ |
Upload File : |
<?php
/**
* @package DJ-Catalog2
* @copyright Copyright (C) DJ-Extensions.com, All rights reserved.
* @license http://www.gnu.org/licenses GNU/GPL
* @author url: http://dj-extensions.com
* @author email contact@dj-extensions.com
*/
defined('_JEXEC') or die();
defined('JPATH_BASE') or die;
use Joomla\CMS\Form\FormField;
use Joomla\CMS\Factory;
jimport('joomla.html.html');
jimport('joomla.form.formfield');
class JFormFieldDjcunit extends FormField {
protected $type = 'Djcunit';
protected function getInput()
{
// Initialize some field attributes.
$size = $this->element['size'] ? ' size="'.(int) $this->element['size'].'"' : '';
$maxLength = $this->element['maxlength'] ? ' maxlength="'.(int) $this->element['maxlength'].'"' : '';
$attr = '';
$class = $this->element['class'] ? (string) $this->element['class'] : '';
$class .= $this->element['required']=='true' ? ' required' : '';
$type = isset($this->element['unit_type']) ? $this->element['unit_type'] : false;
$attr .= 'class="'.$class.'"';
$name = $this->name;
if (isset($this->element['multiple']) && $this->element['multiple'] == 'true') {
$attr .= ' multiple="true" size="10"';
} else {
// such situations should not happen, but if they do (it's possible) we need to assign at least one group of fields
if (is_array($this->value)) {
$newValue = 0;
foreach ($this->value as $v) {
if ($v > 0) {
$newValue = $v;
break;
}
}
$this->value = $newValue;
}
}
$optionText = (!empty($this->element['option_text'])) ? trim((string)$this->element['option_text']) : 'concat';
$clause = 'CONCAT(name, " [", unit, "]") as text';
if ($optionText == 'name') {
$clause = 'name as text';
} else if ($optionText == 'unit') {
$clause = 'unit as text';
}
$db = Factory::getDbo();
$query = $db->getQuery(true);
$query->select('id AS value, '.$clause);
$query->from('#__djc2_units');
if ($type) {
if (strpos($type, ',')) {
$types = explode(',',$type);
$whereTypes = array();
foreach($types as $unittype) {
$whereTypes[] = 'unit_type='.$db->quote(trim((string)$unittype));
}
$query->where('('.implode(' OR ', $whereTypes).')');
} else {
$query->where('unit_type='.$db->quote(trim((string)$type)));
}
}
$query->order('is_default DESC, ordering ASC');
$db->setQuery($query);
$groups = $db->loadObjectList();
$options = array();
/*if (!isset($this->element['multiple']) || $this->element['multiple'] != 'true') {
$options[] = Joomla\CMS\HTML\HTMLHelper::_('select.option', '' , Text::_('COM_DJCATALOG2_LIST_PLEASE_SELECT'));
}*/
$selected = array();
foreach ($groups as $group) {
if ($group->value == $this->value) {
$selected[] =$group->text;
}
$options[] = Joomla\CMS\HTML\HTMLHelper::_('select.option', $group->value, $group->text);
}
$out = Joomla\CMS\HTML\HTMLHelper::_('select.genericlist', $options, $name, trim((string)$attr), 'value', 'text', $this->value, $this->id);
return ($out);
}
}
?>