Index: trunk/WikiWord/WikiWord/src/main/php/wikiword.php |
— | — | @@ -47,6 +47,8 @@ |
48 | 48 | function printLocalConceptLink($lang, $row) { |
49 | 49 | global $wwSelf, $images; |
50 | 50 | |
| 51 | + $row = normalizeConceptRow($lang, $row); |
| 52 | + |
51 | 53 | extract($row); |
52 | 54 | |
53 | 55 | if (!isset($weight) && isset($freq)) $weight = $freq; |
— | — | @@ -117,17 +119,17 @@ |
118 | 120 | |
119 | 121 | if (!$row) return $row; |
120 | 122 | |
121 | | - $row['lang'] = $lang; |
122 | | - |
| 123 | + if (!isset($row['lang'])) $row['lang'] = $lang; |
123 | 124 | if (!isset($row['weight']) && isset($row['freq'])) $row['weight'] = $row['freq']; |
124 | 125 | if (!isset($row['weight']) && isset($row['conf'])) $row['weight'] = $row['conf']; |
125 | | - if (isset($row['local_concept_name'])) $row['concept_name'] = $row['local_concept_name']; |
| 126 | + if (!empty($row['local_concept_name'])) $row['concept_name'] = $row['local_concept_name']; |
126 | 127 | if (!isset($row['concept_name']) && isset($row['name'])) $row['concept_name'] = $row['name']; |
127 | 128 | if (!isset($row['concept_name']) && isset($row['global_concept_name'])) $row['concept_name'] = $row['global_concept_name']; |
128 | 129 | if (!isset($row['reference_id']) && isset($row['global_id'])) $row['reference_id'] = $row['global_id']; |
129 | 130 | if (!isset($row['reference_id']) && isset($row['global_concept'])) $row['reference_id'] = $row['global_concept']; |
130 | 131 | if (!isset($row['reference_id']) && isset($row['concept'])) $row['reference_id'] = $row['concept']; |
131 | 132 | if (!isset($row['reference_id']) && isset($row['id'])) $row['reference_id'] = $row['id']; |
| 133 | + if (!empty($row['definition']) && is_array($row['definition'])) $row['definition'] = $row['definition'][$lang]; |
132 | 134 | |
133 | 135 | #print "<pre>"; |
134 | 136 | #print_r($row); |
— | — | @@ -151,8 +153,9 @@ |
152 | 154 | return $row; |
153 | 155 | } |
154 | 156 | |
155 | | -function printLocalConcept($a_lang, $a_row, $b_lang, $b_row, $pos = 0, $images) { |
156 | | - global $wwSelf; |
| 157 | +function printLocalConcept($a_lang, $a_row, $b_lang, $b_row, $pos = 0, $terse = true) { |
| 158 | + global $wwSelf, $images, $utils; |
| 159 | + global $wwMaxPreviewImages, $wwMaxGalleryImages; |
157 | 160 | |
158 | 161 | $a_row = normalizeConceptRow($a_lang, $a_row); |
159 | 162 | $b_row = normalizeConceptRow($b_lang, $b_row); |
— | — | @@ -164,13 +167,17 @@ |
165 | 168 | <tr class="row_item"> |
166 | 169 | <td class="cell_weight <?php print "weight_$a_wclass"; ?>"><?php print htmlspecialchars($a_weight); ?></td> |
167 | 170 | <td colspan="3" class="cell_name <?php print "weight_$a_wclass"; ?>"> |
| 171 | + <h3> |
168 | 172 | <a href="<?php print htmlspecialchars($a_cu); ?>"><?php print htmlspecialchars($a_concept_name); ?></a> |
169 | 173 | <span class="conceptref">(<a href="<?php print htmlspecialchars($a_wu); ?>" title="<?php print htmlspecialchars($a_concept_name); ?>">wiki page</a>)</span> |
| 174 | + </h3> |
170 | 175 | </td> |
171 | 176 | <?php if ($b_row) { ?> |
172 | 177 | <td colspan="3" class="cell_name <?php print "weight_$b_wclass"; ?>"> |
| 178 | + <h3> |
173 | 179 | <a href="<?php print htmlspecialchars($b_cu); ?>"><?php print htmlspecialchars($b_concept_name); ?></a> |
174 | 180 | <span class="conceptref">(<a href="<?php print htmlspecialchars($b_wu); ?>" title="<?php print htmlspecialchars($b_concept_name); ?>">wiki page</a>)</span> |
| 181 | + </h3> |
175 | 182 | </td> |
176 | 183 | <?php } ?> |
177 | 184 | </tr> |
— | — | @@ -199,6 +206,19 @@ |
200 | 207 | </tr> |
201 | 208 | <?php } ?> |
202 | 209 | |
| 210 | + <?php if ($images) { ?> |
| 211 | + <tr class="row_details row_images"> |
| 212 | + <td></td> |
| 213 | + <td class="cell_label">Images:</td> |
| 214 | + <td class="cell_broader" colspan="<?php $b_row ? 5 : 2 ?>"> |
| 215 | + <?php |
| 216 | + $gallery = $utils->getImagesAbout($a_reference_id, $terse ? $wwMaxPreviewImages : $wwMaxGalleryImages ); |
| 217 | + $c = printConceptImageList( $gallery, $terse ? "terselist" : "gallery" ); |
| 218 | + ?> |
| 219 | + </td> |
| 220 | + </tr> |
| 221 | + <?php } ?> |
| 222 | + |
203 | 223 | <?php if (isset($a_similar) && !empty($a_similar)) { ?> |
204 | 224 | <tr class="row_details row_similar"> |
205 | 225 | <td></td> |
— | — | @@ -247,15 +267,6 @@ |
248 | 268 | </tr> |
249 | 269 | <?php } ?> |
250 | 270 | |
251 | | - <?php if ($images) { ?> |
252 | | - <tr class="row_details row_images"> |
253 | | - <td></td> |
254 | | - <td class="cell_label">Images:</td> |
255 | | - <td class="cell_broader" colspan="<?php $b_row ? 5 : 2 ?>"> |
256 | | - <?php printConceptImageList($a_reference_id); ?> |
257 | | - </td> |
258 | | - </tr> |
259 | | - <?php } ?> |
260 | 271 | <?php |
261 | 272 | if (isset($a_weight) && $a_weight && $a_weight<2 && $pos>=3) return false; |
262 | 273 | else return true; |
— | — | @@ -401,36 +412,9 @@ |
402 | 413 | else if (@$row['concept']) $id = $row['concept']; |
403 | 414 | else $id = "concept"; |
404 | 415 | |
405 | | - if (@$row['local_concept_name']) $title = $row['local_concept_name']; |
406 | | - else if (@$row['concept_name']) $title = $row['concept_name']; |
407 | | - else if (@$row['name']) $title = $row['name']; |
408 | | - else if ($id) $title = "Concept #$id"; |
409 | | - else if ($concept) $title = "Concept #$concept"; |
410 | | - |
411 | 416 | ?> |
412 | 417 | <div id="<?php print htmlspecialchars("concept-$id")?>"> |
413 | | - <h2><?php print htmlspecialchars($title); ?></h2> |
414 | 418 | |
415 | | - <?php |
416 | | - if ($images) $gallery = $utils->getImagesAbout($id); |
417 | | - else $images = NULL; |
418 | | - |
419 | | - if ($gallery) { |
420 | | - $title = "Gallery #$concept"; |
421 | | - ?> |
422 | | - <h2><?php print htmlspecialchars($title); ?></h2> |
423 | | - <div border="0" class="gallery"> |
424 | | - <?php |
425 | | - printConceptImageList($gallery, "gallery"); |
426 | | - ?> |
427 | | - </div> |
428 | | - |
429 | | - <p>Found <?php print count($gallery); ?> images.</p> |
430 | | - |
431 | | - <?php |
432 | | - } |
433 | | - ?> |
434 | | - |
435 | 419 | <table border="0" class="results"> |
436 | 420 | <?php |
437 | 421 | if ($lang) { |
— | — | @@ -462,14 +446,14 @@ |
463 | 447 | if ($tolang && isset($row['global_concept'])) { |
464 | 448 | $toresult = $utils->queryConceptInfo($row['global_concept'], $tolang); |
465 | 449 | while ($torow = mysql_fetch_assoc($toresult)) { |
466 | | - $continue= printLocalConcept($lang, $row, $tolang, $torow, $count, $images); |
| 450 | + $continue= printLocalConcept($lang, $row, $tolang, $torow, $count, true); |
467 | 451 | $show_single = false; |
468 | 452 | } |
469 | 453 | mysql_free_result($toresult); |
470 | 454 | } |
471 | 455 | |
472 | 456 | if ($show_single) { |
473 | | - $continue= printLocalConcept($lang, $row, NULL, NULL, $count, $images); |
| 457 | + $continue= printLocalConcept($lang, $row, NULL, NULL, $count, true); |
474 | 458 | } |
475 | 459 | } |
476 | 460 | //else $continue= printGlobalConcept($lang, $row, $count); |
Index: trunk/WikiWord/WikiWord/src/main/php/wwthesaurus.php |
— | — | @@ -180,10 +180,14 @@ |
181 | 181 | function getRelatedForConcept( $id, $lang = null, $limit = 100 ) { |
182 | 182 | global $wwTablePrefix, $wwThesaurusDataset; |
183 | 183 | |
184 | | - $sql = "SELECT C.* FROM {$wwTablePrefix}_{$wwThesaurusDataset}_concept as C " |
185 | | - . " JOIN {$wwTablePrefix}_{$wwThesaurusDataset}_relation as R ON R.concept2 = C.id " |
186 | | - . " WHERE R.concept1 = ".(int)$id |
| 184 | + $sql = "SELECT " . ($lang ? " C.*, O.* " : " C.* " ) . " FROM {$wwTablePrefix}_{$wwThesaurusDataset}_concept as C " |
| 185 | + . " JOIN {$wwTablePrefix}_{$wwThesaurusDataset}_relation as R ON R.concept2 = C.id "; |
| 186 | + |
| 187 | + if ( $lang ) $sql .= " LEFT JOIN {$wwTablePrefix}_{$wwThesaurusDataset}_origin as O ON O.lang = \"" . mysql_real_escape_string($lang) . "\" AND C.id = O.global_concept "; |
| 188 | + |
| 189 | + $sql .= " WHERE R.concept1 = ".(int)$id |
187 | 190 | . " AND ( R.bilink > 0 OR R.langref > 0 OR R.langmatch > 0 )" |
| 191 | + . " GROUP BY C.id " |
188 | 192 | . " LIMIT " . (int)$limit; |
189 | 193 | |
190 | 194 | return $this->getRows($sql); |
— | — | @@ -192,9 +196,13 @@ |
193 | 197 | function getBroaderForConcept( $id, $lang = null, $limit = 100 ) { |
194 | 198 | global $wwTablePrefix, $wwThesaurusDataset; |
195 | 199 | |
196 | | - $sql = "SELECT C.* FROM {$wwTablePrefix}_{$wwThesaurusDataset}_concept as C " |
197 | | - . " JOIN {$wwTablePrefix}_{$wwThesaurusDataset}_broader as R ON R.broad = C.id " |
198 | | - . " WHERE R.narrow = ".(int)$id |
| 200 | + $sql = "SELECT " . ($lang ? " C.*, O.* " : " C.* " ) . " FROM {$wwTablePrefix}_{$wwThesaurusDataset}_concept as C " |
| 201 | + . " JOIN {$wwTablePrefix}_{$wwThesaurusDataset}_broader as R ON R.broad = C.id "; |
| 202 | + |
| 203 | + if ( $lang ) $sql .= " LEFT JOIN {$wwTablePrefix}_{$wwThesaurusDataset}_origin as O ON O.lang = \"" . mysql_real_escape_string($lang) . "\" AND C.id = O.global_concept "; |
| 204 | + |
| 205 | + $sql .= " WHERE R.narrow = ".(int)$id |
| 206 | + . " GROUP BY C.id " |
199 | 207 | . " LIMIT " . (int)$limit; |
200 | 208 | |
201 | 209 | return $this->getRows($sql); |
— | — | @@ -203,15 +211,19 @@ |
204 | 212 | function getNarrowerForConcept( $id, $lang = null, $limit = 100 ) { |
205 | 213 | global $wwTablePrefix, $wwThesaurusDataset; |
206 | 214 | |
207 | | - $sql = "SELECT C.* FROM {$wwTablePrefix}_{$wwThesaurusDataset}_concept as C " |
208 | | - . " JOIN {$wwTablePrefix}_{$wwThesaurusDataset}_broader as R ON R.narrow = C.id " |
209 | | - . " WHERE R.broad = ".(int)$id |
| 215 | + $sql = "SELECT " . ($lang ? " C.*, O.* " : " C.* " ) . " FROM {$wwTablePrefix}_{$wwThesaurusDataset}_concept as C " |
| 216 | + . " JOIN {$wwTablePrefix}_{$wwThesaurusDataset}_broader as R ON R.narrow = C.id "; |
| 217 | + |
| 218 | + if ( $lang ) $sql .= " LEFT JOIN {$wwTablePrefix}_{$wwThesaurusDataset}_origin as O ON O.lang = \"" . mysql_real_escape_string($lang) . "\" AND C.id = O.global_concept "; |
| 219 | + |
| 220 | + $sql .= " WHERE R.broad = ".(int)$id |
| 221 | + . " GROUP BY C.id " |
210 | 222 | . " LIMIT " . (int)$limit; |
211 | 223 | |
212 | 224 | return $this->getRows($sql); |
213 | 225 | } |
214 | 226 | |
215 | | - function getPagesForConcept( $id, $lang, $limit = 100 ) { |
| 227 | + function getPagesForConcept( $id, $lang = null, $limit = 100 ) { |
216 | 228 | global $wwTablePrefix, $wwThesaurusDataset, $wwLanguages; |
217 | 229 | |
218 | 230 | if ( !$lang ) $lang = array_keys( $wwLanguages ); |
Index: trunk/WikiWord/WikiWord/src/main/php/wwimages.php |
— | — | @@ -252,6 +252,7 @@ |
253 | 253 | if (!isset($wwLanguages[$lang])) continue; |
254 | 254 | |
255 | 255 | foreach ($pages as $page) { |
| 256 | + //FIXME: detect namespace prefix?! |
256 | 257 | $img = $this->getRelevantImagesOnPage($lang, 0, $page, true); |
257 | 258 | $images->addImages($img, $lang . ":" . $page, "article", 1); |
258 | 259 | } |
— | — | @@ -266,21 +267,27 @@ |
267 | 268 | $pages = $concepts['commons']; |
268 | 269 | |
269 | 270 | foreach ($pages as $page) { |
270 | | - $img = $this->getRelevantImagesOnPage("commons", 0, $page, false); |
271 | | - $images->addImages($img, "commons:" . $page, "gallery", 0.8); |
| 271 | + if ( $wwFakeCommonsConcepts || !preg_match('/^Category:(.*)$/', $page) ) { |
| 272 | + $img = $this->getRelevantImagesOnPage("commons", 0, $page, false); |
| 273 | + $images->addImages($img, "commons:" . $page, "gallery", 0.8); |
| 274 | + } |
272 | 275 | |
273 | 276 | if ($max && $images->size()>$max) { |
274 | 277 | $this->addImageTags($images); |
275 | 278 | return $images->listImages($max); |
276 | 279 | } |
277 | 280 | |
278 | | - $img = $this->getImagesInCategory("commons", $page); //FIXME: resource mapping |
279 | | - if ($img) $images->addImages($img, "commons:category:" . $page, "category", 0.5); |
280 | | - else if ($wwFakeCommonsConcepts && $wwFakeCommonsPlural && !preg_match('/s$/', $page)) { |
281 | | - $cname = $page."s"; |
| 281 | + if ( $wwFakeCommonsConcepts || preg_match('/^Category:(.*)$/', $page, $m) ) { |
| 282 | + if ( @$m[1] ) $page = $m[1]; //hack |
| 283 | + $img = $this->getImagesInCategory("commons", $page); |
282 | 284 | |
283 | | - $img = $this->getImagesInCategory("commons", $cname); //FIXME: resource mapping |
284 | | - $images->addImages($img, "commons:category:" . $cname, "category(pl)", 0.5); |
| 285 | + if ($img) $images->addImages($img, "commons:category:" . $page, "category", 0.5); |
| 286 | + else if ($wwFakeCommonsConcepts && $wwFakeCommonsPlural && !preg_match('/s$/', $page)) { |
| 287 | + $cname = $page."s"; |
| 288 | + |
| 289 | + $img = $this->getImagesInCategory("commons", $cname); |
| 290 | + $images->addImages($img, "commons:category:" . $cname, "category(pl)", 0.5); |
| 291 | + } |
285 | 292 | } |
286 | 293 | } |
287 | 294 | } |
Index: trunk/WikiWord/WikiWord/src/main/php/config.sample.php |
— | — | @@ -17,6 +17,7 @@ |
18 | 18 | #error_reporting(E_ALL); |
19 | 19 | |
20 | 20 | $wwMaxPreviewImages = 8; |
| 21 | +$wwMaxGalleryImages = 200; |
21 | 22 | $wwThumbSize = 120; |
22 | 23 | $wwThumbnailURL = "http://toolserver.org/tsthumb/tsthumb?f={name}&domain=commons.wikimedia.org&w={width}&h={height}"; |
23 | 24 | $wwImagePageURL = "http://commons.wikimedia.org/wiki/File:{name}"; |