<?php
/**
* Parse the Google SoC 2008 available to mentors at
* http://code.google.com/soc/2008/drupal/open.html
* in order to include it in a Drupal app
*
* @author FG Marand http://drupal.org/user/27985
* @license GPL2
*
* Usage: log to the SoC2008 site as a mentor, save the page to <your site>/files/soc.html,
* and go to <your site>/testcode
*
* WARNING: this is just demo code
*/
function testcode_menu($may_cache)
{
if ($may_cache)
{
(
'title' => 'Code de test',
'path' => 'testcode',
'callback' => 'testcode_test',
);
}
return $items;
}
function testcode_test()
{
$ret = '';
@$htmlDom = DOMDocument::loadHTML($unsafeFile);
$xml = simplexml_import_dom($htmlDom);
$appList = $xml->xpath('//table[@class="applist"]/tr');
foreach($appList as $row)
{
/**
* Note: trim() silently casts the SimpleXML elements to strings
*/
$class =
trim($row['class']) ==
'listrequestapp' ?
'Request' :
' ';
$link = $row->td[0]->table->tr[0]->td->a;
$l =
l(trim($link[0]),
$link['href']);
$ts = $row->td[0]->table->tr[1]->td;
$student =
trim($row->
td[1]);
$score =
trim($row->
td[3]);
(
'class' => $class,
'link' => $l,
'student' => $student,
'mentor' => $mentor,
'score' => $score,
);
}
/**
* Now we can format the table as wished
*/
$header =
array(t('Status'), t
('Project'), t
('Student'), t
('Mentor'), t
('Score'));
$ret =
theme('table',
$header,
$arApps);
return $ret;
}