3 * Take the generated JSON files and convert them to HTML for a browser
5 * @author Christian Weiske <cweiske@cweiske.de>
7 $wwwDir = __DIR__ . '/../www/';
8 $discoverDir = __DIR__ . '/../www/api/v1/discover-data/';
9 $wwwDiscoverDir = $wwwDir . 'discover/';
11 if (!is_dir($wwwDiscoverDir)) {
12 mkdir($wwwDiscoverDir, 0755);
15 foreach (glob($discoverDir . '*.json') as $discoverFile) {
16 $htmlFile = basename($discoverFile, '.json') . '.htm';
17 if ($htmlFile == 'discover.htm') {
18 $htmlFile = 'index.htm';
21 $wwwDiscoverDir . $htmlFile,
22 renderDiscoverFile($discoverFile)
26 function renderDiscoverFile($discoverFile)
28 $json = json_decode(file_get_contents($discoverFile));
30 $title = $json->title;
32 foreach ($json->rows as $row) {
34 'title' => $row->title,
37 foreach ($row->tiles as $tileId) {
38 $tileData = $json->tiles[$tileId];
39 if ($tileData->type == 'app') {
40 $section->tiles[] = (object) [
41 'type' => $tileData->type,//app
42 'thumb' => $tileData->image,
43 'title' => $tileData->title,
44 'rating' => $tileData->rating->average,
45 'ratingCount' => $tileData->rating->count,
46 'detailUrl' => '../game/' . str_replace(
47 'ouya://launcher/details?app=',
53 $section->tiles[] = (object) [
54 'type' => $tileData->type,//discover
55 'thumb' => $tileData->image,
56 'title' => $tileData->title,
57 'detailUrl' => str_replace(
58 'ouya://launcher/discover/',
65 $sections[] = $section;
68 $discoverTemplate = __DIR__ . '/../data/templates/discover.tpl.php';
70 include $discoverTemplate;
71 $html = ob_get_contents();