"; } return($lnk); } function en_fr($str){ if(preg_match('/( and | to )/',$str)) { $a_prep="des"; $p_prep="des"; } else { $a_prep="de"; $p_prep="du"; } $src = array('certain provisions', 'and', 'to', 'except ', 's.'); $repl = array("certaines dispositions", "et", "à", "à l'exception $a_prep l'", "art."); // $repl = array('certaines dispositions','et', 'à', 'à l\'exception de l\'art.', 'art.'); if(preg_match('/\([0-9]+\)/', $str)) { $repl = array("certaines dispositions", "et", "à", "à l'exception $p_prep ", "para." ); // $repl = array('certaines dispositions', 'et', 'à', 'à l\'exception du para.','para.'); } return(str_replace($src,$repl,$str)); } // SQL query to get Reg Title $sql = "SELECT title_f, last_am from regs "; $sql .= "LEFT JOIN regs_versions on regs.regnum = regs_versions.regnum "; $sql .= "WHERE regs.regnum = '" . $reg . "' AND regs_versions.archived = 0 AND consolidated = 1 LIMIT 1;"; // SQL query to get dates of archived versions $sql2 = "SELECT date_from, date_to, first_version, last_am from regs_versions where regnum = '" . $reg . "' AND archived = 1 ORDER by date_to DESC;"; // get a database connection and execute the two queries include_once($dir . "inc/db_connect.inc"); $rows = getRows($db,$sql); $rows2 = getRows($db,$sql2); $db->close(); unset($db); //output from the SQL queries if($rows) { echo ("

Règlement codifié (versions actuelles et précédentes)

\n"); echo ("

". $rows[0]['title_f'] .", R.M. ". $reg . "

\n"); echo ("

Version la plus à jour"); $mr = ""; $last_am = $rows[0]['last_am']; if(preg_match('/\//',$last_am)) { $mr = " R.M. " . en_fr($last_am); } else { $srch = array('SM','s.'); if(strstr($last_am,'(')) { $rep = array("L.M.","para."); }else{ $rep = array("L.M.","art."); } $mr = " " . str_replace($srch,$rep,$last_am); } echo (" (dernière modification :" . $mr . ")"); echo ("

Version(s) précedente(s) :\n"); if($rows2) { foreach ($rows2 as $row) { $item = "

 — "; $item .= "du " . dMMMy($row['date_from']) . " au "; $item .= dMMMy($row['date_to']) . ""; if($row['first_version']) { $item .= " (première version)"; } else { $last_am = $row['last_am']; if(strstr($last_am,'/')) { $mr = " R.M. " . en_fr($last_am); } else { $srch = array('SM','s.'); if(strstr($last_am,'(')) { $rep = array('L.M.','para.'); }else{ $rep = array('L.M.','art.'); } $mr = " " . str_replace($srch,$rep,$last_am); } $item .= " (dernière modification :". $mr .")"; } echo ($item); $first = $row['first_version']; } if (! $first) { echo("

 

\n"); echo ("

Note : Les versions codifiées antérieurement ne sont pas accessibles en ligne.

\n"); } unset($rows2); } unset($rows); } ?>