Created
October 21, 2012 22:22
-
-
Save patrickkettner/3928735 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static function getSwarmUAIndex() { | |
// Lazy-init and cache | |
if ( self::$swarmUaIndex === null ) { | |
global $swarmContext; | |
global $swarmInstallDir; | |
if (isset($swarmContext)) {echo "i'm set!";}; | |
// Convert from array with string values | |
// to an object with boolean values | |
$swarmUaIndex = new stdClass; | |
$swarmInstallDir = dirname( __DIR__ ); | |
$defaultSettingsJSON = "$swarmInstallDir/config/defaultSettings.json"; | |
$defaultSettings = json_decode( file_get_contents( $defaultSettingsJSON ) ); | |
$browserSets = $defaultSettings->browserSets; | |
foreach ( $browserSets as $browserSetName => $browserSet ) { | |
foreach ( $browserSet as $browserSetIndex => $uaID ) { | |
$swarmUaIndex->$uaID = new stdClass(); | |
$swarmUaIndex->$uaID->displaytitle = self::formatDisplayTitle( $uaID ); | |
list($browserName) = explode("|", $uaID); | |
$swarmUaIndex->$uaID->displayicon = strtolower( str_replace( ' ', '_', $browserName ) ); | |
} | |
} | |
self::$swarmUaIndex = $swarmUaIndex; | |
} | |
return self::$swarmUaIndex; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment