Source for file abstract.php

Documentation is available at abstract.php

  1. <?php
  2. /**
  3.  * @package     FrameworkOnFramework
  4.  * @subpackage  render
  5.  * @copyright   Copyright (C) 2010 - 2012 Akeeba Ltd. All rights reserved.
  6.  * @license     GNU General Public License version 2 or later; see LICENSE.txt
  7.  */
  8. defined('_JEXEC'or die;
  9.  
  10. /**
  11.  * Abstract view renderer class. The renderer is what turns XML view templates
  12.  * into actual HTML code, renders the submenu links and potentially wraps the
  13.  * HTML output in a div with a component-specific ID.
  14.  *
  15.  * @package  FrameworkOnFramework
  16.  * @since    2.0
  17.  */
  18. abstract class FOFRenderAbstract
  19. {
  20.     /** @var int Priority of this renderer. Higher means more important */
  21.     protected $priority = 50;
  22.  
  23.     /** @var int Is this renderer enabled? */
  24.     protected $enabled = false;
  25.  
  26.     /**
  27.      * Returns the information about this renderer
  28.      *
  29.      * @return object 
  30.      */
  31.     public function getInformation()
  32.     {
  33.         return (object) array(
  34.                 'priority'     => $this->priority,
  35.                 'enabled'     => $this->enabled,
  36.         );
  37.     }
  38.  
  39.     /**
  40.      * Echoes any HTML to show before the view template
  41.      *
  42.      * @param   string    $view    The current view
  43.      * @param   string    $task    The current task
  44.      * @param   FOFInput  $input   The input array (request parameters)
  45.      * @param   array     $config  The view configuration array
  46.      *
  47.      * @return  void 
  48.      */
  49.     abstract public function preRender($view$task$input$config array());
  50.  
  51.     /**
  52.      * Echoes any HTML to show after the view template
  53.      *
  54.      * @param   string    $view    The current view
  55.      * @param   string    $task    The current task
  56.      * @param   FOFInput  $input   The input array (request parameters)
  57.      * @param   array     $config  The view configuration array
  58.      *
  59.      * @return  void 
  60.      */
  61.     abstract public function postRender($view$task$input$config array());
  62.  
  63.     /**
  64.      * Renders a FOFForm and returns the corresponding HTML
  65.      *
  66.      * @param   FOFForm   &$form     The form to render
  67.      * @param   FOFModel  $model     The model providing our data
  68.      * @param   FOFInput  $input     The input object
  69.      * @param   string    $formType  The form type: edit, browse or read
  70.      * @param   boolean   $raw       If true, the raw form fields rendering (without the surrounding form tag) is returned.
  71.      *
  72.      * @return  string    The HTML rendering of the form
  73.      */
  74.     public function renderForm(FOFForm &$formFOFModel $modelFOFInput $input$formType null$raw false)
  75.     {
  76.         if (is_null($formType))
  77.         {
  78.             $formType $form->getAttribute('type''edit');
  79.         }
  80.         else
  81.         {
  82.             $formType strtolower($formType);
  83.         }
  84.  
  85.         switch ($formType)
  86.         {
  87.             case 'browse':
  88.                 return $this->renderFormBrowse($form$model$input);
  89.                 break;
  90.  
  91.             case 'read':
  92.                 if ($raw)
  93.                 {
  94.                     return $this->renderFormRaw($form$model$input'read');
  95.                 }
  96.                 else
  97.                 {
  98.                     return $this->renderFormRead($form$model$input);
  99.                 }
  100.  
  101.                 break;
  102.  
  103.             default:
  104.                 if ($raw)
  105.                 {
  106.                     return $this->renderFormRaw($form$model$input'edit');
  107.                 }
  108.                 else
  109.                 {
  110.                     return $this->renderFormEdit($form$model$input);
  111.                 }
  112.                 break;
  113.         }
  114.     }
  115.  
  116.     /**
  117.      * Renders the submenu (link bar) for a category view when it is used in a
  118.      * extension
  119.      *
  120.      * Note: this function has to be called from the addSubmenu function in
  121.      *          the ExtensionNameHelper class located in
  122.      *          administrator/components/com_ExtensionName/helpers/Extensionname.php
  123.      *
  124.      * Example Code:
  125.      *
  126.      *    class ExtensionNameHelper
  127.      *    {
  128.      *         public static function addSubmenu($vName)
  129.      *        {
  130.      *            // Load FOF
  131.      *            include_once JPATH_LIBRARIES . '/fof/include.php';
  132.      *
  133.      *            if (!defined('FOF_INCLUDED'))
  134.      *            {
  135.      *                JError::raiseError('500', 'FOF is not installed');
  136.      *            }
  137.      *
  138.      *            if (FOFPlatform::getInstance()->checkVersion(JVERSION, '3.0', 'ge'))
  139.      *            {
  140.      *                $strapper = new FOFRenderJoomla3;
  141.      *            }
  142.      *            else
  143.      *            {
  144.      *                $strapper = new FOFRenderJoomla;
  145.      *            }
  146.      *
  147.      *            $strapper->renderCategoryLinkbar('com_babioonevent');
  148.      *        }
  149.      *    }
  150.      *
  151.      * @param   string  $extension  The name of the extension
  152.      * @param   array   $config     Extra configuration variables for the toolbar
  153.      *
  154.      * @return  void 
  155.      */
  156.     public function renderCategoryLinkbar($extension$config array())
  157.     {
  158.         // On command line don't do anything
  159.         if (FOFPlatform::getInstance()->isCli())
  160.         {
  161.             return;
  162.         }
  163.  
  164.         // Do not render a category submenu unless we are in the the admin area
  165.         if (!FOFPlatform::getInstance()->isBackend())
  166.         {
  167.             return;
  168.         }
  169.  
  170.         $toolbar FOFToolbar::getAnInstance($extension$config);
  171.         $toolbar->renderSubmenu();
  172.  
  173.         $this->renderLinkbarItems($toolbar);
  174.     }
  175.  
  176.     /**
  177.      * Renders a FOFForm for a Browse view and returns the corresponding HTML
  178.      *
  179.      * @param   FOFForm   &$form  The form to render
  180.      * @param   FOFModel  $model  The model providing our data
  181.      * @param   FOFInput  $input  The input object
  182.      *
  183.      * @return  string    The HTML rendering of the form
  184.      */
  185.     abstract protected function renderFormBrowse(FOFForm &$formFOFModel $modelFOFInput $input);
  186.  
  187.     /**
  188.      * Renders a FOFForm for a Read view and returns the corresponding HTML
  189.      *
  190.      * @param   FOFForm   &$form  The form to render
  191.      * @param   FOFModel  $model  The model providing our data
  192.      * @param   FOFInput  $input  The input object
  193.      *
  194.      * @return  string    The HTML rendering of the form
  195.      */
  196.     abstract protected function renderFormRead(FOFForm &$formFOFModel $modelFOFInput $input);
  197.  
  198.     /**
  199.      * Renders a FOFForm for an Edit view and returns the corresponding HTML
  200.      *
  201.      * @param   FOFForm   &$form  The form to render
  202.      * @param   FOFModel  $model  The model providing our data
  203.      * @param   FOFInput  $input  The input object
  204.      *
  205.      * @return  string    The HTML rendering of the form
  206.      */
  207.     abstract protected function renderFormEdit(FOFForm &$formFOFModel $modelFOFInput $input);
  208.  
  209.     /**
  210.      * Renders a raw FOFForm and returns the corresponding HTML
  211.      *
  212.      * @param   FOFForm   &$form     The form to render
  213.      * @param   FOFModel  $model     The model providing our data
  214.      * @param   FOFInput  $input     The input object
  215.      * @param   string    $formType  The form type e.g. 'edit' or 'read'
  216.      *
  217.      * @return  string    The HTML rendering of the form
  218.      */
  219.     abstract protected function renderFormRaw(FOFForm &$formFOFModel $modelFOFInput $input$formType);
  220. }

Documentation generated on Tue, 19 Nov 2013 14:53:13 +0100 by phpDocumentor 1.4.3