Drupal Project Movers and Shakers: The D-6000
Highlight: WYSIWYG API Gets Top Spot With 97% Growth (Feb 8th - March 29th)
Ever wondered which modules' userbase was growing fastest?
With a bit of simpleXML, 2 hours of boredom, and drupal.org's usage charts, I can provide an answer. Personally I thought the results were rather interesting.
This list only includes projects that got 6000 downloads or more last week. I picked 6000, because otherwise, ubercart wouldn't show up.
[menu_callback, and required function at end -- my toys are your toys, do with them as you like].
The Drupal 6000 [ Feb 8th - March 29th ]
And the surprisingly small, and ugly bit of code that produced this
function mover_shaker($file = 'http://localhost/usage.html') {
$xml = simple_get_xml($file);
$table = $xml->xpath('//table[@id="project-usage-all-projects"]');
$th = 0;
$header = array(array('data' => 'rank'), array('data' => 'project'),array('data'=> 'change'));
foreach($table[0]->thead->tr[0]->th as $key => $label) {
$labels[$th] = (string)$label->a[0];
$th++;
}
$i = 0;
$last_downloads = 3000;
if ($_GET['last_downloads']) {
$last_downloads = check_plain($_GET['last_downloads']);
}
foreach($table[0]->tbody[0]->tr as $key => $data) {
if ($first = str_replace(',', '', (string)$data->td[1]) > $last_downloads) {
if ((string)$data->td[8]) {
$project = l($data->td->a[0], 'http://www.drupal.org'.$data->td->a[0]['href']);
$first = str_replace(',', '', (string)$data->td[1]);
$last = str_replace(',', '', (string)$data->td[8]);
$change = $first - $last;
$percent = $change / $last;
$percent = number_format($percent,2)." %";
$key = $i++;
$rows[$percent.'-'.$i] = array($i,$project, $percent);
$i++;
}
}
}
ksort($rows);
$rows = array_reverse($rows);
$i = 1;
foreach($rows as $key => $row) {
$rows[$key][0] = $i;
$i++;
}
return theme('table', $header, $rows);
}
function simple_get_xml($url) {
$html = new DOMDocument();
@$html->loadHTMLFile($url);
// convert DOM to SimpleXML
$xml = simplexml_import_dom($html);
return $xml;
}
?>
Attachment | Size |
---|---|
Module file for this | 1.49 KB |