
Recherche avancée
Médias (91)
-
Géodiversité
9 septembre 2011, par ,
Mis à jour : Août 2018
Langue : français
Type : Texte
-
USGS Real-time Earthquakes
8 septembre 2011, par
Mis à jour : Septembre 2011
Langue : français
Type : Texte
-
SWFUpload Process
6 septembre 2011, par
Mis à jour : Septembre 2011
Langue : français
Type : Texte
-
La conservation du net art au musée. Les stratégies à l’œuvre
26 mai 2011
Mis à jour : Juillet 2013
Langue : français
Type : Texte
-
Podcasting Legal guide
16 mai 2011, par
Mis à jour : Mai 2011
Langue : English
Type : Texte
-
Creativecommons informational flyer
16 mai 2011, par
Mis à jour : Juillet 2013
Langue : English
Type : Texte
Autres articles (57)
-
Les vidéos
21 avril 2011, parComme les documents de type "audio", Mediaspip affiche dans la mesure du possible les vidéos grâce à la balise html5 .
Un des inconvénients de cette balise est qu’elle n’est pas reconnue correctement par certains navigateurs (Internet Explorer pour ne pas le nommer) et que chaque navigateur ne gère en natif que certains formats de vidéos.
Son avantage principal quant à lui est de bénéficier de la prise en charge native de vidéos dans les navigateur et donc de se passer de l’utilisation de Flash et (...) -
Ecrire une actualité
21 juin 2013, parPrésentez les changements dans votre MédiaSPIP ou les actualités de vos projets sur votre MédiaSPIP grâce à la rubrique actualités.
Dans le thème par défaut spipeo de MédiaSPIP, les actualités sont affichées en bas de la page principale sous les éditoriaux.
Vous pouvez personnaliser le formulaire de création d’une actualité.
Formulaire de création d’une actualité Dans le cas d’un document de type actualité, les champs proposés par défaut sont : Date de publication ( personnaliser la date de publication ) (...) -
Websites made with MediaSPIP
2 mai 2011, parThis page lists some websites based on MediaSPIP.
Sur d’autres sites (7002)
-
How to expose new API methods in the HTTP Reporting API – Introducing the Piwik Platform
26 février 2015, par Thomas Steur — DevelopmentThis is the next post of our blog series where we introduce the capabilities of the Piwik platform (our previous post was How to write UI tests for your plugin). This time you’ll learn how to extend our Reporting API. For this tutorial you will need to have basic knowledge of PHP.
What is Piwik’s Reporting API ?
It allows third party applications to access analytics data and manipulate miscellaneous data (such as users or websites) through HTTP requests.
What is it good for ?
The Reporting API is used by the Piwik UI to render reports, to manage users, and more. If you want to add a feature to the Piwik UI, you might have to expose a method in the API to access this data. As the API is called via HTTP it allows you to fetch or manipulate any Piwik related data from anywhere. In these exposed API methods you can do pretty much anything you want, for example :
- Enhance existing reports with additional data
- Filter existing reports based on custom rules
- Access the database and generate custom reports
- Persist and read any data
- Request server information
Getting started
In this series of posts, we assume that you have already set up your development environment. If not, visit the Piwik Developer Zone where you’ll find the tutorial Setting up Piwik.
To summarize the things you have to do to get setup :
- Install Piwik (for instance via git).
- Activate the developer mode :
./console development:enable
. - Generate a plugin :
./console generate:plugin --name="MyApiPlugin"
. There should now be a folderplugins/MyApiPlugin
. - And activate the created plugin :
./console plugin:activate "MyApiPlugin"
Let’s start creating an API
We start by using the Piwik Console to create a new API :
./console generate:api
The command will ask you to enter the name of the plugin the created API should belong to. I will simply use the above chosen plugin name “MyApiPlugin”. There should now be a file
plugins/MyApiPlugin/API.php
which contains already an example to get you started easily :- class API extends \Piwik\Plugin\API
- {
- public function getAnswerToLife($truth = true)
- {
- if ($truth) {
- return 42;
- }
- return 24;
- }
- public function getExampleReport($idSite, $period, $date, $wonderful = false)
- {
- ));
- return $table;
- }
- }
Any public method in that file will be available via the Reporting API. For example the method
getAnswerToLife
can be called via this URL :index.php?module=API&method=MyApiPlugin.getAnswerToLife
. The URL parametermethod
is a combination of your plugin name and the method name within this class.Passing parameters to your method
Both example methods define some parameters. To pass any value to a parameter of your method simply specify them by name in the URL. For example
...&method=MyApiPlugin.getExampleReport&idSite=1&period=week&date=today&wonderful=1
to pass values to the parameters of the methodgetExampleReport
.Returning a value
In an API method you can return any boolean, number, string or array value. A resource or an object cannot be returned unless it implements the DataTableInterface such as DataTable (the primary data structure used to store analytics data in Piwik), DataTable\Map (stores a set of DataTables) and DataTable\Simple (a DataTable where every row has two columns : label and value).
Did you know ? You can choose the response format of your API request by appending a parameter
&format=JSON|XML|CSV|...
to the URL. Check out the Reporting API Reference for more information.Best practices
Check user permissions
Do not forget to check whether a user actually has permissions to access data or to perform an action. If you’re not familiar with Piwik’s permissions and how to check them read our User Permission guide.
Keep API methods small
At Piwik we aim to write clean code. Therefore, we recommend to keep API methods small (separation of concerns). An API pretty much acts like a Controller :
- public function createLdapUser($idSite, $login, $password)
- {
- Piwik::checkUserHasAdminAccess($idSite);
- $this->checkLogin($login);
- $this->checkPassword($password);
- $myModel = new LdapModel();
- $success = $myModel->createUser($idSite, $login, $password);
- return $success;
- }
This is not only easy to read, it will also allow you to create simple tests for
LdapModel
(without having to bootstrap the whole Piwik layer) and you will be able to reuse it in other places if needed.Calling APIs of other plugins
For example if you want to fetch an existing report from another plugin, say a list of all Page URLs, do not request this report by calling that method directly :
\Piwik\Plugins\Actions\API::getInstance()->getPageUrls($idSite, $period, $date);
. Instead, issue a new API request :
$report = \Piwik\API\Request::processRequest('Actions.getPageUrls', array(
'idSite' => $idSite,
'period' => $period,
'date' => $date,
));This has several advantages :
- It avoids a fatal error if the requested plugin is not available on a Piwik installation
- Other plugins can extend the called API method via events (adding additional report data to a report, doing additional permission checks) but those events will be only triggered when requesting the report as suggested
- If the method parameters change, your request will most likely still work
Publishing your Plugin on the Marketplace
In case you want to share your API with other Piwik users you can do this by pushing your plugin to a public GitHub repository and creating a tag. Easy as that. Read more about how to distribute a plugin and best practices when publishing a plugin.
Isn’t it easy to create a API ? We never even created a file ! If you have any feedback regarding our APIs or our guides in the Developer Zone feel free to send it to us.
-
How to expose new API methods in the HTTP Reporting API – Introducing the Piwik Platform
26 février 2015, par Thomas Steur — DevelopmentThis is the next post of our blog series where we introduce the capabilities of the Piwik platform (our previous post was How to write UI tests for your plugin). This time you’ll learn how to extend our Reporting API. For this tutorial you will need to have basic knowledge of PHP.
What is Piwik’s Reporting API ?
It allows third party applications to access analytics data and manipulate miscellaneous data (such as users or websites) through HTTP requests.
What is it good for ?
The Reporting API is used by the Piwik UI to render reports, to manage users, and more. If you want to add a feature to the Piwik UI, you might have to expose a method in the API to access this data. As the API is called via HTTP it allows you to fetch or manipulate any Piwik related data from anywhere. In these exposed API methods you can do pretty much anything you want, for example :
- Enhance existing reports with additional data
- Filter existing reports based on custom rules
- Access the database and generate custom reports
- Persist and read any data
- Request server information
Getting started
In this series of posts, we assume that you have already set up your development environment. If not, visit the Piwik Developer Zone where you’ll find the tutorial Setting up Piwik.
To summarize the things you have to do to get setup :
- Install Piwik (for instance via git).
- Activate the developer mode :
./console development:enable
. - Generate a plugin :
./console generate:plugin --name="MyApiPlugin"
. There should now be a folderplugins/MyApiPlugin
. - And activate the created plugin :
./console plugin:activate "MyApiPlugin"
Let’s start creating an API
We start by using the Piwik Console to create a new API :
./console generate:api
The command will ask you to enter the name of the plugin the created API should belong to. I will simply use the above chosen plugin name “MyApiPlugin”. There should now be a file
plugins/MyApiPlugin/API.php
which contains already an example to get you started easily :- class API extends \Piwik\Plugin\API
- {
- public function getAnswerToLife($truth = true)
- {
- if ($truth) {
- return 42;
- }
- return 24;
- }
- public function getExampleReport($idSite, $period, $date, $wonderful = false)
- {
- ));
- return $table;
- }
- }
Any public method in that file will be available via the Reporting API. For example the method
getAnswerToLife
can be called via this URL :index.php?module=API&method=MyApiPlugin.getAnswerToLife
. The URL parametermethod
is a combination of your plugin name and the method name within this class.Passing parameters to your method
Both example methods define some parameters. To pass any value to a parameter of your method simply specify them by name in the URL. For example
...&method=MyApiPlugin.getExampleReport&idSite=1&period=week&date=today&wonderful=1
to pass values to the parameters of the methodgetExampleReport
.Returning a value
In an API method you can return any boolean, number, string or array value. A resource or an object cannot be returned unless it implements the DataTableInterface such as DataTable (the primary data structure used to store analytics data in Piwik), DataTable\Map (stores a set of DataTables) and DataTable\Simple (a DataTable where every row has two columns : label and value).
Did you know ? You can choose the response format of your API request by appending a parameter
&format=JSON|XML|CSV|...
to the URL. Check out the Reporting API Reference for more information.Best practices
Check user permissions
Do not forget to check whether a user actually has permissions to access data or to perform an action. If you’re not familiar with Piwik’s permissions and how to check them read our User Permission guide.
Keep API methods small
At Piwik we aim to write clean code. Therefore, we recommend to keep API methods small (separation of concerns). An API pretty much acts like a Controller :
- public function createLdapUser($idSite, $login, $password)
- {
- Piwik::checkUserHasAdminAccess($idSite);
- $this->checkLogin($login);
- $this->checkPassword($password);
- $myModel = new LdapModel();
- $success = $myModel->createUser($idSite, $login, $password);
- return $success;
- }
This is not only easy to read, it will also allow you to create simple tests for
LdapModel
(without having to bootstrap the whole Piwik layer) and you will be able to reuse it in other places if needed.Calling APIs of other plugins
For example if you want to fetch an existing report from another plugin, say a list of all Page URLs, do not request this report by calling that method directly :
\Piwik\Plugins\Actions\API::getInstance()->getPageUrls($idSite, $period, $date);
. Instead, issue a new API request :
$report = \Piwik\API\Request::processRequest('Actions.getPageUrls', array(
'idSite' => $idSite,
'period' => $period,
'date' => $date,
));This has several advantages :
- It avoids a fatal error if the requested plugin is not available on a Piwik installation
- Other plugins can extend the called API method via events (adding additional report data to a report, doing additional permission checks) but those events will be only triggered when requesting the report as suggested
- If the method parameters change, your request will most likely still work
Publishing your Plugin on the Marketplace
In case you want to share your API with other Piwik users you can do this by pushing your plugin to a public GitHub repository and creating a tag. Easy as that. Read more about how to distribute a plugin and best practices when publishing a plugin.
Isn’t it easy to create a API ? We never even created a file ! If you have any feedback regarding our APIs or our guides in the Developer Zone feel free to send it to us.
-
Evolution #3629 : Pouvoir changer la date d’un article quand il est en cours de rédaction
4 mai 2017, par cedric -Le ticket n’est pas mega clair : s’agit-il de changer la date depuis le formulaire edition de l’article, ou de pouvoir changer la date lorsque l’article est en statut redaction ?
Le fait est que la date est reinitialisée au moment de la publication — sauf si elle est dans le futur, pour les post-publications, car on peut la changer quand l’article est proposé à la publication