Source for file message.php

Documentation is available at message.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 system message renderer
  14.  *
  15.  * @package     Joomla.Platform
  16.  * @subpackage  Document
  17.  * @since       11.1
  18.  */
  19. {
  20.     /**
  21.      * Renders the error stack and returns the results as a string
  22.      *
  23.      * @param   string  $name     Not used.
  24.      * @param   array   $params   Associative array of values
  25.      * @param   string  $content  Not used.
  26.      *
  27.      * @return  string  The output of the script
  28.      *
  29.      * @since   11.1
  30.      */
  31.     public function render($name$params array ()$content null)
  32.     {
  33.         $msgList $this->getData();
  34.         $buffer null;
  35.         $app JFactory::getApplication();
  36.         $chromePath JPATH_THEMES '/' $app->getTemplate('/html/message.php';
  37.         $itemOverride false;
  38.  
  39.         if (file_exists($chromePath))
  40.         {
  41.             include_once $chromePath;
  42.             if (function_exists('renderMessage'))
  43.             {
  44.                 $itemOverride true;
  45.             }
  46.         }
  47.  
  48.         $buffer ($itemOverriderenderMessage($msgList$this->renderDefaultMessage($msgList);
  49.  
  50.         return $buffer;
  51.     }
  52.  
  53.     /**
  54.      * Get and prepare system message data for output
  55.      *
  56.      * @return  array  An array contains system message
  57.      *
  58.      * @since   12.2
  59.      */
  60.     private function getData()
  61.     {
  62.         // Initialise variables.
  63.         $lists array();
  64.  
  65.         // Get the message queue
  66.         $messages JFactory::getApplication()->getMessageQueue();
  67.  
  68.         // Build the sorted message list
  69.         if (is_array($messages&& !empty($messages))
  70.         {
  71.             foreach ($messages as $msg)
  72.             {
  73.                 if (isset($msg['type']&& isset($msg['message']))
  74.                 {
  75.                     $lists[$msg['type']][$msg['message'];
  76.                 }
  77.             }
  78.         }
  79.  
  80.         return $lists;
  81.     }
  82.  
  83.     /**
  84.      * Render the system message if no message template file found
  85.      *
  86.      * @param   array  $msgList  An array contains system message
  87.      *
  88.      * @return  string  System message markup
  89.      *
  90.      * @since   12.2
  91.      */
  92.     private function renderDefaultMessage($msgList)
  93.     {
  94.         // Build the return string
  95.         $buffer '';
  96.         $buffer .= "\n<div id=\"system-message-container\">";
  97.  
  98.         // If messages exist render them
  99.         if (is_array($msgList))
  100.         {
  101.             $buffer .= "\n<div id=\"system-message\">";
  102.             foreach ($msgList as $type => $msgs)
  103.             {
  104.                 $buffer .= "\n<div class=\"alert alert-" $type "\">";
  105.  
  106.                 // This requires JS so we should add it trough JS. Progressive enhancement and stuff.
  107.                 $buffer .= "<a class=\"close\" data-dismiss=\"alert\">×</a>";
  108.  
  109.                 if (count($msgs))
  110.                 {
  111.                     $buffer .= "\n<h4 class=\"alert-heading\">" JText::_($type"</h4>";
  112.                     $buffer .= "\n<div>";
  113.                     foreach ($msgs as $msg)
  114.                     {
  115.                         $buffer .= "\n\t\t<p>" $msg "</p>";
  116.                     }
  117.                     $buffer .= "\n</div>";
  118.                 }
  119.                 $buffer .= "\n</div>";
  120.             }
  121.             $buffer .= "\n</div>";
  122.         }
  123.  
  124.         $buffer .= "\n</div>";
  125.  
  126.         return $buffer;
  127.     }
  128. }

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