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:
authorThomas Steur <tsteur@users.noreply.github.com>2017-11-21 05:59:33 +0300
committerMatthieu Aubry <mattab@users.noreply.github.com>2017-11-21 05:59:33 +0300
commit381b7570c998f2c0eea81cd133ce8b370ff89a40 (patch)
treeb34abce2ee129c623924b1a1b2c652b71b3f3ef3 /plugins
parenta25c43e2f5b78a31a77e102573b354af3898f0ff (diff)
let plugins decide whether to embed widgetized iframe empty or not (#12292)
Diffstat (limited to 'plugins')
-rw-r--r--plugins/Dashboard/Dashboard.php10
-rw-r--r--plugins/Widgetize/Controller.php27
2 files changed, 33 insertions, 4 deletions
diff --git a/plugins/Dashboard/Dashboard.php b/plugins/Dashboard/Dashboard.php
index 7392ea119b..3caf0d13f5 100644
--- a/plugins/Dashboard/Dashboard.php
+++ b/plugins/Dashboard/Dashboard.php
@@ -30,10 +30,18 @@ class Dashboard extends \Piwik\Plugin
'UsersManager.deleteUser' => 'deleteDashboardLayout',
'Translate.getClientSideTranslationKeys' => 'getClientSideTranslationKeys',
'Widget.addWidgetConfigs' => 'addWidgetConfigs',
- 'Category.addSubcategories' => 'addSubcategories'
+ 'Category.addSubcategories' => 'addSubcategories',
+ 'Widgetize.shouldEmbedIframeEmpty' => 'shouldEmbedIframeEmpty'
);
}
+ public function shouldEmbedIframeEmpty(&$shouldEmbedEmpty, $controllerName, $actionName)
+ {
+ if ($controllerName == 'Dashboard' && $actionName == 'index') {
+ $shouldEmbedEmpty = true;
+ }
+ }
+
public function addWidgetConfigs(&$widgets)
{
if (Piwik::isUserIsAnonymous()) {
diff --git a/plugins/Widgetize/Controller.php b/plugins/Widgetize/Controller.php
index cf6cb5114a..e639827915 100644
--- a/plugins/Widgetize/Controller.php
+++ b/plugins/Widgetize/Controller.php
@@ -8,9 +8,9 @@
*/
namespace Piwik\Plugins\Widgetize;
-use Piwik\API\Request;
use Piwik\Common;
use Piwik\FrontController;
+use Piwik\Piwik;
use Piwik\View;
/**
@@ -27,7 +27,6 @@ class Controller extends \Piwik\Plugin\Controller
public function iframe()
{
- Request::reloadAuthUsingTokenAuth();
$this->init();
$controllerName = Common::getRequestVar('moduleToWidgetize');
@@ -37,7 +36,29 @@ class Controller extends \Piwik\Plugin\Controller
throw new \Exception("Widgetizing API requests is not supported for security reasons. Please change query parameter 'moduleToWidgetize'.");
}
- if ($controllerName == 'Dashboard' && $actionName == 'index') {
+ $shouldEmbedEmpty = false;
+
+ /**
+ * Triggered to detect whether a widgetized report should be wrapped in the widgetized HTML or whether only
+ * the rendered output of the controller/action should be printed. Set `$shouldEmbedEmpty` to `true` if
+ * your widget renders the full HTML itself.
+ *
+ * **Example**
+ *
+ * public function embedIframeEmpty(&$shouldEmbedEmpty, $controllerName, $actionName)
+ * {
+ * if ($controllerName == 'Dashboard' && $actionName == 'index') {
+ * $shouldEmbedEmpty = true;
+ * }
+ * }
+ *
+ * @param string &$shouldEmbedEmpty Defines whether the iframe should be embedded empty or wrapped within the widgetized html.
+ * @param string $controllerName The name of the controller that will be executed.
+ * @param string $actionName The name of the action within the controller that will be executed.
+ */
+ Piwik::postEvent('Widgetize.shouldEmbedIframeEmpty', array(&$shouldEmbedEmpty, $controllerName, $actionName));
+
+ if ($shouldEmbedEmpty) {
$view = new View('@Widgetize/iframe_empty');
} else {
$view = new View('@Widgetize/iframe');