Access to Package Documentation Expanded to Include Classes

Yesterday I posted a blog entry about a new feature that I added to Flex.org that made it easy to look up package documentation. Within minutes of posting I had a feature request to extend this to classes. In a few minutes today I added that feature to the script on the server, so you now have easy access to class documentation as well. The class documentation is dependent on proper cases for package and class names, so you’ll need to be careful about your upper and lower cases. But, heading to flex.org/mx.controls.Alert will now send you to the proper documentation page on Adobe’s LiveDocs.


For those of you interested, here’s the PHP code that does this. Its pretty simple – just 29 lines. Improvements are appreciated – just add them to the comments. This PHP script gets run on any 404 error for Flex.org.<?php$ArrayOfRequest = explode(".", $_SERVER["REQUEST_URI"]);$URL = "http://livedocs.adobe.com/flex/201/langref";$Package = "";$Class = FALSE;$firstchar = substr(end($ArrayOfRequest),0,1);if( ord( $firstchar) > 64 && ord($firstchar) < 91 )$Class = TRUE;if( $Class === FALSE ){foreach( $ArrayOfRequest as $Package ){$URL .= $Package."/";}header("Location: ".$URL."package-detail.html");}else{$ClassName = array_pop( $ArrayOfRequest );foreach( $ArrayOfRequest as $Package ){$URL .= $Package."/";}header( "Location: ".$URL.$ClassName.".html" );}?>