Skip to content

Commit

Permalink
Merge pull request #2 from Didldu-Florian/master
Browse files Browse the repository at this point in the history
Version 1-2-0-0
  • Loading branch information
HRIT-Florian authored Oct 3, 2016
2 parents c3a7e6a + 5319acd commit 31f56c4
Show file tree
Hide file tree
Showing 5 changed files with 103 additions and 13 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ It´s possible to disable mailto function for each article, but not globally by
Here that Disable MailTo Plugin helps. It allows the activation and deactivation of the component by plugin settins. <br>
By default, com_mailto will be disabled. Just need to install Disable MailTo, it´s all, simple and effective. <br>

This Plugin is like a switch to fire enable/disable com_mailto just on plugin save. So, it´s not realay a System Plugin, <br>
This plugin is like a switch to fire enable/disable com_mailto just on plugin save. So, it´s not realy a system plugin, <br>
it´s a way beetween to optimize page load performance and bring that feature. <br>
**Plugin must be enabled to trigger enable/disable events. To undo changes, just need to uninstall Plugin.** <br>
**Plugin must be enabled to trigger enable/disable events. To undo changes, just need to uninstall plugin.** <br>

# System requirements
Joomla 3.x + <br>
Expand Down
79 changes: 70 additions & 9 deletions dd_disable_mailto.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* @version 1-1-0-0 // Y-m-d 2016-10-01
* @version 1-2-0-0 // Y-m-d 2016-10-04
* @author Didldu e.K. Florian Häusler https://www.hr-it-solutions.com
* @copyright Copyright (C) 2011 - 2016 Didldu e.K. | HR IT-Solutions
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 only
Expand All @@ -22,24 +22,25 @@ class plgSystemDD_Disable_MailTo extends JPlugin
const NAME = 'dd_disable_mailto';

