Index: trunk/extensions/ImportFreeImages/ImportFreeImages.php |
— | — | @@ -17,18 +17,20 @@ |
18 | 18 | $wgExtensionFunctions[] = 'wfImportFreeImages'; |
19 | 19 | $wgIFI_FlickrAPIKey = ''; |
20 | 20 | $wgIFI_CreditsTemplate = 'flickr'; // use this to format the image content with some key parameters |
21 | | -$wgIFI_GetOriginal = false; // import the original version of the photo |
22 | | -$wgIFI_PromptForFilename = false; // prompt the user through javascript for the destination filename |
| 21 | +$wgIFI_GetOriginal = true; // import the original version of the photo |
| 22 | +$wgIFI_PromptForFilename = true; // prompt the user through javascript for the destination filename |
23 | 23 | |
24 | 24 | $wgIFI_ResultsPerPage = 20; |
25 | | -$wgIFI_ResultsPerRow = 5; |
| 25 | +$wgIFI_ResultsPerRow = 4; |
26 | 26 | // see the flickr api page for more information on these params |
27 | 27 | // for licnese info http://www.flickr.com/services/api/flickr.photos.licenses.getInfo.html |
28 | 28 | // default 4 is CC Attribution License |
29 | 29 | $wgIFI_FlickrLicense = "4,5"; |
30 | | -$wgIFI_FlickrSort = "relevance"; |
31 | | -$wgIFI_FlickrSearchBy = "text"; // Can be tags or text. See http://www.flickr.com/services/api/flickr.photos.search.html |
| 30 | +$wgIFI_FlickrSort = "interestingness-desc"; |
| 31 | +$wgIFI_FlickrSearchBy = "tags"; // Can be tags or text. See http://www.flickr.com/services/api/flickr.photos.search.html |
32 | 32 | $wgIFI_AppendRandomNumber = true; /// append random # to destination filename |
| 33 | +$wgIFI_ThumbType = "t"; // s for square t for thumbnail |
| 34 | + |
33 | 35 | require_once("SpecialPage.php"); |
34 | 36 | |
35 | 37 | |
— | — | @@ -59,7 +61,6 @@ |
60 | 62 | 'importfreeimages_filefromflickr' => '$1 by user <b>[$2]</b> from flickr. Original URL', |
61 | 63 | 'importfreeimages_promptuserforfilename' => 'Please enter a destination filename:', |
62 | 64 | 'importfreeimages_returntoform' => 'Or, click <a href=\'$1\'>here</a> to return to return to your search results', |
63 | | - 'importfreeimages_invalidurl' => 'Invalid URL', |
64 | 65 | ) |
65 | 66 | ); |
66 | 67 | |
— | — | @@ -125,7 +126,7 @@ |
126 | 127 | { |
127 | 128 | global $wgUser, $wgOut, $wgScriptPath, $wgRequest, $wgLang, $wgIFI_FlickrAPIKey, $wgTmpDirectory; |
128 | 129 | global $wgIFI_ResultsPerPage, $wgIFI_FlickrSort, $wgIFI_FlickrLicense, $wgIFI_ResultsPerRow, $wgIFI_CreditsTemplate; |
129 | | - global $wgIFI_GetOriginal, $wgIFI_PromptForFilename, $wgIFI_AppendRandomNumber, $wgIFI_FlickrSearchBy; |
| 130 | + global $wgIFI_GetOriginal, $wgIFI_PromptForFilename, $wgIFI_AppendRandomNumber, $wgIFI_FlickrSearchBy, $wgIFI_ThumbType; |
130 | 131 | require_once("phpFlickr-2.0.0/phpFlickr.php"); |
131 | 132 | |
132 | 133 | $fname = "wfSpecialImportFreeImages"; |
— | — | @@ -150,10 +151,10 @@ |
151 | 152 | $import = ''; |
152 | 153 | if ($wgRequest->wasPosted() && isset($_POST['url'])) { |
153 | 154 | $import = $_POST['url']; |
154 | | - if (!preg_match('/^http:\/\/farm[0-9]+.static.flickr.com/', $import)) { |
155 | | - $wgOut->errorpage('error', 'importfreeimages_invalidurl'); |
156 | | - return; |
157 | | - } |
| 155 | + if (!preg_match('/^http:\/\/farm[0-9]+.static.flickr.com/', $import)) { |
| 156 | + $wgOut->errorpage('error', 'importfreeimages_invalidurl'); |
| 157 | + return; |
| 158 | + } |
158 | 159 | |
159 | 160 | $f = new phpFlickr($wgIFI_FlickrAPIKey); |
160 | 161 | |
— | — | @@ -183,7 +184,6 @@ |
184 | 185 | fclose($r); |
185 | 186 | chmod( $name, 0777 ); |
186 | 187 | $info = $f->photos_getInfo($_POST['id']); |
187 | | - |
188 | 188 | |
189 | 189 | if (!empty($wgIFI_CreditsTemplate)) { |
190 | 190 | $caption = "{{" . $wgIFI_CreditsTemplate . $info['license'] . "|{$_POST['id']}|" . urldecode($_POST['owner']) . "|" . urldecode($_POST['name']). "}}"; |
— | — | @@ -191,7 +191,7 @@ |
192 | 192 | $caption = wfMsg('importfreeimages_filefromflickr', $_POST['t'], "http://www.flickr.com/people/" . urlencode($_POST['owner']) . " " . $_POST['name']) . " <nowiki>$import</nowiki>. {{CC by 2.0}} "; |
193 | 193 | } |
194 | 194 | $caption = trim($caption); |
195 | | - $t = $_POST['title']; |
| 195 | + $t = $_POST['ititle']; |
196 | 196 | |
197 | 197 | // handle duplicate filenames |
198 | 198 | $i = strrpos($import, "/"); |
— | — | @@ -215,7 +215,7 @@ |
216 | 216 | "caption" => $caption, |
217 | 217 | "url" => $import, "title" => $_POST['t'] ); |
218 | 218 | */ |
219 | | - $filename = urldecode($_POST['title']) . ($wgIFI_AppendRandomNumber ? "-" . rand(0, 9999) : "") . ".jpg"; |
| 219 | + $filename = urldecode($_POST['ititle']) . ($wgIFI_AppendRandomNumber ? "-" . rand(0, 9999) : "") . ".jpg"; |
220 | 220 | $filename = str_replace("?", "", $filename); |
221 | 221 | $filename = str_replace(":", "", $filename); |
222 | 222 | $filename = preg_replace('/ [ ]*/', ' ', $filename); |
— | — | @@ -275,21 +275,21 @@ |
276 | 276 | <input type=hidden name='action' value='submit'> |
277 | 277 | <input type=hidden name='owner' value=''> |
278 | 278 | <input type=hidden name='name' value=''> |
279 | | - <input type=hidden name='title' value=''> |
| 279 | + <input type=hidden name='ititle' value=''> |
280 | 280 | |
281 | 281 | <script type=\"text/javascript\"> |
282 | 282 | |
283 | | - function s2 (url, id, owner, name, title) { |
| 283 | + function s2 (url, id, owner, name, ititle) { |
284 | 284 | document.uploadphotoform.url.value = url; |
285 | 285 | document.uploadphotoform.id.value = id; |
286 | 286 | document.uploadphotoform.owner.value = owner; |
287 | 287 | document.uploadphotoform.name.value = name; |
288 | | - document.uploadphotoform.title.value = title; |
| 288 | + document.uploadphotoform.ititle.value = ititle; |
289 | 289 | if (" . ($wgIFI_PromptForFilename ? "true" : "false") . ") { |
290 | | - title = title.replace(/\+/g, ' '); |
291 | | - document.uploadphotoform.title.value = prompt('" . wfMsg('importfreeimages_promptuserforfilename') . "', unescape(title)); |
292 | | - if (document.uploadphotoform.title.value == '') { |
293 | | - document.uploadphotoform.title.value = title; |
| 290 | + ititle = ititle.replace(/\+/g, ' '); |
| 291 | + document.uploadphotoform.ititle.value = prompt('" . wfMsg('importfreeimages_promptuserforfilename') . "', unescape(ititle)); |
| 292 | + if (document.uploadphotoform.ititle.value == '') { |
| 293 | + document.uploadphotoform.ititle.value = ititle; |
294 | 294 | } |
295 | 295 | } |
296 | 296 | document.uploadphotoform.submit(); |
— | — | @@ -298,8 +298,6 @@ |
299 | 299 | </script> |
300 | 300 | |
301 | 301 | "); |
302 | | -//print_r($photos); |
303 | | -//exit; |
304 | 302 | foreach ($photos['photo'] as $photo) { |
305 | 303 | if ($i % $wgIFI_ResultsPerRow == 0) $wgOut->addHTML("<tr>"); |
306 | 304 | $owner = $f->people_getInfo($photo['owner']); |
— | — | @@ -309,8 +307,9 @@ |
310 | 308 | $wgOut->addHTML( "<a href='http://www.flickr.com/people/" . $photo['owner'] . "/'>") ; |
311 | 309 | $wgOut->addHTML( $owner['username'] ); |
312 | 310 | $wgOut->addHTML( "</a><br/>" ); |
313 | | - $url="http://farm{$photo['farm']}.static.flickr.com/{$photo['server']}/{$photo['id']}_{$photo['secret']}.jpg"; |
314 | | - $wgOut->addHTML( "<img src=\"http://farm{$photo['farm']}.static.flickr.com/{$photo['server']}/{$photo['id']}_{$photo['secret']}_s.jpg\">" ); |
| 311 | + //$wgOut->addHTML( "<img src=http://static.flickr.com/" . $photo['server'] . "/" . $photo['id'] . "_" . $photo['secret'] . "." . "jpg>" ); |
| 312 | + $url="http://farm{$photo['farm']}.static.flickr.com/{$photo['server']}/{$photo['id']}_{$photo['secret']}.jpg"; |
| 313 | + $wgOut->addHTML( "<img src=\"http://farm{$photo['farm']}.static.flickr.com/{$photo['server']}/{$photo['id']}_{$photo['secret']}_{$wgIFI_ThumbType}.jpg\">" ); |
315 | 314 | |
316 | 315 | $wgOut->addHTML( "<br/>(<a href='#' onclick=\"s2('$url', '{$photo['id']}','{$photo['owner']}', '" |
317 | 316 | . urlencode($owner['username'] ) . "', '" . urlencode($photo['title']) . "');\">" . |
— | — | @@ -327,3 +326,4 @@ |
328 | 327 | } |
329 | 328 | } |
330 | 329 | ?> |
| 330 | + |