DrupalBin
Submit Code
About
Recent Posts
TwitterFeed for D4D review
text
rewrite
Module to overrule the save settings of the "new node" form
Code
apidoc
Empty DateTime Object
Fix for listcars_manufacturer.module
listcars_manufacturer.info
listcars_manufacturer.module
more
User login
Log in using OpenID:
What is OpenID?
Username:
*
Password:
*
Log in using OpenID
Cancel OpenID login
Create new account
Request new password
Tags
CCK
drupal
fapi
jquery
menu
module
php
simpletest
test
theme
user
views
more tags
Home
›
Demo code to parse the Google SoC 2008 applications list available to mentors
Fix for Demo code to parse the Google SoC 2008 applications list available to mentors
View
Fix
Fixes are not saved to the database until you submit.
Summary:
Tags:
Any tags you'd like to associate with your code, delimitered by commas (example: Views, CCK, Module, etc).
Show summary in full view
<?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) { $items = array(); if ($may_cache) { $items[] = array ( 'title' => 'Code de test', 'path' => 'testcode', 'access' => user_access('administer nodes'), 'callback' => 'testcode_test', ); } return $items; } function testcode_test() { $ret = ''; $unsafeFile = file_get_contents('files/soc.html'); @$htmlDom = DOMDocument::loadHTML($unsafeFile); $xml = simplexml_import_dom($htmlDom); $arApps = array(); $appList = $xml->xpath('//table[@class="applist"]/tr'); array_shift($appList); 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]); $mentor = trim(strip_tags($row->td[2]->asXml())); $score = trim($row->td[3]); $arApps[] = array ( '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; }
Syntax highlighting mode:
ActionScript
ColdFusion
Diff
Drupal 5
Drupal 6
HTML
INI
Javascript
MySQL
PHP
Python
robots.txt
SQL
Text
Select the syntax highlighting mode to use.
See Also:
Order
Title:
URL:
-1
0
1
Title:
URL:
-1
0
1
Any links you'd like to have associated with the post (Drupal.org issue, Wikipedia article, etc).
File attachments
Changes made to the attachments are not permanent until you save this post. The first "listed" file will be included in RSS feeds.
Attach new file:
The maximum upload size is
1 MB
. Only files with the following extensions may be uploaded:
jpg jpeg gif png txt doc xls pdf ppt pps odt ods odp
.