**Client Side Properties** Client side properties are properties that should be passed on to the browser so client side JavaScript can use them. Only affects ViewDataTables that output HTML. **Overridable Properties** Overridable properties are properties that can be set via the query string. If a request has a query parameter that matches an overridable property, the property will be set to the query parameter value. **Reusing base properties** Many of the properties in this class only have meaning for the {@link Piwik\Plugin\Visualization} class, but can be set for other visualizations that extend {@link Piwik\Plugin\ViewDataTable} directly. Visualizations that extend {@link Piwik\Plugin\ViewDataTable} directly and want to re-use these properties must make sure the properties are used in the exact same way they are used in {@link Piwik\Plugin\Visualization}. **Defining new display properties** If you are creating your own visualization and want to add new display properties for it, extend this class and add your properties as fields. Properties are marked as client side properties by calling the {@link addPropertiesThatShouldBeAvailableClientSide()} method. Properties are marked as overridable by calling the {@link addPropertiesThatCanBeOverwrittenByQueryParams()} method. ### Example **Defining new display properties** class MyCustomVizConfig extends Config { ** * My custom property. It is overridable. *\/ public $my_custom_property = false; ** * Another custom property. It is available client side. *\/ public $another_custom_property = true; public function __construct() { parent::__construct(); $this->addPropertiesThatShouldBeAvailableClientSide(array('another_custom_property')); $this->addPropertiesThatCanBeOverwrittenByQueryParams(array('my_custom_property')); } }
Beispiel #1
0
 public function __construct()
 {
     parent::__construct();
     $this->enable_sort = true;
     $this->datatable_js_type = 'DataTable';
     $this->addPropertiesThatShouldBeAvailableClientSide(array('show_extra_columns', 'show_goals_columns', 'disable_row_evolution', 'disable_row_actions', 'enable_sort', 'keep_summary_row', 'subtable_controller_action'));
     $this->addPropertiesThatCanBeOverwrittenByQueryParams(array('show_expanded', 'disable_row_actions', 'disable_row_evolution', 'show_extra_columns', 'show_goals_columns', 'disable_subtable_when_show_goals', 'keep_summary_row', 'highlight_summary_row'));
 }
Beispiel #2
0
 public function __construct()
 {
     parent::__construct();
     $this->addPropertiesThatShouldBeAvailableClientSide(array('disable_row_actions'));
     $this->addPropertiesThatCanBeOverwrittenByQueryParams(array('disable_row_actions'));
 }
Beispiel #3
0
 public function __construct()
 {
     parent::__construct();
     $this->addPropertiesThatCanBeOverwrittenByQueryParams(array('display_logo_instead_of_label'));
 }
Beispiel #4
0
 /**
  * Constructor. Initializes display and request properties to their default values.
  * Posts the {@hook ViewDataTable.configure} event which plugins can use to configure the
  * way reports are displayed.
  */
 public function __construct($controllerAction, $apiMethodToRequestDataTable, $overrideParams = array())
 {
     list($controllerName, $controllerAction) = explode('.', $controllerAction);
     $this->requestConfig = static::getDefaultRequestConfig();
     $this->config = static::getDefaultConfig();
     $this->config->subtable_controller_action = $controllerAction;
     $this->config->setController($controllerName, $controllerAction);
     $this->request = new ViewDataTableRequest($this->requestConfig);
     $this->requestConfig->idSubtable = Common::getRequestVar('idSubtable', false, 'int');
     $this->config->self_url = Request::getBaseReportUrl($controllerName, $controllerAction);
     $this->requestConfig->apiMethodToRequestDataTable = $apiMethodToRequestDataTable;
     $report = Report::factory($this->requestConfig->getApiModuleToRequest(), $this->requestConfig->getApiMethodToRequest());
     if (!empty($report)) {
         /** @var Report $report */
         $subtable = $report->getActionToLoadSubTables();
         if (!empty($subtable)) {
             $this->config->subtable_controller_action = $subtable;
         }
         $this->config->show_goals = $report->hasGoalMetrics();
         $relatedReports = $report->getRelatedReports();
         if (!empty($relatedReports)) {
             foreach ($relatedReports as $relatedReport) {
                 $widgetTitle = $relatedReport->getWidgetTitle();
                 if ($widgetTitle && Common::getRequestVar('widget', 0, 'int')) {
                     $relatedReportName = $widgetTitle;
                 } else {
                     $relatedReportName = $relatedReport->getName();
                 }
                 $this->config->addRelatedReport($relatedReport->getModule() . '.' . $relatedReport->getAction(), $relatedReportName);
             }
         }
         $metrics = $report->getMetrics();
         if (!empty($metrics)) {
             $this->config->addTranslations($metrics);
         }
         $processedMetrics = $report->getProcessedMetrics();
         if (!empty($processedMetrics)) {
             $this->config->addTranslations($processedMetrics);
         }
         $report->configureView($this);
     }
     /**
      * Triggered during {@link ViewDataTable} construction. Subscribers should customize
      * the view based on the report that is being displayed.
      *
      * Plugins that define their own reports must subscribe to this event in order to
      * specify how the Piwik UI should display the report.
      *
      * **Example**
      *
      *     // event handler
      *     public function configureViewDataTable(ViewDataTable $view)
      *     {
      *         switch ($view->requestConfig->apiMethodToRequestDataTable) {
      *             case 'VisitTime.getVisitInformationPerServerTime':
      *                 $view->config->enable_sort = true;
      *                 $view->requestConfig->filter_limit = 10;
      *                 break;
      *         }
      *     }
      *
      * @param ViewDataTable $view The instance to configure.
      */
     Piwik::postEvent('ViewDataTable.configure', array($this));
     $this->assignRelatedReportsTitle();
     $this->config->show_footer_icons = false == $this->requestConfig->idSubtable;
     // the exclude low population threshold value is sometimes obtained by requesting data.
     // to avoid issuing unecessary requests when display properties are determined by metadata,
     // we allow it to be a closure.
     if (isset($this->requestConfig->filter_excludelowpop_value) && $this->requestConfig->filter_excludelowpop_value instanceof \Closure) {
         $function = $this->requestConfig->filter_excludelowpop_value;
         $this->requestConfig->filter_excludelowpop_value = $function();
     }
     $this->overrideViewPropertiesWithParams($overrideParams);
     $this->overrideViewPropertiesWithQueryParams();
 }
