primo commit
This commit is contained in:
		
							
								
								
									
										72
									
								
								plugins/system/conditionalcontent/src/Helper.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										72
									
								
								plugins/system/conditionalcontent/src/Helper.php
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,72 @@ | ||||
| <?php | ||||
| /** | ||||
|  * @package         Conditional Content | ||||
|  * @version         2.7.1 | ||||
|  *  | ||||
|  * @author          Peter van Westen <info@regularlabs.com> | ||||
|  * @link            http://www.regularlabs.com | ||||
|  * @copyright       Copyright © 2020 Regular Labs All Rights Reserved | ||||
|  * @license         http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL | ||||
|  */ | ||||
|  | ||||
| namespace RegularLabs\Plugin\System\ConditionalContent; | ||||
|  | ||||
| defined('_JEXEC') or die; | ||||
|  | ||||
| use Joomla\CMS\Factory as JFactory; | ||||
| use RegularLabs\Library\Article as RL_Article; | ||||
| use RegularLabs\Library\Document as RL_Document; | ||||
| use RegularLabs\Library\Html as RL_Html; | ||||
|  | ||||
| /** | ||||
|  * Plugin that replaces stuff | ||||
|  */ | ||||
| class Helper | ||||
| { | ||||
| 	public function onContentPrepare($context, &$article, &$params) | ||||
| 	{ | ||||
| 		$area    = isset($article->created_by) ? 'article' : 'other'; | ||||
| 		$context = (($params instanceof \JRegistry) && $params->get('rl_search')) ? 'com_search.' . $params->get('readmore_limit') : $context; | ||||
|  | ||||
| 		RL_Article::process($article, $context, $this, 'replaceTags', [$area, $context]); | ||||
| 	} | ||||
|  | ||||
| 	public function onAfterDispatch() | ||||
| 	{ | ||||
| 		if ( ! $buffer = RL_Document::getBuffer()) | ||||
| 		{ | ||||
| 			return; | ||||
| 		} | ||||
|  | ||||
| 		if ( ! Replace::replaceTags($buffer, 'component')) | ||||
| 		{ | ||||
| 			return; | ||||
| 		} | ||||
|  | ||||
| 		RL_Document::setBuffer($buffer); | ||||
| 	} | ||||
|  | ||||
| 	public function onAfterRender() | ||||
| 	{ | ||||
| 		$html = JFactory::getApplication()->getBody(); | ||||
|  | ||||
| 		if ($html == '') | ||||
| 		{ | ||||
| 			return; | ||||
| 		} | ||||
|  | ||||
| 		// only do stuff in body | ||||
| 		list($pre, $body, $post) = RL_Html::getBody($html); | ||||
| 		Replace::replaceTags($body, 'body'); | ||||
| 		$html = $pre . $body . $post; | ||||
|  | ||||
| 		Clean::cleanLeftoverJunk($html); | ||||
|  | ||||
| 		JFactory::getApplication()->setBody($html); | ||||
| 	} | ||||
|  | ||||
| 	public function replaceTags(&$string, $area = 'article', $context = '') | ||||
| 	{ | ||||
| 		Replace::replaceTags($string, $area, $context); | ||||
| 	} | ||||
| } | ||||
		Reference in New Issue
	
	Block a user