return $filtered;
}
+function filterBySearchWord($origGames, $searchWord)
+{
+ $filtered = [];
+ foreach ($origGames as $game) {
+ if (stripos($game->title, $searchWord) !== false) {
+ $filtered[] = $game;
+ }
+ }
+ return $filtered;
+}
+
function filterLastUpdated($origGames, $limit)
{
$games = array_values($origGames);
return array_slice($games, 0, $limit);
}
+
+function sortByTitle($games)
+{
+ usort(
+ $games,
+ function ($gameA, $gameB) {
+ return strcasecmp($gameA->title, $gameB->title);
+ }
+ );
+ return $games;
+}
?>
buildMakeCategory('Tutorials', filterByGenre($games, 'Tutorials'))
);
+$searchLetters = 'abcdefghijklmnopqrstuvwxyz0123456789., ';
+foreach (str_split($searchLetters) as $letter) {
+ $letterGames = filterBySearchWord($games, $letter);
+ writeJson(
+ 'api/v1/search-data/' . $letter . '.json',
+ buildSearch($letterGames)
+ );
+}
function buildDiscover(array $games)
filterBestRated($games, 10)
);
- usort(
- $games,
- function ($gameA, $gameB) {
- return strcasecmp($gameA->title, $gameB->title);
- }
- );
+ $games = sortByTitle($games);
$chunks = array_chunk($games, 4);
foreach ($chunks as $chunkGames) {
addDiscoverRow($data, '', $chunkGames);
'tiles' => [],
];
- usort(
- $games,
- function ($gameA, $gameB) {
- return strcasecmp($gameA->title, $gameB->title);
- }
- );
+ $games = sortByTitle($games);
addDiscoverRow($data, '', $games);
return $data;
return $encryptedTwice;
}
+function buildSearch($games)
+{
+ $games = sortByTitle($games);
+ $results = [];
+ foreach ($games as $game) {
+ $results[] = [
+ 'title' => $game->title,
+ 'url' => 'ouya://launcher/details?app=' . $game->packageName,
+ 'contentRating' => $game->contentRating,
+ ];
+ }
+ return [
+ 'count' => count($results),
+ 'results' => $results,
+ ];
+}
+
function dummyEncrypt($data)
{
return [
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^api/v1/games/(.+)/purchases?$ /api/v1/games/purchases-empty.json [END]
+#search
+# q is first parameter
+RewriteCond %{QUERY_STRING} ^q=([^&]+)
+RewriteCond %{DOCUMENT_ROOT}/api/v1/search-data/%1.json -f
+RewriteRule ^api/v1/search /api/v1/search-data/%1.json? [END]
+# q is not the first parameter
+RewriteCond %{QUERY_STRING} &q=([^&]+)
+RewriteCond %{DOCUMENT_ROOT}/api/v1/search-data/%1.json -f
+RewriteRule ^api/v1/search /api/v1/search-data/%1.json? [END]
+
#this one wants a 204 status code
RewriteRule ^api/v1/status$ - [R=204,L]