-
Notifications
You must be signed in to change notification settings - Fork 1
/
jlrouter.php
91 lines (78 loc) · 2.59 KB
/
jlrouter.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<?php
/**
* @package Joomlager Router
*
* @copyright Copyright (C) 2017 Hannes Papenberg. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
class PlgSystemJlrouter extends JPlugin
{
public function construct(&$subject, $config = array())
{
parent::__construct($subject, $config);
$app = JFactory::getApplication();
if ($app->isAdmin())
{
return true;
}
require_once dirname(__FILE__) . '/classes/site.php';
$router = $app->getRouter();
$menu = $app->getMenu();
if ($this->params->get('router_contact') || $this->params->get('router_content') || $this->params->get('router_newsfeed'))
{
require_once dirname(__FILE__) . '/classes/router/viewconfiguration.php';
require_once dirname(__FILE__) . '/classes/router/view.php';
require_once dirname(__FILE__) . '/classes/router/rules/interface.php';
require_once dirname(__FILE__) . '/classes/router/rules/menu.php';
require_once dirname(__FILE__) . '/classes/router/rules/nomenu.php';
require_once dirname(__FILE__) . '/classes/router/rules/standard.php';
}
if ($this->params->get('router_contact'))
{
require_once dirname(__FILE__) . '/classes/contactrouter.php';
$crouter = new ContactRouter($app, $menu);
$crouter->noIDs = $this->params->get('contact_noids');
$router->setComponentRouter('com_contact', $crouter);
}
if ($this->params->get('router_content'))
{
require_once dirname(__FILE__) . '/classes/contentrouter.php';
$crouter = new ContentRouter($app, $menu);
$crouter->noIDs = $this->params->get('content_noids');
$router->setComponentRouter('com_content', $crouter);
}
if ($this->params->get('router_newsfeed'))
{
require_once dirname(__FILE__) . '/classes/newsfeedrouter.php';
$crouter = new NewsfeedsRouter($app, $menu);
$crouter->noIDs = $this->params->get('newsfeed_noids');
$router->setComponentRouter('com_newsfeeds', $crouter);
}
if ($this->params->get('404handling') == '1')
{
$router->handling404 = array($this, 'modern404handling');
}
if ($this->params->get('404handling') == '2')
{
$router->handling404 = array($this, 'strict404handling');
}
}
public function modern404handling($router, $vars, $uri)
{
if (strlen($uri->getPath()) > 0)
{
if (isset($vars['option']) && is_a($router->getComponentRouter($vars['option']), 'JComponentRouterView'))
{
throw new Exception('URL invalid', 404);
}
}
}
public function strict404handling($router, $vars, $uri)
{
if (strlen($uri->getPath()) > 0)
{
throw new Exception('URL invalid', 404);
}
}
}