* @link http://www.nonumber.nl * @copyright Copyright (C) 2010 NoNumber! All Rights Reserved * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL */ // Ensure this file is being included by a parent file defined( '_JEXEC' ) or die( 'Restricted access' ); // Import library dependencies jimport( 'joomla.event.plugin' ); /** * Plugin that places Modules */ class plgSystemModulesAnywhereHelper { function init( &$params ) { $this->params = $this->getParamValues( $params ); $break_tags_start = '(?:
]*)?>\s*)?'; $break_tags_end = '(?:\s*
)?'; $tags = array(); $tags[] = preg_quote( $this->params->module_tag ); $tags[] = preg_quote( $this->params->modulepos_tag ); if ( $this->params->handle_loadposition ) { $tags[] = 'loadposition'; } $tags = '('.implode( '|', $tags ).')'; $this->params->regex = '#'.$break_tags_start.'\{'.$tags.'(?: ([^\}\|]*))?((?:\|[^\}]+)?)\}'.$break_tags_end.'#s'; $acl =& JFactory::getACL(); $this->params->acl = $acl->get_group_data( $this->params->articles_security_level ); $this->params->acl = $this->params->acl['4']; $this->params->acls = array(); $user =& JFactory::getUser(); $this->params->aid = $user->get( 'aid', 0 ); $this->params->aid_jaclplus = $user->get( 'jaclplus', 0 ); } //////////////////////////////////////////////////////////////////// // ARTICLES //////////////////////////////////////////////////////////////////// function replaceInArticles ( &$article ) { $message = ''; if ( isset( $article->created_by ) ) { // Lookup group level of creator if ( !isset( $this->params->acls[$article->created_by] ) ) { $acl =& JFactory::getACL(); $this->params->acls[$article->created_by] = $acl->getAroGroup( $article->created_by ); } $article_group = $this->params->acls[$article->created_by]; if ( !isset( $article_group->lft ) ) { $article_group->lft = 0; } // Set if security is passed // passed = creator is equal or higher than security group level if ( $this->params->acl > $article_group->lft ) { $message = JText::_( 'REMOVED, SECURITY' ); } } if ( isset( $article->text ) ) { $this->processModules( $article->text, 'articles', $message ); } if ( isset( $article->description ) ) { $this->processModules( $article->description, 'articles', $message ); } if ( isset( $article->title ) ) { $this->processModules( $article->title, 'articles', $message ); } if ( isset( $article->author ) ) { if ( isset( $article->author->name ) ) { $this->processModules( $article->author->name, 'articles', $message ); } else if ( is_string( $article->author ) ) { $this->processModules( $article->author, 'articles', $message ); } } } //////////////////////////////////////////////////////////////////// // COMPONENTS //////////////////////////////////////////////////////////////////// function replaceInComponents() { $document =& JFactory::getDocument(); $docType = $document->getType(); if ( $docType == 'feed' && isset( $document->items ) ) { for ( $i = 0; $i < count( $document->items ); $i++ ) { $this->replaceInArticles( $document->items[$i] ); } } if ( isset( $document->_buffer ) ) { $this->tagArea( $document->_buffer, 'component' ); } // PDF if ( $docType == 'pdf' ) { if ( isset( $document->_header ) ) { $this->replaceInTheRest( $document->_header ); $this->cleanLeftoverJunk( $document->_header ); } if ( isset( $document->title ) ) { $this->replaceInTheRest( $document->title ); $this->cleanLeftoverJunk( $document->title ); } if ( isset( $document->_buffer ) ) { $this->replaceInTheRest( $document->_buffer ); $this->cleanLeftoverJunk( $document->_buffer ); } } } //////////////////////////////////////////////////////////////////// // OTHER AREAS //////////////////////////////////////////////////////////////////// function replaceInOtherAreas() { $document =& JFactory::getDocument(); $docType = $document->getType(); // not in pdf's if ( $docType == 'pdf' ) { return; } $html = JResponse::getBody(); $this->protect( $html ); $this->replaceInTheRest( $html ); // only do the handling inside the body if ( !( strpos( $html, '' ) === false ) ) { $html_split = explode( '', $html_split['1'] ); // remove generated articles outside the body $this->removeGeneratedModules( $html_split['0'] ); $this->removeGeneratedModules( $body_split['1'] ); $html_split['1'] = implode( '', $body_split ); $html = implode( 'cleanLeftoverJunk( $html ); $this->unprotect( $html ); JResponse::setBody( $html ); } function replaceInTheRest( &$str, $docType = 'html' ) { if ( $str == '' ) { return; } $option = JRequest::getCmd( 'option' ); $document =& JFactory::getDocument(); $docType = $document->getType(); // COMPONENT if ( $docType == 'feed' ) { $search_regex = '#(