function openShowImage() { global $wgOut, $wgUser, $wgScriptPath; wfProfileIn(__METHOD__); $wgOut->addScriptFile($wgScriptPath . '/extensions/ImageTagging/img_tagging.js'); $wgOut->addScriptFile($wgScriptPath . '/extensions/ImageTagging/json.js'); $imgName = $this->getTitle()->getText(); $wgOut->addHTML("<input type='hidden' value='{$imgName}' id='imgName' />"); $wgOut->addHTML("<input type='hidden' value='{$wgScriptPath}/extensions/ImageTagging' id='imgPath' />"); if ($wgUser->isLoggedIn()) { $wgOut->addHTML('<input type="hidden" value="1" id="userLoggedIn" />'); } if ($wgUser->isAllowed('edit') && $this->mTitle->userCan('edit') && ($this->mTitle->isProtected('edit') == false || in_array('sysop', $wgUser->getGroups()))) { $wgOut->addHTML('<input type="hidden" value="1" id="canEditPage" />'); } $this->modifiedImagePageOpenShowImage(); if ($this->getFile()->exists()) { $tagList = wfGetImageTags($this->getFile(), $imgName); #if ( $tagList ) $wgOut->addHTML("<div id=\"tagListDiv\"><span id=\"tagList\">{$tagList}</span></div>"); } wfProfileOut(__METHOD__); }
function removeTag($action, $article) { if ($action != 'removeTag') { return true; } global $wgRequest, $wgOut, $wgUser; wfProfileIn(__METHOD__); $wgOut->setArticleBodyOnly(true); $tagID = $wgRequest->getVal('tagID'); $tagName = $wgRequest->getText('tagName'); $imgName = $wgRequest->getText('imgName'); $userText = $wgUser->getName(); $tagID = preg_replace("/[\"'<>]/", '', $tagID); $tagName = preg_replace("/[\"'<>]/", '', $tagName); $imgName = preg_replace("/[\"'<>]/", '', $imgName); $img = wfFindFile($imgName); if ($img) { $imgTitle = $img->getTitle(); wfPurgeTitle($imgTitle); $dbw = wfGetDB(DB_MASTER); $dbw->delete('imagetags', array('unique_id' => $tagID), __METHOD__); $wgOut->clearHTML(); $wgOut->addHTML('<!-- removed tag from the database! -->'); $wgOut->addHTML(wfGetImageTags($img, $imgName)); $logPage = new LogPage('tag'); $logComment = wfMsg('imagetagging-logentry', $tagName, $userText); $logPage->addEntry('tag', $imgTitle, $logComment); $enotif = new EmailNotification(); $enotif->notifyOnPageChange($wgUser, $imgTitle, wfTimestampNow(), $logComment, false); } else { $wgOut->clearHTML(); $wgOut->addHTML("<!-- ERROR: img named {$imgName} -->\n\t\t\t<script type='text/javascript'>\n\t\t\talert(\"Error removing tag!\");\n\t\t\t</script>"); } wfProfileOut(__METHOD__); return false; }