Index: trunk/WikiWord/WikiWord/src/main/php/search/wikipics.php |
— | — | @@ -8,19 +8,28 @@ |
9 | 9 | if ($wwAPI) require_once("$IP/common/wwclient.php"); |
10 | 10 | else require_once("$IP/common/wwthesaurus.php"); |
11 | 11 | |
12 | | -function printConceptList($langs, $concepts, $class) { |
13 | | - if (!$concepts) return; |
| 12 | +function printConceptList($langs, $concepts, $class, $limit = false) { |
| 13 | + if (!$concepts) return false; |
| 14 | + |
| 15 | + if (!$limit || $limit > count($concepts)) $limit = count($concepts); |
| 16 | + |
| 17 | + $i = 0; |
14 | 18 | ?> |
15 | 19 | <ul class="<?php print $class; ?>"> |
16 | 20 | <?php |
17 | 21 | foreach ($concepts as $c) { |
18 | 22 | ?><li><?php |
19 | 23 | print getConceptDetailsLink($langs, $c); |
| 24 | + |
| 25 | + $i += 1; |
| 26 | + if ($i >= $limit) break; |
20 | 27 | ?></li><?php |
21 | 28 | } |
22 | 29 | ?> |
23 | 30 | </ul> |
24 | 31 | <?php |
| 32 | + |
| 33 | + return $i < count($concepts); |
25 | 34 | } |
26 | 35 | |
27 | 36 | function getImagesAbout($concept, $max) { |
— | — | @@ -33,44 +42,43 @@ |
34 | 43 | return $pics; |
35 | 44 | } |
36 | 45 | |
37 | | -function printConceptImageList($concept, $class = "tersetable", $columns = 5) { |
38 | | - global $utils, $wwThumbSize, $wwMaxPreviewImages; |
| 46 | +function printConceptImageList($concept, $class = "tersetable", $columns = 5, $limit = false ) { |
| 47 | + global $utils, $wwThumbSize; |
39 | 48 | |
40 | 49 | if (!$concept) return false; |
41 | 50 | |
42 | 51 | if (is_array($concept) && !isset($concept['id'])) $images = $concept; #XXX: HACK |
43 | | - else $images = getImagesAbout($concept, $wwMaxPreviewImages); |
| 52 | + else $images = getImagesAbout($concept, $max ? $max +1 : false); |
44 | 53 | |
45 | 54 | if (!$images) return; |
46 | 55 | |
47 | 56 | $imgList = array_values($images); |
48 | 57 | |
49 | 58 | ?> |
50 | | - <table class="imageTable <?php print $class; ?>"> |
51 | | - <tbody> |
| 59 | + <table class="imageTable <?php print $class; ?>" summary="images"> |
52 | 60 | <?php |
53 | 61 | $i = 0; |
54 | 62 | $c = count($images); |
55 | | - while ($i < $c) { |
56 | | - $i = printConceptImageRow($imgList, $i, $columns); |
| 63 | + if (!$limit || $limit > $c) $limit = $c; |
| 64 | + |
| 65 | + while ($i < $limit) { |
| 66 | + $i = printConceptImageRow($imgList, $i, $limit, $columns); |
57 | 67 | } |
58 | 68 | ?> |
59 | | - </tr> |
60 | | - </tbody> |
61 | 69 | </table> |
62 | 70 | <?php |
| 71 | + |
| 72 | + return $i < $c; |
63 | 73 | } |
64 | 74 | |
65 | | -function printConceptImageRow($images, $from, $columns = 5) { |
| 75 | +function printConceptImageRow($images, $from, $limit, $columns = 5) { |
66 | 76 | global $wwThumbSize, $utils; |
67 | 77 | |
68 | 78 | $cw = $wwThumbSize + 20; |
69 | 79 | $cwcss = $cw . "px"; |
70 | 80 | |
71 | | - $c = count($images); |
72 | | - |
73 | 81 | $to = $from + $columns; |
74 | | - if ( $to > $c ) $to = $c; |
| 82 | + if ( $to > $limit ) $to = $limit; |
75 | 83 | |
76 | 84 | print "\t<tr class=\"imageRow\">\n"; |
77 | 85 | |
— | — | @@ -87,8 +95,11 @@ |
88 | 96 | |
89 | 97 | for ($i = $from; $i<$to; $i += 1) { |
90 | 98 | $img = $images[$i]; |
91 | | - $title = str_replace("_", " ", $img['name']); |
92 | 99 | |
| 100 | + $title = $img['name']; |
| 101 | + $title = str_replace("_", " ", $title); |
| 102 | + $title = preg_replace("/\\.[^.]+$/", "", $title); |
| 103 | + |
93 | 104 | print "\t\t<td class=\"imageMetaCell\" width=\"$cw\" align=\"left\" valign=\"top\" style=\"width: $cwcss\">"; |
94 | 105 | print "<div class=\"imageTitle\">" . htmlspecialchars( $title ) . "</div>"; |
95 | 106 | print "</td>\n"; |
— | — | @@ -107,14 +118,17 @@ |
108 | 119 | return "$wwSelf?id=" . urlencode($concept['id']) . "&lang=" . urlencode($langs); |
109 | 120 | } |
110 | 121 | |
111 | | -function getConceptDetailsLink($langs, $concept) { |
| 122 | +function getConceptDetailsLink($langs, $concept, $text = NULL) { |
112 | 123 | global $utils; |
| 124 | + |
113 | 125 | $name = $utils->pickLocal($concept['name'], $langs); |
114 | 126 | $name = str_replace("_", " ", $name); |
115 | 127 | $score = @$concept['score']; |
| 128 | + |
| 129 | + if ($text === null) $text = $name; |
116 | 130 | |
117 | 131 | $u = getConceptDetailsURL($langs, $concept); |
118 | | - return '<a href="' . htmlspecialchars($u) . '" title="' . htmlspecialchars($name) . ' (score: ' . (int)$score . ')'. '">' . htmlspecialchars($name) . '</a>'; |
| 132 | + return '<a href="' . htmlspecialchars($u) . '" title="' . htmlspecialchars($name) . ' (score: ' . (int)$score . ')'. '">' . htmlspecialchars($text) . '</a>'; |
119 | 133 | } |
120 | 134 | |
121 | 135 | function pickPage( $pages ) { |
— | — | @@ -177,19 +191,32 @@ |
178 | 192 | <?php |
179 | 193 | } |
180 | 194 | |
181 | | -function printConceptPageList( $langs, $concept, $class ) { |
| 195 | +function printConceptPageList( $langs, $concept, $class, $limit = false ) { |
182 | 196 | $linksByLanguage = getAllConceptPageLinks($concept); |
| 197 | + |
| 198 | + $i = 0; |
| 199 | + $more = false; |
183 | 200 | ?> |
184 | 201 | <ul class="<?php print htmlspecialchars($class); ?>"> |
185 | 202 | <?php |
186 | 203 | foreach ( $linksByLanguage as $lang => $links ) { |
187 | 204 | foreach ($links as $link ) { |
188 | 205 | print "\t\t<li>" . $link . "</li>\n"; |
| 206 | + |
| 207 | + $i += 1; |
| 208 | + if ($limit && $i >= $limit) break; |
189 | 209 | } |
| 210 | + |
| 211 | + if ($limit && $i >= $limit) { |
| 212 | + $more = true; |
| 213 | + break; |
| 214 | + } |
190 | 215 | } |
191 | 216 | ?> |
192 | 217 | </ul> |
193 | 218 | <?php |
| 219 | + |
| 220 | + return $more; |
194 | 221 | } |
195 | 222 | |
196 | 223 | function array_key_diff($base, $other) { |
— | — | @@ -201,7 +228,7 @@ |
202 | 229 | return $base; |
203 | 230 | } |
204 | 231 | |
205 | | -function printRelatedConceptList( $langs, $concept, $class = "" ) { |
| 232 | +function getRelatedConceptList( $concept ) { |
206 | 233 | $related = array(); |
207 | 234 | if ( @$concept['similar'] ) $related += $concept['similar']; |
208 | 235 | if ( @$concept['related'] ) $related += $concept['related']; |
— | — | @@ -209,13 +236,9 @@ |
210 | 237 | |
211 | 238 | if (isset($concept['broader'])) $related = array_key_diff($related, $concept['broader']); |
212 | 239 | |
213 | | - printConceptList($langs, $related, $class); |
| 240 | + return $related; |
214 | 241 | } |
215 | 242 | |
216 | | -function printConceptCategoryList( $langs, $concept, $class = "" ) { |
217 | | - if (isset($concept['broader'])) printConceptList($langs, $concept['broader'], $class); |
218 | | -} |
219 | | - |
220 | 243 | function printDefList($items, $scapeKeys = true, $escapeValues = true, $class = "list") { |
221 | 244 | ?> |
222 | 245 | <dl class="<?php print htmlspecialchars($class); ?>"> |
— | — | @@ -245,12 +268,12 @@ |
246 | 269 | } |
247 | 270 | |
248 | 271 | function printConcept($concept, $langs, $terse = true) { |
249 | | - global $utils, $wwMaxPreviewImages, $wwMaxGalleryImages; |
| 272 | + global $utils, $wwMaxPreviewImages, $wwMaxGalleryImages, $wwMaxPreviewLinks, $wwGalleryColumns; |
250 | 273 | |
251 | 274 | extract( $concept ); |
252 | 275 | $wclass = getWeightClass($score); |
253 | 276 | $lclass = $terse ? "terselist" : "list"; |
254 | | - $gallery = getImagesAbout($concept, $terse ? $wwMaxPreviewImages : $wwMaxGalleryImages ); |
| 277 | + $gallery = getImagesAbout($concept, $terse ? $wwMaxPreviewImages*2 : $wwMaxGalleryImages+1 ); |
255 | 278 | |
256 | 279 | if (is_array($definition)) $definition = $utils->pickLocal($definition, $langs); |
257 | 280 | |
— | — | @@ -259,39 +282,54 @@ |
260 | 283 | <td colspan="3"> |
261 | 284 | <h1 class="name <?php print "weight_$wclass"; ?>"><?php print getConceptDetailsLink($langs, $concept); ?>:</h1> |
262 | 285 | <p class="definition"><?php print htmlspecialchars($definition); ?></p> |
263 | | - <div class="wikipages">Pages: <?php printConceptPageList($langs, $concept, $lclass) ?></div> |
| 286 | + <div class="wikipages"><strong class="label">Pages:</strong> <?php printConceptPageList( $langs, $concept, $lclass, $terse ? $wwMaxPreviewLinks : $wwMaxDetailLinks ) ?></div> |
264 | 287 | </td> |
265 | 288 | </tr> |
266 | 289 | |
267 | 290 | <tr class="row_images"> |
268 | | - <td class="cell_images" colspan="3"> |
| 291 | + <td class="cell_images" colspan="2"> |
269 | 292 | <?php |
270 | | - printConceptImageList( $gallery, $terse ? "tersegallery" : "gallery" ); |
| 293 | + $more = printConceptImageList( $gallery, $terse ? "tersegallery" : "gallery", $wwGalleryColumns, $terse ? $wwMaxPreviewImages : $wwMaxGalleryImages ); |
271 | 294 | ?> |
272 | | - <p>more...<!-- TODO --></p> |
273 | 295 | </td> |
| 296 | + <td class="cell_more_images" colspan="1" width="100%" style="vertical-align:bottom; padding: 1ex; font-size:normal;"> |
| 297 | + <?php if ($terse && $more) print " <div><strong class=\"more\">[" . getConceptDetailsLink($langs, $concept, "more...") . "]</strong></div>"; ?> |
| 298 | + </td> |
274 | 299 | </tr> |
275 | 300 | |
| 301 | + <?php |
| 302 | + $related = getRelatedConceptList($concept); |
| 303 | + if ($related) { |
| 304 | + ?> |
276 | 305 | <tr class="row_related"> |
277 | 306 | <td class="cell_related" colspan="3"> |
278 | | - Related: |
| 307 | + <strong class="label">Related:</strong> |
279 | 308 | <?php |
280 | | - printRelatedConceptList( $langs, $concept, $lclass ); |
| 309 | + $more = printConceptList( $langs, $related, $lclass, $terse ? $wwMaxPreviewLinks : $wwMaxDetailLinks ); |
281 | 310 | ?> |
282 | | - <p>more...<!-- TODO --></p> |
| 311 | + <?php if ($terse && $more) print " <strong class=\"more\">[" . getConceptDetailsLink($langs, $concept, "more...") . "]</strong>"; ?> |
283 | 312 | </td> |
284 | 313 | </tr> |
| 314 | + <?php } ?> |
285 | 315 | |
| 316 | + <?php if (@$concept['broader']) { ?> |
286 | 317 | <tr class="row_category"> |
287 | 318 | <td class="cell_related" colspan="3"> |
288 | | - Broader: |
| 319 | + <strong class="label">Broader:</strong> |
289 | 320 | <?php |
290 | | - printConceptCategoryList( $langs, $concept, $lclass ); |
| 321 | + $more = printConceptList( $langs, $concept['broader'], $lclass, $terse ? $wwMaxPreviewLinks : $wwMaxDetailLinks ); |
291 | 322 | ?> |
292 | | - <p>more...<!-- TODO --></p> |
| 323 | + <?php if ($terse && $more) print " <strong class=\"more\">[" . getConceptDetailsLink($langs, $concept, "more...") . "]</strong>"; ?> |
293 | 324 | </td> |
294 | 325 | </tr> |
| 326 | + <?php } ?> |
295 | 327 | |
| 328 | + <tr class="row_blank"> |
| 329 | + <td class="cell_blank" colspan="3"> |
| 330 | + |
| 331 | + </td> |
| 332 | + </tr> |
| 333 | + |
296 | 334 | <?php |
297 | 335 | if (isset($score) && $score && $score<2 && $pos>=3) return false; |
298 | 336 | else return true; |
— | — | @@ -354,7 +392,7 @@ |
355 | 393 | <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr"> |
356 | 394 | <head> |
357 | 395 | <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> |
358 | | - <title>WikiWord Navigator</title> |
| 396 | + <title>WikiPics: multilingual search for Wikimedia Commons</title> |
359 | 397 | |
360 | 398 | <style type="text/css"> |
361 | 399 | body { font-family: verdana, helvetica, arial, sans-serif; } |
— | — | @@ -393,21 +431,29 @@ |
394 | 432 | .row_head .definition { font-style: italic; display:inline; } |
395 | 433 | .row_head .wikipages { font-style: inherit; display:inline; } |
396 | 434 | |
397 | | - .row_related td { font-size: small; } |
398 | | - .row_category td { font-size: small; } |
| 435 | + .row_images td { vertical-align: bottom; } |
| 436 | + |
| 437 | + .row_related td { font-size: small; background-color: #F0F7F9; } |
| 438 | + .row_category td { font-size: small; background-color: #F0F7F9; } |
| 439 | + .row_blank td { font-size: small; } |
| 440 | + |
| 441 | + /* |
399 | 442 | .cell_weight { text-align: right; } |
400 | | - .cell_label { text-align: right; } |
| 443 | + .cell_label { text-align: right; font-weight: bold; } |
| 444 | + */ |
401 | 445 | |
402 | | - .header { text-align: left; margin:0; padding: 0; border-bottom: 1px solid #C9D7F1; } |
| 446 | + .label { font-weight: bold; } |
| 447 | + .note { font-size:small; } |
403 | 448 | |
| 449 | + .header { font-size:small; text-align: left; margin:0 0 1ex 0; padding: 0; border-bottom: 1px solid #C9D7F1; } |
| 450 | + |
404 | 451 | .inputform { text-align: left; margin:0 1ex; } |
405 | 452 | .inputform td { text-align: left; vertical-align: bottom; padding: 0.5ex; } |
406 | 453 | .inputform td.note { font-size:small; } |
407 | 454 | .inputform th { text-align: left; vertical-align: bottom; } |
408 | 455 | |
409 | 456 | |
410 | | - .footer { font-size:80%; text-align: center; border-top: 1px solid #666666; } |
411 | | - .note { font-size:80%; } |
| 457 | + .footer { font-size:small; text-align: center; margin:1ex 0 0 0; padding: 0; border-top: 1px solid #C9D7F1; } |
412 | 458 | |
413 | 459 | .tersegallery, .tersegallery li, .terselist, .terselist li { display: inline; margin:0; padding:0; } |
414 | 460 | .terselist li:before { content:", " } |
— | — | @@ -419,12 +465,12 @@ |
420 | 466 | .results td { text-align: left; vertical-align: top; } |
421 | 467 | .results th { text-align: left; vertical-align: top; font-weight:bold; } |
422 | 468 | |
423 | | - .imageCell { |
| 469 | + .imageTable td.imageCell { |
424 | 470 | vertical-align: bottom; |
425 | 471 | padding-top: 1em; |
426 | 472 | } |
427 | | - .imageCell img { border: 1px solid; } |
428 | | - .imageCell, .imageMetaCell { |
| 473 | + .imageTable td.imageCell img { border: 1px solid; } |
| 474 | + .imageTable td.imageCell, .imageTable td.imageMetaCell { |
429 | 475 | font-size:small; |
430 | 476 | border-spacing: 1em 0; |
431 | 477 | margin: 1em; |
— | — | @@ -441,12 +487,12 @@ |
442 | 488 | |
443 | 489 | <div class="inputform" > |
444 | 490 | <form name="search" action="<?php print $wwSelf; ?>"> |
445 | | - <table border="0" class="inputgrid"> |
| 491 | + <table border="0" class="inputgrid" summary="input form"> |
446 | 492 | <tr> |
447 | 493 | <td> |
448 | 494 | <?php |
449 | 495 | $u = $utils->getThumbnailURL("Commons_logo_optimized.svg", 60); |
450 | | - print "<img class=\"logo\" src=\"".htmlspecialchars($u)."\" title=\"Search Wikimedia Commons\" valign=\"bottom\"/>"; |
| 496 | + print "<img class=\"logo\" alt=\"Wikimedia Commons Logo\" src=\"".htmlspecialchars($u)."\" title=\"Search Wikimedia Commons\" align=\"bottom\"/>"; |
451 | 497 | ?> |
452 | 498 | </td> |
453 | 499 | <td> |
— | — | @@ -484,32 +530,37 @@ |
485 | 531 | if ($result) { |
486 | 532 | if ( $conceptId ) $terse = false; |
487 | 533 | else $terse = true; |
488 | | - |
| 534 | +?> |
| 535 | + <table border="0" class="results" cellspacing="0" summary="search results"> |
| 536 | +<?php |
489 | 537 | $count = 0; |
490 | 538 | foreach ( $result as $row ) { |
491 | 539 | $count = $count + 1; |
492 | 540 | $row['pos'] = $count; |
493 | 541 | |
494 | 542 | ?> |
495 | | - <table border="0" class="results"> |
496 | 543 | <?php |
497 | 544 | $continue= printConcept($row, $languages, $terse); |
498 | 545 | |
499 | 546 | if (!$continue) break; |
500 | 547 | ?> |
501 | | - </table> |
502 | 548 | |
503 | 549 | <?php |
504 | 550 | } #concept loop |
505 | 551 | |
| 552 | +?> |
| 553 | + </table> |
| 554 | +<?php |
| 555 | + |
506 | 556 | if ($term) { ?> |
507 | 557 | <p>Found <?php print $count; ?> items.</p> |
508 | 558 | <?php } |
509 | 559 | } ?> |
510 | 560 | |
511 | | -<p class="footer"> |
512 | | -The WikiWord Navigator is part of the <a href="http://wikimedia.de">Wikimedia</a> project <a href="http://brightbyte.de/page/WikiWord">WikiWord</a> |
513 | | -<p> |
| 561 | +<div class="footer"> |
| 562 | +<p>The WikiWord Navigator is part of the <a href="http://wikimedia.de">Wikimedia</a> project <a href="http://brightbyte.de/page/WikiWord">WikiWord</a></p> |
| 563 | + |
| 564 | +</div> |
514 | 565 | </body> |
515 | 566 | <?php |
516 | 567 | foreach ( $profiling as $key => $value ) { |
Index: trunk/WikiWord/WikiWord/src/main/php/common/wwimages.php |
— | — | @@ -511,12 +511,16 @@ |
512 | 512 | "Carrots_of_many_colors.jpg", |
513 | 513 | "Infantryman_in_1942_with_M1_Garand,_Fort_Knox,_KY.jpg", |
514 | 514 | "Wilhelmshaven_Meerjungfrau.jpg", |
| 515 | + "Sunrise_over_Veterans_Park_2420.jpg", |
| 516 | + "Halde_Rheinpreußen,_Grubenlampe,_III_retouched.jpg", |
515 | 517 | ); |
516 | 518 | |
517 | 519 | $this->morePics = array( |
518 | 520 | "Yellow_Tiger_Moth_Góraszka.JPG", |
519 | 521 | "Mauritania_boy1.jpg", |
520 | 522 | "Mavericks_Surf_Contest_2010b.jpg", |
| 523 | + "Sellers_translating_along_truss_during_EVA-3_on_STS-121.jpg", |
| 524 | + "Fruitbowlwithmelons.jpg", |
521 | 525 | ); |
522 | 526 | |
523 | 527 | $this->fewPics = array( |
Index: trunk/WikiWord/WikiWord/src/main/php/config.sample.php |
— | — | @@ -16,8 +16,11 @@ |
17 | 17 | |
18 | 18 | #error_reporting(E_ALL); |
19 | 19 | |
20 | | -$wwMaxPreviewImages = 8; |
| 20 | +$wwMaxPreviewImages = 5; |
| 21 | +$wwMaxPreviewLinks = 20; |
| 22 | +$wwGalleryColumns = 5; |
21 | 23 | $wwMaxGalleryImages = 200; |
| 24 | +$wwMaxDetailLinks = 1000; |
22 | 25 | $wwThumbSize = 120; |
23 | 26 | $wwThumbnailURL = "http://toolserver.org/tsthumb/tsthumb?f={name}&domain=commons.wikimedia.org&w={width}&h={height}"; |
24 | 27 | $wwImagePageURL = "http://commons.wikimedia.org/wiki/File:{name}"; |