protected function removeDisabledPluginFromLayout($layout) { $layout = str_replace("\n", "", $layout); // if the json decoding works (ie. new Json format) // we will only return the widgets that are from enabled plugins if($layoutObject = json_decode($layout, $assoc = false)) { foreach($layoutObject as &$row) { foreach($row as $widgetId => $widget) { if(isset($widget->parameters->module)) { $controllerName = $widget->parameters->module; $controllerAction = $widget->parameters->action; if(!Piwik_IsWidgetDefined($controllerName, $controllerAction)) { unset($row[$widgetId]); } } } } $layout = json_encode($layoutObject); } return $layout; }
protected function removeDisabledPluginFromLayout($layout) { $layout = str_replace("\n", "", $layout); // if the json decoding works (ie. new Json format) // we will only return the widgets that are from enabled plugins $layoutObject = Piwik_Common::json_decode($layout, $assoc = false); if (is_array($layoutObject)) { $layoutObject = (object) array('config' => array('layout' => '33-33-33'), 'columns' => $layoutObject); } if (empty($layoutObject) || empty($layoutObject->columns)) { $layoutObject = (object) array('config' => array('layout' => '33-33-33'), 'columns' => array()); } foreach ($layoutObject->columns as &$row) { if (!is_array($row)) { $row = array(); continue; } foreach ($row as $widgetId => $widget) { if (isset($widget->parameters->module)) { $controllerName = $widget->parameters->module; $controllerAction = $widget->parameters->action; if (!Piwik_IsWidgetDefined($controllerName, $controllerAction)) { unset($row[$widgetId]); } } else { unset($row[$widgetId]); } } } $layout = Piwik_Common::json_encode($layoutObject); return $layout; }