Commit | Line | Data |
---|---|---|
c495c100 P |
1 | <?php |
2 | ||
3 | /***************************************************************************\ | |
4 | * SPIP, Systeme de publication pour l'internet * | |
5 | * * | |
6 | * Copyright (c) 2001-2007 * | |
7 | * Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James * | |
8 | * * | |
9 | * Ce programme est un logiciel libre distribue sous licence GNU/GPL. * | |
10 | * Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. * | |
11 | \***************************************************************************/ | |
12 | ||
13 | if (!defined("_ECRIRE_INC_VERSION")) return; | |
14 | ||
15 | include_spip('inc/filtres'); | |
16 | ||
17 | // http://doc.spip.org/@action_referencer_traduction_dist | |
18 | function action_referencer_traduction_dist() { | |
19 | ||
20 | $securiser_action = charger_fonction('securiser_action', 'inc'); | |
21 | $arg = $securiser_action(); | |
22 | ||
23 | if (preg_match(",^(\d+)$,", $arg, $r) | |
24 | AND $trad = intval(_request('lier_trad'))) { | |
25 | include_spip('action/editer_article'); | |
26 | if ($err = article_referent($r[1], array('lier_trad' => $trad))) | |
27 | redirige_par_entete(urldecode(_request('redirect')) . $err); | |
28 | } elseif (preg_match(",^(\d+)\D-(\d+)$,", $arg, $r)) { | |
29 | // supprimer le lien de traduction | |
30 | spip_query("UPDATE spip_articles SET id_trad=0 WHERE id_article=" . $r[1]); | |
31 | // Verifier si l'ancien groupe ne comporte plus qu'un seul article. Alors mettre a zero. | |
32 | $cpt = spip_fetch_array(spip_query("SELECT COUNT(*) AS n FROM spip_articles WHERE id_trad=" . $r[2])); | |
33 | ||
34 | if ($cpt['n'] == 1) | |
35 | spip_query("UPDATE spip_articles SET id_trad = 0 WHERE id_trad=" . $r[2]); | |
36 | } elseif (preg_match(",^(\d+)\D(\d+)\D(\d+)$,", $arg, $r)) { | |
37 | // modifier le groupe de traduction de $r[1] (SQL le trouvera) | |
38 | spip_query("UPDATE spip_articles SET id_trad = " . $r[3] . " WHERE id_trad =" . $r[2]); | |
39 | } elseif (preg_match(",^(\d+)\D(\d+)$,", $arg, $r)) { | |
40 | instituer_langue_article($r[1],$r[2]); | |
41 | } else { | |
42 | spip_log("action_referencer_traduction_dist $arg pas compris"); | |
43 | } | |
44 | } | |
45 | ||
46 | // http://doc.spip.org/@instituer_langue_article | |
47 | function instituer_langue_article($id_article, $id_rubrique) { | |
48 | ||
49 | $changer_lang = _request('changer_lang'); | |
50 | ||
51 | if ($GLOBALS['meta']['multi_articles'] == 'oui' AND $changer_lang) { | |
52 | if ($changer_lang != "herit") | |
53 | spip_query("UPDATE spip_articles SET lang=" . _q($changer_lang) . ", langue_choisie='oui' WHERE id_article=$id_article"); | |
54 | else { | |
55 | $langue_parent = spip_fetch_array(spip_query("SELECT lang FROM spip_rubriques WHERE id_rubrique=" . $id_rubrique)); | |
56 | $langue_parent=$langue_parent['lang']; | |
57 | spip_query("UPDATE spip_articles SET lang=" . _q($langue_parent) . ", langue_choisie='non' WHERE id_article=$id_article"); | |
58 | include_spip('inc/lang'); | |
59 | calculer_langues_utilisees(); | |
60 | } | |
61 | } | |
62 | } | |
63 | ?> |