function documentation_pre_liens($texte){ // only for the public site if (test_espace_prive()) return $texte; $regs = $match = array(); // for each link if (preg_match_all(_RACCOURCI_LIEN, $texte, $regs, PREG_SET_ORDER)) { foreach ($regs as $reg) { // if the shortcut is of the form "art40" if (preg_match(_RACCOURCI_URL, $reg[4], $match)) { $title = '|' . $match[1] . $match[2]; // if this title doesn't already exist if (false === strpos($reg[0], $title)) { $lien = substr_replace($reg[0], $title, strpos($reg[0], '->'), 0); $texte = str_replace($reg[0], $lien, $texte); } } } } return $texte; }