r7166 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r7165‎ | r7166 | r7167 >
Date:15:49, 18 January 2005
Author:magnus_manske
Status:old
Tags:
Comment:
draw updates
Modified paths:
  • /trunk/extensions/geo/geo.php (modified) (history)
  • /trunk/extensions/geo/index.php (modified) (history)

Diff [purge]

Index: trunk/extensions/geo/geo.php
@@ -9,6 +9,7 @@
1010 var $max_x = -1000000 ;
1111 var $min_y = 1000000 ;
1212 var $max_y = -1000000 ;
 13+ var $draw = array () ; # What to draw
1314 var $labels = array () ; # The text labels
1415 var $languages = array ( "en" ) ; # Default language
1516 var $styles = array ( "default" => "fill:#EEEEEE;" ) ; # All the styles
@@ -32,27 +33,23 @@
3334 {
3435 $this->languages = explode ( ";" , str_replace ( "," , ";" , $value ) ) ; # "," and ";" are valid separators
3536 }
36 - else if ( $key == "style" || $key == "label" )
 37+ else if ( $key == "style" || $key == "label" || $key == "draw" )
3738 {
3839 $a = explode ( "=" , $value , 2 ) ;
39 - if ( count ( $a ) == 2 )
 40+ if ( count ( $a ) == 1 ) $a[] = "1" ;
 41+ $b = explode ( ";" , str_replace ( "," , ";" , $a[0] ) ) ;
 42+ foreach ( $b AS $c )
4043 {
41 - $b = explode ( ";" , str_replace ( "," , ";" , $a[0] ) ) ;
42 - foreach ( $b AS $c )
 44+ $d = explode ( ";" , str_replace ( "," , ";" , $a[1] ) ) ;
 45+ foreach ( $d AS $e )
4346 {
44 -# if ( $key == "style" )
45 - {
46 - $d = explode ( ";" , str_replace ( "," , ";" , $a[1] ) ) ;
47 - foreach ( $d AS $e )
48 - {
49 - $e = explode ( ":" , $e ) ;
50 - $va = trim ( strtolower ( $e[0] ) ) ;
51 - if ( count ( $e ) < 2 ) $vb = "" ; #/*$this->styles*/$kv[$c][$e[0]] = "" ;
52 - else $vb = trim ( strtolower ( $e[1] ) ) ;# /*$this->styles*/$kv[$c][$e[0]] = trim ( strtolower ( $e[1] ) ) ;
53 - if ( $key == "style" ) $this->styles[$c][$va] = $vb ;
54 - else $this->label_styles[$c][$va] = $vb ;
55 - }
56 - }
 47+ $e = explode ( ":" , $e ) ;
 48+ $va = trim ( strtolower ( $e[0] ) ) ;
 49+ if ( count ( $e ) < 2 ) $vb = "" ; #/*$this->styles*/$kv[$c][$e[0]] = "" ;
 50+ else $vb = trim ( strtolower ( $e[1] ) ) ;# /*$this->styles*/$kv[$c][$e[0]] = trim ( strtolower ( $e[1] ) ) ;
 51+ if ( $key == "style" ) $this->styles[$c][$va] = $vb ;
 52+ else if ( $key == "label" ) $this->label_styles[$c][$va] = $vb ;
 53+ else if ( $key == "draw" ) $this->draw[$c][$va] = $vb ;
5754 }
5855 }
5956 }
@@ -437,7 +434,7 @@
438435 if ( !$this->label_this ( $params ) ) return ;
439436 $text = $this->get_specs ( "name" , $params->languages ) ;
440437 if ( $text == "" ) return "" ; # No label found
441 - $text = $this->data[$text][0] ;
 438+ $text = trim ( $this->data[$text][0] ) ;
442439 if ( $text == "" ) return "" ; # No point in showing an empty label
443440 $x = floor ( $x ) ;
444441 $y = floor ( $y ) ;
@@ -464,7 +461,9 @@
465462 {
466463 $b = $this->get_data ( $params ) ;
467464 $b = $b[0] ; # Only one point for cities...
468 - $r = 300 ;
 465+ if ( isset ( $this->data['magnitude'] ) ) $r = $this->data['magnitude'] * 100 ;
 466+ else $r = 300 ;
 467+ $params->data_to_real ( $b[0] , $b[1] ) ;
469468 $ret .= "<circle cx=\"{$b[0]}\" cy=\"{$b[1]}\" r=\"{$r}\" fill=\"red\" style=\"fill-opacity:0.5\"/>\n" ;
470469 $this->add_label ( $b[0] , $b[1] , $params ) ;
471470 }
@@ -487,7 +486,9 @@
488487
489488 function draw_this ( &$params )
490489 {
491 - return true ;
 490+ $a = $this->my_matches ( $params->draw , $params ) ;
 491+ if ( count ( $a ) > 0 ) return true ;
 492+ return false ;
492493 }
493494
494495 function label_this ( &$params )
Index: trunk/extensions/geo/index.php
@@ -13,11 +13,11 @@
1414 languages:de,en
1515 show:germany
1616 fit:germany
 17+draw:germany[state],germany.bavaria[city]
1718 draw:germany.sh.cities#kiel
18 -draw:germany.bavaria.cities#munich
1919 style:germany[state],germany[isle]=fill:#CCCCCC; stroke:black; stroke-width:10
2020 style:germany.hamburg=fill:red
21 -label:germany.bavaria.cities#munich=font-size:medium;fill-opacity:1.0;clickable:yes
 21+label:germany.bavaria[city]=font-size:medium;fill-opacity:1.0;clickable:yes
2222 label:germany[state]=font-size:medium;fill-opacity:0.7
2323 " ) ;
2424

Follow-up revisions

RevisionCommit summaryAuthorDate
r48744SocialProfile: apply r7166 from wikia codebase (http://trac.wikia-code.com/ch...ashley15:35, 24 March 2009

Status & tagging log