Index: trunk/extensions/SemanticMaps/includes/queryprinters/SM_KMLPrinter.php |
— | — | @@ -11,10 +11,9 @@ |
12 | 12 | * @author Jeroen De Dauw |
13 | 13 | */ |
14 | 14 | class SMKMLPrinter extends SMWResultPrinter { |
15 | | - |
16 | 15 | /** |
17 | 16 | * Constructor. |
18 | | - * |
| 17 | + * |
19 | 18 | * @param $format String |
20 | 19 | * @param $inline |
21 | 20 | */ |
— | — | @@ -22,7 +21,7 @@ |
23 | 22 | parent::__construct( $format, $inline ); |
24 | 23 | $this->useValidator = true; |
25 | 24 | } |
26 | | - |
| 25 | + |
27 | 26 | /** |
28 | 27 | * Handler of the print request. |
29 | 28 | * |
— | — | @@ -30,7 +29,7 @@ |
31 | 30 | * |
32 | 31 | * @param SMWQueryResult $res |
33 | 32 | * @param $outputmode |
34 | | - * |
| 33 | + * |
35 | 34 | * @return array |
36 | 35 | */ |
37 | 36 | public function getResultText( SMWQueryResult $res, $outputmode ) { |
— | — | @@ -41,51 +40,51 @@ |
42 | 41 | return $this->getLink( $res, $outputmode ); |
43 | 42 | } |
44 | 43 | } |
45 | | - |
| 44 | + |
46 | 45 | /** |
47 | 46 | * @see SMWResultPrinter::handleParameters |
48 | | - * |
| 47 | + * |
49 | 48 | * @since 1.0 |
50 | | - * |
| 49 | + * |
51 | 50 | * @param array $params |
52 | 51 | * @param $outputmode |
53 | 52 | */ |
54 | 53 | protected function handleParameters( array $params, $outputmode ) { |
55 | 54 | $this->m_params = $params; |
56 | 55 | } |
57 | | - |
| 56 | + |
58 | 57 | /** |
59 | 58 | * Returns a list of parameter definitions. |
60 | | - * |
| 59 | + * |
61 | 60 | * @since 0.7.4 |
62 | | - * |
| 61 | + * |
63 | 62 | * @return array |
64 | 63 | */ |
65 | 64 | public function getParameters() { |
66 | 65 | global $egMapsDefaultLabel, $egMapsDefaultTitle; |
67 | | - |
| 66 | + |
68 | 67 | $params = array_merge( parent::getParameters(), $this->exportFormatParameters() ); |
69 | | - |
| 68 | + |
70 | 69 | $params['text'] = new Parameter( 'text', Parameter::TYPE_STRING, $egMapsDefaultLabel ); |
71 | 70 | //$params['text']->setDescription(); |
72 | | - |
| 71 | + |
73 | 72 | $params['title'] = new Parameter( 'title', Parameter::TYPE_STRING, $egMapsDefaultTitle ); |
74 | | - |
| 73 | + |
75 | 74 | $params[] = new Parameter( 'linkabsolute', Parameter::TYPE_BOOLEAN, true ); |
76 | | - |
| 75 | + |
77 | 76 | $params['pagelinktext'] = new Parameter( 'pagelinktext', Parameter::TYPE_STRING, wfMsg( 'semanticmaps-default-kml-pagelink' ) ); |
78 | 77 | |
79 | 78 | return $params; |
80 | 79 | } |
81 | | - |
| 80 | + |
82 | 81 | /** |
83 | 82 | * Returns the KML for the query result. |
84 | | - * |
| 83 | + * |
85 | 84 | * @since 0.7.3 |
86 | | - * |
| 85 | + * |
87 | 86 | * @param SMWQueryResult $res |
88 | 87 | * @param integer $outputmode |
89 | | - * |
| 88 | + * |
90 | 89 | * @return string |
91 | 90 | */ |
92 | 91 | protected function getKML( SMWQueryResult $res, $outputmode ) { |
— | — | @@ -93,32 +92,30 @@ |
94 | 93 | $queryHandler->setText( $this->m_params['text'] ); |
95 | 94 | $queryHandler->setTitle( $this->m_params['title'] ); |
96 | 95 | $queryHandler->setSubjectSeparator( '' ); |
97 | | - |
| 96 | + |
98 | 97 | $formatter = new MapsKMLFormatter( $this->m_params ); |
99 | 98 | $formatter->addPlacemarks( $queryHandler->getLocations() ); |
100 | | - |
| 99 | + |
101 | 100 | return $formatter->getKML(); |
102 | 101 | } |
103 | | - |
| 102 | + |
104 | 103 | /** |
105 | 104 | * Returns a link (HTML) pointing to a query that returns the actual KML file. |
106 | | - * |
| 105 | + * |
107 | 106 | * @since 0.7.3 |
108 | | - * |
| 107 | + * |
109 | 108 | * @param SMWQueryResult $res |
110 | 109 | * @param integer $outputmode |
111 | | - * |
| 110 | + * |
112 | 111 | * @return string |
113 | | - */ |
| 112 | + */ |
114 | 113 | protected function getLink( SMWQueryResult $res, $outputmode ) { |
115 | 114 | $searchLabel = $this->getSearchLabel( $outputmode ); |
116 | 115 | $link = $res->getQueryLink( $searchLabel ? $searchLabel : wfMsgForContent( 'semanticmaps-kml-link' ) ); |
117 | 116 | $link->setParameter( 'kml', 'format' ); |
118 | | - |
119 | 117 | $link->setParameter( $this->m_params['linkabsolute'] ? 'yes' : 'no', 'linkabsolute' ); |
120 | | - |
121 | 118 | $link->setParameter( $this->m_params['pagelinktext'], 'pagelinktext' ); |
122 | | - |
| 119 | + |
123 | 120 | if ( array_key_exists( 'limit', $this->m_params ) ) { |
124 | 121 | $link->setParameter( $this->m_params['limit'], 'limit' ); |
125 | 122 | } else { // Use a reasonable default limit. |
— | — | @@ -126,10 +123,10 @@ |
127 | 124 | } |
128 | 125 | |
129 | 126 | $this->isHTML = ( $outputmode == SMW_OUTPUT_HTML ); |
130 | | - |
131 | | - return $link->getText( $outputmode, $this->mLinker ); |
| 127 | + |
| 128 | + return $link->getText( $outputmode, $this->mLinker ); |
132 | 129 | } |
133 | | - |
| 130 | + |
134 | 131 | /** |
135 | 132 | * @see SMWResultPrinter::getMimeType() |
136 | 133 | */ |
— | — | @@ -139,17 +136,16 @@ |
140 | 137 | |
141 | 138 | /** |
142 | 139 | * @see SMWResultPrinter::getFileName() |
143 | | - */ |
| 140 | + */ |
144 | 141 | public function getFileName( $res ) { |
145 | | - // TODO FIXME |
| 142 | + // @TODO FIXME |
146 | 143 | return 'kml.kml'; |
147 | 144 | } |
148 | | - |
| 145 | + |
149 | 146 | /** |
150 | 147 | * @see SMWResultPrinter::getName() |
151 | 148 | */ |
152 | 149 | public final function getName() { |
153 | 150 | return wfMsg( 'semanticmaps-kml' ); |
154 | 151 | } |
155 | | - |
156 | 152 | } |