r64959 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r64958‎ | r64959 | r64960 >
Date:11:13, 12 April 2010
Author:daniel
Status:deferred
Tags:
Comment:
tweak query, scores, page list, etc
Modified paths:
  • /trunk/WikiWord/WikiWord/src/main/php/common/wwimages.php (modified) (history)
  • /trunk/WikiWord/WikiWord/src/main/php/config.sample.php (modified) (history)
  • /trunk/WikiWord/WikiWord/src/main/php/search/wikipics.php (modified) (history)

Diff [purge]

Index: trunk/WikiWord/WikiWord/src/main/php/search/wikipics.php
@@ -18,8 +18,11 @@
1919 <ul class="<?php print $class; ?>">
2020 <?php
2121 foreach ($concepts as $c) {
 22+ $link = getConceptDetailsLink($langs, $c);
 23+ if (!$link) continue;
 24+
2225 ?><li><?php
23 - print getConceptDetailsLink($langs, $c);
 26+ print $link;
2427
2528 $i += 1;
2629 if ($i >= $limit) break;
@@ -164,13 +167,13 @@
165168 foreach ( $img['tags'] as $tag ) {
166169 foreach ( $wwLabelPatterns as $pattern => $label ) {
167170 if ( preg_match($pattern, $tag) ) {
168 - $labels[$label] = 1;
 171+ $labels[$label] = "<span title=\"".htmlspecialchars($tag)."\">".htmlspecialchars($label)."</span>";
169172 break;
170173 }
171174 }
172175 }
173176
174 - $labels = array_keys($labels);
 177+ $labels = array_values($labels);
175178 return $labels;
176179 }
177180
@@ -186,6 +189,8 @@
187190 global $utils;
188191
189192 $name = $utils->pickLocal($concept['name'], $langs);
 193+ if ( $name === false || $name === null) return false;
 194+
190195 $name = str_replace("_", " ", $name);
191196 $score = @$concept['score'];
192197
@@ -247,6 +252,7 @@
248253 <ul class="<?php print htmlspecialchars($class); ?>">
249254 <?php
250255 foreach ($items as $item) {
 256+ if ( !$item ) continue;
251257 if ( $escape ) $item = htmlspecialchars($item);
252258 print "<li>" . trim($item) . "</li>";
253259 }
@@ -391,7 +397,6 @@
392398 <td colspan="3">
393399 <h1 class="name <?php print "weight_$wclass"; ?>"><?php print getConceptDetailsLink($langs, $concept); ?>:</h1>
394400 <p class="definition"><?php print htmlspecialchars($definition); ?></p>
395 - <div class="wikipages"><strong class="label">Pages:</strong> <?php printConceptPageList( $langs, $concept, $lclass, $terse ? $wwMaxPreviewLinks : $wwMaxDetailLinks ) ?></div>
396401 </td>
397402 </tr>
398403
@@ -448,6 +453,15 @@
449454 </tr>
450455 <?php } ?>
451456
 457+ <?php if (!$terse && @$concept['pages']) { ?>
 458+ <tr class="row_pages">
 459+ <td class="cell_pages wikipages" colspan="3">
 460+ <strong class="label">Wiki pages:</strong> <?php $more = printConceptPageList( $langs, $concept, $lclass, $terse ? $wwMaxPreviewLinks : $wwMaxDetailLinks ); ?>
 461+ <?php if ($terse && $more) print " <strong class=\"more\">[" . getConceptDetailsLink($langs, $concept, "more...") . "]</strong>"; ?>
 462+ </td>
 463+ </tr>
 464+ <?php } ?>
 465+
452466 <tr class="row_blank">
453467 <td class="cell_blank" colspan="3">
454468 &nbsp;
@@ -514,6 +528,8 @@
515529
516530 $lang = $languages[0];
517531
 532+$allLanguages = array_keys($wwLanguages);
 533+
