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

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'core/PluginsFunctions/WidgetsList.php')
-rw-r--r--core/PluginsFunctions/WidgetsList.php33
1 files changed, 32 insertions, 1 deletions
diff --git a/core/PluginsFunctions/WidgetsList.php b/core/PluginsFunctions/WidgetsList.php
index ce1b7a417f..1ab172a645 100644
--- a/core/PluginsFunctions/WidgetsList.php
+++ b/core/PluginsFunctions/WidgetsList.php
@@ -16,10 +16,15 @@
class Piwik_WidgetsList
{
static protected $widgets = null;
+ static protected $hookCalled = false;
static function get()
{
- Piwik_PostEvent('WidgetsList.add');
+ if(!self::$hookCalled)
+ {
+ self::$hookCalled = true;
+ Piwik_PostEvent('WidgetsList.add');
+ }
return self::$widgets;
}
@@ -28,6 +33,10 @@ class Piwik_WidgetsList
$widgetCategory = Piwik_Translate($widgetCategory);
$widgetName = Piwik_Translate($widgetName);
$widgetUniqueId = 'widget' . $controllerName . $controllerAction;
+ foreach($customParameters as $name => $value)
+ {
+ $widgetUniqueId .= $name . $value;
+ }
self::$widgets[$widgetCategory][] = array(
'name' => $widgetName,
'uniqueId' => $widgetUniqueId,
@@ -36,6 +45,23 @@ class Piwik_WidgetsList
) + $customParameters
);
}
+
+ static function isDefined($controllerName, $controllerAction)
+ {
+ $widgetsList = self::get();
+ foreach($widgetsList as $widgetCategory => $widgets)
+ {
+ foreach($widgets as $widget)
+ {
+ if($widget['parameters']['module'] == $controllerName
+ && $widget['parameters']['action'] == $controllerAction)
+ {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
}
function Piwik_GetWidgetsList()
@@ -47,3 +73,8 @@ function Piwik_AddWidget( $widgetCategory, $widgetName, $controllerName, $contro
{
Piwik_WidgetsList::add($widgetCategory, $widgetName, $controllerName, $controllerAction, $customParameters);
}
+
+function Piwik_IsWidgetDefined($controllerName, $controllerAction)
+{
+ return Piwik_WidgetsList::isDefined($controllerName, $controllerAction);
+}