Index: trunk/WikiWord/WikiWord/src/main/php/search/wikiword.php |
— | — | @@ -1,12 +1,12 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | | -$IP = dirname(__FILE__); |
| 4 | +$IP = dirname( dirname(__FILE__) ); |
5 | 5 | |
6 | 6 | require_once("$IP/config.php"); |
7 | | -require_once("$IP/wwimages.php"); |
| 7 | +require_once("$IP/common/wwimages.php"); |
8 | 8 | |
9 | | -if ($wwAPI) require_once("$IP/wwclient.php"); |
10 | | -else require_once("$IP/wwthesaurus.php"); |
| 9 | +if ($wwAPI) require_once("$IP/common/wwclient.php"); |
| 10 | +else require_once("$IP/common/wwthesaurus.php"); |
11 | 11 | |
12 | 12 | function printLocalConceptList($lang, $concepts) { |
13 | 13 | global $utils; |
Index: trunk/WikiWord/WikiWord/src/main/php/search/wikipics.php |
— | — | @@ -1,20 +1,21 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | | -$IP = dirname(__FILE__); |
| 4 | +$IP = dirname( dirname(__FILE__) ); |
5 | 5 | |
6 | 6 | require_once("$IP/config.php"); |
7 | | -require_once("$IP/wwimages.php"); |
| 7 | +require_once("$IP/common/wwimages.php"); |
8 | 8 | |
9 | | -if ($wwAPI) require_once("$IP/wwclient.php"); |
10 | | -else require_once("$IP/wwthesaurus.php"); |
| 9 | +if ($wwAPI) require_once("$IP/common/wwclient.php"); |
| 10 | +else require_once("$IP/common/wwthesaurus.php"); |
11 | 11 | |
12 | | -function printConceptList($concepts, $lang) { |
| 12 | +function printConceptList($langs, $concepts, $class) { |
| 13 | + if (!$concepts) return; |
13 | 14 | ?> |
14 | | - <ul class="terselist"> |
| 15 | + <ul class="<?php print $class; ?>"> |
15 | 16 | <?php |
16 | 17 | foreach ($concepts as $c) { |
17 | 18 | ?><li><?php |
18 | | - print getConceptDetailsLink($lang, $c); |
| 19 | + print getConceptDetailsLink($langs, $c); |
19 | 20 | ?></li><?php |
20 | 21 | } |
21 | 22 | ?> |
— | — | @@ -27,7 +28,7 @@ |
28 | 29 | |
29 | 30 | if (!$concept) return false; |
30 | 31 | |
31 | | - if (is_array($concept) && !isset($concept['id']) && isset($concept[0])) $images = $concept; #XXX: HACK |
| 32 | + if (is_array($concept) && !isset($concept['id'])) $images = $concept; #XXX: HACK |
32 | 33 | else $images = $utils->getImagesAbout($concept, $wwMaxPreviewImages); |
33 | 34 | |
34 | 35 | ?> |
— | — | @@ -54,9 +55,10 @@ |
55 | 56 | function getConceptDetailsLink($langs, $concept) { |
56 | 57 | global $utils; |
57 | 58 | $name = $utils->pickLocal($concept['name'], $langs); |
| 59 | + $score = @$concept['score']; |
58 | 60 | |
59 | 61 | $u = getConceptDetailsURL($langs, $concept); |
60 | | - return '<a href="' . htmlspecialchars($u) . '">' . htmlspecialchars($name) . '</a>'; |
| 62 | + return '<a href="' . htmlspecialchars($u) . '" title="' . htmlspecialchars($name) . ' (score: ' . (int)$score . ')'. '">' . htmlspecialchars($name) . '</a>'; |
61 | 63 | } |
62 | 64 | |
63 | 65 | function pickPage( $pages ) { |
— | — | @@ -78,7 +80,7 @@ |
79 | 81 | $urls = array(); |
80 | 82 | foreach ($concept['pages'][$lang] as $page => $type) { |
81 | 83 | $u = "http://$domain/wiki/" . urlencode($page); |
82 | | - $links[$page] = $u; |
| 84 | + $urls[$page] = $u; |
83 | 85 | } |
84 | 86 | |
85 | 87 | return $urls; |
— | — | @@ -89,8 +91,7 @@ |
90 | 92 | if (!$urls) return false; |
91 | 93 | |
92 | 94 | foreach ($urls as $page => $u) { |
93 | | - $u = "http://$domain/wiki/" . urlencode($page); |
94 | | - $links[] = '<a href="' . htmlspecialchars($u) . '">' . htmlspecialchars( str_replace("_", " ", $page) ) . '</a>'; |
| 95 | + $links[] = '<a href="' . htmlspecialchars($u) . '" title="' . htmlspecialchars( str_replace("_", " ", $page) ) . '">' . htmlspecialchars( $lang . ":" . str_replace("_", " ", $page) ) . '</a>'; |
95 | 96 | } |
96 | 97 | |
97 | 98 | return $links; |
— | — | @@ -120,6 +121,45 @@ |
121 | 122 | <?php |
122 | 123 | } |
123 | 124 | |
| 125 | +function printConceptPageList( $langs, $concept, $class ) { |
| 126 | + $linksByLanguage = getAllConceptPageLinks($concept); |
| 127 | + ?> |
| 128 | + <ul class="<?php print htmlspecialchars($class); ?>"> |
| 129 | + <?php |
| 130 | + foreach ( $linksByLanguage as $lang => $links ) { |
| 131 | + foreach ($links as $link ) { |
| 132 | + print "\t\t<li>" . $link . "</li>\n"; |
| 133 | + } |
| 134 | + } |
| 135 | + ?> |
| 136 | + </ul> |
| 137 | + <?php |
| 138 | +} |
| 139 | + |
| 140 | +function array_key_diff($base, $other) { |
| 141 | + $keys = array_keys($other); |
| 142 | + foreach ($keys as $k) { |
| 143 | + unset($base[$k]); |
| 144 | + } |
| 145 | + |
| 146 | + return $base; |
| 147 | +} |
| 148 | + |
| 149 | +function printRelatedConceptList( $langs, $concept, $class = "" ) { |
| 150 | + $related = array(); |
| 151 | + if ( @$concept['similar'] ) $related += $concept['similar']; |
| 152 | + if ( @$concept['related'] ) $related += $concept['related']; |
| 153 | + if ( @$concept['narrower'] ) $related += $concept['narrower']; |
| 154 | + |
| 155 | + if (isset($concept['broader'])) $related = array_key_diff($related, $concept['broader']); |
| 156 | + |
| 157 | + printConceptList($langs, $related, $class); |
| 158 | +} |
| 159 | + |
| 160 | +function printConceptCategoryList( $langs, $concept, $class = "" ) { |
| 161 | + if (isset($concept['broader'])) printConceptList($langs, $concept['broader'], $class); |
| 162 | +} |
| 163 | + |
124 | 164 | function printDefList($items, $scapeKeys = true, $escapeValues = true, $class = "list") { |
125 | 165 | ?> |
126 | 166 | <dl class="<?php print htmlspecialchars($class); ?>"> |
— | — | @@ -153,39 +193,67 @@ |
154 | 194 | |
155 | 195 | extract( $concept ); |
156 | 196 | $wclass = getWeightClass($score); |
| 197 | + $lclass = $terse ? "terselist" : "list"; |
| 198 | + $gallery = $utils->getImagesAbout($concept, $terse ? $wwMaxPreviewImages : $wwMaxGalleryImages ); |
157 | 199 | |
| 200 | + if (is_array($definition)) $definition = $utils->pickLocal($definition, $langs); |
| 201 | + |
158 | 202 | ?> |
159 | | - <tr class="row_item"> |
160 | | - <td class="cell_weight <?php print "weight_$wclass"; ?>"><?php print htmlspecialchars($score); ?></td> |
161 | | - <td colspan="3" class="cell_name <?php print "weight_$wclass"; ?>"> |
162 | | - <h3> |
| 203 | + <tr class="row_top"> |
| 204 | + <td colspan="3"> </td> |
| 205 | + </tr> |
| 206 | + |
| 207 | + <tr class="row_head"> |
| 208 | + <td colspan="1" class="cell_name"> |
| 209 | + <h3 class="<?php print "weight_$wclass"; ?>"> |
163 | 210 | <?php print getConceptDetailsLink($langs, $concept); ?> |
164 | | - <?php /* TODO: wiki links */ ?> |
165 | 211 | </h3> |
166 | 212 | </td> |
| 213 | + <td colspan="2" class="cell_pages"> |
| 214 | + <?php printConceptPageList($langs, $concept, $lclass) ?> |
| 215 | + </td> |
167 | 216 | </tr> |
168 | 217 | |
169 | | - <?php if (isset($definition) && !empty($definition)) { |
170 | | - $definition = $utils->pickLocal($definition, $langs); |
171 | | - ?> |
172 | | - |
173 | 218 | <tr class="row_def"> |
174 | | - <td></td> |
175 | 219 | <td colspan="3"><?php print htmlspecialchars($definition); ?></td> |
176 | 220 | </tr> |
177 | | - <?php } ?> |
178 | 221 | |
179 | | - <tr class="row_details row_images"> |
| 222 | + <tr class="row_related"> |
| 223 | + <td class="cell_related" colspan="3"> |
| 224 | + Related: |
| 225 | + <?php |
| 226 | + printRelatedConceptList( $langs, $concept, $lclass ); |
| 227 | + ?> |
| 228 | + </td> |
| 229 | + </tr> |
| 230 | + |
| 231 | + <tr class="row_images"> |
180 | 232 | <td></td> |
181 | 233 | <td class="cell_images" colspan="3"> |
182 | 234 | <?php |
183 | | - $gallery = $utils->getImagesAbout($concept, $terse ? $wwMaxPreviewImages : $wwMaxGalleryImages ); |
184 | | - $c = printConceptImageList( $gallery, $terse ? "terselist" : "gallery" ); |
| 235 | + printConceptImageList( $gallery, $terse ? "tersegallery" : "gallery" ); |
185 | 236 | ?> |
| 237 | + more...<!-- TODO --> |
186 | 238 | </td> |
187 | 239 | </tr> |
188 | 240 | |
| 241 | + <tr class="row_category"> |
| 242 | + <td class="cell_related" colspan="3"> |
| 243 | + Broader: |
| 244 | + <?php |
| 245 | + printConceptCategoryList( $langs, $concept, $lclass ); |
| 246 | + ?> |
| 247 | + </td> |
| 248 | + </tr> |
189 | 249 | |
| 250 | + <tr class="row_bottom"> |
| 251 | + <td colspan="3"> </td> |
| 252 | + </tr> |
| 253 | + |
| 254 | + <tr class="row_blank"> |
| 255 | + <td colspan="3"> </td> |
| 256 | + </tr> |
| 257 | + |
190 | 258 | <?php |
191 | 259 | if (isset($score) && $score && $score<2 && $pos>=3) return false; |
192 | 260 | else return true; |
— | — | @@ -261,8 +329,8 @@ |
262 | 330 | .inputform { text-align: center; margin:1ex auto; padding:1ex; width:80%; border:1px solid #666666; background-color:#DDDDDD; } |
263 | 331 | .footer { font-size:80%; text-align: center; border-top: 1px solid #666666; } |
264 | 332 | .note { font-size:80%; } |
265 | | - .terselist, .terselist li { display: inline; margin:0; padding:0; } |
266 | | - .terselist li { display: inline; } |
| 333 | + |
| 334 | + .tersegallery, .tersegallery li, .terselist, .terselist li { display: inline; margin:0; padding:0; } |
267 | 335 | .terselist li:before { content:" - " } |
268 | 336 | .terselist li:first-child:before { content:"" } |
269 | 337 | |
— | — | @@ -320,7 +388,6 @@ |
321 | 389 | if (!$continue) break; |
322 | 390 | ?> |
323 | 391 | </table> |
324 | | - </div> |
325 | 392 | |
326 | 393 | <?php |
327 | 394 | } #concept loop |
Index: trunk/WikiWord/WikiWord/src/main/php/common/wwclient.php |
— | — | @@ -14,8 +14,15 @@ |
15 | 15 | foreach ( $params as $k => $v ) { |
16 | 16 | if ($v===null) continue; |
17 | 17 | if ($v===false) $v = ""; |
18 | | - if (is_array($v)) $v = implode("|", $v); |
19 | 18 | |
| 19 | + if (is_array($v)) { |
| 20 | + # if (is_array($v[0])) { |
| 21 | + # print_r($v); |
| 22 | + # throw new Exception("foo"); |
| 23 | + # } |
| 24 | + $v = implode("|", $v); |
| 25 | + } |
| 26 | + |
20 | 27 | $url .= '&'; |
21 | 28 | $url .= urlencode( $k ); |
22 | 29 | $url .= '='; |
Index: trunk/WikiWord/WikiWord/src/main/php/common/wwthesaurus.php |
— | — | @@ -368,7 +368,14 @@ |
369 | 369 | |
370 | 370 | foreach ( $byLanguage as $lang => $items ) { |
371 | 371 | foreach ( $items as $id => $name ) { |
372 | | - $byId[$id][$lang] = $name; |
| 372 | + if (!isset($byId[$id])) { |
| 373 | + $byId[$id] = array( |
| 374 | + 'id' => $id, |
| 375 | + 'name' => array() |
| 376 | + ); |
| 377 | + } |
| 378 | + |
| 379 | + $byId[$id]['name'][$lang] = $name; |
373 | 380 | } |
374 | 381 | } |
375 | 382 | |
Index: trunk/WikiWord/WikiWord/src/main/php/config.sample.php |
— | — | @@ -33,6 +33,9 @@ |
34 | 34 | $wwCommonsServerName = null; |
35 | 35 | |
36 | 36 | $wwTagsTable = null; |
| 37 | + |
| 38 | +#$wwGilNoiceTable = null; |
| 39 | +#$wwGilNoiceThreshold = 10; |
37 | 40 | $wwFrequentImageThreshold = 10; |
38 | 41 | |
39 | 42 | $wwTagScores = array( |