File: /home/mmickelson/old.loveandlaughterpreschool.com/plugins/content/comascon.php
<?php
/**
* Author: Omar Mohammed
* Email: Knightofbaghdad@yahoo.com
* Mambot: Component as Content
* Version: 1.5.0
*/
// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );
$mainframe->registerEvent( 'onPrepareContent', 'plgContentcomascon' );
function plgContentcomascon( &$row, &$params, $page=0 ) {
// simple performance check to determine whether bot should process further
if ( strpos( $row->text, 'component' ) === false )
{return true;}
// define the regular expression for the bot
$regex = "#{component}(.*?){/component}#s";
// perform the replacement
$row->text = preg_replace_callback( $regex, 'botComponentCode_replacer', $row->text );
return true;
}
/**
* Replaces the matched tags
* @param array An array of matches (see preg_match_all)
* @return string
*/
function botComponentCode_replacer( &$matches ) {
global $database ;
$query = "SELECT params"
. "\n FROM #__mambots"
. "\n WHERE element = 'comascon'"
. "\n AND folder = 'content'"
;
$database=&JFactory::getDBO();
$database->setQuery( $query );
$plugin =& JPluginHelper::getPlugin('content', 'comascon');
$pluginParams = new JParameter( $plugin->params );
$height = $pluginParams->set( 'height', '500' );
$width = $pluginParams->def( 'width', '500' );
$scroll = $pluginParams->def( 'scroll', 'no' );
$parentopen = $pluginParams->def( 'parentopen', '0' );
if (strpos( $matches[1], '|' ) == true)
{
$userparams = explode('|',$matches[1]);
$matches[1] = $userparams[0];
$width = $userparams[1];
$height = $userparams[2];
}
$url = $matches[1];
$url = 'index2.php?' . $url;
$para = 'id="comascon" '.
'src="'.$url.'" '.
'width="'.$width.'" '.
'height="'.$height.'" '.
'frameborder="0" '.
'allowtransparency="true" '.
'scrolling="'.$scroll.'" ';
$url = "<!-- Component as Content starts here --><iframe ".$para." >\n".
"</iframe><!-- Component as Content ends here -->\n";
return $url;
}
?>