-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpagedata.php
executable file
·60 lines (44 loc) · 1.41 KB
/
pagedata.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
// grammar reference N5: https://en.wikibooks.org/wiki/JLPT_Guide/JLPT_N5_Grammar
function page($jfile) {
$string = file_get_contents($jfile);
$json_a = json_decode($string, true);
$gdata = $json_a['data'];
$html_elements = "";
// print "<pre>"; print_r($json_a);
$i = 0;
foreach($gdata as $key=>$item) {
// print "<h2>" . $i++ . " " . $key . "</h2>";
// print "<pre>"; print_r($item); exit(0);
$class = "";
foreach($item['class'] as $cl) {
$class .= $cl . " ";
}
$video = "";
$vid_i = 0;
if ( !empty($item['video']) ) {
foreach($item['video'] as $vid) {
$vid_i++;
$video .= "<p class='video{$vid_i}'><a href=$vid target='_blank'>video $vid_i</a></p>";
}
}
$meanings = "";
if ( !empty($item['meanings']) ) {
$meanings = $item['meanings'];
}
$template =<<<TEM
<div class="element-item $class " data-category="{$item['data_cat']}" style="background-image: url('img/{$item['img']}'); background-size: 100%;">
<h3 class="name">$key $meanings</h3>
<p class="symbol">{$item['symbol']}</p>
<p class="express">{$item['express']}</p>
<p class="example">{$item['example']}</p>
<p class="translate">{$item['translate']}</p>
<p class="number">{$item['number']}</p>
$video
<p class="level">{$item['level']}</p>
</div>
TEM;
$html_elements .= $template;
}
return $html_elements;
}