-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
executable file
·82 lines (73 loc) · 2.86 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
<?php
require_once 'base.php';
$searchValue = urldecode($_GET['search']);
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>sdf</title>
<script>
function showHideContent(docId) {
var el = document.getElementById('content_' + docId),
currentStatus = el.style.display,
newStatus = currentStatus === 'none' ? 'block' : 'none';
el.style.display = newStatus;
}
</script>
</head>
<body>
<h1>ir2015 търсачка</h1>
<form action="index.php" method="get">
<input type="text" name="search" placeholder="Търсене..." value="<?php echo $searchValue; ?>" />
<input type="submit" value="Търси" />
</form>
<?php
if (!empty($searchValue)) {
$searchEngine = new SearchEngine();
$searchResult = $searchEngine->search($searchValue);
if (empty($searchResult)) {
?>
<p>Няма резултати.</p>
<?php
} else {
?>
<ul style="list-style: none;">
<?php
foreach ($searchResult as $result) {
$encoding = mb_detect_encoding($result['content']);
?>
<li style="border-bottom: 1px solid #000; margin-bottom: 15px;">
<strong><?php echo $result['title']; ?></strong><br />
<em style="color: green;"><?php echo $result['file_name']; ?></em><br/>
<?php echo $result['summary']; ?><br />
<strong>Предложения: </strong>
<?php
$suggestions = array();
foreach($result['suggestions'] as $suggestion) {
$suggestions[] = '<a href="' . BASE_URL . 'index.php?search=' . $suggestion . '">' . $suggestion . '</a>';
}
unset($suggestion);
echo implode(' | ', $suggestions);
?><br />
<p style="text-decoration: underline; color: blue; cursor: pointer; "
onclick="showHideContent(<?php echo $result['id']; ?>)">Покажи/скрии целия текст</p>
<div style="padding: 15px; background-color: #eee; display: none;" id="content_<?php echo $result['id']; ?>">
<?php echo $result['content']; ?>
</div>
</li>
<?php
}
unset($result);
?>
</ul>
<?php
}
} else {
?>
<p>Можете да търсите сред <strong><?php echo Helper::getCountOfDocuments(); ?></strong> документа с <strong><?php echo Helper::getCountOfTerms(); ?></strong> индексирани думи. :)</p>
<?php
}
?>
</body>
</html>