-
Notifications
You must be signed in to change notification settings - Fork 0
/
blogpost.php
148 lines (102 loc) · 8.81 KB
/
blogpost.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
141
142
143
144
145
<!DOCTYPE html>
<?php
include("inc/blogdata.php");
$individualblog = $_GET['blog'];
$full = $_GET['full'];
$grade = $_GET['grade'];
include("inc/header.php");
?>
<?php
// STEP 1 - creates an variable containing an array of IDs generated by the array_category function. Specify the input to pass to the search function
$test = array_category($blogpost,$individualblog);
// STEP 2 - Search function - outputs an array of IDs based on parameters of a foreach loop, and specified input value $grade
function array_category($blogpost,$individualblog){
$output = array();
foreach ($blogpost as $id => $item){
if($item["date"] == $individualblog){
$sort = $item["date"];
$output[$id] = $sort;
}
}
asort($output);
return array_keys($output);
}
// STEP 4 - function takes IDs and returns corresponding values from data.php
function get_grade($grade,$id,$item){
$hardgrade = ["V13","V12","V11","V10","V9","V8","V7","V6","V5","V4","V3","V2","V1"];
$classicgrade = ["V15","V14","V13","V11","V10","V9","V8","V7","V5/6","V4","V3","V2","V1"];
if($grade == "h"){$paragraph = $item['paragraph'];} else {$paragraph = str_replace($hardgrade,$classicgrade,$item['paragraph']);}
$blogdatecode = $item['date'];
if($grade == "TMI" or $grade == null){$blogtitle = $item['title'];}
if($grade == "h"){$blogtitle = $item['title'];} else {$blogtitle = str_replace($hardgrade,$classicgrade,$item['title']);}
$blogdate = $item['dateverbose'];
$imgwidth2 = $item['imgwidth'][0];
$imgwidth3 = $item['imgwidth'][1];
$imgwidth4 = $item['imgwidth'][2];
$imgwidth5 = $item['imgwidth'][3];
$imgwidth6 = $item['imgwidth'][4];
$imgwidth7 = $item['imgwidth'][5];
if(isset($item['paragraph'][0])){$paragraph1 = $paragraph[0];} else {$paragraph1 = "";}
if(isset($item['paragraph'][1])){$paragraph2 = $paragraph[1];} else {$paragraph2 = "";}
if(isset($item['paragraph'][2])){$paragraph3 = $paragraph[2];} else {$paragraph3 = "";}
if(isset($item['paragraph'][3])){$paragraph4 = $paragraph[3];} else {$paragraph4 = "";}
if(isset($item['paragraph'][4])){$paragraph5 = $paragraph[4];} else {$paragraph5 = "";}
if(isset($item['paragraph'][5])){$paragraph6 = $paragraph[5];} else {$paragraph6 = "";}
if(isset($item['paragraph'][6])){$paragraph7 = $paragraph[6];} else {$paragraph7 = "";}
$blogsummary = $item['summary'];
$image1 = "<img src='img/blo/".$item['date']."_1_1000.jpg.jpg"."' alt='none' class='w3-hover-opacity' width='100%' class='w3-center' sizes='(max-width:600px) 90vw, 768px' srcset='img/blo/".$item['date']."_1_600.jpg 600w, img/blo/".$item['date']."_1_1000.jpg 1000w, img/blo/".$item['date']."_1_1500.jpg 1500w'>";
if(isset($item['paragraph'][1])){
if($item['imglink'][0] != "n" xOR empty($item['imglink'][0])){
$image2 = "<a href='".$item['imglink'][0]."'><img src='img/blo/".$item['date']."_2_1000.jpg.jpg"."' alt='none' width='$imgwidth2' class='w3-center w3-hover-opacity' 90vw, 768px' srcset='img/blo/".$item['date']."_2_600.jpg 600w, img/blo/".$item['date']."_2_1000.jpg 1000w, img/blo/".$item['date']."_2_1500.jpg 1500w'></a>";
} else $image2 = "<img src='img/blo/".$item['date']."_2_1000.jpg.jpg"."' alt='none' width='$imgwidth2' class='w3-center' 90vw, 768px' srcset='img/blo/".$item['date']."_2_600.jpg 600w, img/blo/".$item['date']."_2_1000.jpg 1000w, img/blo/".$item['date']."_2_1500.jpg 1500w'>";} else {$image2 = "";}
if(isset($item['paragraph'][2])){
if($item['imglink'][1] != "n" xOR empty($item['imglink'][1])){
$image3 = "<a href='".$item['imglink'][1]."'><img src='img/blo/".$item['date']."_3_1000.jpg.jpg"."' alt='none' width='$imgwidth3' class='w3-center w3-hover-opacity' 90vw, 768px' srcset='img/blo/".$item['date']."_3_600.jpg 600w, img/blo/".$item['date']."_3_1000.jpg 1000w, img/blo/".$item['date']."_3_1500.jpg 1500w'></a>";
} else $image3 = "<img src='img/blo/".$item['date']."_3_1000.jpg.jpg"."' alt='none' width='$imgwidth3' class='w3-center' 90vw, 768px' srcset='img/blo/".$item['date']."_3_600.jpg 600w, img/blo/".$item['date']."_3_1000.jpg 1000w, img/blo/".$item['date']."_3_1500.jpg 1500w'>";} else {$image3 = "";}
if(isset($item['paragraph'][3])){
if($item['imglink'][2] != "n" xOR empty($item['imglink'][2])){
$image4 = "<a href='".$item['imglink'][2]."'><img src='img/blo/".$item['date']."_4_1000.jpg.jpg"."' alt='none' width='$imgwidth4' class='w3-center w3-hover-opacity' 90vw, 768px' srcset='img/blo/".$item['date']."_4_600.jpg 600w, img/blo/".$item['date']."_4_1000.jpg 1000w, img/blo/".$item['date']."_4_1500.jpg 1500w'></a>";
} else $image4 = "<img src='img/blo/".$item['date']."_4_1000.jpg.jpg"."' alt='none' width='$imgwidth4' class='w3-center' 90vw, 768px' srcset='img/blo/".$item['date']."_4_600.jpg 600w, img/blo/".$item['date']."_4_1000.jpg 1000w, img/blo/".$item['date']."_4_1500.jpg 1500w'>";} else {$image4 = "";}
if(isset($item['paragraph'][4])){
if($item['imglink'][3] != "n" xOR empty($item['imglink'][3])){
$image5 = "<a href='".$item['imglink'][3]."'><img src='img/blo/".$item['date']."_5_1000.jpg.jpg"."' alt='none' width='$imgwidth5' class='w3-center w3-hover-opacity' 90vw, 768px' srcset='img/blo/".$item['date']."_5_600.jpg 600w, img/blo/".$item['date']."_5_1000.jpg 1000w, img/blo/".$item['date']."_5_1500.jpg 1500w'></a>";
} else $image5 = "<img src='img/blo/".$item['date']."_5_1000.jpg.jpg"."' alt='none' width='$imgwidth5' class='w3-center' 90vw, 768px' srcset='img/blo/".$item['date']."_5_600.jpg 600w, img/blo/".$item['date']."_5_1000.jpg 1000w, img/blo/".$item['date']."_5_1500.jpg 1500w'>";} else {$image5 = "";}
if(isset($item['paragraph'][5])){
if($item['imglink'][4] != "n" xOR empty($item['imglink'][4])){
$image6 = "<a href='".$item['imglink'][4]."'><img src='img/blo/".$item['date']."_6_1000.jpg.jpg"."' alt='none' width='$imgwidth6' class='w3-center w3-hover-opacity' 90vw, 768px' srcset='img/blo/".$item['date']."_6_600.jpg 600w, img/blo/".$item['date']."_6_1000.jpg 1000w, img/blo/".$item['date']."_6_1500.jpg 1500w'></a>";
} else $image6 = "<img src='img/blo/".$item['date']."_6_1000.jpg.jpg"."' alt='none' width='$imgwidth6' class='w3-center' 90vw, 768px' srcset='img/blo/".$item['date']."_6_600.jpg 600w, img/blo/".$item['date']."_6_1000.jpg 1000w, img/blo/".$item['date']."_6_1500.jpg 1500w'>";} else {$image6 = "";}
if(isset($item['paragraph'][6])){
if($item['imglink'][5] != "n" xOR empty($item['imglink'][5])){
$image7 = "<a href='".$item['imglink'][5]."'><img src='img/blo/".$item['date']."_7_1000.jpg.jpg"."' alt='none' width='$imgwidth7' class='w3-center w3-hover-opacity' 90vw, 768px' srcset='img/blo/".$item['date']."_7_600.jpg 600w, img/blo/".$item['date']."_7_1000.jpg 1000w, img/blo/".$item['date']."_7_1500.jpg 1500w'></a>";
} else $image7 = "<img src='img/blo/".$item['date']."_7_1000.jpg.jpg"."' alt='none' width='$imgwidth7' class='w3-center' 90vw, 768px' srcset='img/blo/".$item['date']."_7_600.jpg 600w, img/blo/".$item['date']."_7_1000.jpg 1000w, img/blo/".$item['date']."_7_1500.jpg 1500w'>";} else {$image7 = "";}
$bloglink = "/blogpost.php?blog=".$item['date'];
$blogyoutube = $item["youtube"];
$output = "<title>".$blogtitle."</title><div class='blog-row-padding w3-content w3-center w3-large blog-text'><div><div class='w3-container w3-white w3-card'><h2 class='w3-wide'>".$blogtitle."</h2><p class='w3-opacity'><i>".$blogdate."</i></p></div><a href='".$blogyoutube."'>".$image1."</a><div class='w3-container w3-white w3-card'><p class='w3-left-align'>".$paragraph1."</p>".$image2."<p class='w3-left-align'>".$paragraph2."</p>".$image3."<p class='w3-left-align'>".$paragraph3."</p>".$image4."<p class='w3-left-align'>".$paragraph4."</p>".$image5."<p class='w3-left-align'>".$paragraph5."</p>".$image6."<p class='w3-left-align'>".$paragraph6."</p>".$image7."<p class='w3-left-align'>".$paragraph7."</p>";
return $output;
}
?>
<!-- !PAGE CONTENT! -->
<div class="w3-main" style="margin-left:250px">
<!-- Site Header -->
<div class="w3-display-container w3-container bgimg backgroundimage">
</div>
<!-- Blog post photo grid -->
<div class="w3-light-grey w3-row-padding w3-padding-16 w3-center">
<h5 class="w3-center w3-light-grey"><span class="w3-tag w3-wide">BLOG</span></h5>
</div>
<!-- First Row -->
<div class="w3-light-grey w3-center" id="food" style="margin-top:0px;">
<div class="w3-light-grey w3-center" id="food" style="margin-top:0px;">
<?php
// STEP 4 code the calls the results of the sorted and formatted search array and inserts results into the page
foreach ($test as $id){
echo get_grade($grade,$id,$blogpost[$id]);
}
?>
<!-- Blog post -->
<!-- END BLOG ENTRIES -->
</div>
</div>
<?php include("inc/footer.php");?>
</body>
</html>