Example #1
0
 /**
  * Méthode qui parse l'article du fichier $filename
  * 
  * @param	filename	fichier de l'article à parser
  * @return	array
  * @author	Anthony GUÉRIN, Florent MONTHEL, Stéphane F
  **/
 public function parseArticle($filename)
 {
     # Mise en place du parseur XML
     $data = implode('', file($filename));
     $parser = xml_parser_create(PLX_CHARSET);
     xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
     xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 0);
     xml_parse_into_struct($parser, $data, $values, $iTags);
     xml_parser_free($parser);
     # Recuperation des valeurs de nos champs XML
     $art['title'] = trim($values[$iTags['title'][0]]['value']);
     $art['allow_com'] = trim($values[$iTags['allow_com'][0]]['value']);
     $art['template'] = isset($iTags['template']) ? trim($values[$iTags['template'][0]]['value']) : 'article.php';
     $art['chapo'] = isset($values[$iTags['chapo'][0]]['value']) ? trim($values[$iTags['chapo'][0]]['value']) : '';
     $art['content'] = isset($values[$iTags['content'][0]]['value']) ? trim($values[$iTags['content'][0]]['value']) : '';
     $art['tags'] = isset($values[$iTags['tags'][0]]['value']) ? trim($values[$iTags['tags'][0]]['value']) : '';
     # Informations obtenues en analysant le nom du fichier
     $art['filename'] = $filename;
     $tmp = $this->artInfoFromFilename($filename);
     $art['numero'] = $tmp['artId'];
     $art['author'] = $tmp['usrId'];
     $art['categorie'] = $tmp['catId'];
     $art['url'] = $tmp['artUrl'];
     $art['date'] = plxDate::dateToIso($tmp['artDate'], $this->aConf['delta']);
     # On recupere le nombre de commentaires de cet article si besoin est
     if ($this->mode != 'article') {
         # En mode article, on a cette information autrement
         $motif = '/^' . $art['numero'] . '.[0-9]{10}.[0-9]+.xml$/';
         $art['nb_com'] = $this->getNbCommentaires($motif);
     }
     # On retourne le tableau
     return $art;
 }