Permalink
Browse files

Added Joomla 2.5 support.

Added diagnostic parameter
Added description and styled the back end a bit.
  • Loading branch information...
1 parent f99edcd commit 864d4a1d23feb7bc6ff35411d2a7b8b25fb44b7d @betweenbrain committed Oct 26, 2012
Showing with 92 additions and 18 deletions.
  1. +3 −7 README.md
  2. +10 −6 hideitems.php
  3. +79 −5 hideitems.xml
View
10 README.md
@@ -1,8 +1,8 @@
An experimental plugin that removes list items from your page buffer before they are rendered by the browser. No more is the day of hidden Joomla menus!!!
- To use:
+To use:
- Define a series of lists, consisting of when to fire the plugin and what to remove. List syntax is:
+Define a series of lists, consisting of when to fire the plugin and what to remove. List syntax is:
X:class1,class2,class3;
X2:class4,class5,class6;
@@ -17,10 +17,6 @@ The lists can be on different lines in the textarea, and the last list does not
TIP: Use 0: to designate a set of classes to remove from all pages.
-Tricky, eh?
-
-Oh yeah, it only works with Joomla 1.5 at the moment.
-
-Credits:
+Works with both Joomla 1.5 and 2.5.
Uber crafty regex based on that of http://www.sitepoint.com/forums/showthread.php?655366-Regex-to-replace-li-tags-with-asterisk&s=8b5d43a72a5fe9afff45553861d61a86&p=4481896&viewfull=1#post4481896
View
16 hideitems.php
@@ -21,22 +21,26 @@ function onAfterRender()
return;
}
- $buffer = JResponse::getBody();
- $itemId = JRequest::getInt('Itemid', 0);
-
- $itemlists = $this->params->get('itemlists');
- $lists = explode(';', rtrim($itemlists,';'));
+ $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(':', '', (strstr($list, ':')))));
+ $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;
View
84 hideitems.xml
@@ -3,16 +3,90 @@
<name>System - Hide Items</name>
<author>Matt Thomas</author>
<creationDate>October, 21st 2012</creationDate>
- <copyright>(C) 2012 Matt Thomas. All rights reserved.</copyright>
- <license>GNU/GPL</license>
+ <copyright>Copyright (C) 2012 Matt Thomas. All rights reserved.</copyright>
+ <license>GNU GPL v3 or later</license>
<authorEmail>matt@betweenbrain.com</authorEmail>
- <authorUrl>www.betweenbrain.com</authorUrl>
+ <authorUrl>http://betweenbrain.com</authorUrl>
<version>0.1</version>
- <description></description>
+ <description><![CDATA[
+ <style type="text/css">
+ .panel {background: #ddd;
+ background-image: -moz-linear-gradient(100% 100% 90deg, rgba(225,225,225,1), rgba(255,255,255,1));
+ background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(rgba(255,255,255,1)), to(rgba(225,225,225,1)));
+ filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffff', endColorstr='#dddddd');
+ -moz-border-radius: 2px 12px 2px 2px;
+ -webkit-border-radius: 2px 12px 2px 2px;
+ border-radius: 2px 12px 2px 2px;
+ -moz-box-shadow: 1px 1px 2px #ddd;
+ -webkit-box-shadow: 1px 1px 2px #ddd;
+ border-box-shadow: 1px 1px 2px #ddd;
+ border: 1px solid #ccc;
+ padding: 6px 10px;
+ color: #444;
+ text-decoration: none;}
+ table.admintable td.paramlist_key {font-weight:normal;text-transform:uppercase;text-align:left;}
+ table.admintable td.paramlist_value label {text-transform:none;}
+ table.admintable td.key, table.admintable td.paramlist_key,.pane-sliders .content,.pane-sliders .panel h3, div.panel fieldset {background:none;}
+ div.panel fieldset {margin-bottom:0;padding-bottom:0;}
+ table.admintable td.key, table.admintable td.paramlist_key {border:none;}
+ </style>
+ <h1>No more hidden menus!!!</h1>
+ <p><em>Hide Items</em> is an experimental plugin that removes list items from your page buffer before they are rendered by the browser.</p>
+ <p>To use, define a series of lists, consisting of when to fire the plugin and what to remove. List syntax is:</p>
+ <pre><code>
+ X:class1,class2,class3;
+ X2:class4,class5,class6;
+ X3:parent,hidden,secret
+ </code></pre>
+ <p>Where X is the context menu item (i.e. being viewed) when to fire the plugin, and <code>class</code> is the class of the menu item to remove from the page.</p>
+ <ul>
+ <li>Be sure that the context menu item is followed by a colon.</li>
+ <li>Make sure that each list ends with a semi-colon.</li>
+ <li>The lists can be on different lines in the textarea, and the last list does not need to end with a semi-colon.</li>
+ </ul>
+ <p>TIP: Use 0: to designate a set of classes to remove from all pages.</p>
+ <p style="clear:left">&copy; 2012 Matt Thomas, a.k.a. <a href="http://betweenbrain.com/">betweenbrain</a></p>
+ <p>For support, visit <a href="https://github.com/betweenbrain/hideitems/issues" target="_blank">https://github.com/betweenbrain/hideitems</a></p>
+ ]]></description>
<files>
<filename plugin="hideitems">hideitems.php</filename>
</files>
<params>
- <param name="itemlists" type="textarea" default="0:foo,bar;1:item0,baz" label="Item Lists" description="A series of lists, consisting of when to fire the plugin and what to remove. List syntax is X:class1,class2,class3;X2:class4,class5,class6;X3:class1,class3,class5 where X is the menu item, when being viewed, to fire the plguin, and class is the class of the menu item to remove from the page. Be sure that the menu item being viewed is followed by a colon, and each list ends with a semi-colon. The lists can be on different lines in the textarea, and the last list does not need to end with a semi-colon. TIP: Use 0: to deginate a set of classes to remove from all pages." rows="10" cols="50" />
+ <param name="diagnostics"
+ type="radio"
+ default="0"
+ label="Enable Diagnostics"
+ description="When enabled, will prepend the buffer with the menu item being viewed in the front-end.">
+ <option value="0">No</option>
+ <option value="1">Yes</option>
+ </param>
+ <param name="itemlists"
+ type="textarea"
+ default="0:foo,bar;1:item0,baz"
+ label="Item Lists"
+ description="A series of lists, consisting of when to fire the plugin and what to remove. List syntax is X:class1,class2,class3;X2:class4,class5,class6;X3:class1,class3,class5 where X is the menu item, when being viewed, to fire the plguin, and class is the class of the menu item to remove from the page. Be sure that the menu item being viewed is followed by a colon, and each list ends with a semi-colon. The lists can be on different lines in the textarea, and the last list does not need to end with a semi-colon. TIP: Use 0: to deginate a set of classes to remove from all pages."
+ rows="10"
+ cols="50"/>
</params>
+ <config>
+ <fields name="params">
+ <fieldset name="basic">
+ <field name="diagnostics"
+ type="radio"
+ default="0"
+ label="Enable Diagnostics"
+ description="When enabled, will prepend the buffer with the menu item being viewed in the front-end.">
+ <option value="0">JNo</option>
+ <option value="1">JYes</option>
+ </field>
+ <field name="itemlists"
+ type="textarea"
+ default="0:foo,bar;1:item0,baz"
+ label="Item Lists"
+ description="A series of lists, consisting of when to fire the plugin and what to remove. List syntax is X:class1,class2,class3;X2:class4,class5,class6;X3:class1,class3,class5 where X is the menu item, when being viewed, to fire the plguin, and class is the class of the menu item to remove from the page. Be sure that the menu item being viewed is followed by a colon, and each list ends with a semi-colon. The lists can be on different lines in the textarea, and the last list does not need to end with a semi-colon. TIP: Use 0: to deginate a set of classes to remove from all pages."
+ rows="10"
+ cols="50"/>
+ </fieldset>
+ </fields>
+ </config>
</install>

0 comments on commit 864d4a1

Please sign in to comment.