// info for highest version $highestVersion = ''; $highestVersionData = ''; while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) { // is this row for the current version? if ($line['extversion'] == $reqItemVersion) { // if so $thisVersionData = $line; } else { if (vercmp($reqItemVersion, $line['extversion']) > 0) { // did we already see an update with a higher version than this? if ($highestVersion != '' && vercmp($highestVersion, $line['extversion']) < 0) { continue; } // does this update support my current app version? if (vercmp($line['appmaxver'], $reqTargetAppVersion) > 0 || vercmp($reqTargetAppVersion, $line['appminver']) > 0) { continue; } $highestVersion = $line['extversion']; $highestVersionData = $line; } } } mysql_free_result($result); // // Now to spit out the RDF. We hand-generate because the data is pretty simple. // print "<?xml version=\"1.0\"?>\n"; print "<RDF:RDF xmlns:RDF=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\" xmlns:em=\"http://www.mozilla.org/2004/em-rdf#\">\n\n"; print "<RDF:Description about=\"urn:mozilla:extension:{$reqItemGuid}\">\n"; // output list of updates (just highest and this)
// info for this version $thisVersionData = ''; // info for highest version $highestVersionData = ''; $itemType = ''; while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) { if (empty($itemType)) { $itemType = $ext_typemap[$line['exttype']]; } // Do we already have the current or a newer one? if (vercmp($line['extversion'], $reqItemVersion[$i]) <= 0) { $thisVersionData = $line; break; } // Is this one compatible? if (vercmp($line['appmaxver'], $reqTargetAppVersion) >= 0 && vercmp($line['appminver'], $reqTargetAppVersion) <= 0) { $highestVersionData = $line; break; } // Keep going until we find one that is } print "<RDF:Description about=\"urn:mozilla:{$itemType}:{$reqItemGuid[$i]}\">\n"; // output list of updates (just highest and this) print " <em:updates><RDF:Seq>\n"; if (!empty($thisVersionData)) { print " <RDF:li resource=\"urn:mozilla:{$itemType}:{$reqItemGuid[$i]}:{$thisVersionData['extversion']}\"/>\n"; } if (!empty($highestVersionData)) { print " <RDF:li resource=\"urn:mozilla:{$itemType}:{$reqItemGuid[$i]}:{$highestVersionData['extversion']}\"/>\n"; } print " </RDF:Seq></em:updates>\n";