/**
* onUserAfterSave Events
* Construct Events
* @since Version 3.6.2
*/
function __construct( $subject )
{

parent::__construct($subject);

if (JFactory::getApplication()->isAdmin()){ // Trigger Events only in Backend
// Load plugin parameters
$this->plugin = JPluginHelper::getPlugin(self::TYPE, self::NAME);
$this->params = new JRegistry($this->plugin->params);

$input = JFactory::getApplication()->input;
$option = $input->get->get("option",0,"STR");
$app = JFactory::getApplication();

if($option === "com_plugins" ){ // And only on plugin page, to save performance
if ($app->isAdmin()){ // Trigger Events only in Backend

$option = $app->input->get->get("option",0,"STR");

// Load plugin parameters
$this->plugin = JPluginHelper::getPlugin(self::TYPE, self::NAME);
$this->params = new JRegistry($this->plugin->params);
if($option === "com_plugins" ){ // And only on plugin page, to save performance

$disable_mailTo = $this->params->get('disable_mailto',0);

Expand All @@ -52,7 +53,67 @@ function __construct( $subject )
}

}
}


/**
* onAfterRoute Event
* - redirectOldMailtoLinks
* @since Version 3.6.2
*/
public function onAfterRoute(){

// Redirect old mailTo otion
if ($this->params->get('redirect_mailto',0))
{
$this->redirectOldMailtoLinks(); // Redirect
}

}

/**
* onAfterRender Event
* - remveMailtoLink
* @since Version 3.6.2
*/
public function onAfterRender()
{
$app = JFactory::getApplication();
// Front end
if ($app instanceof JApplicationSite)
{

if ($this->params->get('remove_mailto_link',0)) // Remove mailTo link Option
{
$html = $app->getBody();
$html = $this->remveMailtoLink($html);
$app->setBody($html);
}

}
}


/**
* Remove bootstrap mailto list link (like protostar, etc...) method
* @return string without list elemenent email-icon
* @since Version 3.6.2
*/
private function remveMailtoLink($content)
{
return preg_replace('#<li class="email-icon">(.*?)</li>#', ' ', $content);
}

/**
* Redirect old mailto links to home by HTTP STATUS 301 method
* @return string without list elemenent email-icon
* @since Version 3.6.2
*/
private function redirectOldMailtoLinks()
{
if(strpos(JUri::current(), 'component/mailto') !== false){
JFactory::getApplication()->redirect(JURI::base(),301);
}
}

/**
Expand Down
20 changes: 19 additions & 1 deletion dd_disable_mailto.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<extension version="3.1" type="plugin" group="system" method="upgrade">
<name>PLG_SYSTEM_DD_DISABLE_MAILTO</name>
<version>1.1.0.0</version>
<version>1.2.0.0</version>
<creationDate>01.01.2016</creationDate>
<author>Didldu e.K. Florian Häusler</author>
<authorEmail>[email protected]</authorEmail>
Expand Down Expand Up @@ -34,6 +34,24 @@
<option value="1">JENABLED</option>
<option value="0">JDISABLED</option>
</field>
<field name="remove_mailto_link"
type="radio"
default="0"
label="PLG_SYSTEM_DD_DISABLE_MAILTO_FIELD_REMOVE_MAILTO_LINK_LABEL"
description="PLG_SYSTEM_DD_DISABLE_MAILTO_FIELD_REMOVE_MAILTO_LINK"
class="btn-group" >
<option value="1">JENABLED</option>
<option value="0">JDISABLED</option>
</field>
<field name="redirect_mailto"
type="radio"
default="0"
label="PLG_SYSTEM_DD_DISABLE_MAILTO_FIELD_REDIRECT_MAILTO_LABEL"
description="PLG_SYSTEM_DD_DISABLE_MAILTO_FIELD_REDIRECT_MAILTO"
class="btn-group" >
<option value="1">JENABLED</option>
<option value="0">JDISABLED</option>
</field>
</fieldset>
</fields>
</config>
Expand Down
7 changes: 7 additions & 0 deletions dd_disable_mailto_script.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
<?php
/**
* @version 1-1-0-0 // Y-m-d 2016-10-01
* @author Didldu e.K. Florian Häusler https://www.hr-it-solutions.com
* @copyright Copyright (C) 2011 - 2016 Didldu e.K. | HR IT-Solutions
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 only
**/

defined('_JEXEC') or die();

class plgSystemDD_Disable_MailToInstallerScript
Expand Down
6 changes: 5 additions & 1 deletion language/en-GB/en-GB.plg_system_dd_disable_mailto.sys.ini
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,8 @@
PLG_SYSTEM_DD_DISABLE_MAILTO="DD Disable Mailto"
PLG_SYSTEM_DD_DISABLE_MAILTO_XML_DESCRIPTION="System plugin to disable mailto function!<br>This removes also the "recommend to a friend link" and the "recommend to a friend form" from frontend.<br><br><b>Plugin must be enabled to trigger enable/disable events. To undo changes, just need to uninstall Plugin.</b>"
PLG_SYSTEM_DD_DISABLE_MAILTO_FIELD_DISABLE_MAILTO_LABEL="Mailto Component"
PLG_SYSTEM_DD_DISABLE_MAILTO_FIELD_DISABLE_MAILTO="This will enable/disable Joomla locked Mailto Component. Set disable to disable mailto function!"
PLG_SYSTEM_DD_DISABLE_MAILTO_FIELD_DISABLE_MAILTO="This will enable/disable Joomla locked Mailto Component. Set disable to disable mailto function!"
PLG_SYSTEM_DD_DISABLE_MAILTO_FIELD_REMOVE_MAILTO_LINK_LABEL="Remove mailto link from frontend <br><b>(experimental:</b> configured based on tpl protostar <b>) </b>"
PLG_SYSTEM_DD_DISABLE_MAILTO_FIELD_REMOVE_MAILTO_LINK="This will remove all bootstrap <li class'email-icon'><a href'... etc.. links from frontend."
PLG_SYSTEM_DD_DISABLE_MAILTO_FIELD_REDIRECT_MAILTO_LABEL="Redirect old mailto links to home"
PLG_SYSTEM_DD_DISABLE_MAILTO_FIELD_REDIRECT_MAILTO="SEO redirect by HTTP STATUS Code 301, moved permanently."

0 comments on commit 31f56c4

Please sign in to comment.