Sugree

Main menu

  • About
    • Self
  • Project
    • Barcode Generator / Reader
    • GT200
    • GeoPin
    • Mitter
    • Red Mob
    • Thairath Breaking News
    • Twitter Android SDK
    • jibjib
    • microblog-purple
    • English
    • Thai

Getting the latest release of Drupal

Submitted by sugree on Tue, 03/18/2008 - 01:00
  • Drupal
  • English

markpeak has been trying to improve introduction page at Drupal Thailand. His UI design skill is being increased. One thing he needed is to have download buttons directly linked to the latest versions at drupal.org. For example, the front page of Drupal has links to both Drupal 6.1 and Drupal 5.7 (20080318 00:55). It is possible to implement the same at Drupal Thailand using php snippet to fetch information just like update_status did.

<?php
 
function _release_fetch($project, $core_version) {
  global $base_url;
 
  $available = array();
  $data = array();
 
  $site_key = md5($base_url . drupal_get_private_key());
  $baseurl = "http://updates.drupal.org/release-history";
 
  $url = $baseurl . "/" . $project . "/" . $core_version;
  if (!empty($site_key)) {
    $url .= (strpos($url, '?') === TRUE) ? '&' : '?';
    $url .= 'site_key=';
    $url .= drupal_urlencode($site_key);
  }
  $xml = drupal_http_request($url);
  if (isset($xml->data)) { 
    $data[] = $xml->data;
  }
 
  if ($data) {
    $parser = new update_status_xml_parser;
    $info = $parser->parse($data);
    $available = array_shift($info[$project]["releases"]);
  }
  return $available;
}
 
function _release_get_available($cores) {
  if (($cache = cache_get('intro_release_info', 'cache'))
      && $cache->expire > time()) {
    $available = unserialize($cache->data);
  }
  else {
    $project = "drupal";
    $available = array();
    foreach ($cores as $core) {
      $available[$core] = _release_fetch($project, $core);
    }
    cache_set('intro_release_info', 'cache', serialize($available), time() + (60 * 60 * 24));
    variable_set('intro_release_last', time());
  }
  return $available;
}
 
function _release_link($info) {
  return l("Drupal " . $info["version"], $info["download_link"]);
}
 
$available = _release_get_available(array("6.x", "5.x"));
 
?>

After this point you are able to generate a link as follow.

<?php print _release_link($available["6.x"]) ?>
<?php print _release_link($available["5.x"]) ?>

Note that above code is based on update_status module. In Drupal 6.x, update_status_xml_parser must be changed to update_xml_parser.

Roti (alpha) thinks you may like these:
  • Getting Away
  • getting start flex/เริ่มต้นจับ flex
  • Getting Girls Attention
  • I am getting fat
  • Getting Started with VIM
  • Login to post comments
by mk (not verified) on Tue, 03/18/2008 - 03:01 #121

Need to think about Download button design.

  • Login to post comments
by Вечерний макияж глаз фото (not verified) on Thu, 05/15/2008 - 15:41 #263

I not understend what U want

  • Login to post comments

Popular Tags

Android BarCamp BarCampBangkok Book Django Drupal Education Family Google Hardware Hardy Health Interview Intrepid Java jibjib Joke Life microblog-purple OpenOffice.org OpenSource Podcast Python Review SoC Social Network Trip Twitter Ubuntu Weekly Suki
more tags

Powered By

debian
apache
drupal
drupal.in.th
openfreehost
inox
feedburner

© 2007-2008 Sugree Phatanapherom. Creative Commons [Feed Content / Comment]
RoopleTheme