r20367 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r20366‎ | r20367 | r20368 >
Date:13:33, 12 March 2007
Author:travis
Status:old
Tags:
Comment:
add back in things taken out
Modified paths:
  • /trunk/extensions/ImportFreeImages/ImportFreeImages.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ImportFreeImages/ImportFreeImages.php
@@ -17,18 +17,20 @@
1818 $wgExtensionFunctions[] = 'wfImportFreeImages';
1919 $wgIFI_FlickrAPIKey = '';
2020 $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
2323
2424 $wgIFI_ResultsPerPage = 20;
25 -$wgIFI_ResultsPerRow = 5;
 25+$wgIFI_ResultsPerRow = 4;
2626 // see the flickr api page for more information on these params
2727 // for licnese info http://www.flickr.com/services/api/flickr.photos.licenses.getInfo.html
2828 // default 4 is CC Attribution License
2929 $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
3232 $wgIFI_AppendRandomNumber = true; /// append random # to destination filename
 33+$wgIFI_ThumbType = "t"; // s for square t for thumbnail
 34+
3335 require_once("SpecialPage.php");
3436
3537
@@ -59,7 +61,6 @@
6062 'importfreeimages_filefromflickr' => '$1 by user <b>[$2]</b> from flickr. Original URL',
6163 'importfreeimages_promptuserforfilename' => 'Please enter a destination filename:',
6264 'importfreeimages_returntoform' => 'Or, click <a href=\'$1\'>here</a> to return to return to your search results',
63 - 'importfreeimages_invalidurl' => 'Invalid URL',
6465 )
6566 );
6667
@@ -125,7 +126,7 @@
126127 {
127128 global $wgUser, $wgOut, $wgScriptPath, $wgRequest, $wgLang, $wgIFI_FlickrAPIKey, $wgTmpDirectory;
128129 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;
130131 require_once("phpFlickr-2.0.0/phpFlickr.php");
131132
132133 $fname = "wfSpecialImportFreeImages";
@@ -150,10 +151,10 @@
151152 $import = '';
152153 if ($wgRequest->wasPosted() && isset($_POST['url'])) {
153154 $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+ }
158159
159160 $f = new phpFlickr($wgIFI_FlickrAPIKey);
160161
@@ -183,7 +184,6 @@
184185 fclose($r);
185186 chmod( $name, 0777 );
186187 $info = $f->photos_getInfo($_POST['id']);
187 -
188188
189189 if (!empty($wgIFI_CreditsTemplate)) {
190190 $caption = "{{" . $wgIFI_CreditsTemplate . $info['license'] . "|{$_POST['id']}|" . urldecode($_POST['owner']) . "|" . urldecode($_POST['name']). "}}";
@@ -191,7 +191,7 @@
192192 $caption = wfMsg('importfreeimages_filefromflickr', $_POST['t'], "http://www.flickr.com/people/" . urlencode($_POST['owner']) . " " . $_POST['name']) . " <nowiki>$import</nowiki>. {{CC by 2.0}} ";
193193 }
194194 $caption = trim($caption);
195 - $t = $_POST['title'];
 195+ $t = $_POST['ititle'];
196196
197197 // handle duplicate filenames
198198 $i = strrpos($import, "/");
@@ -215,7 +215,7 @@
216216 "caption" => $caption,
217217 "url" => $import, "title" => $_POST['t'] );
218218 */
219 - $filename = urldecode($_POST['title']) . ($wgIFI_AppendRandomNumber ? "-" . rand(0, 9999) : "") . ".jpg";
 219+ $filename = urldecode($_POST['ititle']) . ($wgIFI_AppendRandomNumber ? "-" . rand(0, 9999) : "") . ".jpg";
220220 $filename = str_replace("?", "", $filename);
221221 $filename = str_replace(":", "", $filename);
222222 $filename = preg_replace('/ [ ]*/', ' ', $filename);
@@ -275,21 +275,21 @@
276276 <input type=hidden name='action' value='submit'>
277277 <input type=hidden name='owner' value=''>
278278 <input type=hidden name='name' value=''>
279 - <input type=hidden name='title' value=''>
 279+ <input type=hidden name='ititle' value=''>
280280
281281 <script type=\"text/javascript\">
282282
283 - function s2 (url, id, owner, name, title) {
 283+ function s2 (url, id, owner, name, ititle) {
284284 document.uploadphotoform.url.value = url;
285285 document.uploadphotoform.id.value = id;
286286 document.uploadphotoform.owner.value = owner;
287287 document.uploadphotoform.name.value = name;
288 - document.uploadphotoform.title.value = title;
 288+ document.uploadphotoform.ititle.value = ititle;
289289 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;
294294 }
295295 }
296296 document.uploadphotoform.submit();
@@ -298,8 +298,6 @@
299299 </script>
300300
301301 ");
302 -//print_r($photos);
303 -//exit;
304302 foreach ($photos['photo'] as $photo) {
305303 if ($i % $wgIFI_ResultsPerRow == 0) $wgOut->addHTML("<tr>");
306304 $owner = $f->people_getInfo($photo['owner']);
@@ -309,8 +307,9 @@
310308 $wgOut->addHTML( "<a href='http://www.flickr.com/people/" . $photo['owner'] . "/'>") ;
311309 $wgOut->addHTML( $owner['username'] );
312310 $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\">" );
315314
316315 $wgOut->addHTML( "<br/>(<a href='#' onclick=\"s2('$url', '{$photo['id']}','{$photo['owner']}', '"
317316 . urlencode($owner['username'] ) . "', '" . urlencode($photo['title']) . "');\">" .
@@ -327,3 +326,4 @@
328327 }
329328 }
330329 ?>
 330+