english/libraries/joomla/application/component/helper.php
/**
	 * Render the component.
	 *
	 * @param   string  $option  The component option.
	 * @param   array   $params  The component parameters
	 *
	 * @return  void
	 * @since   11.1
	 */
Render the component.
@param   string  $option  The component option.
@param   array   $params  The component parameters


Render the component . @param string $option The component option . @param array $params The component parameters
public static function renderComponent($option, $params = array())
	{
		$app	= JFactory::getApplication();
		$template	= $app->getTemplate(true)->template;
		$lang = JFactory::getLanguage();
			$lang->load('tpl_'.$template, JPATH_BASE, null, false, false)
		||	$lang->load('tpl_'.$template, JPATH_THEMES."/$template", null, false, false)
		||	$lang->load('tpl_'.$template, JPATH_BASE, $lang->getDefault(), false, false)
		||	$lang->load('tpl_'.$template, JPATH_THEMES."/$template", $lang->getDefault(), false, false);
		if (empty($option)) {
			JError::raiseError(404, JText::_('JLIB_APPLICATION_ERROR_COMPONENT_NOT_FOUND'));
			return;
		}
		$scope = $app->scope;
		$app->scope = $option;
		$option	= preg_replace('/[^A-Z0-9_\.-]/i', '', $option);
		$file	= substr($option, 4);
		define('JPATH_COMPONENT',				JPATH_BASE . '/components/' . $option);
		define('JPATH_COMPONENT_SITE',			JPATH_SITE . '/components/' . $option);
		define('JPATH_COMPONENT_ADMINISTRATOR',	JPATH_ADMINISTRATOR . '/components/' . $option);
		if ($app->isAdmin() && file_exists(JPATH_COMPONENT . '/admin.'.$file.'.php')) {
			$path = JPATH_COMPONENT . '/admin.'.$file.'.php';
		} else {
			$path = JPATH_COMPONENT . '/' . $file.'.php';
		}
		if (!self::isEnabled($option) || !file_exists($path)) {
			JError::raiseError(404, JText::_('JLIB_APPLICATION_ERROR_COMPONENT_NOT_FOUND'));
		}
		$task = JRequest::getString('task');
			$lang->load($option, JPATH_BASE, null, false, false)
		||	$lang->load($option, JPATH_COMPONENT, null, false, false)
		||	$lang->load($option, JPATH_BASE, $lang->getDefault(), false, false)
		||	$lang->load($option, JPATH_COMPONENT, $lang->getDefault(), false, false);
		$contents = null;
		ob_start();
		require_once $path;
		$contents = ob_get_contents();
		ob_end_clean();
		jimport('joomla.application.helper');
		if (($path = JApplicationHelper::getPath('toolbar')) && $app->isAdmin()) {
			$task = JRequest::getString('task');
			include_once $path;
		}
		$app->scope = $scope;
		return $contents;
	}
public static function renderComponent ( $ option , $ params = array ( ) ) { $ app = JFactory :: getApplication ( ) ; $ template = $ app -> getTemplate ( true ) -> template ; $ lang = JFactory :: getLanguage ( ) ; $ lang -> load ( 'tpl_' . $ template , JPATH_BASE , null , false , false ) || $ lang -> load ( 'tpl_' . $ template , JPATH_THEMES . " / $ template " , null , false , false ) || $ lang -> load ( 'tpl_' . $ template , JPATH_BASE , $ lang -> getDefault ( ) , false , false ) || $ lang -> load ( 'tpl_' . $ template , JPATH_THEMES . " / $ template " , $ lang -> getDefault ( ) , false , false ) ; if ( empty ( $ option ) ) { JError :: raiseError ( 404 , JText :: _ ( 'JLIB_APPLICATION_ERROR_COMPONENT_NOT_FOUND' ) ) ; return ; } $ scope = $ app -> scope ; $ app -> scope = $ option ; $ option = preg_replace ( '/[^A-Z0-9_\.-]/i' , '' , $ option ) ; $ file = substr ( $ option , 4 ) ; define ( 'JPATH_COMPONENT' , JPATH_BASE . '/components/' . $ option ) ; define ( 'JPATH_COMPONENT_SITE' , JPATH_SITE . '/components/' . $ option ) ; define ( 'JPATH_COMPONENT_ADMINISTRATOR' , JPATH_ADMINISTRATOR . '/components/' . $ option ) ; if ( $ app -> isAdmin ( ) && file_exists ( JPATH_COMPONENT . '/admin.' . $ file . '.php' ) ) { $ path = JPATH_COMPONENT . '/admin.' . $ file . '.php' ; } else { $ path = JPATH_COMPONENT . '/' . $ file . '.php' ; } if ( ! self :: isEnabled ( $ option ) || ! file_exists ( $ path ) ) { JError :: raiseError ( 404 , JText :: _ ( 'JLIB_APPLICATION_ERROR_COMPONENT_NOT_FOUND' ) ) ; } $ task = JRequest :: getString ( 'task' ) ; $ lang -> load ( $ option , JPATH_BASE , null , false , false ) || $ lang -> load ( $ option , JPATH_COMPONENT , null , false , false ) || $ lang -> load ( $ option , JPATH_BASE , $ lang -> getDefault ( ) , false , false ) || $ lang -> load ( $ option , JPATH_COMPONENT , $ lang -> getDefault ( ) , false , false ) ; $ contents = null ; ob_start ( ) ; require_once $ path ; $ contents = ob_get_contents ( ) ; ob_end_clean ( ) ; jimport ( 'joomla.application.helper' ) ; if ( ( $ path = JApplicationHelper :: getPath ( 'toolbar' ) ) && $ app -> isAdmin ( ) ) { $ task = JRequest :: getString ( 'task' ) ; include_once $ path ; } $ app -> scope = $ scope ; return $ contents ; }
Render the component.
Render the component .
// Initialise variables. // Load template language files. // Throw 404 if no component // Record the scope // Set scope to component name // Build the component path. // Define component path. // Get component path // If component is disabled throw error // Load common and local language files. // Handle template preview outlining. // Execute the component. // Build the component toolbar // Get the task again, in case it has changed // Make the toolbar // Revert the scope