Welcome to mirror list, hosted at ThFree Co, Russian Federation.

Top.php « Menu « core - github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 3d5b37edd137061482a2ece2355a4d8ec89f09cf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
<?php
/**
 * Piwik - Open source web analytics
 * 
 * @link http://piwik.org
 * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
 * @version $Id$
 * 
 * @category Piwik
 * @package Piwik_Menu
 */

/**
 * @package Piwik_Menu
 */
class Piwik_Menu_Top extends Piwik_Menu_Abstract
{
	static private $instance = null;

	/**
	 * @return Piwik_Menu_Top
	 */
	static public function getInstance()
	{
		if (self::$instance == null)
		{
			self::$instance = new self;
		}
		return self::$instance;
	}

	/**
	 * Directly adds a menu entry containing html.
	 *
	 * @param string   $menuName
	 * @param string   $data
	 * @param boolean  $displayedForCurrentUser
	 * @param int      $order
	 */
	public function addHtml($menuName, $data, $displayedForCurrentUser, $order)
	{
		if($displayedForCurrentUser)
		{
			if(!isset($this->menu[$menuName]))
			{
				$this->menu[$menuName]['_html'] = $data;
				$this->menu[$menuName]['_order'] = $order;
				$this->menu[$menuName]['_hasSubmenu'] = false;
			}
		}
	}

	/**
	 * Triggers the TopMenu.add hook and returns the menu.
	 *
	 * @return Array
	 */
	public function get()
	{
		if(!$this->menu)
		{
			Piwik_PostEvent('TopMenu.add');
		}
		return parent::get();
	}
}

/**
 * Returns the TopMenu as an array.
 *
 * @return array
 */
function Piwik_GetTopMenu()
{
	return Piwik_Menu_Top::getInstance()->get();
}

/**
 * Adds a new entry to the TopMenu.
 *
 * @param string   $topMenuName
 * @param string   $data
 * @param boolean  $displayedForCurrentUser
 * @param int      $order
 * @param bool     $isHTML
 */
function Piwik_AddTopMenu( $topMenuName, $data, $displayedForCurrentUser = true, $order = 10, $isHTML = false)
{
	if($isHTML)
	{
		Piwik_Menu_Top::getInstance()->addHtml($topMenuName, $data, $displayedForCurrentUser, $order);
	}
	else
	{
		Piwik_Menu_Top::getInstance()->add($topMenuName, null, $data, $displayedForCurrentUser, $order);
	}
}

/**
 * Renames a entry of the TopMenu
 *
 * @param string  $topMenuOriginal
 * @param string  $topMenuRenamed
 */
function Piwik_RenameTopMenuEntry($topMenuOriginal, $topMenuRenamed)
{
	Piwik_Menu_Top::getInstance()->rename($topMenuOriginal, null, $topMenuRenamed, null);
}