Last change
on this file since 108458 was
108458,
checked in by nicolas.dorigny@…, 3 years ago
|
Un plugin qui ajoute une date de création sur tous les objets SPIP, et qui insère la date à la création d'un objet.
|
File size:
1.5 KB
|
Line | |
---|
1 | <?php |
---|
2 | /** |
---|
3 | * Utilisations de pipelines par Date de création |
---|
4 | * |
---|
5 | * @plugin Date de création |
---|
6 | * @copyright 2018 |
---|
7 | * @author nicod_ |
---|
8 | * @licence GNU/GPL |
---|
9 | * @package SPIP\Datecreation\Pipelines |
---|
10 | */ |
---|
11 | |
---|
12 | if (!defined('_ECRIRE_INC_VERSION')) { |
---|
13 | return; |
---|
14 | } |
---|
15 | |
---|
16 | include_spip('inc/config'); |
---|
17 | |
---|
18 | /** |
---|
19 | * Enregistrer la date de creation lors de l'insertion d'un objet |
---|
20 | * |
---|
21 | * @param array $flux |
---|
22 | * |
---|
23 | * @return array |
---|
24 | */ |
---|
25 | function datecreation_pre_insertion($flux) { |
---|
26 | include_spip('datecreation_administrations'); |
---|
27 | datecreation_creer_champs_date_creation(); |
---|
28 | |
---|
29 | $tables = unserialize(lire_config('datecreation/objets')); |
---|
30 | if (is_array($tables) && in_array($flux['args']['table'], $tables)) { |
---|
31 | $flux['data']['date_creation'] = date('Y-m-d H:i:s'); |
---|
32 | } |
---|
33 | |
---|
34 | return $flux; |
---|
35 | } |
---|
36 | |
---|
37 | /** |
---|
38 | * Afficher la date de creation sur la fiche d'un objet |
---|
39 | * |
---|
40 | * @param array $flux |
---|
41 | * |
---|
42 | * @return array |
---|
43 | */ |
---|
44 | function datecreation_afficher_contenu_objet($flux) { |
---|
45 | |
---|
46 | $tables = unserialize(lire_config('datecreation/objets')); |
---|
47 | $table = table_objet_sql($flux['args']['type']); |
---|
48 | |
---|
49 | if (is_array($tables) |
---|
50 | && in_array($table, $tables) |
---|
51 | && $id_objet = $flux['args']['id_objet'] |
---|
52 | ) { |
---|
53 | $id_table_objet = id_table_objet($flux['args']['type']); |
---|
54 | $date_creation = sql_getfetsel('date_creation', $table, $id_table_objet . '=' . intval($id_objet)); |
---|
55 | $date_creation = intval($date_creation) ? affdate_heure($date_creation) : _T('datecreation:non_renseignee'); |
---|
56 | $flux['data'] .= '<div><strong>' . propre(_T('datecreation:date_creation') . " :</strong> " . $date_creation) . '</div>'; |
---|
57 | } |
---|
58 | |
---|
59 | return $flux; |
---|
60 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.