| Server IP : 54.36.91.62 / Your IP : 216.73.216.86 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_jlexreview/models/ |
Upload File : |
<?php
/**
* @package JLex Review
* @version 4.2.3
* @copyright Copyright (c) 2013-2018 JLexArt. All rights reserved
* @license GNU General Public License version 2 or later;
* @author www.jlexart.com
*/
defined('_JEXEC') or die;
class JLexReviewModelReplacer extends JModelLegacy
{
public $limitstart = 0;
public $limit = 20;
public $total = 0;
public $sort = "r.created DESC";
public function getReplacers()
{
$query = $this->_db->getQuery(true);
$query->select("SQL_CALC_FOUND_ROWS r.id,r.caption,r.created_by,r.created,r.published,u.name AS author")
->from("#__jlexreview_replacer AS r")
->leftJoin("#__users AS u ON r.created_by=u.id")
->order($this->sort);
$items = $this->_db->setQuery($query, $this->limitstart, $this->limit)->loadObjectList();
$this->total = (int) $this->_db->setQuery("SELECT FOUND_ROWS()" )->loadResult();
if(!$items) return null;
foreach($items as $k=>&$item)
{
$items[$k]->jprofile = JUri::base(true) . "/index.php?option=com_users&task=user.edit&id=" . $item->created_by;
$items[$k]->url2edit = JUri::base(true) . "/index.php?option=com_jlexreview&view=replacer&layout=form&id=" . $item->id;
$items[$k]->created = JHtml::date($item->created, $this->_db->getDateFormat());
}
return $items;
}
public function getPagaNav()
{
jimport("joomla.html.pagination");
return new JPagination($this->total, $this->limitstart, $this->limit);
}
public function getForm()
{
$path = dirname(__FILE__) . "/forms/replacer.xml";
$form = JForm::getInstance("jreview_replacer", $path, array('control' => 'jform'));
$form->addFieldPath(dirname(__FILE__) . "/fields");
return $form;
}
public function getItem($id)
{
if($id<1) return null;
$query = $this->_db->getQuery(true);
$query->select("*")
->from("#__jlexreview_replacer")
->where("id=" . $id);
$item = $this->_db->setQuery($query)->loadObject();
if($item) $item->params = json_decode($item->params);
return $item;
}
public function save()
{
$app = JFactory::getApplication();
$data = $app->getInput()->get("jform", null, "array");
$form = $this->getForm();
$form->bind($data);
$data = $form->filter($data);
$return = $form->validate($data);
if($return===false)
{
// Get the validation messages.
$errors = $form->getErrors();
foreach ($errors as $error)
{
if($error instanceof Exception)
{
$this->setError($error->getMessage());
} else {
$this->setError($error);
}
}
return false;
}
$row = $this->getTable("replacer", "TableJR");
if(array_key_exists("params", $data))
{
$data["params"] = json_encode($data["params"]);
} else {
$data["params"] = "";
}
$row->bind($data);
if(!$row->store(true))
{
$this->setError("An error appear while saving data. Try again later.");
return false;
}
return true;
}
public function cmd($task)
{
$app = JFactory::getApplication();
$cid = $app->getInput()->get("cid", null, "array");
if(empty($cid) || !count($cid))
{
$this->setError("No row select.");
return false;
}
$query = $this->_db->getQuery(true);
switch($task)
{
case "publish":
case "unpublish":
$query->clear()
->update("#__jlexreview_replacer")
->set("published=".($task=="publish"?1:0))
->where("id IN(".implode(",", $cid).")");
break;
case "remove":
$query->clear()
->delete("#__jlexreview_replacer")
->where("id IN(".implode(",", $cid).")");
break;
}
$this->_db->setQuery($query)->execute();
return true;
}
}