-
Notifications
You must be signed in to change notification settings - Fork 35
/
Copy pathsearch.php
123 lines (106 loc) · 3.87 KB
/
search.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
<?php
/************************************************************************/
/* AContent */
/************************************************************************/
/* Copyright (c) 2010 */
/* Inclusive Design Institute */
/* */
/* This program is free software. You can redistribute it and/or */
/* modify it under the terms of the GNU General Public License */
/* as published by the Free Software Foundation. */
/************************************************************************/
define('TR_INCLUDE_PATH', '../include/');
include(TR_INCLUDE_PATH.'vitals.inc.php');
include_once(TR_INCLUDE_PATH.'handbook_pages.inc.php');
include_once(TR_INCLUDE_PATH.'classes/DAO/LanguageTextDAO.class.php');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict //EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html lang="<?php if ($missing_lang) { echo DEFAULT_LANGUAGE_CODE; } else { echo $req_lang; } ?>">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php echo _AT('Transformable_documentation'); ?></title>
<base target="body" />
<style>
body { font-family: Verdana,Arial,sans-serif; font-size: x-small; margin: 0px; padding: 0px; background: #fafafa; margin-left: -5px; }
ul, ol { list-style: none; padding-left: 0px; margin-left: -15px; }
li { margin-left: 19pt; padding-top: 2px; }
a { background-repeat: no-repeat; background-position: 0px 1px; padding-left: 12px; text-decoration: none; }
a.tree { background-image: url('../images/folder.gif'); }
a.leaf { background-image: url('../images/paper.gif'); }
a:link, a:visited { color: #006699; }
a:hover { color: #66AECC; }
</style>
</head>
<body>
<?php
echo '<a href="frame_toc.php" target="_self">';
echo _AT('back_to_contents');
echo '</a>';
if ($_GET['query']) {
$_GET['query'] = str_replace(',', ' ', $_GET['query']);
$_GET['query'] = str_replace('"', '', $_GET['query']);
if (strlen($_GET['query']) > 3) {
$_GET['query'] = strtolower($_GET['query']);
$search_terms = explode(' ', $_GET['query']);
$results = array();
$languageTextDAO = new LanguageTextDAO();
$final_match_rows = array();
foreach ($search_terms as $term)
{
$match_rows = $languageTextDAO->getHelpByMatchingText($term, $_SESSION['lang']);
if (is_array($match_rows)) $final_match_rows = array_merge($final_match_rows, $match_rows);
}
if (is_array($final_match_rows))
{
foreach ($final_match_rows as $match)
{
if (is_array($result))
$all_match_terms = array_keys($result);
else
$all_match_terms = array();
if (!in_array($match['term'], $all_match_terms))
{
$count = 0;
$contents = strtolower($match['text']);
foreach ($search_terms as $term)
{
$term = trim($term);
if ($term) {
$count += substr_count($contents, $term);
}
}
if ($count)
{
$results[$match['term']] = $count;
}
}
}
}
// replace term in match array with script name
if ($results)
{
arsort($results);
echo '<ol>';
foreach ($results as $term => $count)
{
foreach ($_pages as $this_page => $page_def)
{
if (strcmp($page_def['guide'], $term) == 0)
echo '<li><a href="frame_content.php?p='.$this_page.'" class="leaf" target="body">'._AT($page_def['title_var']).'</a></li>';
}
}
echo '</ol>';
} else {
echo '<p style="padding: 8px;">';
echo _AT('no_results_found');
echo '</p>';
}
} else {
echo '<p style="padding: 8px;">';
echo _AT('search_term_longer_3_chars');
echo '</p>';
}
}
?>
</body>
</html>