Index: trunk/extensions/SmoothGallery/SmoothGallery.php |
— | — | @@ -35,7 +35,7 @@ |
36 | 36 | $wgExtensionCredits['other'][] = array( |
37 | 37 | 'path' => __FILE__, |
38 | 38 | 'name' => 'SmoothGallery parser extension', |
39 | | - 'version' => '1.1d', |
| 39 | + 'version' => '1.1e', |
40 | 40 | 'author' => 'Ryan Lane', |
41 | 41 | 'description' => 'Allows users to create galleries with images that have been uploaded. Allows most options of SmoothGallery', |
42 | 42 | 'descriptionmsg' => 'smoothgallery-desc', |
Index: trunk/extensions/SmoothGallery/SmoothGalleryParser.php |
— | — | @@ -22,70 +22,53 @@ |
23 | 23 | |
24 | 24 | function parseArguments( $argv ) { |
25 | 25 | // Parse arguments, set defaults, and do sanity checks |
| 26 | + $this->argumentArray = array( "height" => "300px", "width" => "400px", "carousel" => true, "timed" => false, |
| 27 | + "delay" => "9000", "showarrows" => true, "showinfopane" => true, |
| 28 | + "slideinfozoneslide" => true, "slideinfozoneopacity" => "0.7", "fallback" => "gallery", |
| 29 | + "nolink" => false ); |
| 30 | + |
26 | 31 | if ( isset( $argv["height"] ) && is_numeric( $argv["height"] ) ) { |
27 | 32 | $this->argumentArray["height"] = $argv["height"] . "px"; |
28 | | - } else { |
29 | | - $this->argumentArray["height"] = "300px"; |
30 | 33 | } |
31 | 34 | |
32 | 35 | if ( isset( $argv["width"] ) && is_numeric( $argv["width"] ) ) { |
33 | 36 | $this->argumentArray["width"] = $argv["width"] . "px"; |
34 | | - } else { |
35 | | - $this->argumentArray["width"] = "400px"; |
36 | 37 | } |
37 | 38 | |
38 | 39 | if ( isset( $argv["showcarousel"] ) && $argv["showcarousel"] == "false" ) { |
39 | 40 | $this->argumentArray["carousel"] = false; |
40 | | - } else { |
41 | | - $this->argumentArray["carousel"] = true; |
42 | 41 | } |
43 | 42 | |
44 | 43 | if ( isset( $argv["timed"] ) && $argv["timed"] == "true" ) { |
45 | 44 | $this->argumentArray["timed"] = true; |
46 | | - } else { |
47 | | - $this->argumentArray["timed"] = false; |
48 | 45 | } |
49 | 46 | |
50 | 47 | if ( isset( $argv["delay"] ) && is_numeric( $argv["delay"] ) ) { |
51 | 48 | $this->argumentArray["delay"] = $argv["delay"]; |
52 | | - } else { |
53 | | - $this->argumentArray["delay"] = "9000"; |
54 | 49 | } |
55 | 50 | |
56 | 51 | if ( isset( $argv["showarrows"] ) && $argv["showarrows"] == "false" ) { |
57 | 52 | $this->argumentArray["showarrows"] = false; |
58 | | - } else { |
59 | | - $this->argumentArray["showarrows"] = true; |
60 | 53 | } |
61 | 54 | |
62 | 55 | if ( isset( $argv["showinfopane"] ) && $argv["showinfopane"] == "false" ) { |
63 | 56 | $this->argumentArray["showinfopane"] = false; |
64 | | - } else { |
65 | | - $this->argumentArray["showinfopane"] = true; |
66 | 57 | } |
67 | 58 | |
68 | 59 | if ( isset( $argv["slideinfozoneslide"] ) && $argv["slideinfozoneslide"] == "false" ) { |
69 | 60 | $this->argumentArray["slideinfozoneslide"] = false; |
70 | | - } else { |
71 | | - $this->argumentArray["slideinfozoneslide"] = true; |
72 | 61 | } |
73 | 62 | |
74 | 63 | if ( isset( $argv["slideinfozoneopacity"] ) && is_numeric( $argv["slideinfozoneopacity"] ) ) { |
75 | 64 | $this->argumentArray["slideinfozoneopacity"] = $argv["slideinfozoneopacity"]; |
76 | | - } else { |
77 | | - $this->argumentArray["slideinfozoneopacity"] = "0.7"; |
78 | 65 | } |
79 | 66 | |
80 | 67 | if ( isset( $argv["fallback"] ) ) { |
81 | 68 | $this->argumentArray["fallback"] = htmlspecialchars( $argv["fallback"] ); |
82 | | - } else { |
83 | | - $this->argumentArray["fallback"] = "gallery"; |
84 | 69 | } |
85 | 70 | |
86 | 71 | if ( isset( $argv["nolink"] ) && $argv["nolink"] == "true" ) { |
87 | 72 | $this->argumentArray["nolink"] = true; |
88 | | - } else { |
89 | | - $this->argumentArray["nolink"] = false; |
90 | 73 | } |
91 | 74 | } |
92 | 75 | |
— | — | @@ -143,10 +126,12 @@ |
144 | 127 | $img_arr = explode( "|", $line, 2 ); |
145 | 128 | $img = $img_arr[0]; |
146 | 129 | if ( count( $img_arr ) > 1 ) { |
| 130 | + SmoothGallery::debug( 'sgallery line has description: ' . $img_arr[1] ); |
147 | 131 | $img_desc = $img_arr[1]; |
148 | 132 | } else { |
149 | 133 | $img_desc = ''; |
150 | 134 | } |
| 135 | + SmoothGallery::debug( 'sgallery line as img_arr: ', $img_arr ); |
151 | 136 | |
152 | 137 | if ( $wgSmoothGalleryAllowExternal && |
153 | 138 | ( ( strlen( $img ) >= 7 && substr( $img, 0, 7 ) == "http://" ) || |
— | — | @@ -178,20 +163,13 @@ |
179 | 164 | $ns = $title->getNamespace(); |
180 | 165 | |
181 | 166 | if ( $ns == NS_IMAGE ) { |
182 | | - if ( $img_desc != '' ) { |
183 | | - $galleryArray = $this->parseImage( $title, $parser, $galleryArray, true ); |
184 | | - if ( isset( $galleryArray["descriptions"]["$title"] ) ) { |
185 | | - $galleryArray["descriptions"]["$title"] = $img_desc; |
186 | | - } |
187 | | - } else { |
188 | | - $galleryArray = $this->parseImage( $title, $parser, $galleryArray ); |
189 | | - } |
| 167 | + $galleryArray = $this->parseImage( $title, $parser, $galleryArray, $img_desc ); |
190 | 168 | } else if ( $ns == NS_CATEGORY ) { |
191 | 169 | // list images in category |
192 | 170 | $cat_images = $this->smoothGalleryImagesByCat( $title ); |
193 | 171 | if ( $cat_images ) { |
194 | 172 | foreach ( $cat_images as $title ) { |
195 | | - $galleryArray = $this->parseImage( $title, $parser, $galleryArray ); |
| 173 | + $galleryArray = $this->parseImage( $title, $parser, $galleryArray, '' ); |
196 | 174 | } |
197 | 175 | } |
198 | 176 | } |
— | — | @@ -200,7 +178,7 @@ |
201 | 179 | return $galleryArray; |
202 | 180 | } |
203 | 181 | |
204 | | - function parseImage( $title, $parser, $galleryArray, $getDescription = false ) { |
| 182 | + function parseImage( $title, $parser, $galleryArray, $description ) { |
205 | 183 | global $wgUser; |
206 | 184 | global $wgSmoothGalleryThumbHeight, $wgSmoothGalleryThumbWidth; |
207 | 185 | |
— | — | @@ -258,27 +236,25 @@ |
259 | 237 | } |
260 | 238 | } |
261 | 239 | |
262 | | - $fulldesc = ''; |
263 | | - |
264 | 240 | if ( $this->argumentArray["showinfopane"] ) { |
265 | | - if ( $getDescription ) { |
| 241 | + if ( $description == '' ) { |
266 | 242 | // Load the image page from the database with the provided title from |
267 | 243 | // the image object |
268 | 244 | $db = wfGetDB( DB_SLAVE ); |
269 | 245 | $img_rev = Revision::loadFromTitle( $db, $title ); |
270 | 246 | |
271 | 247 | // Get the text from the image page's description |
272 | | - $fulldesc = $img_rev->getText(); |
| 248 | + $description = $img_rev->getText(); |
273 | 249 | } |
274 | 250 | |
275 | 251 | // convert wikitext to HTML |
276 | 252 | // TODO: find out why this doesn't work with special pages |
277 | 253 | if ( $parser ) { |
278 | | - $pout = $parser->recursiveTagParse( $fulldesc, $title, $parser->mOptions, true ); |
279 | | - $fulldesc = strip_tags( $pout ); |
| 254 | + $pout = $parser->recursiveTagParse( $description, $title, $parser->mOptions, true ); |
| 255 | + $description = strip_tags( $pout ); |
280 | 256 | # $fulldesc = strip_tags( $pout->getText() ); |
281 | 257 | } else { // fall back to HTML-escaping |
282 | | - $fulldesc = htmlspecialchars( $fulldesc ); |
| 258 | + $description = htmlspecialchars( $description ); |
283 | 259 | } |
284 | 260 | } |
285 | 261 | |
— | — | @@ -289,7 +265,7 @@ |
290 | 266 | |
291 | 267 | # We need the following for the image's div |
292 | 268 | $imageArray["heading"] = $skin->makeKnownLinkObj( $img_obj->getTitle(), $img_obj->getName() ); |
293 | | - $imageArray["description"] = $fulldesc; |
| 269 | + $imageArray["description"] = $description; |
294 | 270 | $imageArray["full_url"] = $title->getFullURL(); |
295 | 271 | $imageArray["view_url"] = $img_obj->getViewURL(); |
296 | 272 | $imageArray["full_thumb_url"] = $full_thumb; |