518534 $profiling['thesaurus'] = 0;
519535 $profiling['pics'] = 0;
520536
@@ -522,11 +538,11 @@
523539 try {
524540 if ($lang && $conceptId) {
525541 $mode = "concept";
526 - $result = $thesaurus->getConceptInfo($conceptId, $languages);
 542+ $result = $thesaurus->getConceptInfo($conceptId, $allLanguages);
527543 if ( $result ) $result = array( $result ); //hack
528544 } else if ($lang && $term) {
529545 $mode = "term";
530 - $result = $thesaurus->getConceptsForTerm($lang, $term, $languages, $norm, $limit);
 546+ $result = $thesaurus->getConceptsForTerm($lang, $term, $allLanguages, $norm, $limit);
531547 }
532548 } catch (Exception $e) {
533549 $error = $e->getMessage();
@@ -580,7 +596,7 @@
581597
582598 .row_images td { vertical-align: bottom; }
583599
584 - .row_related td, .row_category, .row_narrower { font-size: small; background-color: #F0F7F9; }
 600+ .row_related td, .row_category, .row_narrower, .row_pages { font-size: small; background-color: #F0F7F9; }
585601 .row_blank td { font-size: small; }
586602
587603 /*
Index: trunk/WikiWord/WikiWord/src/main/php/common/wwimages.php
@@ -410,6 +410,7 @@
411411 $images = new ImageCollection();
412412
413413 $globalImageList = $this->getImagesOnPagesGlobally($pages); //use wikis for $wwLanguages only
 414+
414415 //TODO: sanity limit on number of images. $max * 5 ?
415416 $globalImageUsage = $this->getGlobalUsageCounts($globalImageList, ".*wiki"); //use all wikipedias
416417
@@ -417,7 +418,7 @@
418419 $m = @$usage['*max*'];
419420 if ( $m >= $wwFrequentImageThreshold ) continue;
420421
421 - foreach ($usage as $wiki => $c) {
 422+ foreach ($usage as $wiki => $c) { //FIXME: only count usage on *RELEVANT* pages.
422423 $images->addImageUsage($image, $wiki.":*", "article", 1);
423424 }
424425 }
Index: trunk/WikiWord/WikiWord/src/main/php/config.sample.php
@@ -42,28 +42,35 @@
4343 $wwFrequentImageThreshold = 10;
4444
4545 $wwTagScores = array(
46 - 'Category:Featured_pictures_on_Wikimedia_Commons' => 3,
47 - 'Category:Featured_pictures_on_Wikipedia,_German' => 3,
 46+ 'Category:Featured_pictures_on_Wikimedia_Commons' => 10,
 47+ 'Category:Featured_pictures_on_Wikipedia,_German' => 10,
4848
49 - 'Template:Former_featured_picture' => 2.8,
 49+ 'Template:Former_featured_picture' => 6,
5050
51 - 'Template:Media_of_the_day' => 2.5,
52 - 'Template:Picture_of_the_day' => 2.5,
 51+ 'Template:Media_of_the_day' => 10,
 52+ 'Template:Picture_of_the_day' => 10,
5353
54 - 'Category:Quality_images' => 2.0,
 54+ 'Category:Quality_images' => 8,
5555
56 - 'Category:Valued_image' => 1.4,
57 - 'Category:Former_valued_images' => 1.3,
58 - 'Category:Images_used_in_valued_image_sets' => 1.2,
 56+ 'Category:Valued_image' => 8,
 57+ 'Category:Former_valued_images' => 6,
 58+ 'Category:Images_used_in_valued_image_sets' => 7,
5959
60 - 'assessment:Media_of_the_day' => 2.5,
61 - 'assessment:Picture_of_the_day' => 2.5,
62 - 'assessment:Quality_image' => 2.0,
63 - 'assessment:Featured_picture' => 3.0,
 60+ 'assessment:Media_of_the_day' => 10,
 61+ 'assessment:Picture_of_the_day' => 10,
 62+ 'assessment:Picture_of_the_week' => 15,
 63+ 'assessment:Picture_of_the_month' => 20,
 64+ 'assessment:Picture_of_the_year' => 25,
 65+ 'assessment:Quality_image' => 8,
 66+ 'assessment:Featured_picture' => 15,
6467 );
6568
 69+
6670 $wwLabelPatterns = array(
6771 '/^assessment:.*_of_the_day([-_].*|$)/' => "PotD",
 72+ '/^assessment:.*_of_the_week([-_].*|$)/' => "PotW",
 73+ '/^assessment:.*_of_the_month([-_].*|$)/' => "PotM",
 74+ '/^assessment:.*_of_the_year([-_].*|$)/' => "PotY",
6875 '/^assessment:(Featured|Former_featured_picture).*/' => 'FP',
6976 '/^assessment:Quiality.*/' => 'QI',
7077 '/^assessment:(Valued|Former_valued_images|Images_used_in_valued_image_sets).*/' => 'VI',

Status & tagging log