| 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/views/item/ |
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;
use Joomla\CMS\MVC\View\HtmlView;
use Joomla\CMS\Factory;
use Joomla\CMS\Version;
use Joomla\CMS\Toolbar\ToolbarHelper;
use Joomla\CMS\Language\Text;
jimport('joomla.application.component.view');
class Djcatalog2ViewItem extends HtmlView {
protected $state;
protected $item;
protected $form;
protected $itemId;
protected $groupId;
public function display($tpl = null)
{
$layout = $this->getLayout();
if ($layout == 'extrafields') {
return $this->displayExtraFields($tpl);
}
$this->state = $this->get('State');
$this->item = $this->get('Item');
$this->form = $this->get('Form');
$this->cart_attributes = $this->get('CartAttributes');
$this->customisations = $this->get('Customisations');
$this->customisationsGroups = $this->get('CustomisationsGroups');
//$this->fields = $this->get('Fields');
// Check for errors.
if (count($errors = $this->get('Errors'))) {
throw new Joomla\CMS\MVC\View\GenericDataException(implode("\n", $errors), 500);
return false;
}
$db = Factory::getDbo();
$db->setQuery('SELECT * FROM #__djc2_customisations_groups');
$this->groups = $db->loadObjectList();
// $document = Factory::getDocument();
// Joomla\CMS\HTML\HTMLHelper::_('behavior.framework');
// Joomla\CMS\HTML\HTMLHelper::_('behavior.calendar');
// $document->addScript(JURI::root() . "administrator/components/com_djcatalog2/views/item/item.js");
// $document->addScript(JURI::root() . "components/com_djcatalog2/assets/nicEdit/nicEdit.js");
$version = new Version;
if (version_compare($version->getShortVersion(), '3.0.0', '<')) {
$tpl = 'legacy';
}
$this->addToolbar();
parent::display($tpl);
}
public function displayExtraFields($tpl = null) {
$app = Factory::getApplication();
$this->itemId = $app->input->getInt('itemId',0);
$this->groupId = $app->input->getInt('groupId',0);
$db = Factory::getDbo();
if ($this->groupId >= 0){
$query = $db->getQuery(true);
$query->select('f.*');
$query->from('#__djc2_items_extra_fields AS f');
$query->select('CASE '
.'WHEN (f.type=\'text\' OR f.type=\'textarea\' OR f.type=\'html\' OR f.type=\'media\') '
.'THEN vt.value '
.'WHEN (f.type=\'calendar\') '
.'THEN vd.value '
.'WHEN (f.type=\'checkbox\' OR f.type=\'select\' OR f.type=\'radio\') '
.'THEN GROUP_CONCAT(vi.value SEPARATOR \'|\')'
.'ELSE "" END AS field_value');
$query->join('LEFT','#__djc2_items_extra_fields_values_text AS vt ON f.id=vt.field_id AND vt.item_id='.(int)$this->itemId);
$query->join('LEFT','#__djc2_items_extra_fields_values_int AS vi ON f.id=vi.field_id AND vi.item_id='.(int)$this->itemId);
$query->join('LEFT','#__djc2_items_extra_fields_values_date AS vd ON f.id=vd.field_id AND vd.item_id='.(int)$this->itemId);
$query->where('f.group_id='.(int)$this->groupId.' OR f.group_id=0');
$query->group('f.id');
$query->order('f.group_id asc, f.ordering asc');
//echo str_replace('#_', 'jos', (string)$query);die();
$db->setQuery($query);
$this->fields = ($db->loadObjectList('id'));
if (count($this->fields)) {
$fieldIds = array_keys($this->fields);
$db->setQuery('SELECT * FROM #__djc2_items_extra_fields_options WHERE field_id IN ('.implode(',', $fieldIds).') ORDER BY field_id ASC, ordering ASC');
$optionList = $db->loadObjectList();
foreach($this->fields as $field_id => $field) {
foreach ($optionList as $optionRow) {
if ($optionRow->field_id == $field_id) {
if (empty($field->optionlist)) {
$this->fields[$field_id]->optionlist = array();
}
$this->fields[$field_id]->optionlist[] = $optionRow;
}
}
}
} else {
echo Text::_('COM_DJCATALOG2_NO_FIELDS_IN_GROUP');
return;
}
} else {
echo Text::_('COM_DJCATALOG2_CHOOSE_FIELDGROUP_FIRST');
return;
}
$version = new Version;
if (version_compare($version->getShortVersion(), '3.0.0', '<')) {
$tpl = 'legacy';
}
parent::display($tpl);
}
protected function addToolbar()
{
Factory::getApplication()->input->set('hidemainmenu', true);
$user = Factory::getUser();
$isNew = ($this->item->id == 0);
$text = $isNew ? Text::_( 'COM_DJCATALOG2_NEW' ) : Text::_( 'COM_DJCATALOG2_EDIT' );
ToolbarHelper::title( Text::_( 'COM_DJCATALOG2_ITEM' ).': <small><small>[ ' . $text.' ]</small></small>', 'generic.png' );
ToolbarHelper::apply('item.apply', 'JTOOLBAR_APPLY');
ToolbarHelper::save('item.save', 'JTOOLBAR_SAVE');
ToolbarHelper::custom('item.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false);
ToolbarHelper::custom('item.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false);
if (empty($this->item->id)) {
ToolbarHelper::cancel('item.cancel', 'JTOOLBAR_CANCEL');
}
else {
ToolbarHelper::cancel('item.cancel', 'JTOOLBAR_CLOSE');
}
}
}
?>