Skip to content

Instantly share code, notes, and snippets.

@rakotomandimby
Created October 29, 2012 10:27
Show Gist options
  • Save rakotomandimby/3972830 to your computer and use it in GitHub Desktop.
Save rakotomandimby/3972830 to your computer and use it in GitHub Desktop.
<?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;
}
}
<?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;
}
}
<?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