Smart Shoutbox (The Krotek); no repo -> deployed files. Signed-off-by: LÁZÁR Imre <imre@illusion.hu> Assisted-by: claude-code@claude-opus-4-8
86 lines
1.9 KiB
PHP
86 lines
1.9 KiB
PHP
<?php
|
|
/*------------------------------------------------------------------------
|
|
# Smart Shoutbox
|
|
# ------------------------------------------------------------------------
|
|
# The Krotek
|
|
# Copyright (C) 2011-2018 The Krotek. All Rights Reserved.
|
|
# @license - http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
|
|
# Website: https://thekrotek.com
|
|
# Support: support@thekrotek.com
|
|
-------------------------------------------------------------------------*/
|
|
|
|
defined('_JEXEC') or die('Restricted access');
|
|
|
|
class SmartShoutboxRouter extends JComponentRouterBase
|
|
{
|
|
public function build(&$query)
|
|
{
|
|
static $items;
|
|
static $default;
|
|
static $chat;
|
|
|
|
$segments = array();
|
|
|
|
if (empty($items)) {
|
|
$items = $this->menu->getItems('component', 'com_smartshoutbox');
|
|
|
|
for ($i = 0, $n = count($items); $i < $n; $i++) {
|
|
$view = $items[$i]->query['view'];
|
|
|
|
if (empty($chat) && !empty($view) && ($view == 'chat')) {
|
|
$chat = $items[$i]->id;
|
|
}
|
|
}
|
|
|
|
if ($chat) $default = $chat;
|
|
}
|
|
|
|
if (!empty($query['view'])) {
|
|
switch ($query['view']) {
|
|
case 'chat':
|
|
if ($query['Itemid'] = $chat) unset($query['view']);
|
|
else $query['Itemid'] = $default;
|
|
break;
|
|
default:
|
|
if (!empty($query['view'])) $segments[] = $query['view'];
|
|
unset ($query['view']);
|
|
break;
|
|
}
|
|
}
|
|
|
|
for ($i = 0; $i < count($segments); $i++) {
|
|
$segments[$i] = str_replace(':', '-', $segments[$i]);
|
|
}
|
|
|
|
return $segments;
|
|
}
|
|
|
|
public function parse(&$segments)
|
|
{
|
|
$vars = array();
|
|
|
|
for ($i = 0; $i < count($segments); $i++) {
|
|
$segments[$i] = preg_replace('/-/', ':', $segments[$i], 1);
|
|
}
|
|
|
|
if (count($segments) < 1) return;
|
|
|
|
return $vars;
|
|
}
|
|
}
|
|
|
|
function SmartShoutboxBuildRoute(&$query)
|
|
{
|
|
$router = new SmartShoutboxRouter;
|
|
|
|
return $router->build($query);
|
|
}
|
|
|
|
function SmartShoutboxParseRoute($segments)
|
|
{
|
|
$router = new SmartShoutboxRouter;
|
|
|
|
return $router->parse($segments);
|
|
}
|
|
|
|
?>
|