-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbrand_frontpage.php
156 lines (126 loc) · 5.2 KB
/
brand_frontpage.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
146
147
148
149
150
151
152
153
154
155
156
<?php
require_once("configuration.php");
$_BRANDFP = true;
if (!isset($_SESSION["LOGIN_USER"]))
{
header('Location: ' . $SITE_URL . '/subscription_block');
exit;
}
$brand = @$_GET["papbrand"];
if (!isset($_GET["papbrand"]))
{
die("ERROR: Paper brand not defined");
}
$papCnt = $dataconnection->query("SELECT paperID FROM papers WHERE paperBrand = '$brand'");
$pages = $papCnt->num_rows;
$dataquery = "SELECT brandCode, mainColor, secondColor, brandName, logoIMG, archived FROM paper_brands WHERE brandCode = '" . mysqli_real_escape_string($dataconnection, $brand) . "' LIMIT 1";
$dataresult = $dataconnection->query($dataquery);
if ($dataresult->num_rows <= 0)
{
die("paper data missing");
}
$brandCODE = "UNDEFINED";
$brandNAME = "UNDEFINED";
$mainCOLOR = "UNDEFINED";
$secondCOLOR = "UNDEFINED";
$logoIMG = "UNDEFINED";
$archived = 0;
while($papbrand = $dataresult->fetch_assoc())
{
$brandCODE = $papbrand["brandCode"];
$brandNAME = $papbrand["brandName"];
$mainCOLOR = $papbrand["mainColor"];
$secondCOLOR = $papbrand["secondColor"];
$logoIMG = $papbrand["logoIMG"];
$archived = $papbrand["archived"];
}
$dateresult = $dataconnection->query("SELECT paperPublished FROM papers WHERE paperBrand = '" . mysqli_real_escape_string($dataconnection, $brand) . "' ORDER BY paperPublished LIMIT 1");
$row = $dateresult->fetch_assoc();
include("includes/header.php");
?>
<script>
$(document).ready(function(){
loadFirstPage();
$('.search-panel .dropdown-menu').find('a').click(function(e) {
e.preventDefault();
var param = $(this).attr("href").replace("#","");
var concept = $(this).text();
$('.search-panel span#search_concept').text(concept);
$('.input-group #search_param').val(param);
});
$( "#searchBut" ).click(function() {
$("#results").html("<div class=\"col-xs-6 col-xs-offset-3\"><h2><i>Haetaan..</i></h2></div>");
$.post('/json_searchpapers.php',{'paper':'<?php echo $brandCODE; ?>', 'searchKeyword': document.getElementsByName('searchBox')[0].value }, function(data) {
$("#results").empty();
var searchResults = JSON.parse(JSON.stringify(data));
var papBrand = searchResults.paperBrand;
for (i = 0; i < searchResults.results.length; i++)
{
//$("#results").append(pageData.items[i].id);
var paperId = searchResults.results[i].paperId;
var pNumber = searchResults.results[i].pageNumber;
var paperId = searchResults.results[i].paperId;
var phraseTitle = searchResults.results[i].phraseTitle;
var phraseText = searchResults.results[i].phraseText;
var teaserImage = searchResults.results[i].teaserImage;
if (teaserImage == "")
{
teaserImage = "/assets/images/nophoto.png";
}
$("#results").append('<div class="col-lg-2 col-md-4 col-xs-6 thumb" style="margin-bottom: -99999px; padding-bottom: 99999px;"><a class="thumbnail" href="/paper/' + papBrand + '/read/' + paperId + '?page=' + pNumber + '"><img class="img-responsive" style="overflow: hidden;" src="' + teaserImage + '" alt="Uutiskuva"></a><b>' + phraseTitle + '</b><br><p class="phraseText" style="height: 100px; overflow: hidden;">' + phraseText + '</p></div>');
}
})
});
});
</script>
<h2 style="color: <?php echo $mainCOLOR; ?>; text-shadow: -1px 0 black, 0 1px black, 1px 0 black, 0 -1px black;">
<?php echo utf8_encode($brandNAME); ?>
</h2>
<?php if ($archived) {
echo "<p><i>Tämä lehtijulkaisija on arkistoitu. Uusia lehtiä ei enää ole tulossa ja aiemmat eivät ole mahdollisesti luettavissa. Julkaisija on vaihtanut alustaa.</i></p>";
}
?>
<div class="col-xs-5 col-xs-offset-3">
<div class="input-group">
<!-- <div class="input-group-btn search-panel">
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
<span id="search_concept">Suodata</span> <span class="caret"></span>
</button>
<ul class="dropdown-menu" role="menu">
<li><a href="#contains">Otsikko</a></li>
<li><a href="#its_equal">Sisältö</a></li>
</ul>
</div>
-->
<input type="hidden" name="search_param" value="all" id="search_param">
<input type="text" class="form-control" name="searchBox" placeholder="Etsitkö jotain? Kirjoita se tähän">
<span class="input-group-btn">
<button id="searchBut" class="btn btn-default" type="button"><span class="glyphicon glyphicon-search"></span></button>
</span>
</div>
</div>
<br><br>
<?php
if (isset($_GET["error"]))
{
$currentErr = "";
switch (intval($_GET["error"]))
{
case 1:
$currentErr = "<strong>Ounou!</strong> Lehtitietojen lataaminen epäonnistui. Ole hyvä ja yritä myöhemmin uudelleen.";
break;
default:
$currentErr = "Mitä sinä yrität!?";
break;
}
echo '<div class="alert alert-danger">
' . $currentErr . '
</div>';
}
?>
<div class="row" id="results"> <a href="#" onclick="loadFirstPage(); return false;"></a>
</div>
</div>
<?php
include("includes/footer.php");
?>