Skip to content
Extraits de code Groupes Projets
Valider 381b7570 rédigé par Thomas Steur's avatar Thomas Steur Validation de Matthieu Aubry
Parcourir les fichiers

let plugins decide whether to embed widgetized iframe empty or not (#12292)

parent a25c43e2
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -8,6 +8,7 @@ The Product Changelog at **[piwik.org/changelog](https://piwik.org/changelog)**
### New APIs
* Themes can now customize the header text color using `@theme-color-header-text`
* New event `Widgetize.shouldEmbedIframeEmpty` added so plugins can optionally define the output of the widgetized HTML themselves
## Piwik 3.2.0
......
......@@ -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()) {
......
......@@ -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');
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter