|
|
@ -21,26 +21,44 @@ class Parser
|
|
|
|
}
|
|
|
|
}
|
|
|
|
public function parseArticles(Flux $flux): array
|
|
|
|
public function parseArticles(Flux $flux): array
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
print("debut parseArticles******************</br>");
|
|
|
|
$dom = new DOMDocument();
|
|
|
|
$dom = new DOMDocument();
|
|
|
|
|
|
|
|
print("creation du dom</br>");
|
|
|
|
$tabArticle = array();
|
|
|
|
$tabArticle = array();
|
|
|
|
|
|
|
|
|
|
|
|
if ($dom->load($flux->getFlux())){
|
|
|
|
if ($dom->load($flux->getFlux())){
|
|
|
|
$items = $dom->getElementsByTagName('item');
|
|
|
|
$items = $dom->getElementsByTagName('item');
|
|
|
|
|
|
|
|
print("après avoir getElementByTagName</br>");
|
|
|
|
|
|
|
|
var_dump($items);
|
|
|
|
foreach ($items as $item) {
|
|
|
|
foreach ($items as $item) {
|
|
|
|
$title = $item->getElementsByTagName('title')[0]->nodeValue;
|
|
|
|
$title = $item->getElementsByTagName('title')[0]->nodeValue;
|
|
|
|
|
|
|
|
print("le titre </br>");
|
|
|
|
|
|
|
|
var_dump($title);
|
|
|
|
$date = $item->getElementsByTagName('pubDate')[0]->nodeValue;
|
|
|
|
$date = $item->getElementsByTagName('pubDate')[0]->nodeValue;
|
|
|
|
|
|
|
|
print("la date </br>");
|
|
|
|
|
|
|
|
var_dump($date);
|
|
|
|
$guid = $item->getElementsByTagName('guid')[0]->nodeValue;
|
|
|
|
$guid = $item->getElementsByTagName('guid')[0]->nodeValue;
|
|
|
|
$link = $item->getElementsByTagName('link')[0]->nodeValue;
|
|
|
|
$link = $item->getElementsByTagName('link')[0]->nodeValue;
|
|
|
|
$description = $item->getElementsByTagName('description')[0]->nodeValue;
|
|
|
|
$description = $item->getElementsByTagName('description')[0]->nodeValue;
|
|
|
|
|
|
|
|
|
|
|
|
$media = $item->getElementsByTagName('media:content');
|
|
|
|
$media = $item->getElementsByTagName('media:content');
|
|
|
|
|
|
|
|
print("media : </br>");
|
|
|
|
|
|
|
|
var_dump($media);
|
|
|
|
$mediaUrl = null;
|
|
|
|
$mediaUrl = null;
|
|
|
|
if ($media->length > 0){
|
|
|
|
if ($media->length > 0){
|
|
|
|
$mediaUrl = $media->item(0)->getAttribute('url');
|
|
|
|
$mediaUrl = $media->item(0)->getAttribute('url');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$tabArticle[] = new Article((int)null, $title, $date, $description, $guid, $link, $mediaUrl, $flux->getId());
|
|
|
|
$tabArticle[] = new Article(
|
|
|
|
|
|
|
|
(int)null,
|
|
|
|
|
|
|
|
$title,
|
|
|
|
|
|
|
|
$date,
|
|
|
|
|
|
|
|
$description,
|
|
|
|
|
|
|
|
$guid,
|
|
|
|
|
|
|
|
$link,
|
|
|
|
|
|
|
|
($mediaUrl !== null) ? (string)$mediaUrl : '',
|
|
|
|
|
|
|
|
$flux->getId());
|
|
|
|
|
|
|
|
print("Tableau de l'article");
|
|
|
|
|
|
|
|
var_dump($tabArticle);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $tabArticle;
|
|
|
|
return $tabArticle;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
@ -55,10 +73,16 @@ class Parser
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public function parseAll($fluxes){
|
|
|
|
public function parseAll($fluxes){
|
|
|
|
$tabArticles = [];
|
|
|
|
$tabArticles = [];
|
|
|
|
|
|
|
|
print("debut parseAll</br>");
|
|
|
|
foreach ($fluxes as $flux){
|
|
|
|
foreach ($fluxes as $flux){
|
|
|
|
var_dump($flux);
|
|
|
|
$fluxx = new Flux($flux[0],$flux[1]);
|
|
|
|
$tabArticles[] =$this->parseArticles($flux);
|
|
|
|
print("flux de parseAll</br>");
|
|
|
|
|
|
|
|
var_dump($fluxx);
|
|
|
|
|
|
|
|
$tabArticles[] = $this->parseArticles($fluxx);
|
|
|
|
|
|
|
|
print("fin parsqeAll</br>");
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var_dump($tabArticles);
|
|
|
|
return $tabArticles;
|
|
|
|
return $tabArticles;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -71,16 +95,20 @@ class Parser
|
|
|
|
$this->articleGateway->removeAllArticleForParser();
|
|
|
|
$this->articleGateway->removeAllArticleForParser();
|
|
|
|
|
|
|
|
|
|
|
|
$allItemFlux = $this->fluxGateway->findAllFlux();
|
|
|
|
$allItemFlux = $this->fluxGateway->findAllFlux();
|
|
|
|
var_dump($allItemFlux);
|
|
|
|
|
|
|
|
foreach ($allItemFlux as $ItemFlux){
|
|
|
|
foreach ($allItemFlux as $ItemFlux){
|
|
|
|
$tabFluxes[] = $ItemFlux[1];
|
|
|
|
$tabFluxes[] = $ItemFlux[1];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$allArticles = $this->parseAll($tabFluxes);
|
|
|
|
print("tableau de flux</br>");
|
|
|
|
var_dump($allArticles);
|
|
|
|
var_dump($tabFluxes);
|
|
|
|
foreach ($allArticles as $article) {
|
|
|
|
|
|
|
|
$this->articleGateway->addArticle($article);
|
|
|
|
$allTabArticles = $this->parseAll($allItemFlux);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach ($allTabArticles as $tabArticle) {
|
|
|
|
|
|
|
|
foreach ($tabArticle as $item) {
|
|
|
|
|
|
|
|
$this->articleGateway->addArticle($item);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $allArticles;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|