| Server IP : 54.36.91.62 / Your IP : 216.73.217.111 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/annonces/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 JLexReviewControllerReview extends JControllerLegacy
{
public function display($cachable = false, $urlparams = array())
{
$this->addModelPath ( JREVIEW_ADMIN . '/models', 'JLexReview' );
$model = $this->getModel ("rating");
$view = $this->getView("reviews", "html");
$view->setModel($model);
// add template path
JLexReviewHelperSite::loadThemes($view);
$view->display_form();
}
public function save()
{
$app = JFactory::getApplication();
$this->addModelPath ( JREVIEW_ADMIN . '/models', 'JLexReview' );
$config = JLexReviewHelperAdmin::getConfig();
$model = $this->getModel ('rating');
$return = $model->save();
$errorMsg = array();
$html = array();
if ($return===false)
{
$errors = $model->getErrors();
foreach ($errors as $error)
{
if ($error instanceof Exception)
{
$errorMsg[] = $error->getMessage();
} else {
$errorMsg[] = $error;
}
}
$html[]= '<script type="text/javascript">';
$html[]= 'window.parent.jlexreview.formErrors('. json_encode($errorMsg) .');';
$html[]= '</script>';
} else {
// find url based on review id
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select("item.url,item.object,item.object_id")
->from("#__jlexreview r")
->leftJoin("#__jlexreview_entry item ON item.id=r.entry_id")
->where("r.id=" . $return);
$item = $db->setQuery($query,0,1)->loadObject();
if ($config->def("link_type",0)=="1")
{
$up = JLexReviewHelperAdmin::getItemDetail($item->object, $item->object_id, '', $item->url);
$url = str_replace(JUri::root(true), '', $up->url);
} else {
$url = urldecode($item->url);
}
$url = trim($url, '/');
$url = preg_match("/^https?:\/\//", $url) ? $url : JUri::root() . $url;
$url.= (preg_match("/\?/", $url) ? "&" : "?") . "review_id=" . $return;
$html[]= '<script type="text/javascript">';
$html[]= 'window.parent.jlexreview.helper.redirect("'. urlencode($url) .'");';
if($config->get('review_alert',0)==1 && !preg_match('/^\s*$/', $config->get('review_alert_msg', '')))
{
$html[]='window.parent.alert("'.htmlspecialchars(jtext::_($config->get('review_alert_msg'))).'");';
}
$html[]= '</script>';
}
$app->close(implode(PHP_EOL, $html));
}
public function quick()
{
$app = JFactory::getApplication();
$this->addModelPath(JREVIEW_ADMIN . '/models', 'JLexReview');
$obj = $app->input->post->getCmd('obj', '');
$obj_id = $app->input->post->getInt('obj_id', 0);
$score = $app->input->post->get('score', 0, 'float');
$section_id = $app->input->post->get('section_id', 0);
$name = $app->input->getString('name', '');
$url = $app->input->getString('url', '');
if(!preg_match('/^\s*$/', $url))
{
$url = trim($url);
$url = str_replace(JUri::root(), '', $url);
}
if(!preg_match('/^[A-z0-9\_]+$/', $obj) || !preg_match('/^[1-9][0-9]*$/', $obj_id) || $score<0 || $section_id<0)
{
JLexReviewHelperAdmin::toJson([
'status' => 400,
'error' => 'Bad require!'
]);
}
$config = JLexReviewHelperAdmin::getConfig();
$model = $this->getModel('rating');
$return = $model->rating($obj, $obj_id, $score, $section_id, $name, $url);
if(!$return)
{
JLexReviewHelperAdmin::toJson([
'status' => 400,
'error' => $model->getError(),
'login' => $model->needLogin(),
'method' => [
'name' => $config->get('quick_rate_login', 'redirect'),
'value' => $config->get('quick_rate_login', 'redirect')=='redirect'?JRoute::_('index.php?option=com_users&view=login'):$config->get('quick_rate_login_js')
]
]);
}
// success
JLexReviewHelperAdmin::toJson([
'status' => 200,
'row' => $return,
'edit' => (int) $config->get("quick_rate_change",0)==1
]);
}
public function unvote()
{
$app = JFactory::getApplication();
$this->addModelPath(JREVIEW_ADMIN . '/models', 'JLexReview');
$obj = $app->input->post->getCmd('obj', '');
$obj_id = $app->input->post->getInt('obj_id', 0);
if(!preg_match('/^[A-z0-9\_]+$/', $obj) || !preg_match('/^[1-9][0-9]*$/', $obj_id))
{
JLexReviewHelperAdmin::toJson([
'status' => 400,
'error' => 'Bad require!'
]);
}
$model = $this->getModel('rating');
$return = $model->unvote($obj, $obj_id);
if(!$return)
{
JLexReviewHelperAdmin::toJson([
'status' => 400,
'error' => $model->getError()
]);
}
// success
JLexReviewHelperAdmin::toJson([
'status' => 200,
'row' => $return
]);
}
private function _cmd($cmd)
{
$app = JFactory::getApplication();
$id = $app->input->getInt("id", 0);
$model = $this->getModel( "review" );
$model->set("id", $id);
switch( $cmd )
{
case "state":
$return = $model->state();
break;
case "featured":
$return = $model->hl();
break;
case "remove":
$return = $model->remove();
break;
default:
return false;
}
if ($return===false)
{
$response = array(
"status" => 400,
"error" => $model->getError()
);
} else {
$response = array(
"status" => 200,
"data" => $return
);
}
JLexReviewHelperAdmin::toJson( $response );
}
public function state()
{
$this->_cmd( "state" );
}
public function featured()
{
$this->_cmd( "featured" );
}
public function remove()
{
$this->_cmd( "remove" );
}
}