remove old readme
[atutor.git] / docs / documentation / common / search.php
1 <?php require(dirname(__FILE__) . '/vitals.inc.php'); ?>\r
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict //EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">\r
3 <html lang="<?php if ($missing_lang) { echo 'en'; } else { echo $req_lang; } ?>">\r
4 <head>\r
5         <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />\r
6         <title><?php get_text('atutor_documentation'); ?></title>\r
7         <base target="body" />\r
8 <style>\r
9 body { font-family: Verdana,Arial,sans-serif; font-size: x-small; margin: 0px; padding: 0px; background: #fafafa; margin-left: -5px; }\r
10 ul, ol { list-style: none; padding-left: 0px; margin-left: -15px; }\r
11 li { margin-left: 19pt; padding-top: 2px; }\r
12 a { background-repeat: no-repeat; background-position: 0px 1px; padding-left: 12px; text-decoration: none; }\r
13 a.tree { background-image: url('folder.gif'); }\r
14 a.leaf { background-image: url('paper.gif'); }\r
15 a:link, a:visited { color: #006699; }\r
16 a:hover { color: #66AECC; }\r
17 </style>\r
18 </head>\r
19 <body>\r
20 <?php\r
21 require('../'.$section.'/pages.inc.php');\r
22 if (($req_lang != 'en') && (file_exists('../'.$section.'/'.$req_lang.'/pages.inc.php'))) {\r
23         require('../'.$section.'/'.$req_lang.'/pages.inc.php');\r
24 }\r
25 \r
26 echo '<a href="frame_toc.php?'.$section.'" target="_self">';\r
27 get_text('back_to_contents');\r
28 echo '</a>';\r
29 \r
30 if ($_GET['query']) {\r
31         $_GET['query'] = str_replace(',', ' ', $_GET['query']);\r
32         $_GET['query'] = str_replace('"', '', $_GET['query']);\r
33 \r
34         if (strlen($_GET['query']) > 3) {\r
35                 $_GET['query'] = strtolower($_GET['query']);\r
36 \r
37                 $search_terms = explode(' ', $_GET['query']);\r
38 \r
39                 $results = array();\r
40                 if ($req_lang == 'en') {\r
41                         $files = glob('../'.$section . '/*.php');\r
42                 } else {\r
43                         $files = glob('../'.$section . '/'.$req_lang.'/*.php');\r
44                 }\r
45                 if (is_array($files)) {\r
46                         foreach ($files as $filename) {\r
47                         \r
48                                 $count = 0;\r
49                                 $filename = basename($filename);\r
50                                 \r
51                                 if ($req_lang == 'en') {\r
52                                         $contents = strtolower(file_get_contents('../'.$section.'/'.$filename));\r
53                                 } else {\r
54                                         $contents = strtolower(file_get_contents('../'.$section. '/'.$req_lang.'/'.$filename));\r
55                                 }\r
56 \r
57                                 foreach ($search_terms as $term) {\r
58                                         $term = trim($term);\r
59                                         if ($term) {\r
60                                                 $count += substr_count($contents, $term);\r
61                                         }\r
62                                 }\r
63                                 if ($count) {\r
64                                         $results[$filename] = $count;\r
65                                 }\r
66                         }\r
67                 }\r
68 \r
69                 if ($results) {\r
70                         arsort($results);\r
71                         echo '<ol>';\r
72                         foreach ($results as $file => $count) \r
73                         {\r
74                                 if (($req_lang != 'en') && (file_exists('../'.$section.'/'.$req_lang.'/'.$file))) \r
75                                         $full_file = '../'.$section.'/'.$req_lang.'/'.$file;\r
76                                 else\r
77                                         $full_file = '../'.$section.'/'.$file;\r
78 \r
79                                 echo '<li><a href="'.$full_file.'?'.$req_lang.'" class="leaf" target="body">'.$_pages[$file].'</a></li>';\r
80                         }\r
81                         echo '</ol>';\r
82                 } else {\r
83                         echo '<p style="padding: 8px;">';\r
84                         get_text('no_results_found');\r
85                         echo '</p>';\r
86                 }\r
87         } else {\r
88                 echo '<p style="padding: 8px;">';\r
89                 get_text('search_term_longer_3_chars');\r
90                 echo '</p>';\r
91         }\r
92 }\r
93 ?>\r
94 </body>\r
95 </html>