diff --git a/.gitattributes b/.gitattributes index b00cf5b5cfa839bbb4f84fc5d01b8694668afbfb..382cf9445b146d37a9f6afe2d8b81ea2be2aefc1 100644 --- a/.gitattributes +++ b/.gitattributes @@ -369,6 +369,7 @@ img_pack/soyezcreateurs_help-24.png -text img_pack/soyezcreateurs_help-48.png -text inc/sc_agenda.php -text inc/sc_article.php -text +inc/sc_utils.php -text inc/soyezcreateurs_ieconfig.php -text inc/soyezcreateurs_noizetier_config.php -text inc/titrer_document.php -text diff --git a/inc/sc_utils.php b/inc/sc_utils.php new file mode 100644 index 0000000000000000000000000000000000000000..84eabb0501e1e84d2370e2283513c490cb1318ff --- /dev/null +++ b/inc/sc_utils.php @@ -0,0 +1,38 @@ +<?php +/* +* Configuration de Noizetier pour SoyezCreateurs +* Realisation : RealET : real3t@gmail.com +*/ + +if (!defined('_ECRIRE_INC_VERSION')) return; + +include_spip('base/soyezcreateurs'); + +/* + Fonction pour changer les mots liés à un article : + - changer un mot pour un autre + - inverser 2 mots +*/ +function sc_mig_mot($mot_source, $gp_source, $mot_dest, $gp_dest, $inverser = false) { + $id_mot_source = id_mot($mot_source,id_groupe($gp_source)); + $id_mot_dest = id_mot($mot_dest,id_groupe($gp_dest)); + // Trouver les articles attachés à EDITO et ZoomSur + $Articles_Source = sql_allfetsel('id_objet', "spip_mots_liens", "id_mot=$id_mot_source AND objet='article'"); + if ($inverser) { + $Articles_Dest = sql_allfetsel('id_objet', "spip_mots_liens", "id_mot=$id_mot_dest AND objet='article'"); + } + if ($Articles_Source) { + foreach ($Articles_Source as $Article_Source) { + create_lien_mot($id_mot_dest, $Article_Source['id_objet'], 'article'); + delete_lien_mot($id_mot_source, $Article_Source['id_objet'], 'article'); + } + } + if ($inverser) { + if ($Articles_Dest) { + foreach ($Articles_Dest as $Article_Dest) { + create_lien_mot($id_mot_source, $Article_Dest['id_objet'], 'article'); + delete_lien_mot($id_mot_dest, $Article_Dest['id_objet'], 'article'); + } + } + } +} \ No newline at end of file