| 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/nice/administrator/components/com_djcatalog2/tables/ |
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
*
*/
// No direct access
defined('_JEXEC') or die;
use Joomla\CMS\Table\Table;
use Joomla\CMS\Factory;
use Joomla\Registry\Registry;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Application\ApplicationHelper;
use Joomla\CMS\Component\ComponentHelper;
class Djcatalog2TableItems extends Table
{
public function __construct(&$db)
{
parent::__construct('#__djc2_items', 'id', $db);
}
function bind($array, $ignore = '')
{
if (isset($array['params']) && is_array($array['params'])) {
$registry = new Registry();
$registry->loadArray($array['params']);
$array['params'] = (string)$registry;
}
if (isset($array['config_dimensions']) && is_array($array['config_dimensions'])) {
$registry = new Registry();
$registry->loadArray($array['config_dimensions']);
$array['config_dimensions'] = (string)$registry;
} else if (!isset($array['config_dimensions'])) {
$array['config_dimensions'] = '';
}
if (isset($array['config_dimensions_settings']) && is_array($array['config_dimensions_settings'])) {
$registry = new Registry();
$registry->loadArray($array['config_dimensions_settings']);
$array['config_dimensions_settings'] = (string)$registry;
} else if (!isset($array['config_dimensions_settings'])) {
$array['config_dimensions_settings'] = '';
}
if (isset($array['sections']) && is_array($array['sections'])) {
$registry = new Registry();
$registry->loadArray($array['sections']);
$array['sections'] = (string)$registry;
} else if (!isset($array['sections'])) {
$array['sections'] = '';
}
if (isset($array['location']) && is_array($array['location'])) {
foreach ($array['location'] as $k=>$v) {
$array[$k] = $v;
}
unset($array['location']);
}
if (isset($array['grant_usergroups']) && is_array($array['grant_usergroups'])) {
$registry = new Registry();
$registry->loadArray($array['grant_usergroups']);
$array['grant_usergroups'] = (string)$registry;
}
if(empty($array['alias'])) {
$array['alias'] = $array['name'];
}
$array['alias'] = ApplicationHelper::stringURLSafe($array['alias']);
if(trim(str_replace('-','',$array['alias'])) == '') {
$array['alias'] = Factory::getDate()->format('Y-m-d-H-i-s');
}
return parent::bind($array, $ignore);
}
/*
public function load($keys=null, $reset=true) {
if ($ret = parent::load($keys, $reset)) {
if (!isset($this->categories)){
$this->_db->setQuery('SELECT category_id FROM #__djc2_items_categories WHERE item_id=\''.$this->id.'\'');
$this->categories = $this->_db->loadResultArray();
}
return $ret;
} else {
return false;
}
}*/
public function store($updateNulls = false)
{
$date = Factory::getDate();
$user = Factory::getUser();
$app = Factory::getApplication();
$db = Factory::getDbo();
$this->modified = $date->toSql();
$params = ComponentHelper::getParams('com_djcatalog2');
if (!$this->created) {
$this->created = $date->toSql();
}
if (!$this->id) {
if (empty($this->created_by)) {
$this->created_by = $user->get('id');
}
} else {
$this->modified_by = $user->get('id');
}
$table = Table::getInstance('Items', 'Djcatalog2Table');
$task = $app->input->get('task');
if ($this->parent_id == 0) {
if ($app->isClient('site') || $task == 'import' || $task == 'save2copy') {
if ($table->load(array('alias'=>$this->alias)) && ($table->id != $this->id || $this->id==0)) {
$db->setQuery('select alias from #__djc2_items where id != '.$this->id.' and alias like '.$db->quote($db->escape($this->alias).'%').' order by alias asc');
$aliases = $db->loadColumn();
$suffix = 1;
while(in_array($this->alias.'-'.$suffix, $aliases)) {
$suffix++;
}
$this->alias = $this->alias.'-'.$suffix;
}
} else {
if ($params->get('seo_advanced', 0) == '1') {
if ($table->load(array('alias'=>$this->alias)) && ($table->id != $this->id || $this->id==0)) {
$this->setError(Text::_('COM_DJCATALOG2_ERROR_UNIQUE_ALIAS'));
return false;
}
} else {
if ($table->load(array('alias'=>$this->alias,'cat_id'=>$this->cat_id)) && ($table->id != $this->id || $this->id==0)) {
$this->setError(Text::_('COM_DJCATALOG2_ERROR_UNIQUE_ALIAS'));
return false;
}
}
}
}
if ($this->parent_id > 0) {
$loaded = $table->load(array('id'=>$this->parent_id));
if (!$loaded || (@$table->parent_id > 0)) {
$this->parent_id = 0;
}
if ($this->id > 0) {
$loaded = $table->load(array('parent_id'=>$this->id));
if ($loaded) {
$this->parent_id = 0;
}
if ($this->parent_id == $this->id) {
$this->parent_id = 0;
}
}
}
return parent::store($updateNulls);
}
}