| 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/nice2/administrator/components/com_jlexreview/controllers/ |
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 JLexReviewControllerSync extends JControllerLegacy
{
public function display($cachable = false, $urlparams = array())
{
$app = JFactory::getApplication();
$layout = $app->input->getCmd('layout', '');
$view = $this->getView('sync', 'html');
$model = $this->getModel('sync');
$view->setModel($model);
if($layout=='form')
{
$view->setLayout('form');
$form = $model->getForm();
$keep = $app->getUserState('jlexreview.sync');
if(empty($keep))
{
$id = $app->input->getInt('id', 0);
if($id>0)
{
$item = $model->getCallback($id);
if(!empty($item)) $form->bind($item);
}
} else {
$form->bind($keep);
$app->setUserState('jlexreview.sync', null);
}
$view->set('form', $form);
} else {
$view->set('items', $model->getCallbacks());
$view->set('pagination', $model->getPagination());
}
$view->display();
}
public function save()
{
$app = JFactory::getApplication();
$user = JFactory::getUser();
$errorMsg = array();
$model = $this->getModel("sync");
$return = $model->save();
if ($return===false)
{
$errors = $model->getErrors();
foreach ($errors as $error)
{
if ($error instanceof Exception)
{
$app->enqueueMessage($error->getMessage(), 'error');
} else {
$app->enqueueMessage($error, 'error');
}
}
// create cache variable
$data = array_key_exists("jform", $_POST) ? $_POST["jform"] : null;
$app->setUserState('jlexreview.sync', $data);
$this->setRedirect(JUri::base(true).'/index.php?option=com_jlexreview&view=sync&layout=form');
return;
}
$this->setRedirect( JUri::base(true).'/index.php?option=com_jlexreview&view=sync', jtext::_('JR_SYNC_ITEM_SAVED'));
}
public function cancel()
{
$this->setRedirect( JUri::base(true).'/index.php?option=com_jlexreview&view=sync' );
}
public function add()
{
$this->setRedirect( JUri::base(true).'/index.php?option=com_jlexreview&view=sync&layout=form' );
}
public function publish()
{
$this->listCmd('publish');
$this->setRedirect(JUri::base(true).'/index.php?option=com_jlexreview&view=sync', jtext::_('JR_ITEMS_PUBLISHED'));
}
public function unpublish()
{
$this->listCmd('unpublish');
$this->setRedirect(JUri::base(true).'/index.php?option=com_jlexreview&view=sync', jtext::_('JR_ITEMS_UNPUBLISHED'));
}
public function sync()
{
$app = JFactory::getApplication();
$offset = $app->input->getInt('offset', 0);
$model = $this->getModel('sync');
if($offset>0) $model->set('offset', $offset);
$result = $model->sync();
JLexReviewHelperAdmin::toJson($result);
}
protected function listCmd($action)
{
$app = JFactory::getApplication();
$cid = $app->input->get("cid",null,"array");
if(!$cid || !count($cid))
{
throw new Exception(jtext::_('JR_MAKE_SELECTION_FROM_THE_LIST'), 500);
}
$model = $this->getModel('sync');
$model->listCmd($action, $cid);
return true;
}
}