Created
October 29, 2012 10:15
-
-
Save rakotomandimby/3972754 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class ArticleModel | |
{ | |
public static function getArticleIds() | |
{ | |
$xml = new XMLReader(); | |
$tmp = $xml->open('encheres.xml'); | |
while($xml->read()) | |
{ | |
if(('item' == $xml->name) && ($xml->nodeType == XMLReader::ELEMENT)) | |
{ | |
$result[]=$xml->getAttribute('id'); | |
} | |
} | |
return $result; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class ArticleView | |
{ | |
public function renderArticleIdList($article_id_array) | |
{ | |
$result = '<html><head></head><body>'; | |
$result .= '<ul>'; | |
foreach($article_id_array as $un_id) | |
{ | |
$result .= '<li><a href="?article='.$un_id.'">'.$un_id.'</a></li>'; | |
} | |
$result .= '</ul>'; | |
$result .= '</body></html>'; | |
return $result; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require_once('Model/ArticleModel.php'); | |
require_once('View/ArticleView.php'); | |
if($_REQUEST['q'] == 'liste-articles') | |
{ | |
$article_id_array=ArticleModel::getArticleIds(); | |
$view = new ArticleView(); | |
$output = $view->renderArticleIdList($article_id_array); | |
print $output; | |
} | |
else | |
{print 'mauvais paramètres';} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment