Index: trunk/extensions/ImageTagging/ImageTagPage.php |
— | — | @@ -18,6 +18,12 @@ |
19 | 19 | $wgHooks['ArticleFromTitle'][] = 'wfArticleFromTitle'; |
20 | 20 | |
21 | 21 | |
| 22 | +$dir = dirname(__FILE__) . '/'; |
| 23 | +$wgAutoloadClasses['TaggedImages'] = $dir . 'SpecialTaggedImages.php'; |
| 24 | +$wgSpecialPages['TaggedImages'] = 'TaggedImages'; |
| 25 | + |
| 26 | + |
| 27 | + |
22 | 28 | /******************** |
23 | 29 | * End Trie Handlers |
24 | 30 | ********************/ |
— | — | @@ -30,8 +36,8 @@ |
31 | 37 | { |
32 | 38 | $db =& wfGetDB(DB_SLAVE); |
33 | 39 | $res = $db->query("SELECT article_tag, tag_rect, unique_id, COUNT(article_tag) AS count FROM ". |
34 | | - " `$wgDBname`.`imagetags` ". |
35 | | - " WHERE article_tag='" . addslashes($wgTitle->getText()). "'" . /*LIMIT 1"*/ " GROUP BY article_tag" ); |
| 40 | + $db->tableName('imagetags'). |
| 41 | + " WHERE article_tag='" . addslashes($wgTitle->getText()). "' GROUP BY article_tag" ); |
36 | 42 | |
37 | 43 | if ($o = $db->fetchObject($res)) { |
38 | 44 | $taggedImagesObj = Title::newFromText('TaggedImages', NS_SPECIAL); |
— | — | @@ -92,12 +98,14 @@ |
93 | 99 | wfPurgeTitle($imgTitle); |
94 | 100 | |
95 | 101 | $db =& wfGetDB(DB_MASTER); |
96 | | - $db->insert("`$wgDBname`.`imagetags`", |
97 | | - array( 'img_page_id' => 0,//$img->getTitle()->getArticleID(), |
98 | | - 'img_name' => $imgName, |
99 | | - 'article_tag' => $tagName, |
100 | | - 'tag_rect' => $tagRect, |
101 | | - 'user_text' => $userText)); |
| 102 | + $db->insert('imagetags', |
| 103 | + array( |
| 104 | + 'img_page_id' => 0, |
| 105 | + 'img_name' => $imgName, |
| 106 | + 'article_tag' => $tagName, |
| 107 | + 'tag_rect' => $tagRect, |
| 108 | + 'user_text' => $userText) |
| 109 | + ); |
102 | 110 | |
103 | 111 | $wgOut->clearHTML(); |
104 | 112 | $wgOut->addHTML("<!-- added tag for image $imgName to database! -->"); |
— | — | @@ -108,7 +116,8 @@ |
109 | 117 | $logComment = "Image [[$link|$imgName]] was tagged to article [[$tagName]] by $userText"; |
110 | 118 | $logPage->addEntry( 'tag', $imgTitle, $logComment); |
111 | 119 | |
112 | | - EmailNotification::notifyOnPageChange($imgTitle, wfTimestampNow(), $logComment, false); |
| 120 | + $enotif = new EmailNotification; |
| 121 | + $enotif->notifyOnPageChange($wgUser, $imgTitle, wfTimestampNow(), $logComment, false); |
113 | 122 | } |
114 | 123 | else { |
115 | 124 | $wgOut->clearHTML(); |
— | — | @@ -150,7 +159,7 @@ |
151 | 160 | wfPurgeTitle($imgTitle); |
152 | 161 | |
153 | 162 | $db =& wfGetDB(DB_MASTER); |
154 | | - $db->delete("`$wgDBname`.`imagetags`", array('unique_id' => $tagID)); |
| 163 | + $db->delete('imagetags', array('unique_id' => $tagID)); |
155 | 164 | |
156 | 165 | $wgOut->clearHTML(); |
157 | 166 | $wgOut->addHTML("<!-- removed tag to database! -->"); |
— | — | @@ -160,7 +169,8 @@ |
161 | 170 | $logComment = "Removed tag to article [[$tagName]] by $userText"; |
162 | 171 | $logPage->addEntry( 'tag', $imgTitle, $logComment); |
163 | 172 | |
164 | | - EmailNotification::notifyOnPageChange($imgTitle, wfTimestampNow(), $logComment, false); |
| 173 | + $enotif = new EmailNotification; |
| 174 | + $enotif->notifyOnPageChange($wgUser, $imgTitle, wfTimestampNow(), $logComment, false); |
165 | 175 | } |
166 | 176 | else { |
167 | 177 | $wgOut->clearHTML(); |
— | — | @@ -391,7 +401,6 @@ |
392 | 402 | $wgMessageCache->addMessage('removetagsuccess', "Removed tag."); |
393 | 403 | $wgMessageCache->addMessage('oneactionatatimemessage', "Removed tag."); |
394 | 404 | $wgMessageCache->addMessage('canteditneedloginmessage', "You can't edit this page. It may be because you need to login to tag images. Do you want to login now?"); |
395 | | - $wgMessageCache->addMessage('canteditothermessage', "You can't edit this page, either because you don't have the rights, or because this page has been locked for other reasons. For more information, see http://www.wikia.com/wiki/Protection"); |
396 | 405 | $wgMessageCache->addMessage('oneactionatatimemessage', "Sorry, only one tagging action at a time. Please wait for the existing action to complete."); |
397 | 406 | $wgMessageCache->addMessage('oneuniquetagmessage', "Sorry, this image already has a tag with this name."); |
398 | 407 | $wgMessageCache->addMessage('imagetag_seemoreimages', 'See more images of “$1” ($2)'); |
— | — | @@ -401,32 +410,27 @@ |
402 | 411 | class ImageTagPage extends ImagePage |
403 | 412 | { |
404 | 413 | function openShowImage() { |
405 | | - global $wgOut, $wgUser, $wgServer, $wgImageTaggingPath, $wgStyleVersion; |
| 414 | + global $wgOut, $wgUser, $wgServer, $wgImageTaggingPath, $wgStyleVersion, $wgJsMimeType, $wgScriptPath; |
406 | 415 | |
407 | 416 | wfProfileIn( __METHOD__ ); |
408 | 417 | |
409 | | - // TKL 2007-03-09: get files only from extensions directory, and not from skins/common |
410 | | - if ( $wgImageTaggingPath == '' ) { $wgImageTaggingPath = '/wiki/extensions/wikia/ImageTagging/'; } |
411 | 418 | |
412 | | - $wgOut->addScript('<script type="text/javascript" src="' . $wgImageTaggingPath . 'img_tagging.js?'.$wgStyleVersion.'" charset="utf-8"></script>'); |
413 | | - $wgOut->addScript('<script type="text/javascript" src="' . $wgImageTaggingPath . 'json.js?'.$wgStyleVersion.'" charset="utf-8"></script>'); |
| 419 | + global $wgJsMimeType, $wgScriptPath ; |
| 420 | + $wgOut->addScript("<script type=\"{$wgJsMimeType}\" src=\"$wgScriptPath/extensions/ImageTagging/img_tagging.js?$wgStyleVersion\"></script>\n" ); |
| 421 | + $wgOut->addScript("<script type=\"{$wgJsMimeType}\" src=\"$wgScriptPath/extensions/ImageTagging/json.js?$wgStyleVersion\"></script>\n" ); |
414 | 422 | |
415 | | - // TKL commented out 2007-03-06 |
416 | | - // $wgOut->addHTML('<script type="text/javascript"> var baseUrl = "{$wgServer}/wiki/"; </script>'); |
417 | | - // $wgOut->addScript('<script type="text/javascript" src="' . $wgImageTaggingPath . 'WSuggest.js"></script>'); |
| 423 | + $imgName = $this->getTitle()->getText(); |
| 424 | + $wgOut->addHTML("<input type='hidden' value='$imgName' id='imgName' />"); |
| 425 | + $wgOut->addHTML("<input type='hidden' value='$wgScriptPath/extensions/magTagging' id='imgPath' />"); |
418 | 426 | |
419 | | - $imgName = $this->getTitle()->getText(); |
420 | | - $wgOut->addHTML("<input type='hidden' value='" . $imgName . "' id='imgName' />"); |
421 | | - $wgOut->addHTML("<input type='hidden' value='" . $wgImageTaggingPath . "' id='imgPath' />"); |
| 427 | + if ( $wgUser->isLoggedIn() ) |
| 428 | + $wgOut->addHTML("<input type='hidden' value='1' id='userLoggedIn'/>"); |
| 429 | + |
| 430 | + if ( $wgUser->isAllowed('edit') && |
| 431 | + $this->mTitle->userCanEdit() && |
| 432 | + ( $this->mTitle->isProtected('edit') == false || in_array( 'sysop', $wgUser->getGroups() ) ) ) |
| 433 | + $wgOut->addHTML("<input type='hidden' value='1' id='canEditPage'/>"); |
422 | 434 | |
423 | | - if ( $wgUser->isLoggedIn() ) |
424 | | - $wgOut->addHTML("<input type='hidden' value='1' id='userLoggedIn'/>"); |
425 | | - |
426 | | - if ( $wgUser->isAllowed('edit') && |
427 | | - $this->mTitle->userCanEdit() && |
428 | | - ( $this->mTitle->isProtected('edit') == false || in_array( 'sysop', $wgUser->getGroups() ) ) ) |
429 | | - $wgOut->addHTML("<input type='hidden' value='1' id='canEditPage'/>"); |
430 | | - |
431 | 435 | $this->modifiedImagePageOpenShowImage(); |
432 | 436 | |
433 | 437 | if ( $this->img->exists() ) { |
Index: trunk/extensions/ImageTagging/SpecialTaggedImages.php |
— | — | @@ -5,7 +5,7 @@ |
6 | 6 | * @subpackage SpecialPage |
7 | 7 | */ |
8 | 8 | |
9 | | -define(TAGGEDIMGS_PER_PAGE, 12); |
| 9 | +define('TAGGEDIMGS_PER_PAGE', 12); |
10 | 10 | |
11 | 11 | |
12 | 12 | $wgExtensionFunctions[] = 'wfSpecialTaggedImages'; |
— | — | @@ -64,27 +64,31 @@ |
65 | 65 | |
66 | 66 | $db =& wfGetDB(DB_SLAVE); |
67 | 67 | |
68 | | - # COUNT(img_name) AS img_count |
69 | | -/* |
70 | | - $res = $db->query("SELECT " . ( $this->mQuery ? "" : "DISTINCT " ) . "imagetags.img_name, image.img_timestamp FROM " . |
71 | | - " `$wgDBname`.`imagetags` LEFT JOIN `$wgDBname`.`image` ON imagetags.img_name = image.img_name ". |
72 | | - ( $this->mQuery ? " WHERE article_tag='" . $this->mQuery . "'" : "" ) . |
73 | | - " GROUP BY unique_id " . |
74 | | - " ORDER BY image.img_timestamp desc " . |
75 | | - " LIMIT " . ($this->mStartPage * TAGGEDIMGS_PER_PAGE) . |
76 | | - ", " . TAGGEDIMGS_PER_PAGE); |
77 | | -*/ |
| 68 | + $WHERECLAUSE = ''; |
| 69 | + if ($this->mQuery) { |
| 70 | + $WHERECLAUSE = " WHERE article_tag='$this->mQuery'"; |
| 71 | + } |
78 | 72 | |
79 | | - $res = $db->query("SELECT image.img_name, image.img_timestamp FROM starwars.image WHERE image.img_name IN (SELECT imagetags.img_name FROM imagetags ".($this->mQuery ? " WHERE imagetags.article_tag='" . $this->mQuery . "'" : "")." GROUP by imagetags.unique_id) ORDER BY image.img_timestamp DESC LIMIT " . ($this->mStartPage * TAGGEDIMGS_PER_PAGE) . ", " . TAGGEDIMGS_PER_PAGE); |
| 73 | + $imagetable = $db->tableName( 'image' ); |
| 74 | + $imagetagstable = $db->tableName( 'imagetags' ); |
80 | 75 | |
| 76 | + $SQL = " |
| 77 | +SELECT img_name, img_timestamp |
| 78 | +FROM $imagetable |
| 79 | +WHERE img_name IN |
| 80 | + (SELECT img_name FROM $imagetagstable $WHERECLAUSE) |
| 81 | +ORDER BY img_timestamp DESC"; |
| 82 | + |
| 83 | + $SQL = $db->LimitResult($SQL, TAGGEDIMGS_PER_PAGE, $this->mStartPage * TAGGEDIMGS_PER_PAGE); |
| 84 | + |
| 85 | + $res = $db->query($SQL); |
81 | 86 | while ($o = $db->fetchObject($res)) { |
82 | 87 | $img = Image::newFromName($o->img_name); |
83 | 88 | $this->add($img, ''); |
84 | 89 | } |
85 | 90 | $db->freeResult($res); |
86 | 91 | |
87 | | - $res = $db->query("SELECT COUNT(img_name) as img_count FROM " . |
88 | | - " `$wgDBname`.`imagetags` ". |
| 92 | + $res = $db->query("SELECT COUNT(img_name) as img_count FROM $imagetagstable". |
89 | 93 | ( $this->mQuery ? " WHERE article_tag='" . $this->mQuery . "'" : "" ) . |
90 | 94 | " GROUP BY article_tag"); |
91 | 95 | if ( $o = $db->fetchObject($res) ) { |