Skip to content
GitLab
Explorer
Connexion
S'inscrire
Navigation principale
Rechercher ou aller à…
Projet
S
stats-facil
Gestion
Activité
Membres
Labels
Programmation
Tickets
Tableaux des tickets
Jalons
Wiki
Code
Requêtes de fusion
Dépôt
Branches
Validations
Étiquettes
Graphe du dépôt
Comparer les révisions
Extraits de code
Compilation
Pipelines
Jobs
Planifications de pipeline
Artéfacts
Déploiement
Releases
Registre de paquets
Registre de conteneur
Registre de modèles
Opération
Environnements
Modules Terraform
Surveillance
Incidents
Analyse
Données d'analyse des chaînes de valeur
Analyse des contributeurs
Données d'analyse CI/CD
Données d'analyse du dépôt
Expériences du modèle
Aide
Aide
Support
Documentation de GitLab
Comparer les forfaits GitLab
Forum de la communauté
Contribuer à GitLab
Donner votre avis
Raccourcis clavier
?
Extraits de code
Groupes
Projets
Afficher davantage de fils d'Ariane
facil
stats-facil
Validations
82a36f16
Valider
82a36f16
rédigé
11 years ago
par
diosmosis
Parcourir les fichiers
Options
Téléchargements
Correctifs
Plain Diff
Refs #4200, documented ViewDataTable\Factory.
parent
e18a6a22
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
Modifications
2
Masquer les modifications d'espaces
En ligne
Côte à côte
Affichage de
2 fichiers modifiés
core/Plugin/Controller.php
+6
-3
6 ajouts, 3 suppressions
core/Plugin/Controller.php
core/ViewDataTable/Factory.php
+59
-14
59 ajouts, 14 suppressions
core/ViewDataTable/Factory.php
avec
65 ajouts
et
17 suppressions
core/Plugin/Controller.php
+
6
−
3
Voir le fichier @
82a36f16
...
@@ -204,9 +204,12 @@ abstract class Controller
...
@@ -204,9 +204,12 @@ abstract class Controller
/**
/**
* Convenience method that creates and renders a ViewDataTable for a API method.
* Convenience method that creates and renders a ViewDataTable for a API method.
*
*
* @param string $apiAction The name of the API action (eg, getResolution).
* @param string $pluginName The name of the plugin (eg, `'UserSettings'`).
* @throws \Exception
* @param string $apiAction The name of the API action (eg, `'getResolution'`).
* @return string
* @param bool $fetch If `true`, the rendered string is returned, if `false` it is `echo`'d.
* @throws \Exception if `$pluginName` is not an existing plugin or if `$apiAction` is not an
* existing method of the plugin's API.
* @return string|void See `$fetch`.
*/
*/
protected
function
renderReport
(
$apiAction
)
protected
function
renderReport
(
$apiAction
)
{
{
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
core/ViewDataTable/Factory.php
+
59
−
14
Voir le fichier @
82a36f16
...
@@ -16,8 +16,45 @@ use Piwik\Piwik;
...
@@ -16,8 +16,45 @@ use Piwik\Piwik;
use
Piwik\Plugins\CoreVisualizations\Visualizations\HtmlTable
;
use
Piwik\Plugins\CoreVisualizations\Visualizations\HtmlTable
;
/**
/**
*
TODO
*
Provides a means of creating [ViewDataTable](#) instances by ID.
*
*
* ### Examples
*
* **Creating a ViewDataTable for a report**
*
* // method in MyPlugin\Controller
* public function myReport()
* {
* $view = Factory::build('table', 'MyPlugin.myReport');
* $view->config->show_limit_control = true;
* $view->config->translations['myFancyMetric'] = "My Fancy Metric";
* echo $view->render();
* }
*
* **Displaying a report in another way**
*
* // method in MyPlugin\Controller
* // use the same data that's used in myReport() above, but transform it in some way before
* // displaying.
* public function myReportShownDifferently()
* {
* $view = Factory::build('table', 'MyPlugin.myReport', 'MyPlugin.myReportShownDifferently');
* $view->config->filters[] = array('MyMagicFilter', array('an arg', 'another arg'));
* echo $view->render();
* }
*
* **Force a report to be shown as a bar graph**
*
* // method in MyPlugin\Controller
* // force the myReport report to show as a bar graph if there is no viewDataTable query param,
* // even though it is configured to show as a table.
* public function myReportShownAsABarGraph()
* {
* $view = Factory::build('graphVerticalBar', 'MyPlugin.myReport', 'MyPlugin.myReportShownAsABarGraph',
* $forceDefault = true);
* echo $view->render();
* }
*
* @package Piwik
* @package Piwik
* @subpackage ViewDataTable
* @subpackage ViewDataTable
*
*
...
@@ -25,7 +62,6 @@ use Piwik\Plugins\CoreVisualizations\Visualizations\HtmlTable;
...
@@ -25,7 +62,6 @@ use Piwik\Plugins\CoreVisualizations\Visualizations\HtmlTable;
*/
*/
class
Factory
class
Factory
{
{
/**
/**
* Cache for getDefaultTypeViewDataTable result.
* Cache for getDefaultTypeViewDataTable result.
*
*
...
@@ -34,19 +70,28 @@ class Factory
...
@@ -34,19 +70,28 @@ class Factory
private
static
$defaultViewTypes
=
null
;
private
static
$defaultViewTypes
=
null
;
/**
/**
* Returns a Piwik_ViewDataTable_* object.
* Creates a [ViewDataTable](#) instance by ID. If the **viewDataTable** query parameter is set,
* By default it will return a ViewDataTable_Html
* this parameter's value is used as the ID.
* If there is a viewDataTable parameter in the URL, a ViewDataTable of this 'viewDataTable' type will be returned.
*
* If defaultType is specified and if there is no 'viewDataTable' in the URL, a ViewDataTable of this $defaultType will be returned.
* See [ViewDataTable docs](#) to read about the ViewDataTable implementations that are packaged with Piwik.
* If force is set to true, a ViewDataTable of the $defaultType will be returned in all cases.
*
*
* @param string|null $defaultType A ViewDataTable ID representing the default ViewDataTable type to use. If
* @param string $defaultType Any of these: table, cloud, graphPie, graphVerticalBar, graphEvolution, sparkline, generateDataChart*
* the **viewDataTable** query parameter is not found, this value is used as
* @param string|bool $apiAction
* the ID of the ViewDataTable to create.
* @param string|bool $controllerAction
*
* @param bool $forceDefault
* If a visualization type is configured for the report being displayed, it
*
* is used instead of the default type. (See [ViewDataTable.getDefaultType](#)).
* If nothing is configured for the report and `null` is supplied for this
* argument, **table** is used.
* @param string|false $apiAction The API method for the report that will be displayed, eg,
* `'UserSettings.getBrowser'`.
* @param string|false $controllerAction The controller name and action dedicated to displaying the report. This
* action is used when reloading reports or changing the report visualization.
* Defaulted to `$apiAction` if `false` is supplied.
* @param bool $forceDefault If true, then the visualization type that was configured for the report will be
* ignored and `$defaultType` will be used as the default.
* @throws \Exception
* @throws \Exception
* @return \Piwik\Plugin\ViewDataTable
|\Piwik\Plugin\Visualization|\Piwik\Plugins\CoreVisualizations\Visualizations\Sparkline;
* @return \Piwik\Plugin\ViewDataTable
*/
*/
public
static
function
build
(
$defaultType
=
null
,
$apiAction
=
false
,
$controllerAction
=
false
,
$forceDefault
=
false
)
public
static
function
build
(
$defaultType
=
null
,
$apiAction
=
false
,
$controllerAction
=
false
,
$forceDefault
=
false
)
{
{
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
Aperçu
0%
Chargement en cours
Veuillez réessayer
ou
joindre un nouveau fichier
.
Annuler
You are about to add
0
people
to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Enregistrer le commentaire
Annuler
Veuillez vous
inscrire
ou vous
se connecter
pour commenter