1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* **************************************************************************** |
4
|
|
|
* references - MODULE FOR XOOPS |
5
|
|
|
* Copyright (c) Hervé Thouzard of Instant Zero (http://www.instant-zero.com) |
6
|
|
|
* |
7
|
|
|
* You may not change or alter any portion of this comment or credits |
8
|
|
|
* of supporting developers from this source code or any supporting source code |
9
|
|
|
* which is considered copyrighted (c) material of the original comment or credit authors. |
10
|
|
|
* This program is distributed in the hope that it will be useful, |
11
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
12
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
13
|
|
|
* |
14
|
|
|
* @copyright Hervé Thouzard of Instant Zero (http://www.instant-zero.com) |
15
|
|
|
* @license http://www.fsf.org/copyleft/gpl.html GNU public license |
16
|
|
|
* @package references |
17
|
|
|
* @author Hervé Thouzard of Instant Zero (http://www.instant-zero.com) |
18
|
|
|
* |
19
|
|
|
* **************************************************************************** |
20
|
|
|
*/ |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* Plugin chargé de notifier de la création d'une nouvelle catégorie |
24
|
|
|
* |
25
|
|
|
*/ |
26
|
|
|
class referencesNewreferenceAction extends references_action |
|
|
|
|
27
|
|
|
{ |
28
|
|
View Code Duplication |
public function registerEvents() |
|
|
|
|
29
|
|
|
{ |
30
|
|
|
/** |
31
|
|
|
* La liste des évènements traités par le plugin se présente sous la forme d'un tableau compposé comme ceci : |
32
|
|
|
* |
33
|
|
|
* Indice Signification |
34
|
|
|
* ---------------------- |
35
|
|
|
* 0 Evènement sur lequel se raccrocher (voir class/references_plugins.php::EVENT_ON_PRODUCT_CREATE |
36
|
|
|
* 1 Priorité du plugin (de 1 à 5) |
37
|
|
|
* 2 Script Php à inclure |
38
|
|
|
* 3 Classe à instancier |
39
|
|
|
* 4 Méthode à appeler |
40
|
|
|
*/ |
41
|
|
|
$events = array(); |
42
|
|
|
$events[] = array( |
43
|
|
|
references_plugins::EVENT_ON_REFERENCE_CREATE, |
44
|
|
|
references_plugins::EVENT_PRIORITY_1, |
45
|
|
|
basename(__FILE__), |
46
|
|
|
__CLASS__, |
47
|
|
|
'fireNewReference' |
48
|
|
|
); |
49
|
|
|
|
50
|
|
|
return $events; |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* Méthode appelée pour indiquer qu'une nouvelle référence a été créée |
55
|
|
|
* |
56
|
|
|
* @param object $parameters La référence qui vient d'être publiée |
57
|
|
|
* @return void |
58
|
|
|
*/ |
59
|
|
|
public function fireNewReference($parameters) |
60
|
|
|
{ |
61
|
|
|
$article = $parameters['reference']; |
62
|
|
|
$notification_handler = xoops_getHandler('notification'); |
63
|
|
|
$articleForTemplate = array(); |
64
|
|
|
$originalArticle = $article->toArray('n'); |
65
|
|
|
|
66
|
|
|
foreach ($originalArticle as $key => $value) { |
67
|
|
|
@$articleForTemplate[strtoupper($key)] = strip_tags($value); |
|
|
|
|
68
|
|
|
} |
69
|
|
|
$articleForTemplate['REFERENCES_URL'] = $article->getUrl(); |
70
|
|
|
$articleForTemplate['ARTICLE_SHORT_TEXT'] = references_utils::truncate_tagsafe($article->getVar('article_text'), REFERENCES_SHORTEN_TEXT); |
71
|
|
|
$notification_handler->triggerEvent('global', 0, 'new_article', $articleForTemplate); |
72
|
|
|
} |
73
|
|
|
} |
74
|
|
|
|
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.