.
diff --git a/README.md b/README.md
index 9fe1aa8..6efb43d 100644
--- a/README.md
+++ b/README.md
@@ -1,16 +1,15 @@
-seenthis_opencalais
-===================
+# seenthis/opencalais
-recuperer les tags automatiques sur OpenCalais
+Récupérer les tags automatiques sur OpenCalais
-
-## Usage :
+## Usage
Le service OpenCalais n'est pas libre.
Pour utiliser leur API il faut au préalable demander une clé d'autorisation.
Une fois l'autorisation obtenue, vous devrez ajouter dans le fichier `mes_options.php` la ligne suivante :
-```
+
+```php
define('_OPENCALAIS_APIKEY', "3cve82h1b7n2fg637cr2vxc1");
```
diff --git a/action/lien_mot.php b/action/lien_mot.php
index 5913651..6f937c2 100755
--- a/action/lien_mot.php
+++ b/action/lien_mot.php
@@ -1,29 +1,33 @@
0) {
- #var_dump("ME", $id_me, $tag, $statut);
-
- $query = sql_select("id_auteur", "spip_me", "id_me=$id_me AND id_auteur=$auteur_session");
+ $query = sql_select('id_auteur', 'spip_me', "id_me=$id_me AND id_auteur=$auteur_session");
if ($row = sql_fetch($query)) {
$autoriser = true;
sql_updateq(
- "spip_me_tags",
- array("off"=> $statut),
- "id_me=$id_me AND tag=".sql_quote($tag)
+ 'spip_me_tags',
+ ['off' => $statut],
+ "id_me=$id_me AND tag=" . sql_quote($tag)
);
# old style
if ($id_mot > 0) {
- sql_updateq(
- "spip_me_mot",
- array("off"=> $statut),
- "id_me=$id_me AND id_mot=$id_mot"
+ sql_updateq(
+ 'spip_me_mot',
+ ['off' => $statut],
+ "id_me=$id_me AND id_mot=$id_mot"
);
}
}
@@ -58,23 +60,17 @@ function action_lien_mot() {
# OLD STYLE -
if ($id_syndic > 0 && $autoriser) {
- #echo "SYNDIC";
- sql_updateq(
- "spip_syndic_oc",
- array("off"=> $statut),
- "id_syndic=$id_syndic AND id_mot=$id_mot"
- );
+ sql_updateq(
+ 'spip_syndic_oc',
+ ['off' => $statut],
+ "id_syndic=$id_syndic AND id_mot=$id_mot"
+ );
}
-
+
if ($id_me > 0 && $autoriser) {
cache_message($id_me);
include_spip('inc/headers');
redirige_par_entete(generer_url_entite($id_me, 'me'));
}
}
-
}
-
-
-
-?>
\ No newline at end of file
diff --git a/base/seenthisoc.php b/base/seenthisoc.php
index c606e86..13e0bf4 100644
--- a/base/seenthisoc.php
+++ b/base/seenthisoc.php
@@ -1,24 +1,25 @@
SPIP
function seenthisoc_lire_create_table($x) {
- $m = array('field' => array(), 'key' => array());
+ $m = ['field' => [], 'key' => []];
- foreach(explode("\n", $x) as $line) {
+ foreach (explode("\n", $x) as $line) {
$line = trim(preg_replace('/,$/', '', $line));
- if (preg_match("/^(PRIMARY KEY) \(`(.*?)`\)/", $line, $c)) {
+ if (preg_match('/^(PRIMARY KEY) \(`(.*?)`\)/', $line, $c)) {
$m['key'][$c[1]] = $c[2];
}
- elseif (preg_match("/^(KEY) `(.*?)`\s+\((.*?)\)/", $line, $c)) {
- $m['key'][$c[1]." ".$c[2]] = $c[3];
+ elseif (preg_match('/^(KEY) `(.*?)`\s+\((.*?)\)/', $line, $c)) {
+ $m['key'][$c[1] . ' ' . $c[2]] = $c[3];
}
- elseif (preg_match("/^`(.*?)`\s+(.*?)$/", $line, $c)) {
+ elseif (preg_match('/^`(.*?)`\s+(.*?)$/', $line, $c)) {
$m['field'][$c[1]] = str_replace('`', '', $c[2]);
}
}
@@ -26,112 +27,72 @@ function seenthisoc_lire_create_table($x) {
return $m;
}
-/*
-function seenthisoc_declarer_tables_interfaces($interface){
- return $interface;
-}
-function seenthisoc_declarer_tables_objets_surnoms($interface){
- return $interface;
-}
-function seenthisoc_declarer_tables_principales($tables_principales){
- return $tables_principales;
-}
-*/
-
-function seenthisoc_declarer_tables_auxiliaires($tables_auxiliaires){
- /*
- $tables_auxiliaires['spip_syndic_oc'] = seenthis_lire_create_table(
- "
- `id_syndic` bigint(21) NOT NULL,
- `id_mot` bigint(21) NOT NULL,
- `relevance` int(11) NOT NULL,
- `off` varchar(3) NOT NULL DEFAULT 'non',
- KEY `id_syndic` (`id_syndic`),
- KEY `id_mot` (`id_mot`)
-"
- );
- */
-
-## table cree a l'upgrade, par injection des donneesÉ
-/*
- $tables_auxiliaires['spip_oc_uri'] = seenthis_lire_create_table(
- "
- `uri` text NOT NULL,
- `relevance` int(11) NOT NULL,
- `off` varchar(3) NOT NULL DEFAULT 'non',
- `tag` longtext NOT NULL
-"
-## SPIP 2.1 n'accepte pas les KEY avec (60)
-## on l'ajoute a la main plus bas
-# KEY `tag` (`tag`(60)),
-# KEY `uri` (`uri`(60)),
- );
-*/
-
+function seenthisoc_declarer_tables_auxiliaires($tables_auxiliaires) {
return $tables_auxiliaires;
-
}
-function seenthisoc_upgrade($nom_meta_base_version,$version_cible){
+function seenthisoc_upgrade($nom_meta_base_version, $version_cible) {
$current_version = 0.0;
- if ((!isset($GLOBALS['meta'][$nom_meta_base_version]) )
- || (($current_version = $GLOBALS['meta'][$nom_meta_base_version])!=$version_cible)){
+ if (
+ (!isset($GLOBALS['meta'][$nom_meta_base_version]) )
+ || (($current_version = $GLOBALS['meta'][$nom_meta_base_version]) != $version_cible)
+ ) {
include_spip('base/abstract_sql');
- if (version_compare($current_version,"1.0.2",'<')){
+ if (version_compare($current_version, '1.0.2', '<')) {
include_spip('base/serial');
include_spip('base/auxiliaires');
include_spip('base/create');
creer_base();
- maj_tables(array(
+ maj_tables([
'spip_syndic_oc',
- ));
-
- if (version_compare($current_version,"1.0.2",'<')) {
+ ]);
+
+ if (version_compare($current_version, '1.0.2', '<')) {
seenthisoc_recuperer_tags_102();
- sql_query("ALTER TABLE spip_oc_uri ADD INDEX `tag` (`tag`(60))");
- sql_query("ALTER TABLE spip_oc_uri ADD INDEX `uri` (`uri`(60))");
+ sql_query('ALTER TABLE spip_oc_uri ADD INDEX `tag` (`tag`(60))');
+ sql_query('ALTER TABLE spip_oc_uri ADD INDEX `uri` (`uri`(60))');
}
- /* pour la version suivante
- if (version_compare($current_version,"1.0.3",'<')) {
- sql_drop_table("spip_syndic_oc");
- }
- */
+ /**
+ * pour la version suivante
+ * if (version_compare($current_version,"1.0.3",'<')) {
+ * sql_drop_table("spip_syndic_oc");
+ * }
+ */
- ecrire_meta($nom_meta_base_version,$current_version=$version_cible,'non');
+ ecrire_meta($nom_meta_base_version, $current_version = $version_cible, 'non');
}
-
}
}
function seenthisoc_vider_tables($nom_meta_base_version) {
effacer_meta($nom_meta_base_version);
- sql_drop_table("spip_syndic_oc");
+ sql_drop_table('spip_syndic_oc');
}
-function seenthisoc_install($action,$prefix,$version_cible){
- $version_base = $GLOBALS[$prefix."_base_version"];
- switch ($action){
+function seenthisoc_install($action, $prefix, $version_cible) {
+ $version_base = $GLOBALS[$prefix . '_base_version'];
+ switch ($action) {
case 'test':
- $ok = (isset($GLOBALS['meta'][$prefix."_base_version"])
- AND version_compare($GLOBALS['meta'][$prefix."_base_version"],$version_cible,">="));
+ $ok = (isset($GLOBALS['meta'][$prefix . '_base_version'])
+ and version_compare($GLOBALS['meta'][$prefix . '_base_version'], $version_cible, '>='));
if (!function_exists('curl_init')) {
$ok = false;
- echo ""._L("nécessite @module@", array('module' => 'php-curl'))."
";
+ echo "" . _L('nécessite @module@', ['module' => 'php-curl']) . '
';
}
return $ok;
break;
case 'install':
- seenthisoc_upgrade($prefix."_base_version",$version_cible);
+ seenthisoc_upgrade($prefix . '_base_version', $version_cible);
break;
case 'uninstall':
- seenthisoc_vider_tables($prefix."_base_version");
+ seenthisoc_vider_tables($prefix . '_base_version');
break;
}
}
@@ -146,7 +107,4 @@ function seenthisoc_recuperer_tags_102() {
LEFT JOIN spip_groupes_mots AS g ON m.id_groupe=g.id_groupe
LEFT JOIN spip_syndic AS u ON u.id_syndic=a.id_syndic
");
-
}
-
-?>
\ No newline at end of file
diff --git a/composer.json b/composer.json
new file mode 100644
index 0000000..120497a
--- /dev/null
+++ b/composer.json
@@ -0,0 +1,27 @@
+{
+ "name": "seenthis/opencalais",
+ "description": "Sphinx pour Seenthis",
+ "license": "GPL-3.0-or-later",
+ "type": "spip-plugin",
+ "authors": [
+ {
+ "name": "Arno*",
+ "email": "arno@rezo.net"
+ }
+ ],
+ "require-dev": {
+ "dealerdirect/phpcodesniffer-composer-installer": "^1.0",
+ "phpcompatibility/php-compatibility": "10.x-dev",
+ "spip/coding-standards": "^1.3"
+ },
+ "config": {
+ "allow-plugins": {
+ "dealerdirect/phpcodesniffer-composer-installer": true
+ }
+ },
+ "extra": {
+ "branch-alias": {
+ "dev-master": "2.0.x-dev"
+ }
+ }
+}
diff --git a/paquet.xml b/paquet.xml
new file mode 100644
index 0000000..d7e5ecc
--- /dev/null
+++ b/paquet.xml
@@ -0,0 +1,18 @@
+
+
+ Seenthis - OpenCalais
+
+ ARNO*
+
+
+
+
+
+
+
diff --git a/php/opencalais.php b/php/opencalais.php
index b94e13a..90591cd 100644
--- a/php/opencalais.php
+++ b/php/opencalais.php
@@ -1,88 +1,92 @@
_errors = array();
-
- if( empty($accessToken) ) {
- $this -> _errors = array('Please enter unique access key as 1st parameter');
- return false;
- }
-
- // Init Header Params
- $headers = array(
- 'X-AG-Access-Token: '.$accessToken,
- "Content-Type: text/raw",
- 'Content-length: '.strlen($post_content),
- 'outputformat: application/json'
- );
-
- // Init Curl
- $curlOptions = array (
- CURLOPT_URL => $this -> _url,
- CURLOPT_HTTPHEADER => $headers,
- CURLOPT_SSL_VERIFYPEER => false,
- CURLOPT_RETURNTRANSFER => 1,
- CURLOPT_POSTFIELDS => $post_content,
- );
-
- $ch = curl_init();
- curl_setopt_array($ch,$curlOptions);
-
- // send request and get response from api..........
- $response = curl_exec($ch);
-
- // check cURL errors............
- if (curl_errno($ch)) {
- $this -> _errors = curl_error($ch);
+ /**
+ * Errors array init....
+ * @var array
+ */
+ public $_errors = [];
+
+ /**
+ * Request URL init...
+ * @var string
+ */
+ protected $_url = 'https://api-eit.refinitiv.com/permid/calais';
+
+ /**
+ * request function info....
+ *
+ * @param string $accessToken .....
+ * @return array / json Response array.....
+ */
+ public function request($accessToken, $post_content) {
+ $this -> _errors = [];
+
+ if (empty($accessToken)) {
+ $this -> _errors = ['Please enter unique access key as 1st parameter'];
+ return false;
+ }
+
+ // Init Header Params
+ $headers = [
+ 'X-AG-Access-Token: ' . $accessToken,
+ 'Content-Type: text/raw',
+ 'Content-length: ' . strlen($post_content),
+ 'outputformat: application/json'
+ ];
+
+ // Init Curl
+ $curlOptions = [
+ CURLOPT_URL => $this -> _url,
+ CURLOPT_HTTPHEADER => $headers,
+ CURLOPT_SSL_VERIFYPEER => false,
+ CURLOPT_RETURNTRANSFER => 1,
+ CURLOPT_POSTFIELDS => $post_content,
+ ];
+
+ $ch = curl_init();
+ curl_setopt_array($ch, $curlOptions);
+
+ // send request and get response from api..........
+ $response = curl_exec($ch);
+
+ // check cURL errors............
+ if (curl_errno($ch)) {
+ $this -> _errors = curl_error($ch);
spip_log($this -> _errors, 'opencalais');
- curl_close($ch);
- return false;
- } else {
- curl_close($ch);
- //print_r($response);
- $response = @json_decode($response);
- spip_log($response, 'opencalais');
- return $response;
- }
- }
+ curl_close($ch);
+ return false;
+ } else {
+ curl_close($ch);
+ //print_r($response);
+ $response = @json_decode($response);
+ spip_log($response, 'opencalais');
+ return $response;
+ }
+ }
}
function getOpenCalais($content) {
$apiKey = _OPENCALAIS_APIKEY;
-
+
$calais = new HTTPSClientCalaisPost();
$response = $calais->request($apiKey, $content);
- if (!is_object($response)) return false;
+ if (!is_object($response)) {
+ return false;
+ }
- $ret = array();
- foreach($response as $key => $val) {
- if ($key != "doc") $ret[$key] = $val;
+ $ret = [];
+ foreach ($response as $key => $val) {
+ if ($key != 'doc') { $ret[$key] = $val;
+ }
}
return $ret;
-
}
/*
@@ -92,13 +96,13 @@ function getOpenCalais($content) {
* - spip_oc_uri pour les textes récupérés sur des sites distants
*
*/
-function traiterOpenCalais($texte, $id, $id_tag="id_article", $lien) {
+function traiterOpenCalais($texte, $id, $id_tag = 'id_article', $lien) {
// Effacer les liens entre le mot et l'objet
// uniquement avec relevance > 0
// pour ne pas effacer les spip_me_mot des hashtags (qui n'ont pas de pondération)
-
-
+
+
$oc = getOpenCalais($texte);
if (!is_array($oc)) {
@@ -107,27 +111,27 @@ function traiterOpenCalais($texte, $id, $id_tag="id_article", $lien) {
}
// filtrer les $oc : on ne veut que les entities, et leur relevance
- $tags = array();
- foreach($oc as &$tag) {
+ $tags = [];
+ foreach ($oc as &$tag) {
if ($tag->_typeGroup == 'entities') {
$key = $tag->_type . ':' . $tag->name;
$relevance = $tag->relevance;
- $tags[$key] = round(1000*$relevance);
+ $tags[$key] = round(1000 * $relevance);
}
}
// NEW STYLE: spip_me_tags, pour les messages
if ($id_tag == 'id_me') {
// recuperer l'uuid
- $u = sql_fetsel('uuid', 'spip_me', 'id_me='.sql_quote($id));
+ $u = sql_fetsel('uuid', 'spip_me', 'id_me=' . sql_quote($id));
$uuid = $u['uuid'];
- $idoff = sql_allfetsel('tag', 'spip_me_tags', 'uuid='.sql_quote($uuid).' AND off="oui" AND class="oc"');
+ $idoff = sql_allfetsel('tag', 'spip_me_tags', 'uuid=' . sql_quote($uuid) . ' AND off="oui" AND class="oc"');
- sql_delete('spip_me_tags', 'uuid='.sql_quote($uuid).' AND class="oc"');
- foreach($tags as $tag => $relevance) {
+ sql_delete('spip_me_tags', 'uuid=' . sql_quote($uuid) . ' AND class="oc"');
+ foreach ($tags as $tag => $relevance) {
if ($relevance > 100) {
- $off = in_array(array('tag'=>$tag), $idoff);
- sql_insertq('spip_me_tags', $c = array(
+ $off = in_array(['tag' => $tag], $idoff);
+ sql_insertq('spip_me_tags', $c = [
'uuid' => $uuid,
'id_me' => $id,
'tag' => $tag,
@@ -135,7 +139,7 @@ function traiterOpenCalais($texte, $id, $id_tag="id_article", $lien) {
'class' => 'oc',
'off' => $off ? 'oui' : 'non',
'date' => 'NOW()'
- ));
+ ]);
}
}
}
@@ -143,26 +147,23 @@ function traiterOpenCalais($texte, $id, $id_tag="id_article", $lien) {
// spip_oc_uri, pour les sites
if ($id_tag == 'id_syndic') {
// recuperer l'uri
- $u = sql_fetsel('url_site', 'spip_syndic', 'id_syndic='.sql_quote($id));
+ $u = sql_fetsel('url_site', 'spip_syndic', 'id_syndic=' . sql_quote($id));
$uri = $u['url_site'];
- $idoff = sql_allfetsel('tag', 'spip_oc_uri', 'uri='.sql_quote($uri).' AND off="oui"');
+ $idoff = sql_allfetsel('tag', 'spip_oc_uri', 'uri=' . sql_quote($uri) . ' AND off="oui"');
- sql_delete('spip_oc_uri', 'uri='.sql_quote($uri));
- foreach($tags as $tag => $relevance) {
+ sql_delete('spip_oc_uri', 'uri=' . sql_quote($uri));
+ foreach ($tags as $tag => $relevance) {
if ($relevance > 300) {
- $off = in_array(array('tag'=>$tag), $idoff);
- sql_insertq('spip_oc_uri', $c = array(
+ $off = in_array(['tag' => $tag], $idoff);
+ sql_insertq('spip_oc_uri', $c = [
'uri' => $uri,
'tag' => $tag,
'relevance' => $relevance,
'off' => $off ? 'oui' : 'non'
- ));
+ ]);
}
}
}
return $tags;
-
}
-
-?>
diff --git a/phpcs.xml.dist b/phpcs.xml.dist
new file mode 100644
index 0000000..ad11e28
--- /dev/null
+++ b/phpcs.xml.dist
@@ -0,0 +1,13 @@
+
+
+ .
+ vendor/**/*
+
+
+
+
+
+
+
+
+
diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon
new file mode 100644
index 0000000..5bfea32
--- /dev/null
+++ b/phpstan-baseline.neon
@@ -0,0 +1,181 @@
+parameters:
+ ignoreErrors:
+ -
+ message: "#^Function _request not found\\.$#"
+ count: 2
+ path: action/lien_mot.php
+
+ -
+ message: "#^Function cache_message not found\\.$#"
+ count: 1
+ path: action/lien_mot.php
+
+ -
+ message: "#^Function generer_url_entite not found\\.$#"
+ count: 1
+ path: action/lien_mot.php
+
+ -
+ message: "#^Function include_spip not found\\.$#"
+ count: 1
+ path: action/lien_mot.php
+
+ -
+ message: "#^Function redirige_par_entete not found\\.$#"
+ count: 1
+ path: action/lien_mot.php
+
+ -
+ message: "#^Function sql_fetch not found\\.$#"
+ count: 2
+ path: action/lien_mot.php
+
+ -
+ message: "#^Function sql_query not found\\.$#"
+ count: 1
+ path: action/lien_mot.php
+
+ -
+ message: "#^Function sql_quote not found\\.$#"
+ count: 2
+ path: action/lien_mot.php
+
+ -
+ message: "#^Function sql_select not found\\.$#"
+ count: 1
+ path: action/lien_mot.php
+
+ -
+ message: "#^Function sql_updateq not found\\.$#"
+ count: 3
+ path: action/lien_mot.php
+
+ -
+ message: "#^Undefined variable\\: \\$id_mot$#"
+ count: 1
+ path: action/lien_mot.php
+
+ -
+ message: "#^Variable \\$id_mot might not be defined\\.$#"
+ count: 1
+ path: action/lien_mot.php
+
+ -
+ message: "#^Function _L not found\\.$#"
+ count: 1
+ path: base/seenthisoc.php
+
+ -
+ message: "#^Function creer_base not found\\.$#"
+ count: 1
+ path: base/seenthisoc.php
+
+ -
+ message: "#^Function ecrire_meta not found\\.$#"
+ count: 1
+ path: base/seenthisoc.php
+
+ -
+ message: "#^Function effacer_meta not found\\.$#"
+ count: 1
+ path: base/seenthisoc.php
+
+ -
+ message: "#^Function include_spip not found\\.$#"
+ count: 4
+ path: base/seenthisoc.php
+
+ -
+ message: "#^Function maj_tables not found\\.$#"
+ count: 1
+ path: base/seenthisoc.php
+
+ -
+ message: "#^Function sql_drop_table not found\\.$#"
+ count: 1
+ path: base/seenthisoc.php
+
+ -
+ message: "#^Function sql_query not found\\.$#"
+ count: 3
+ path: base/seenthisoc.php
+
+ -
+ message: "#^Constant _OPENCALAIS_APIKEY not found\\.$#"
+ count: 1
+ path: php/opencalais.php
+
+ -
+ message: "#^Function spip_log not found\\.$#"
+ count: 3
+ path: php/opencalais.php
+
+ -
+ message: "#^Function sql_allfetsel not found\\.$#"
+ count: 2
+ path: php/opencalais.php
+
+ -
+ message: "#^Function sql_delete not found\\.$#"
+ count: 2
+ path: php/opencalais.php
+
+ -
+ message: "#^Function sql_fetsel not found\\.$#"
+ count: 2
+ path: php/opencalais.php
+
+ -
+ message: "#^Function sql_insertq not found\\.$#"
+ count: 2
+ path: php/opencalais.php
+
+ -
+ message: "#^Function sql_quote not found\\.$#"
+ count: 6
+ path: php/opencalais.php
+
+ -
+ message: "#^Function cache_message not found\\.$#"
+ count: 1
+ path: seenthisoc_options.php
+
+ -
+ message: "#^Function include_spip not found\\.$#"
+ count: 2
+ path: seenthisoc_options.php
+
+ -
+ message: "#^Function job_queue_add not found\\.$#"
+ count: 3
+ path: seenthisoc_options.php
+
+ -
+ message: "#^Function sql_fetch not found\\.$#"
+ count: 2
+ path: seenthisoc_options.php
+
+ -
+ message: "#^Function sql_fetsel not found\\.$#"
+ count: 1
+ path: seenthisoc_options.php
+
+ -
+ message: "#^Function sql_select not found\\.$#"
+ count: 2
+ path: seenthisoc_options.php
+
+ -
+ message: "#^Function texte_de_me not found\\.$#"
+ count: 1
+ path: seenthisoc_options.php
+
+ -
+ message: "#^Variable \\$tags might not be defined\\.$#"
+ count: 1
+ path: seenthisoc_options.php
+
+ -
+ message: "#^Variable \\$texte might not be defined\\.$#"
+ count: 4
+ path: seenthisoc_options.php
diff --git a/phpstan-constants.php b/phpstan-constants.php
new file mode 100644
index 0000000..d500c49
--- /dev/null
+++ b/phpstan-constants.php
@@ -0,0 +1,5 @@
+
- Seenthis - OpenCalais
- ARNO*
- 1.0.4
- stable
-
- OpenCalais pour Seenthis
-
- seenthisoc
- seenthisoc_options.php
-
-
- declarer_tables_auxiliaires
- base/seenthisoc.php
-
-
-
- seenthis_instance_objet
- thematiser
- seenthisoc_options.php
-
-
-
-
- 1.0.2
- base/seenthisoc.php
-
-
-
-
-
-
diff --git a/seenthisoc_options.php b/seenthisoc_options.php
index 6a6de8d..66156f6 100644
--- a/seenthisoc_options.php
+++ b/seenthisoc_options.php
@@ -1,17 +1,16 @@
10) {
- $tags = traiterOpenCalais($texte, $id_syndic, "id_syndic", "spip_syndic_oc");
+ $tags = traiterOpenCalais($texte, $id_syndic, 'id_syndic', 'spip_syndic_oc');
}
return $tags;
@@ -37,25 +36,18 @@ function OC_site($id_syndic) {
// afin de programmer une tache de thematisation par opencalais
// [ anciennement function oc_thematiser_message($id_me) ou OC_Site(id_syndic) ]
function seenthisoc_thematiser($flux) {
-
- # spip_log($flux, 'debug');
-
- if (in_array($flux['action'], array('update', 'create'))) {
-
+ if (in_array($flux['action'], ['update', 'create'])) {
if ($id_me = $flux['id_me']) {
-
- $p = sql_fetsel("id_parent", "spip_me", "id_me=$id_me");
+ $p = sql_fetsel('id_parent', 'spip_me', "id_me=$id_me");
if ($p['id_parent'] > 0) {
- job_queue_add('OC_message', 'thématiser message '.$p['id_parent'], array($p['id_parent']));
+ job_queue_add('OC_message', 'thématiser message ' . $p['id_parent'], [$p['id_parent']]);
} else {
- job_queue_add('OC_message', 'thématiser message '.$id_me, array($id_me));
+ job_queue_add('OC_message', 'thématiser message ' . $id_me, [$id_me]);
}
- } else if ($id_syndic = $flux['id_syndic']) {
- job_queue_add('OC_site', 'thématiser site '.$flux['url'], array($id_syndic));
+ } elseif ($id_syndic = $flux['id_syndic']) {
+ job_queue_add('OC_site', 'thématiser site ' . $flux['url'], [$id_syndic]);
}
}
return $flux;
}
-
-?>