/libraries/joomla/document/html/renderer/message.php

https://gitlab.com/vitaliylukin91/text · PHP · 87 lines · 43 code · 11 blank · 33 comment · 6 complexity · ce2641a1479b9214535de257d43cacde MD5 · raw file

  1. <?php
  2. /**
  3. * @package Joomla.Platform
  4. * @subpackage Document
  5. *
  6. * @copyright Copyright (C) 2005 - 2015 Open Source Matters, Inc. All rights reserved.
  7. * @license GNU General Public License version 2 or later; see LICENSE
  8. */
  9. defined('JPATH_PLATFORM') or die;
  10. /**
  11. * JDocument system message renderer
  12. *
  13. * @since 11.1
  14. */
  15. class JDocumentRendererMessage extends JDocumentRenderer
  16. {
  17. /**
  18. * Renders the error stack and returns the results as a string
  19. *
  20. * @param string $name Not used.
  21. * @param array $params Associative array of values
  22. * @param string $content Not used.
  23. *
  24. * @return string The output of the script
  25. *
  26. * @since 11.1
  27. */
  28. public function render($name, $params = array(), $content = null)
  29. {
  30. $msgList = $this->getData();
  31. $displayData = array(
  32. 'msgList' => $msgList,
  33. 'name' => $name,
  34. 'params' => $params,
  35. 'content' => $content
  36. );
  37. $app = JFactory::getApplication();
  38. $chromePath = JPATH_THEMES . '/' . $app->getTemplate() . '/html/message.php';
  39. if (file_exists($chromePath))
  40. {
  41. include_once $chromePath;
  42. }
  43. if (function_exists('renderMessage'))
  44. {
  45. JLog::add('renderMessage() is deprecated. Override system message rendering with layouts instead.', JLog::WARNING, 'deprecated');
  46. return renderMessage($msgList);
  47. }
  48. return JLayoutHelper::render('joomla.system.message', $displayData);
  49. }
  50. /**
  51. * Get and prepare system message data for output
  52. *
  53. * @return array An array contains system message
  54. *
  55. * @since 12.2
  56. */
  57. private function getData()
  58. {
  59. // Initialise variables.
  60. $lists = array();
  61. // Get the message queue
  62. $messages = JFactory::getApplication()->getMessageQueue();
  63. // Build the sorted message list
  64. if (is_array($messages) && !empty($messages))
  65. {
  66. foreach ($messages as $msg)
  67. {
  68. if (isset($msg['type']) && isset($msg['message']))
  69. {
  70. $lists[$msg['type']][] = $msg['message'];
  71. }
  72. }
  73. }
  74. return $lists;
  75. }
  76. }