| 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/nimes/components/com_rsfeedback/helpers/ |
Upload File : |
<?php
/**
* @package RSFeedback!
* @copyright (C) 2010-2018 www.rsjoomla.com
* @license GPL, http://www.gnu.org/copyleft/gpl.html
*/
defined( '_JEXEC' ) or die( 'Restricted access' );
use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\Table\Table;
use Joomla\CMS\Factory;
class RSFeedbackRoute
{
public static function Category($cat_id, $tmpl = '') {
$Itemid = RSFeedbackHelper::getConfig('advanced_sef') ? self::getCategoryBestMatch($cat_id) : 0;
return 'index.php?option=com_rsfeedback&view=feedbacks&cat_id='.$cat_id.($Itemid ? "&Itemid=$Itemid" : '').(!empty($tmpl) ? '&tmpl='.$tmpl : '');
}
public static function Feedback($id, $tmpl = '') {
$Itemid = RSFeedbackHelper::getConfig('advanced_sef') ? self::getFeedbackBestMatch($id) : 0;
return 'index.php?option=com_rsfeedback&view=feedback&id='.$id.($Itemid ? "&Itemid=$Itemid" : '').(!empty($tmpl) ? '&tmpl='.$tmpl : '');
}
public static function DeleteFeedback($id, $cat_id, $tmpl = '') {
$id = (int) $id;
$cat_id = (int) $cat_id;
return 'index.php?option=com_rsfeedback&view=feedbacks&task=feedbacks.delete&id='.$id.($cat_id != 0 ? '&cat_id='.$cat_id : '').(!empty($tmpl) ? '&tmpl='.$tmpl : '');
}
public static function EditFeedback($id, $return = null, $tmpl = '') {
$id = (int) $id;
return 'index.php?option=com_rsfeedback&task=feedback.edit&id='.$id.(!empty($return) ? '&return='.$return : '').(!empty($tmpl) ? '&tmpl='.$tmpl : '');
}
public static function FlagFeedback($id, $return = null, $tmpl = '') {
$id = (int) $id;
return 'index.php?option=com_rsfeedback&view=feedback&layout=default_form_flag&id='.$id.(!empty($return) ? '&return='.$return : '').(!empty($tmpl) ? '&tmpl='.$tmpl : '');
}
protected static function getCategoryBestMatch($id) {
static $items;
if ($items === null) {
$items = array();
if ($menus = Factory::getApplication()->getMenu('site')) {
$component = ComponentHelper::getComponent('com_rsfeedback');
$attributes = array('component_id');
$values = array($component->id);
$items = $menus->getItems($attributes, $values);
}
}
if ($items) {
$matches = array(
'category' => false,
'multiple_categories' => false,
'all_categories' => false
);
foreach ($items as $item) {
if (isset($item->query) && is_array($item->query) && isset($item->query['view']) && $item->query['view'] == 'feedbacks') {
$ShowFromCategories = array_map('intval', $item->getParams()->get('ShowFromCategories', array()));
// Found best match - a menu item with the exact category
if (count($ShowFromCategories) == 1 && in_array($id, $ShowFromCategories)) {
$matches['category'] = $item->id;
continue;
}
// Found second best match - a menu item with the exact category selected in a list of categories
if (in_array($id, $ShowFromCategories)) {
$matches['multiple_categories'] = $item->id;
continue;
}
// Found l(e)ast possible match - a menu item with feedbacks from all categories
if (empty($ShowFromCategories)) {
$matches['all_categories'] = $item->id;
continue;
}
}
}
$matches = array_filter($matches);
if ($match = reset($matches)) {
return $match;
}
}
return 0;
}
protected static function getFeedbackBestMatch($id) {
static $items;
if ($items === null) {
$items = array();
if ($menus = Factory::getApplication()->getMenu('site')) {
$component = ComponentHelper::getComponent('com_rsfeedback');
$attributes = array('component_id');
$values = array($component->id);
$items = $menus->getItems($attributes, $values);
}
Table::addIncludePath(JPATH_ADMINISTRATOR.'/components/com_rsfeedback/tables');
}
if ($items) {
$feedback = Table::getInstance('feedback', 'RSFeedbackTable');
if (!$feedback->load($id)) {
return 0;
}
$matches = array(
'feedback' => false,
'category' => false,
'multiple_categories' => false,
'all_categories' => false
);
foreach ($items as $item) {
if (isset($item->query) && is_array($item->query) && isset($item->query['view']) && ($item->query['view'] == 'feedbacks' || $item->query['view'] == 'feedback')) {
// Found a menu item with the exact feedback setup
if ($item->query['view'] == 'feedback' && !isset($item->query['layout'])) {
$feedback_id = $item->getParams()->get('feedback_id', '0');
if ($feedback_id == $feedback->id) {
$matches['feedback'] = $item->id;
continue;
}
}
if ($item->query['view'] == 'feedbacks') {
$ShowFromCategories = array_map('intval', $item->getParams()->get('ShowFromCategories', array()));
// Found best match - a menu item with the exact category
if (count($ShowFromCategories) == 1 && in_array($feedback->cat_id, $ShowFromCategories)) {
$matches['category'] = $item->id;
continue;
}
// Found second best match - a menu item with the exact category selected in a list of categories
if (in_array($feedback->cat_id, $ShowFromCategories)) {
$matches['multiple_categories'] = $item->id;
continue;
}
// Found l(e)ast possible match - a menu item with feedbacks from all categories
if (empty($ShowFromCategories) || in_array(0, $ShowFromCategories)) {
$matches['all_categories'] = $item->id;
continue;
}
}
}
}
$matches = array_filter($matches);
if ($match = reset($matches)) {
return $match;
}
}
return 0;
}
}