-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathhideitems.php
53 lines (40 loc) · 1.32 KB
/
hideitems.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
<?php defined('_JEXEC') or die;
/**
* File hideitems.php
* Created 10/21/12 3:57 PM
* Author Matt Thomas
* Website http://betweenbrain.com/
* Support https://github.com/betweenbrain/hideitems/issues
* Copyright Copyright (C) 2012 betweenbrain llc. All Rights Reserved.
* License GNU GPL v3 or later
*/
jimport('joomla.plugin.plugin');
class plgSystemHideitems extends JPlugin
{
function onAfterRender()
{
$app = JFactory::getApplication();
if ($app->isAdmin()) {
return;
}
$buffer = JResponse::getBody();
$diagnostics = $this->params->get('diagnostics');
$itemId = JRequest::getInt('Itemid', 0);
$itemlists = $this->params->get('itemlists');
$lists = explode(';', rtrim($itemlists, ';'));
foreach ($lists as $list) {
$targetid = strstr($list, ':', TRUE);
if (($targetid == '0') || ($targetid == $itemId)) {
$targetclasses = explode(',', (str_replace(':', '', rtrim(strstr($list, ':'), ','))));
foreach ($targetclasses as $targetclass) {
$buffer = preg_replace('/<li( id=\"(.*?)\")? class=\"([a-zA-Z0-9-_ ]*)?\b' . $targetclass . '\b([a-zA-Z0-9-_ ]*)?\"[^>]*>([\s\S]*?)<\/li>/i', '', $buffer);
}
}
}
if ($diagnostics == '1') {
$buffer = 'Current Item ID: ' . $itemId . $buffer;
}
JResponse::setBody($buffer);
return TRUE;
}
}