1 | <?php |
---|
2 | |
---|
3 | |
---|
4 | function documentation_pre_boucle($boucle){ |
---|
5 | // ARTICLES, RUBRIQUES : {par num titre, titre} |
---|
6 | if (in_array($boucle->type_requete, array('rubriques','articles')) |
---|
7 | AND !$boucle->order) { |
---|
8 | $boucle->select[] = "0+" . $boucle->id_table . ".titre AS autonum"; |
---|
9 | $boucle->order[] = "'autonum'"; |
---|
10 | $boucle->order[] = "'" . $boucle->id_table . ".titre'"; |
---|
11 | } |
---|
12 | return $boucle; |
---|
13 | } |
---|
14 | |
---|
15 | |
---|
16 | function documentation_jquery_plugins($plugins){ |
---|
17 | $plugins[] = "javascript/menu_documentation.js"; |
---|
18 | $plugins[] = "javascript/documentation.js"; |
---|
19 | return $plugins; |
---|
20 | } |
---|
21 | |
---|
22 | function documentation_insert_head($flux){ |
---|
23 | // pour les petites roues ajax de .animeajax() |
---|
24 | $flux .= " |
---|
25 | <script type='text/javascript'><!-- |
---|
26 | var ajax_image_searching = \"<img src='" . url_absolue(chemin_image("searching.gif")) . "' alt='' />\"; |
---|
27 | --></script> |
---|
28 | "; |
---|
29 | return $flux; |
---|
30 | } |
---|
31 | |
---|
32 | // valeurs par defaut sur les nouveaux tickets |
---|
33 | function documentation_formulaire_charger($flux){ |
---|
34 | if ($flux['args']['form'] == 'editer_ticket' |
---|
35 | and (!$flux['args']['args'][0] OR $flux['args']['args'][0] == 'oui') // nouveau ticket |
---|
36 | and !$flux['data']['type']) { |
---|
37 | $flux['data']['type'] = 2; |
---|
38 | $flux['data']['severite'] = 4; |
---|
39 | } |
---|
40 | return $flux; |
---|
41 | } |
---|
42 | |
---|
43 | |
---|
44 | // ajouter automatiquement des title "art30" sur les raccourcis [->art30] |
---|
45 | // donc, transformer [->art30] en [|art30->art30] |
---|
46 | // ce qui permet a l'integrale de gerer des numeros de pages sur les liens |
---|
47 | function documentation_pre_liens($texte){ |
---|
48 | // uniquement dans le public |
---|
49 | if (test_espace_prive()) return $texte; |
---|
50 | |
---|
51 | $regs = $match = array(); |
---|
52 | // pour chaque lien |
---|
53 | if (preg_match_all(_RACCOURCI_LIEN, $texte, $regs, PREG_SET_ORDER)) { |
---|
54 | foreach ($regs as $reg) { |
---|
55 | // si le lien est de type raccourcis "art40" |
---|
56 | if (preg_match(_RACCOURCI_URL, $reg[4], $match)) { |
---|
57 | $title = '|' . $match[1] . $match[2]; |
---|
58 | // s'il n'y a pas deja ce title |
---|
59 | if (false === strpos($reg[0], $title)) { |
---|
60 | $lien = substr_replace($reg[0], $title, strpos($reg[0], '->'), 0); |
---|
61 | $texte = str_replace($reg[0], $lien, $texte); |
---|
62 | } |
---|
63 | } |
---|
64 | } |
---|
65 | } |
---|
66 | return $texte; |
---|
67 | } |
---|
68 | |
---|
69 | // transformer les <a title="art30" href="xxx">zzz</a> |
---|
70 | // en <a href="#art30">zzz</a> (enfin <a title="art30" href="#art30">zzz</a> en attendant mieux) |
---|
71 | // seulement dans le squelette integrale |
---|
72 | // pour que le pdf puisse calculer les numero de page des liens |
---|
73 | function documentation_affichage_final($page){ |
---|
74 | // uniquement dans le public |
---|
75 | if (test_espace_prive()) return $page; |
---|
76 | |
---|
77 | if (_request('page') == 'integrale') { |
---|
78 | include_spip('inc/filtres'); |
---|
79 | include_spip('inc/lien'); |
---|
80 | $as = extraire_balises($page, 'a'); |
---|
81 | foreach($as as $a) { |
---|
82 | if ($title = extraire_attribut($a, 'title')) { |
---|
83 | if (preg_match(_RACCOURCI_URL, $title, $match)) { |
---|
84 | $old_a = $a; |
---|
85 | // on laisse le title parce que a[href|="#"] ne semble pas pris en compte avec Prince... |
---|
86 | // $a = vider_attribut($a, 'title'); |
---|
87 | $a = inserer_attribut($a, 'href', '#' . $title); |
---|
88 | $page = str_replace($old_a, $a, $page); |
---|
89 | } |
---|
90 | } |
---|
91 | } |
---|
92 | unset($as, $a, $old_a, $title); |
---|
93 | |
---|
94 | // INDEX |
---|
95 | // et dans la foulee : generer des liens d'index dans l'ordre de la page : |
---|
96 | // on cherche les <!-- index_moi:mot#ID_MOT --> |
---|
97 | if (preg_match_all('#<!-- index_moi:(mot\d+) -->#', $page, $regs, PREG_SET_ORDER)) { |
---|
98 | foreach ($regs as $reg) { |
---|
99 | $liens = array(); |
---|
100 | $trouve = 'id="('.$reg[1].'([[:alpha:]][^"]+))"'; // au moins un caractere car si "mot10" on pourrait trouver des "mot103rub4" |
---|
101 | if (preg_match_all("#$trouve#", $page, $ids, PREG_SET_ORDER)) { |
---|
102 | foreach ($ids as $id) { |
---|
103 | $interessant = ($id[2][0] == 'r'); // vers une rubrique... loin d'etre ideal |
---|
104 | $lien = "<a href='#$id[1]'></a>"; |
---|
105 | if ($interessant) $lien = '<strong>'.$lien.'</strong>'; |
---|
106 | $liens[] = $lien; |
---|
107 | } |
---|
108 | } |
---|
109 | $liens = implode(', ', $liens); |
---|
110 | $page = str_replace("<!-- index_moi:$reg[1] -->", $liens, $page); |
---|
111 | } |
---|
112 | } |
---|
113 | } |
---|
114 | return $page; |
---|
115 | } |
---|
116 | |
---|
117 | ?> |
---|