Beispiel #5
0
 public function __construct()
 {
     parent::__construct();
     $this->show_limit_control = false;
     $this->addPropertiesThatShouldBeAvailableClientSide(array('show_series_picker', 'allow_multi_select_series_picker', 'selectable_columns', 'selectable_rows', 'display_percentage_in_tooltip'));
     $this->addPropertiesThatCanBeOverwrittenByQueryParams(array('show_all_ticks', 'show_series_picker'));
 }
Beispiel #6
0
 public function __construct()
 {
     parent::__construct();
     $this->translations = Metrics::getDefaultMetricTranslations();
 }
 /**
  * Constructor. Initializes display and request properties to their default values.
  * Posts the {@hook ViewDataTable.configure} event which plugins can use to configure the
  * way reports are displayed.
  */
 public function __construct($controllerAction, $apiMethodToRequestDataTable)
 {
     list($controllerName, $controllerAction) = explode('.', $controllerAction);
     $this->requestConfig = static::getDefaultRequestConfig();
     $this->config = static::getDefaultConfig();
     $this->config->subtable_controller_action = $controllerAction;
     $this->config->setController($controllerName, $controllerAction);
     $this->request = new ViewDataTableRequest($this->requestConfig);
     $this->requestConfig->idSubtable = Common::getRequestVar('idSubtable', false, 'int');
     $this->config->self_url = Request::getBaseReportUrl($controllerName, $controllerAction);
     $this->requestConfig->apiMethodToRequestDataTable = $apiMethodToRequestDataTable;
     /**
      * Triggered during {@link ViewDataTable} construction. Subscribers should customize
      * the view based on the report that is being displayed.
      * 
      * Plugins that define their own reports must subscribe to this event in order to
      * specify how the Piwik UI should display the report.
      * 
      * **Example**
      *
      *     // event handler
      *     public function configureViewDataTable(ViewDataTable $view)
      *     {
      *         switch ($view->requestConfig->apiMethodToRequestDataTable) {
      *             case 'VisitTime.getVisitInformationPerServerTime':
      *                 $view->config->enable_sort = true;
      *                 $view->requestConfig->filter_limit = 10;
      *                 break;
      *         }
      *     }
      * 
      * @param ViewDataTable $view The instance to configure.
      */
     Piwik::postEvent('ViewDataTable.configure', array($this));
     $this->config->show_footer_icons = false == $this->requestConfig->idSubtable;
     // the exclude low population threshold value is sometimes obtained by requesting data.
     // to avoid issuing unecessary requests when display properties are determined by metadata,
     // we allow it to be a closure.
     if (isset($this->requestConfig->filter_excludelowpop_value) && $this->requestConfig->filter_excludelowpop_value instanceof \Closure) {
         $function = $this->requestConfig->filter_excludelowpop_value;
         $this->requestConfig->filter_excludelowpop_value = $function();
     }
     $this->overrideViewPropertiesWithQueryParams();
 }