Created
October 29, 2012 10:27
-
-
Save rakotomandimby/3972830 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 PersonModel | |
{ | |
public static function getPersonIds() | |
{ | |
$xml = new XMLReader(); | |
$tmp = $xml->open('encheres.xml'); | |
while($xml->read()) | |
{ | |
if(('person' == $xml->name) && ($xml->nodeType == XMLReader::ELEMENT)) | |
{ | |
$result[]=$xml->getAttribute('id'); | |
} | |
} | |
return $result; | |
} | |
} |
This file contains hidden or 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 PersonView | |
{ | |
public function renderPersonIdList($person_id_array) | |
{ | |
$result = '<html><head></head><body>'; | |
$result .= '<ul>'; | |
foreach($person_id_array as $un_id) | |
{ | |
$result .= '<li><a href="?person='.$un_id.'">'.$un_id.'</a></li>'; | |
} | |
$result .= '</ul>'; | |
$result .= '</body></html>'; | |
return $result; | |
} | |
} |
This file contains hidden or 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/PersonModel.php'); | |
require_once('View/PersonView.php'); | |
if($_REQUEST['q'] == 'liste-personnes') | |
{ | |
$person_id_array=PersonModel::getPersonIds(); | |
$view = new PersonView(); | |
$output = $view->renderPersonIdList($person_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