-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
140 lines (134 loc) · 5.25 KB
/
index.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
<?php
// TODO: motore di ricerca libera, motore di ricerca filtri, inserire dati mancanti per i primi 20, paginazione
require_once("./includes/config.php");
include_once("./includes/dao.php");
$dao = new DAO();
$dao->setDb($db);
$genre_post = urldecode(filter_var($_GET['genre'],FILTER_SANITIZE_STRING,FILTER_FLAG_NO_ENCODE_QUOTES));
$album_year = filter_var($_GET['album_year'],FILTER_SANITIZE_STRING,FILTER_FLAG_NO_ENCODE_QUOTES);
$score_post = filter_var($_GET['score'],FILTER_SANITIZE_STRING,FILTER_FLAG_NO_ENCODE_QUOTES);
$submit = filter_var($_GET['submit'],FILTER_SANITIZE_STRING,FILTER_FLAG_NO_ENCODE_QUOTES);
if ($submit == "filter") {
$rows = $dao->filter_albums($genre_post,$album_year,$score_post);
}
else {
$rows = $dao->read_albums();
}
$genres = $dao->read_genres();
$years = $dao->read_years();
//var_dump($rows);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Pitchfork's Album review scores</title>
<?php include_once('./includes/head.php');?>
</head>
<body class="hp">
<h1>
Pitchfork's scores
<div class="since">(Albums, since August, 2018)</div>
</h1>
<div class="container">
<div id="search">
<form id="f1" name="f1" method="GET" >
<div class="row">
<div class="col-lg-3 col-md-6 col-sm-6 col-xs-12">
<select name="genre" id="genre">
<option value="">Choose genre</option>
<option value="">---</option>
<option value="">All</option>
<?php foreach($genres as $genre) { ?>
<option value="<?php echo urlencode($genre->genre);?>" <?php if ($genre_post == $genre->genre) {echo 'selected="selected"';}?>><?php echo $genre->genre;?></option>
<?php } ?>
</select>
</div>
<div class="col-lg-3 col-md-6 col-sm-6 col-xs-12">
<select name="album_year" id="album_year">
<option value="">Choose year</option>
<option value="">---</option>
<?php foreach($years as $year) {
$clean_year = str_replace(" • ","",$year->album_year);
$clean_year = str_replace("• ","",$clean_year);
$clean_year = str_replace("• ","",$clean_year);
$clean_year = trim($clean_year);
if ($clean_year != "") {
?>
<option value="<?php echo urlencode($clean_year);?>" <?php if ($album_year == $clean_year) {echo 'selected="selected"';}?>><?php echo $clean_year;?></option>
<?php } }?>
</select>
</div>
<div class="col-lg-3 col-md-6 col-sm-6 col-xs-12">
<select name="score" id="score">
<option value="">Choose score</option>
<option value="">---</option>
<?php
$scores = array(1,2,3,4,5,6,7,8,9,10);
foreach ($scores as $score) { ?>
<option value="<?php echo urlencode($score);?>" <?php if ($score_post == $score) {echo 'selected="selected"';}?>><?php echo $score." and something";?></option>
<?php } ?>
</select>
</div>
<div class="col-lg-3 col-md-6 col-sm-6 col-xs-12">
<button type="submit" name="submit" value="filter" id="submit">Filter</button>
<a href="export.php" style="display:inline-block; float:right; color: #fff; text-decoration:none; padding:4px 20px; background: #999; text-align:center;">Export csv</a>
</div>
</div>
</form>
</div>
<table class="minimal" id="scores">
<thead>
<tr>
<th>Date</th>
<th>Cover</th>
<th>Score</th>
<th>Author</th>
<th>Album</th>
<th>Genre</th>
<th>Label</th>
<th>Year</th>
</tr>
</thead>
</thead>
<tbody>
<?php foreach($rows as $item) { ?>
<tr class="row_<?php echo $item->id;?>">
<td>
<?php
//echo $item->pubdate;
$time = strtotime($item->review_date);
$newformat = date('d M Y',$time);
echo $newformat;
?>
</td>
<td>
<a href="<?php echo $item->link; ?>" target="_blank" title="<?php echo $item->description; ?>">
<?php if ($item->album_art) { ?>
<img src="<?php echo $item->album_art; ?>" width="80"/>
<?php } else { ?>
<img src="https://lamorbidamacchina.com/pitchforkscores/assets/images/lp_record_icon.png?123" width="80"/>
<?php } ?>
</a>
</td>
<?php
$more_than_80 = "";
$score_num = str_replace(".","",$item->score);
if ($score_num >= 80) {$more_than_80 = "circle_red";}
?>
<td><div class="circle <?php echo $more_than_80;?>"><?php echo $item->score; ?></div></td>
<td><?php echo $item->album_author; ?></td>
<td><a href="<?php echo $item->link; ?>" target="_blank" title="<?php echo $item->description; ?>"><?php echo $item->album_title; ?></a></td>
<td><?php echo $item->genre; ?></td>
<td><?php echo $item->album_label; ?></td>
<td><?php echo str_replace("• ","",$item->album_year); ?></td>
</tr>
<?php }?>
</tbody>
</table>
<p>
<br /><br />
All the content © 2018 Condé Nast. This website is intended as a python / php development excercise related to <a href="https://medium.com/@simogol/pitchfork-reviews-and-scores-a-quick-analysis-tool-in-python-and-php-e0895b8db629" target="_blank">this article</a>. I am not earning a penny from it.
</p>
</div>
</body>
</html>