PageRenderTime 27ms CodeModel.GetById 21ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/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
10defined('JPATH_PLATFORM') or die;
11
12/**
13 * JDocument system message renderer
14 *
15 * @since  11.1
16 */
17class JDocumentRendererMessage extends JDocumentRenderer
18{
19	/**
20	 * Renders the error stack and returns the results as a string
21	 *
22	 * @param   string  $name     Not used.
23	 * @param   array   $params   Associative array of values
24	 * @param   string  $content  Not used.
25	 *
26	 * @return  string  The output of the script
27	 *
28	 * @since   11.1
29	 */
30	public function render($name, $params = array(), $content = null)
31	{
32		$msgList = $this->getData();
33		$displayData = array(
34			'msgList' => $msgList,
35			'name' => $name,
36			'params' => $params,
37			'content' => $content
38		);
39
40		$app = JFactory::getApplication();
41		$chromePath = JPATH_THEMES . '/' . $app->getTemplate() . '/html/message.php';
42
43		if (file_exists($chromePath))
44		{
45			include_once $chromePath;
46		}
47
48		if (function_exists('renderMessage'))
49		{
50			JLog::add('renderMessage() is deprecated. Override system message rendering with layouts instead.', JLog::WARNING, 'deprecated');
51
52			return renderMessage($msgList);
53		}
54
55		return JLayoutHelper::render('joomla.system.message', $displayData);
56	}
57
58	/**
59	 * Get and prepare system message data for output
60	 *
61	 * @return  array  An array contains system message
62	 *
63	 * @since   12.2
64	 */
65	private function getData()
66	{
67		// Initialise variables.
68		$lists = array();
69
70		// Get the message queue
71		$messages = JFactory::getApplication()->getMessageQueue();
72
73		// Build the sorted message list
74		if (is_array($messages) && !empty($messages))
75		{
76			foreach ($messages as $msg)
77			{
78				if (isset($msg['type']) && isset($msg['message']))
79				{
80					$lists[$msg['type']][] = $msg['message'];
81				}
82			}
83		}
84
85		return $lists;
86	}
87}