Source for file base.php

Documentation is available at base.php

  1. <?php
  2. /**
  3.  * @package     Joomla.Libraries
  4.  * @subpackage  Layout
  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.txt
  8.  */
  9.  
  10. defined('JPATH_BASE'or die;
  11.  
  12. /**
  13.  * Base class for rendering a display layout
  14.  *
  15.  * @package     Joomla.Libraries
  16.  * @subpackage  Layout
  17.  * @see         http://docs.joomla.org/Sharing_layouts_across_views_or_extensions_with_JLayout
  18.  * @since       3.0
  19.  */
  20. class JLayoutBase implements JLayout
  21. {
  22.     /**
  23.      * Options object
  24.      *
  25.      * @var    JRegistry 
  26.      * @since  3.2
  27.      */
  28.     protected $options = null;
  29.  
  30.     /**
  31.      * Debug information messages
  32.      *
  33.      * @var    array 
  34.      * @since  3.2
  35.      */
  36.     protected $debugMessages = array();
  37.  
  38.     /**
  39.      * Set the options
  40.      *
  41.      * @param   mixed  $options  Array / JRegistry object with the options to load
  42.      *
  43.      * @return  JLayoutBase  Instance of $this to allow chaining.
  44.      *
  45.      * @since   3.2
  46.      */
  47.     public function setOptions($options null)
  48.     {
  49.         // Received JRegistry
  50.         if ($options instanceof JRegistry)
  51.         {
  52.             $this->options = $options;
  53.         }
  54.         // Received array
  55.         elseif (is_array($options))
  56.         {
  57.             $this->options = new JRegistry($options);
  58.         }
  59.         else
  60.         {
  61.             $this->options = new JRegistry;
  62.         }
  63.  
  64.         return $this;
  65.     }
  66.  
  67.     /**
  68.      * Get the options
  69.      *
  70.      * @return  JRegistry  Object with the options
  71.      *
  72.      * @since   3.2
  73.      */
  74.     public function getOptions()
  75.     {
  76.         // Always return a JRegistry instance
  77.         if (!($this->options instanceof JRegistry))
  78.         {
  79.             $this->resetOptions();
  80.         }
  81.  
  82.         return $this->options;
  83.     }
  84.  
  85.     /**
  86.      * Function to empty all the options
  87.      *
  88.      * @return  JLayoutBase  Instance of $this to allow chaining.
  89.      *
  90.      * @since   3.2
  91.      */
  92.     public function resetOptions()
  93.     {
  94.         return $this->setOptions(null);
  95.     }
  96.  
  97.     /**
  98.      * Method to escape output.
  99.      *
  100.      * @param   string  $output  The output to escape.
  101.      *
  102.      * @return  string  The escaped output.
  103.      *
  104.      * @since   3.0
  105.      */
  106.     public function escape($output)
  107.     {
  108.         return htmlspecialchars($outputENT_COMPAT'UTF-8');
  109.     }
  110.  
  111.     /**
  112.      * Get the debug messages array
  113.      *
  114.      * @return  array 
  115.      *
  116.      * @since   3.2
  117.      */
  118.     public function getDebugMessages()
  119.     {
  120.         return $this->debugMessages;
  121.     }
  122.  
  123.     /**
  124.      * Method to render the layout.
  125.      *
  126.      * @param   object  $displayData  Object which properties are used inside the layout file to build displayed output
  127.      *
  128.      * @return  string  The necessary HTML to display the layout
  129.      *
  130.      * @since   3.0
  131.      */
  132.     public function render($displayData)
  133.     {
  134.         return '';
  135.     }
  136.  
  137.     /**
  138.      * Render the list of debug messages
  139.      *
  140.      * @return  string  Output text/HTML code
  141.      *
  142.      * @since   3.2
  143.      */
  144.     public function renderDebugMessages()
  145.     {
  146.         return implode($this->debugMessages"\n");
  147.     }
  148.  
  149.     /**
  150.      * Add a debug message to the debug messages array
  151.      *
  152.      * @param   string  $message  Message to save
  153.      *
  154.      * @return  void 
  155.      *
  156.      * @since   3.2
  157.      */
  158.     public function addDebugMessage($message)
  159.     {
  160.         $this->debugMessages[$message;
  161.     }
  162. }

Documentation generated on Tue, 19 Nov 2013 14:54:24 +0100 by phpDocumentor 1.4.3