|
|
@ -21,28 +21,17 @@ 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');
|
|
|
@ -57,8 +46,6 @@ class Parser
|
|
|
|
$link,
|
|
|
|
$link,
|
|
|
|
($mediaUrl !== null) ? (string)$mediaUrl : '',
|
|
|
|
($mediaUrl !== null) ? (string)$mediaUrl : '',
|
|
|
|
$flux->getId());
|
|
|
|
$flux->getId());
|
|
|
|
print("Tableau de l'article");
|
|
|
|
|
|
|
|
var_dump($tabArticle);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $tabArticle;
|
|
|
|
return $tabArticle;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
@ -73,16 +60,11 @@ class Parser
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public function parseAll($fluxes){
|
|
|
|
public function parseAll($fluxes){
|
|
|
|
$tabArticles = [];
|
|
|
|
$tabArticles = [];
|
|
|
|
print("debut parseAll</br>");
|
|
|
|
|
|
|
|
foreach ($fluxes as $flux){
|
|
|
|
foreach ($fluxes as $flux){
|
|
|
|
$fluxx = new Flux($flux[0],$flux[1]);
|
|
|
|
$fluxx = new Flux($flux[0],$flux[1]);
|
|
|
|
print("flux de parseAll</br>");
|
|
|
|
|
|
|
|
var_dump($fluxx);
|
|
|
|
|
|
|
|
$tabArticles[] = $this->parseArticles($fluxx);
|
|
|
|
$tabArticles[] = $this->parseArticles($fluxx);
|
|
|
|
print("fin parsqeAll</br>");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
var_dump($tabArticles);
|
|
|
|
|
|
|
|
return $tabArticles;
|
|
|
|
return $tabArticles;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -98,9 +80,6 @@ class Parser
|
|
|
|
foreach ($allItemFlux as $ItemFlux){
|
|
|
|
foreach ($allItemFlux as $ItemFlux){
|
|
|
|
$tabFluxes[] = $ItemFlux[1];
|
|
|
|
$tabFluxes[] = $ItemFlux[1];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
print("tableau de flux</br>");
|
|
|
|
|
|
|
|
var_dump($tabFluxes);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$allTabArticles = $this->parseAll($allItemFlux);
|
|
|
|
$allTabArticles = $this->parseAll($allItemFlux);
|
|
|
|
|
|
|
|
|
|
|
|
foreach ($allTabArticles as $tabArticle) {
|
|
|
|
foreach ($allTabArticles as $tabArticle) {
|
|
|
|