Location: PHPKode > projects > Anahita Social Engine > dependencies/plg_system_socialengine/socialengine/util/document/html.php
<?php 
/**
 * @version		1.0.0
 * @category	Anahita Social Engine™
 * @copyright	Copyright (C) 2008 - 2010 rmdStudio Inc. and Peerglobe Technology Inc. All rights reserved.
 * @license		GNU GPLv2 <http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>
 * @link     	http://www.anahitapolis.com
 */

class AnUtilDocumentHtml extends JDocumentHTML
{	
		
	/**
	 * Count the modules based on the given condition
	 *
	 * @access public
	 * @param  string 	$condition	The condition to use
	 * @return integer  Number of modules found
	 */
	public function countModules($condition)
	{
			
		$result = '';
		if (strpos($condition,'component.') === 0) {			
			return $this->getBuffer('component',$condition);
		}
		
		$words = explode(' ', $condition);
		for($i = 0; $i < count($words); $i+=2)
		{
			// odd parts (modules)
			$name		= strtolower($words[$i]);
			$words[$i]	= 0;
			
			if(!isset($this->_buffer['modules'][$name])) 
			{
				$result  = $this->getBuffer('modules', $name);
				$words[$i] += !empty($result);
			}
		}
	
		$str = 'return '.implode(' ', $words).';';
		
		return eval($str);
	}
	
	
	
	/**
	 * Outputs the template to the browser.
	 *
	 * @access public
	 * @param boolean 	$cache		If true, cache the output
	 * @param array		$params		Associative array of attributes
	 * @return 	The rendered data
	 */
	public function render( $cache = false, array $params = array())
	{	
		$baseurl = JFactory::getURI()->base(true);
		unset($this->_scripts[$baseurl.'/media/system/js/mootools.js']);
		unset($this->_scripts[$baseurl.'/media/system/js/caption.js']);
		return parent::render($cache, $params);
	}
	
	
	public function addScript($url)
	{
		if ( strpos($url, 'system/js/mootools.js') ) 
			return;
		
		parent::addScript($url);
	}
	
	/**
	 * Get the contents of a document include
	 *
	 * @access public
	 * @param string 	$type	The type of renderer
	 * @param string 	$name	 The name of the element to render
	 * @param array   	$attribs Associative array of remaining attributes.
	 * @return 	The output of the renderer
	 */
	public function getBuffer($type = null, $name = null, array $attribs = array())
	{	
		
		if (strpos($name, 'component.') === 0) 
		{			
			$name = str_replace('component.','',$name);
			$type = 'component';
			
			if (isset($this->_buffer[$type][$name])) 
				$content =  $this->_buffer[$type][$name];
			else 
			{
				
				$component =& $this->_buffer['component'][null];
				$tag = $type.':'.$name;
				$matches  = array();
				$pattern  = "/<{$tag} ?([^>]+)?>(.*)<\/{$tag}>/siU";
				preg_match_all($pattern,$component,$matches);
				$count  = count($matches[0]);
				
				$buffer = array();
	
				for($i=0; $i < $count; $i++) {
					$attrs = $matches[1][$i];
					$buffer[$i] = $matches[2][$i];
					if (strpos($attrs,'style') > 0) {
						$buffer[$i] = "<div class=\"module an-se-module an-se-component\"><div><div><div>{$buffer[$i]}</div></div></div></div>";
					}
				}
				
				$component = str_replace($matches[0],'',$component);
				$this->_buffer[$type][$name] = implode('',$buffer);
				$content = $this->_buffer[$type][$name];
			}
			
			if (isset($attribs['style']) && $attribs['style'] == 'rounded') {
				return "<div class=\"module an-se-module an-se-component\"><div><div><div>$content</div></div></div></div>";
			}
			
			return $content;
		}
		
		return parent::getBuffer($type, $name, $attribs);
	}
	
	
//end class	
}
Return current item: Anahita Social Engine