--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/enmi12/glossaire/writeWords.php Wed Nov 06 03:21:17 2013 +0000
@@ -0,0 +1,84 @@
+ <!DOCTYPE html>
+ <html class="no-js">
+ <head>
+ <meta charset="iso-8859-1">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1, charset=iso-8859-1">
+ <title></title>
+ <meta name="description" content="">
+ <meta name="viewport" content="width=device-width">
+
+ <!-- Place favicon.ico and apple-touch-icon.png in the root directory -->
+
+ <link rel="stylesheet" href="css/normalize.css">
+ <link rel="stylesheet" href="css/style.css">
+ <!--<script src="js/vendor/modernizr-2.6.2.min.js"></script>-->
+ </head>
+ <body>
+<?php
+function removeAccents($str, $charset='utf-8')
+ {
+ $str = htmlentities($str, ENT_NOQUOTES, $charset);
+
+ $str = preg_replace('#&([A-za-z])(?:acute|cedil|circ|grave|orn|ring|slash|th|tilde|uml);#', '\1', $str);
+ $str = preg_replace('#&([A-za-z]{2})(?:lig);#', '\1', $str); // pour les ligatures e.g. 'œ'
+ $str = preg_replace('#&[^;]+;#', '', $str);
+ $str = str_replace(' ','',$str);
+
+ return $str;
+ }
+function writeLinks(){
+ $document = 'mots.xml';
+ $document_xml = new DomDocument();
+ $document_xml->load($document);
+ $elements = $document_xml->getElementsByTagName('glossaire');
+ $resultat_html = '';
+ $arbre = $elements->item(0);
+
+ $mots = $arbre -> childNodes;
+
+ $monfichier = fopen('mots.txt', 'r+');
+ fseek($monfichier, 0);
+
+ $value = 0;
+
+ foreach($mots as $mot){
+ if($mot->hasChildNodes()){
+ if($mot->hasAttributes()){
+ $wordName = $mot -> getAttribute('name');
+ $wordName = removeAccents($wordName);
+ $wordName = strtolower($wordName);
+ echo($wordName);
+ }
+ else{
+ echo($mot -> nodeValue);
+ }
+
+ if(isset($wordName)){
+ $wordUrl = 'http://enmi12.org/glossaire/index.php?mot=' . $wordName;
+ }
+ else{
+ echo($mot -> nodeValue);
+ }
+
+ fseek($monfichier, 0, SEEK_END);
+
+ if(isset($wordName) && isset($wordUrl)){
+fputs($monfichier, '
+<link wordName="' . $wordName . '">
+ ' . $wordUrl . '
+</link>');
+ $value++;
+ echo($value);
+ }
+ }
+
+ }
+
+ fclose($monfichier);
+
+}
+
+writeLinks();
+?>
+</body>
+</html>
\ No newline at end of file