Source for file module.php

Documentation is available at module.php

  1. <?php
  2. /**
  3.  * @package     Joomla.Platform
  4.  * @subpackage  Document
  5.  *
  6.  * @copyright   Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
  7.  * @license     GNU General Public License version 2 or later; see LICENSE
  8.  */
  9.  
  10. defined('JPATH_PLATFORM'or die;
  11.  
  12. /**
  13.  * JDocument Module renderer
  14.  *
  15.  * @package     Joomla.Platform
  16.  * @subpackage  Document
  17.  * @since       11.1
  18.  */
  19. {
  20.     /**
  21.      * Renders a module script and returns the results as a string
  22.      *
  23.      * @param   string  $module   The name of the module to render
  24.      * @param   array   $attribs  Associative array of values
  25.      * @param   string  $content  If present, module information from the buffer will be used
  26.      *
  27.      * @return  string  The output of the script
  28.      *
  29.      * @since   11.1
  30.      */
  31.     public function render($module$attribs array()$content null)
  32.     {
  33.         if (!is_object($module))
  34.         {
  35.             $title = isset($attribs['title']$attribs['title'null;
  36.  
  37.             $module JModuleHelper::getModule($module$title);
  38.  
  39.             if (!is_object($module))
  40.             {
  41.                 if (is_null($content))
  42.                 {
  43.                     return '';
  44.                 }
  45.                 else
  46.                 {
  47.                     /**
  48.                      * If module isn't found in the database but data has been pushed in the buffer
  49.                      * we want to render it
  50.                      */
  51.                     $tmp $module;
  52.                     $module new stdClass;
  53.                     $module->params null;
  54.                     $module->module $tmp;
  55.                     $module->id 0;
  56.                     $module->user 0;
  57.                 }
  58.             }
  59.         }
  60.  
  61.         // Get the user and configuration object
  62.         // $user = JFactory::getUser();
  63.         $conf JFactory::getConfig();
  64.  
  65.         // Set the module content
  66.         if (!is_null($content))
  67.         {
  68.             $module->content $content;
  69.         }
  70.  
  71.         // Get module parameters
  72.         $params new JRegistry;
  73.         $params->loadString($module->params);
  74.  
  75.         // Use parameters from template
  76.         if (isset($attribs['params']))
  77.         {
  78.             $template_params new JRegistry;
  79.             $template_params->loadString(html_entity_decode($attribs['params']ENT_COMPAT'UTF-8'));
  80.             $params->merge($template_params);
  81.             $module clone $module;
  82.             $module->params = (string) $params;
  83.         }
  84.  
  85.         // Default for compatibility purposes. Set cachemode parameter or use JModuleHelper::moduleCache from within the
  86.         // module instead
  87.         $cachemode $params->get('cachemode''oldstatic');
  88.  
  89.         if ($params->get('cache'0== && $conf->get('caching'>= && $cachemode != 'id' && $cachemode != 'safeuri')
  90.         {
  91.  
  92.             // Default to itemid creating method and workarounds on
  93.             $cacheparams new stdClass;
  94.             $cacheparams->cachemode $cachemode;
  95.             $cacheparams->class 'JModuleHelper';
  96.             $cacheparams->method 'renderModule';
  97.             $cacheparams->methodparams array($module$attribs);
  98.  
  99.             $contents JModuleHelper::ModuleCache($module$params$cacheparams);
  100.  
  101.         }
  102.         else
  103.         {
  104.             $contents JModuleHelper::renderModule($module$attribs);
  105.         }
  106.  
  107.         return $contents;
  108.     }
  109. }

Documentation generated on Tue, 19 Nov 2013 15:08:38 +0100 by phpDocumentor 1.4.3