r64079 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r64078‎ | r64079 | r64080 >
Date:17:00, 23 March 2010
Author:daniel
Status:deferred
Tags:
Comment:
UI improvements
Modified paths:
  • /trunk/WikiWord/WikiWord/src/main/php/common/wwclient.php (modified) (history)
  • /trunk/WikiWord/WikiWord/src/main/php/common/wwthesaurus.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)
  • /trunk/WikiWord/WikiWord/src/main/php/search/wikiword.php (modified) (history)

Diff [purge]

Index: trunk/WikiWord/WikiWord/src/main/php/search/wikiword.php
@@ -1,12 +1,12 @@
22 <?php
33
4 -$IP = dirname(__FILE__);
 4+$IP = dirname( dirname(__FILE__) );
55
66 require_once("$IP/config.php");
7 -require_once("$IP/wwimages.php");
 7+require_once("$IP/common/wwimages.php");
88
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");
1111
1212 function printLocalConceptList($lang, $concepts) {
1313 global $utils;
Index: trunk/WikiWord/WikiWord/src/main/php/search/wikipics.php
@@ -1,20 +1,21 @@
22 <?php
33
4 -$IP = dirname(__FILE__);
 4+$IP = dirname( dirname(__FILE__) );
55
66 require_once("$IP/config.php");
7 -require_once("$IP/wwimages.php");
 7+require_once("$IP/common/wwimages.php");
88
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");
1111
12 -function printConceptList($concepts, $lang) {
 12+function printConceptList($langs, $concepts, $class) {
 13+ if (!$concepts) return;
1314 ?>
14 - <ul class="terselist">
 15+ <ul class="<?php print $class; ?>">
1516 <?php
1617 foreach ($concepts as $c) {
1718 ?><li><?php
18 - print getConceptDetailsLink($lang, $c);
 19+ print getConceptDetailsLink($langs, $c);
1920 ?></li><?php
2021 }
2122 ?>
@@ -27,7 +28,7 @@
2829
2930 if (!$concept) return false;
3031
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
3233 else $images = $utils->getImagesAbout($concept, $wwMaxPreviewImages);
3334
3435 ?>
@@ -54,9 +55,10 @@
5556 function getConceptDetailsLink($langs, $concept) {
5657 global $utils;
5758 $name = $utils->pickLocal($concept['name'], $langs);
 59+ $score = @$concept['score'];
5860
5961 $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>';
6163 }
6264
6365 function pickPage( $pages ) {
@@ -78,7 +80,7 @@
7981 $urls = array();
8082 foreach ($concept['pages'][$lang] as $page => $type) {
8183 $u = "http://$domain/wiki/" . urlencode($page);
82 - $links[$page] = $u;
 84+ $urls[$page] = $u;
8385 }
8486
8587 return $urls;
@@ -89,8 +91,7 @@
9092 if (!$urls) return false;
9193
9294 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>';
9596 }
9697
9798 return $links;
@@ -120,6 +121,45 @@
121122 <?php
122123 }
123124
 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+
124164 function printDefList($items, $scapeKeys = true, $escapeValues = true, $class = "list") {
125165 ?>
126166 <dl class="<?php print htmlspecialchars($class); ?>">
@@ -153,39 +193,67 @@
154194
155195 extract( $concept );
156196 $wclass = getWeightClass($score);
 197+ $lclass = $terse ? "terselist" : "list";
 198+ $gallery = $utils->getImagesAbout($concept, $terse ? $wwMaxPreviewImages : $wwMaxGalleryImages );
157199
 200+ if (is_array($definition)) $definition = $utils->pickLocal($definition, $langs);
 201+
158202 ?>
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">&nbsp;</td>
 205+ </tr>
 206+
 207+ <tr class="row_head">
 208+ <td colspan="1" class="cell_name">
 209+ <h3 class="<?php print "weight_$wclass"; ?>">
163210 <?php print getConceptDetailsLink($langs, $concept); ?>
164 - <?php /* TODO: wiki links */ ?>
165211 </h3>
166212 </td>
 213+ <td colspan="2" class="cell_pages">
 214+ <?php printConceptPageList($langs, $concept, $lclass) ?>
 215+ </td>
167216 </tr>
168217
169 - <?php if (isset($definition) && !empty($definition)) {
170 - $definition = $utils->pickLocal($definition, $langs);
171 - ?>
172 -
173218 <tr class="row_def">
174 - <td></td>
175219 <td colspan="3"><?php print htmlspecialchars($definition); ?></td>
176220 </tr>
177 - <?php } ?>
178221
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">
180232 <td></td>
181233 <td class="cell_images" colspan="3">
182234 <?php
183 - $gallery = $utils->getImagesAbout($concept, $terse ? $wwMaxPreviewImages : $wwMaxGalleryImages );
184 - $c = printConceptImageList( $gallery, $terse ? "terselist" : "gallery" );
 235+ printConceptImageList( $gallery, $terse ? "tersegallery" : "gallery" );
185236 ?>
 237+ more...<!-- TODO -->
186238 </td>
187239 </tr>
188240
 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>
189249
 250+ <tr class="row_bottom">
 251+ <td colspan="3">&nbsp;</td>
 252+ </tr>
 253+
 254+ <tr class="row_blank">
 255+ <td colspan="3">&nbsp;</td>
 256+ </tr>
 257+
190258 <?php
191259 if (isset($score) && $score && $score<2 && $pos>=3) return false;
192260 else return true;
@@ -261,8 +329,8 @@
262330 .inputform { text-align: center; margin:1ex auto; padding:1ex; width:80%; border:1px solid #666666; background-color:#DDDDDD; }
263331 .footer { font-size:80%; text-align: center; border-top: 1px solid #666666; }
264332 .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; }
267335 .terselist li:before { content:" - " }
268336 .terselist li:first-child:before { content:"" }
269337
@@ -320,7 +388,6 @@
321389 if (!$continue) break;
322390 ?>
323391 </table>
324 - </div>
325392
326393 <?php
327394 } #concept loop
Index: trunk/WikiWord/WikiWord/src/main/php/common/wwclient.php
@@ -14,8 +14,15 @@
1515 foreach ( $params as $k => $v ) {
1616 if ($v===null) continue;
1717 if ($v===false) $v = "";
18 - if (is_array($v)) $v = implode("|", $v);
1918
 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+
2027 $url .= '&';
2128 $url .= urlencode( $k );
2229 $url .= '=';
Index: trunk/WikiWord/WikiWord/src/main/php/common/wwthesaurus.php
@@ -368,7 +368,14 @@
369369
370370 foreach ( $byLanguage as $lang => $items ) {
371371 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;
373380 }
374381 }
375382
Index: trunk/WikiWord/WikiWord/src/main/php/config.sample.php
@@ -33,6 +33,9 @@
3434 $wwCommonsServerName = null;
3535
3636 $wwTagsTable = null;
 37+
 38+#$wwGilNoiceTable = null;
 39+#$wwGilNoiceThreshold = 10;
3740 $wwFrequentImageThreshold = 10;
3841
3942 $wwTagScores = array(

Status & tagging log