public function renderWidget($widgetModule = null, $widgetAction = null) { Piwik::checkUserHasSomeViewAccess(); $widget = PluginWidgets::factory($widgetModule, $widgetAction); if (!empty($widget)) { return $widget->{$widgetAction}(); } throw new Exception(Piwik::translate('General_ExceptionWidgetNotFound')); }
private function createWidgetController($module, $action, array &$parameters) { $widget = Widgets::factory($module, $action); if (!$widget) { return null; } $parameters['widget'] = $widget; $parameters['method'] = $action; return array($this->createCoreHomeController(), 'renderWidget'); }
protected function makeController($module, $action, &$parameters) { $controllerClassName = $this->getClassNameController($module); // TRY TO FIND ACTION IN CONTROLLER if (class_exists($controllerClassName)) { $class = $this->getClassNameController($module); /** @var $controller Controller */ $controller = new $class(); $controllerAction = $action; if ($controllerAction === false) { $controllerAction = $controller->getDefaultAction(); } if (is_callable(array($controller, $controllerAction))) { return array($controller, $controllerAction); } if ($action === false) { $this->triggerControllerActionNotFoundError($module, $controllerAction); } } // TRY TO FIND ACTION IN WIDGET $widget = Widgets::factory($module, $action); if (!empty($widget)) { $parameters['widgetModule'] = $module; $parameters['widgetMethod'] = $action; return array(new CoreHomeController(), 'renderWidget'); } // TRY TO FIND ACTION IN REPORT $report = Report::factory($module, $action); if (!empty($report)) { $parameters['reportModule'] = $module; $parameters['reportAction'] = $action; return array(new CoreHomeController(), 'renderReportWidget'); } if (!empty($action) && 'menu' === substr($action, 0, 4)) { $reportAction = lcfirst(substr($action, 4)); // menuGetPageUrls => getPageUrls $report = Report::factory($module, $reportAction); if (!empty($report)) { $parameters['reportModule'] = $module; $parameters['reportAction'] = $reportAction; return array(new CoreHomeController(), 'renderReportMenu'); } } $this->triggerControllerActionNotFoundError($module, $action); }