corrade-vassal – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | vero | 1 | <?php |
2 | |||
3 | //============================================================================= |
||
4 | // System : Sandcastle Help File Builder (PHP port) |
||
5 | // Author : Latif Khalifa <latifer@streamgrid.net>, All rights reserved |
||
6 | // Copyright (c) 2011, Latif Khalifa <latifer@streamgrid.net> |
||
7 | // |
||
8 | // Permission is hereby granted, free of charge, to any person obtaining a copy |
||
9 | // of this software and associated documentation files (the "Software"), to deal |
||
10 | // in the Software without restriction, including without limitation the rights |
||
11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
||
12 | // copies of the Software, and to permit persons to whom the Software is |
||
13 | // furnished to do so, subject to the following conditions: |
||
14 | |||
15 | // The above copyright notice and this permission notice shall be included in |
||
16 | // all copies or substantial portions of the Software. |
||
17 | |||
18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||
19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||
20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
||
21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||
22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
||
23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
||
24 | // THE SOFTWARE. |
||
25 | // |
||
26 | // Based on C# version by Eric Woodruff (Eric@EWoodruff.us) from code by Ferdinand Prantl |
||
27 | // Copyright 2008, Eric Woodruff, All rights reserved |
||
28 | |||
29 | |||
30 | $searchText = $_GET["Keywords"]; |
||
31 | |||
32 | |||
33 | if (!$searchText) { |
||
34 | print "<b class=\"PaddedText\">Nothing found</b>"; |
||
35 | die(); |
||
36 | } |
||
37 | |||
38 | $sortByTitle = $_GET["SortByTitle"] == "true"; |
||
39 | |||
40 | $keywords = preg_split("/\\W+/", $searchText); |
||
41 | $keywordList = array(); |
||
42 | |||
43 | for ($i=0; $i<count($keywords); $i++) { |
||
44 | $checkWord = strtolower($keywords[$i]); |
||
45 | if (strlen($checkWord) > 1 && !isset($keywordList[$checkWord])) { |
||
46 | $keywordList[$checkWord] = 1; |
||
47 | } |
||
48 | } |
||
49 | |||
50 | $keywordList = array_keys($keywordList); |
||
51 | |||
52 | if (!count($keywordList)) { |
||
53 | print "<b class=\"PaddedText\">No search keywords (min length 2)</b>"; |
||
54 | die(); |
||
55 | } |
||
56 | |||
57 | $ki = DOMDocument::load("WebKI.xml"); |
||
58 | $xpath = new DOMXpath($ki); |
||
59 | $root = $xpath->query("*" ); |
||
60 | |||
61 | $max = 100; |
||
62 | $hits = 0; |
||
63 | |||
64 | $ret = ""; |
||
65 | |||
66 | foreach($root as $node) { |
||
67 | |||
68 | $title = $node->getAttribute("Title"); |
||
69 | $url = $node->getAttribute("Url"); |
||
70 | |||
71 | $found = true; |
||
72 | |||
73 | foreach($keywordList as $word) { |
||
74 | if (false === stristr($title, $word)) { |
||
75 | $found = false; |
||
76 | break; |
||
77 | } |
||
78 | } |
||
79 | |||
80 | if ($found) { |
||
81 | $hits++; |
||
82 | |||
83 | $ret .= sprintf("<div class=\"TreeItem\">\r\n<img src=\"Item.gif\"/>" . |
||
84 | "<a class=\"UnselectedNode\" target=\"TopicContent\" " . |
||
85 | "href=\"%s\" onclick=\"javascript: SelectSearchNode(this);\">" . |
||
86 | "%s</a>\r\n</div>\r\n", $url, $title); |
||
87 | |||
88 | } |
||
89 | |||
90 | if ($hits > $max) break; |
||
91 | } |
||
92 | |||
93 | $ret .= sprintf("<span id=\"SearchKeywords\" style=\"display: none\">%s</span>", implode(" ", $keywordList)); |
||
94 | |||
95 | print $ret; |