r34854 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r34853‎ | r34854 | r34855 >
Date:12:54, 15 May 2008
Author:siebrand
Status:old
Tags:
Comment:
* rename files to use name of directory
* add imagetagging-desc message
* fix localisation/description of special page
* remove duplicate $wgSpecialPages
Modified paths:
  • /trunk/extensions/ImageTagging/ImageTagPage.php (deleted) (history)
  • /trunk/extensions/ImageTagging/ImageTagging.i18n.php (modified) (history)
  • /trunk/extensions/ImageTagging/ImageTagging.php (added) (history)
  • /trunk/extensions/ImageTagging/ImageTagging.php (added) (history)
  • /trunk/extensions/ImageTagging/ImageTagging_body.php (added) (history)
  • /trunk/extensions/ImageTagging/ImageTagging_body.php (added) (history)
  • /trunk/extensions/ImageTagging/SpecialTaggedImages.php (deleted) (history)

Diff [purge]

Index: trunk/extensions/ImageTagging/ImageTagPage.php
@@ -1,620 +0,0 @@
2 -<?php
3 -/**
4 - * ImageTagging extension by Wikia, Inc.
5 - * Lets a user select regions of an embedded image and associate an article with that region
6 - *
7 - * @author Tristan Harris
8 - * @author Tomasz Klim
9 - * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
10 - */
11 -
12 -$wgHooks['UnknownAction'][] = 'addTag';
13 -$wgHooks['UnknownAction'][] = 'removeTag';
14 -$wgHooks['UnknownAction'][] = 'tagSearch';
15 -
16 -$wgExtensionFunctions[] = 'wfImageTagPageSetup';
17 -$wgExtensionCredits['other'][] = array(
18 - 'name' => 'Image Tagging',
19 - 'author' => 'Wikia, Inc. (Tristan Harris, Tomasz Klim)',
20 - 'version' => 1.0,
21 - 'url' => 'http://www.mediawiki.org/wiki/Extension:ImageTagging',
22 - 'description' => 'Lets a user select regions of an embedded image and associate an article with that region',
23 - 'descriptionmsg' => 'imagetagging-desc',
24 -);
25 -
26 -// other hooks to try: 'ParserAfterTidy', ...
27 -#$wgHooks['OutputPageBeforeHTML'][] = 'wfCheckArticleImageTags';
28 -$wgHooks['ArticleFromTitle'][] = 'wfArticleFromTitle';
29 -
30 -$dir = dirname(__FILE__) . '/';
31 -$wgAutoloadClasses['TaggedImages'] = $dir . 'SpecialTaggedImages.php';
32 -$wgExtensionMessagesFiles['ImageTagging'] = $dir . 'ImageTagging.i18n.php';
33 -$wgSpecialPages['TaggedImages'] = 'TaggedImages';
34 -
35 -/********************
36 - * End Trie Handlers
37 - ********************/
38 -
39 -function wfCheckArticleImageTags($outputPage, $text) {
40 - global $wgOut, $wgDBname, $wgTitle;
41 -
42 - if ( $outputPage->isArticle() ) {
43 - $db =& wfGetDB(DB_SLAVE);
44 - $res = $db->query("SELECT article_tag, tag_rect, unique_id, COUNT(article_tag) AS count FROM ".
45 - $db->tableName('imagetags').
46 - " WHERE article_tag='" . addslashes($wgTitle->getText()). "' GROUP BY article_tag" );
47 -
48 - if ($o = $db->fetchObject($res)) {
49 - $taggedImagesObj = Title::newFromText('TaggedImages', NS_SPECIAL);
50 - $titleText = $wgTitle->getText();
51 -
52 - $wgOut->addHTML('
53 - <a href="' . $taggedImagesObj->getLocalUrl('q='.$titleText) . '">
54 - <span style="position:absolute;
55 - z-index:1;
56 - border:none;
57 - background:none;
58 - right:30px;
59 - top:3.7em;
60 - float:right;
61 - margin:0.0em;
62 - padding:0.0em;
63 - line-height:1.7em; /*1.5em*/
64 - text-align:right;
65 - text-indent:0;
66 - font-size:100%;
67 - text-transform:none;
68 - white-space:nowrap;" id="coordinates" class="plainlinksneverexpand">
69 - ' . wfMsg('imagetagging-imagetag-seemoreimages', $titleText, $o->count) .
70 - '</span></a>');
71 - }
72 - }
73 - return true;
74 -}
75 -
76 -// TKL 2006-03-07: it doesn't work in new MediaWiki, modification required in includes/Wiki.php (class name change only)
77 -// $wgNamespaceTemplates[NS_IMAGE] = 'ImageTagPage';
78 -
79 -function addTag($action, $article) {
80 - if($action != 'addTag') return true;
81 -
82 - global $wgRequest, $wgTitle, $wgDBname, $wgOut, $wgUser;
83 -
84 - wfProfileIn( __METHOD__ );
85 -
86 - $wgOut->setArticleBodyOnly(true);
87 -
88 - $tagRect = $wgRequest->getText('rect');
89 - $tagName = $wgRequest->getText('tagName');
90 - $imgName = $wgRequest->getText('imgName');
91 - $userText = $wgUser->getName();
92 -
93 - $tagRect = preg_replace( "/[\"'<>]/", "", $tagRect );
94 - $tagName = preg_replace( "/[\"'<>]/", "", $tagName );
95 - $imgName = preg_replace( "/[\"'<>]/", "", $imgName );
96 -
97 - $img = Image::newFromName($imgName);
98 - if ($img) {
99 - $imgTitle = $img->getTitle();
100 -
101 - wfPurgeTitle($imgTitle);
102 -
103 - $db =& wfGetDB(DB_MASTER);
104 - $db->insert('imagetags',
105 - array(
106 - 'img_page_id' => 0,
107 - 'img_name' => $imgName,
108 - 'article_tag' => $tagName,
109 - 'tag_rect' => $tagRect,
110 - 'user_text' => $userText)
111 - );
112 -
113 - $wgOut->clearHTML();
114 - $wgOut->addHTML("<!-- added tag for image $imgName to database! -->");
115 - $wgOut->addHTML( wfGetImageTags($img, $imgName) );
116 -
117 - $logPage = new LogPage( 'tag' );
118 - $link = basename( $img->title->getLocalURL() );
119 - $logComment = wfMsg('imagetagging-log-tagged', $link, $imgName, $tagName, $userText);
120 - $logPage->addEntry( 'tag', $imgTitle, $logComment);
121 -
122 - $enotif = new EmailNotification;
123 - $enotif->notifyOnPageChange($wgUser, $imgTitle, wfTimestampNow(), $logComment, false);
124 - } else {
125 - $wgOut->clearHTML();
126 - $wgOut->addHTML("<!-- ERROR: img named $imgName -->
127 - <script type='text/javascript'>
128 - alert(\"Error adding tag!\");
129 - </script>");
130 - }
131 - wfProfileOut( __METHOD__ );
132 - return false;
133 -}
134 -
135 -function removeTag($action, $article) {
136 - if ($action != 'removeTag') return true;
137 -
138 - global $wgRequest, $wgTitle, $wgOut, $wgDBname, $wgUser;
139 -
140 - wfProfileIn( __METHOD__ );
141 -
142 - $wgOut->setArticleBodyOnly(true);
143 -
144 - $tagID = $wgRequest->getVal('tagID');
145 - $tagName = $wgRequest->getText('tagName');
146 - $imgName = $wgRequest->getText('imgName');
147 - $userText = $wgUser->getName();
148 -
149 - $tagID = preg_replace( "/[\"'<>]/", "", $tagID );
150 - $tagName = preg_replace( "/[\"'<>]/", "", $tagName );
151 - $imgName = preg_replace( "/[\"'<>]/", "", $imgName );
152 -
153 - $img = Image::newFromName($imgName);
154 - if ($img) {
155 - $imgTitle = $img->getTitle();
156 -
157 - wfPurgeTitle($imgTitle);
158 -
159 - $db =& wfGetDB(DB_MASTER);
160 - $db->delete('imagetags', array('unique_id' => $tagID));
161 -
162 - $wgOut->clearHTML();
163 - $wgOut->addHTML("<!-- removed tag to database! -->");
164 - $wgOut->addHTML( wfGetImageTags($img, $imgName) );
165 -
166 - $logPage = new LogPage( 'tag' );
167 - $logComment = wfMsg('imagetagging-logentry', $tagName, $userText);
168 - $logPage->addEntry( 'tag', $imgTitle, $logComment);
169 -
170 - $enotif = new EmailNotification;
171 - $enotif->notifyOnPageChange($wgUser, $imgTitle, wfTimestampNow(), $logComment, false);
172 - } else {
173 - $wgOut->clearHTML();
174 - $wgOut->addHTML("<!-- ERROR: img named $imgName -->
175 - <script type='text/javascript'>
176 - alert(\"Error removing tag!\");
177 - </script>");
178 - }
179 -
180 - wfProfileOut( __METHOD__ );
181 - return false;
182 -}
183 -
184 -function tagSearch($action, $article) {
185 - if($action != 'tagSearch') return true;
186 -
187 - global $wgRequest, $wgTitle, $wgDBname, $wgOut, $wgUser;
188 -
189 - wfProfileIn( __METHOD__ );
190 -
191 - $wgOut->setArticleBodyOnly(true);
192 -
193 - $query = $wgRequest->getText('q');
194 - $query = preg_replace( "/[\"'<>]/", "", $query );
195 -
196 - $search = SearchEngine::create();
197 - $search->setLimitOffset( 10, 0 );
198 - $search->setNamespaces( array(NS_MAIN) );
199 - $search->showRedirects = true;
200 - $titleMatches = $search->searchTitle( $query );
201 -
202 - $numResults = ( $titleMatches ? $titleMatches->numRows() : 0 );
203 - if ( $numResults > 0 )
204 - $wgOut->addHTML(wfTagSearchShowMatches($titleMatches));
205 -
206 - #echo "numResults: " . $numResults . ", query: " . $query;
207 -
208 - wfProfileOut( __METHOD__ );
209 - return false;
210 -}
211 -
212 -/**
213 - * @param SearchResultSet $matches
214 - * @param string $terms partial regexp for highlighting terms
215 - */
216 -function wfTagSearchShowMatches( &$matches ) {
217 - global $wgContLang;
218 -
219 - wfProfileIn( __METHOD__ );
220 -
221 - $tm = $wgContLang->convertForSearchResult( $matches->termMatches() );
222 - $terms = implode( '|', $tm );
223 -
224 - $out = "<searchresults>\n";
225 -
226 - while( $result = $matches->next() ) {
227 - $out .= wfTagSearchHitXML( $result, $terms );
228 - }
229 - $out .= "</searchresults>\n";
230 -
231 - // convert the whole thing to desired language variant
232 - $out = $wgContLang->convert( $out );
233 -
234 - wfProfileOut( __METHOD__ );
235 - return $out;
236 -}
237 -
238 -/**
239 - * Format a single hit result
240 - * @param SearchResult $result
241 - * @param string $terms partial regexp for highlighting terms
242 - */
243 -function wfTagSearchHitXML( $result, $terms ) {
244 - global $wgUser, $wgContLang;
245 -
246 - wfProfileIn( __METHOD__ );
247 -
248 - $t = $result->getTitle();
249 - if( is_null( $t ) ) {
250 - wfProfileOut( __METHOD__ );
251 - return "<!-- Broken link in search result -->\n";
252 - }
253 - $sk =& $wgUser->getSkin();
254 -
255 - $contextlines = 5;
256 - $contextchars = 50;
257 -
258 - $link = $sk->makeKnownLinkObj( $t );
259 - $revision = Revision::newFromTitle( $t );
260 - $text = $revision->getText();
261 -
262 - $lines = explode( "\n", $text );
263 -
264 - $max = intval( $contextchars ) + 1;
265 - $pat1 = "/(.*)($terms)(.{0,$max})/i";
266 -
267 - $lineno = 0;
268 -
269 - $extract = '';
270 - foreach ( $lines as $line ) {
271 - if ( 0 == $contextlines ) {
272 - break;
273 - }
274 - ++$lineno;
275 - if ( ! preg_match( $pat1, $line, $m ) ) {
276 - continue;
277 - }
278 - $contextlines--;
279 - $pre = $wgContLang->truncate( $m[1], -$contextchars, '...' );
280 -
281 - if ( count( $m ) < 3 ) {
282 - $post = '';
283 - } else {
284 - $post = $wgContLang->truncate( $m[3], $contextchars, '...' );
285 - }
286 -
287 - $found = $m[2];
288 -
289 - $line = htmlspecialchars( $pre . $found . $post );
290 - $pat2 = '/(' . $terms . ")/i";
291 - $line = preg_replace( $pat2, "<span class='searchmatch'>\\1</span>", $line );
292 -
293 - $extract .= "<br /><small>{$lineno}: {$line}</small>\n";
294 - }
295 -
296 - wfProfileOut( __METHOD__ );
297 - return "<result>\n<link>{$link}</link>\n<context>{$extract}</context>\n</result>\n";
298 -}
299 -
300 -function wfPurgeTitle($title) {
301 - global $wgUseSquid;
302 -
303 - wfProfileIn( __METHOD__ );
304 -
305 - $title->invalidateCache();
306 -
307 - if ( $wgUseSquid ) {
308 - // Commit the transaction before the purge is sent
309 - $dbw =& wfGetDB( DB_MASTER );
310 - $dbw->immediateCommit();
311 -
312 - // Send purge
313 - $update = SquidUpdate::newSimplePurge( $title );
314 - $update->doUpdate();
315 - }
316 -
317 - wfProfileOut( __METHOD__ );
318 -}
319 -
320 -function wfGetImageTags($img, $imgName) {
321 - global $wgDBname;
322 - global $wgUser;
323 - global $wgOut;
324 -
325 - wfProfileIn( __METHOD__ );
326 -
327 - $sk = $wgUser->getSkin();
328 - $db =& wfGetDB(DB_SLAVE);
329 - $db->selectDB($wgDBname);
330 - $res = $db->select(
331 - array("imagetags"),
332 - array("article_tag", "tag_rect", "unique_id"),
333 - array("img_name" => $imgName),
334 - __METHOD__ );
335 -
336 - $html = '';
337 - $wgOut->addHTML("<!-- this many image tags: " . count($res) . " from img " . $img->name . " -->");
338 - while ($o = $db->fetchObject($res)) {
339 - if ( strlen($html) > 0 )
340 - $html .= ', ';
341 -
342 - $wgOut->addHTML("<!-- tag rect: " . $o->tag_rect . ", tag title: " . $o->article_tag . ", unique_id: " . $o->unique_id . "-->");
343 -
344 - $span = '<span id="' . $o->article_tag . '-tag" onmouseout="hideTagBox()" onmouseover="tagBoxPercent(' . $o->tag_rect . ', false)">';
345 -
346 - #echo "article tag: " . $o->article_tag . "\n";
347 - $articleTitle = Title::newFromText($o->article_tag);
348 -
349 - #$articleLink = '<a href="' . $articleTitle->escapeFullURL() . '" onmouseout="hideTagBox()">' . $o->article_tag . '</a>';
350 - $articleLink = $sk->makeLinkObj($articleTitle);
351 -
352 - $specialImagesTitle = Title::newFromText("Special:TaggedImages");
353 -
354 - $imagesLink = '<a onmouseover="tagBoxPercent(' . $o->tag_rect . ', false)" onmouseout="hideTagBox()" href="' . $specialImagesTitle->escapeFullURL("q=".$o->article_tag) . '">' . wfMsgHtml('imagetagging-images') . '</a>';
355 -
356 - $removeLink = '<a href="#" onclick="removeTag(' . $o->unique_id . ', this, \'' . addslashes( $o->article_tag ) . '\'); return false;">' . wfMsgHtml('imagetagging-removetag') . '</a>';
357 -
358 - $html .= $span . $articleLink . ' (' . $imagesLink . ' | ' . $removeLink . ')</span>';
359 - }
360 - $db->freeResult($res);
361 -
362 - if ( $html )
363 - $html = wfMsg('imagetagging-inthisimage', $html);
364 -
365 - wfProfileOut( __METHOD__ );
366 - return $html;
367 -}
368 -
369 -function wfArticleFromTitle( &$title, &$article ) {
370 - global $wgUser;
371 -
372 - wfProfileIn( __METHOD__ );
373 -
374 - if ( NS_IMAGE == $title->getNamespace() && !$wgUser->isBlocked() ) {
375 - $article = new ImageTagPage( $title );
376 - }
377 -
378 - wfProfileOut( __METHOD__ );
379 - return true;
380 -}
381 -
382 -function wfImageTagPageSetup() {
383 - global $wgLogTypes;
384 -
385 - $wgLogTypes[] = 'tag';
386 - wfLoadExtensionMessages('ImageTagging');
387 -
388 - class ImageTagPage extends ImagePage {
389 - function openShowImage() {
390 - global $wgOut, $wgUser, $wgServer, $wgStyleVersion, $wgJsMimeType, $wgScriptPath;
391 -
392 - wfProfileIn( __METHOD__ );
393 -
394 - global $wgJsMimeType, $wgScriptPath;
395 - $wgOut->addScript("<script type=\"{$wgJsMimeType}\" src=\"$wgScriptPath/extensions/ImageTagging/img_tagging.js?$wgStyleVersion\"></script>\n" );
396 - $wgOut->addScript("<script type=\"{$wgJsMimeType}\" src=\"$wgScriptPath/extensions/ImageTagging/json.js?$wgStyleVersion\"></script>\n" );
397 -
398 - $imgName = $this->getTitle()->getText();
399 - $wgOut->addHTML("<input type='hidden' value='$imgName' id='imgName' />");
400 - $wgOut->addHTML("<input type='hidden' value='$wgScriptPath/extensions/ImageTagging' id='imgPath' />");
401 -
402 - if ( $wgUser->isLoggedIn() )
403 - $wgOut->addHTML("<input type='hidden' value='1' id='userLoggedIn'/>");
404 -
405 - if ( $wgUser->isAllowed('edit') &&
406 - $this->mTitle->userCanEdit() &&
407 - ( $this->mTitle->isProtected('edit') == false || in_array( 'sysop', $wgUser->getGroups() ) ) )
408 - $wgOut->addHTML("<input type='hidden' value='1' id='canEditPage'/>");
409 -
410 - $this->modifiedImagePageOpenShowImage();
411 -
412 - if ( $this->img->exists() ) {
413 - $tagList = wfGetImageTags($this->img, $imgName);
414 -
415 - #if ( $tagList )
416 - $wgOut->addHTML("<div id='tagListDiv'><span id='tagList'>$tagList</span></div>");
417 - }
418 -
419 - wfProfileOut( __METHOD__ );
420 - }
421 -
422 - function modifiedImagePageOpenShowImage() {
423 - global $wgOut, $wgUser, $wgImageLimits, $wgRequest, $wgUseImageResize;
424 -
425 - wfProfileIn( __METHOD__ );
426 -
427 - $full_url = $this->img->getURL();
428 - $anchoropen = '';
429 - $anchorclose = '';
430 -
431 - if( $wgUser->getOption( 'imagesize' ) == '' ) {
432 - $sizeSel = User::getDefaultOption( 'imagesize' );
433 - } else {
434 - $sizeSel = intval( $wgUser->getOption( 'imagesize' ) );
435 - }
436 - if( !isset( $wgImageLimits[$sizeSel] ) ) {
437 - $sizeSel = User::getDefaultOption( 'imagesize' );
438 - }
439 - $max = $wgImageLimits[$sizeSel];
440 - $maxWidth = $max[0];
441 - $maxHeight = $max[1];
442 - $maxWidth = 600;
443 - $maxHeight = 460;
444 - $sk = $wgUser->getSkin();
445 -
446 - if ( $this->img->exists() ) {
447 - # image
448 - $width = $this->img->getWidth();
449 - $height = $this->img->getHeight();
450 - $showLink = false;
451 -
452 - if ( $this->img->allowInlineDisplay() and $width and $height) {
453 - # image
454 -
455 - # "Download high res version" link below the image
456 - $msg = wfMsgHtml('show-big-image', $width, $height, intval( $this->img->getSize()/1024 ) );
457 -
458 - # We'll show a thumbnail of this image
459 - if ( $width > $maxWidth || $height > $maxHeight ) {
460 - # Calculate the thumbnail size.
461 - # First case, the limiting factor is the width, not the height.
462 - if ( $width / $height >= $maxWidth / $maxHeight ) {
463 - $height = round( $height * $maxWidth / $width);
464 - $width = $maxWidth;
465 - # Note that $height <= $maxHeight now.
466 - } else {
467 - $newwidth = floor( $width * $maxHeight / $height);
468 - $height = round( $height * $newwidth / $width );
469 - $width = $newwidth;
470 - # Note that $height <= $maxHeight now, but might not be identical
471 - # because of rounding.
472 - }
473 -
474 - if( $wgUseImageResize ) {
475 - $thumbnail = $this->img->getThumbnail( $width );
476 - if ( $thumbnail == null ) {
477 - $url = $this->img->getViewURL();
478 - } else {
479 - $url = $thumbnail->getURL();
480 - }
481 - } else {
482 - # No resize ability? Show the full image, but scale
483 - # it down in the browser so it fits on the page.
484 - $url = $this->img->getViewURL();
485 - }
486 - $anchoropen = "<a href=\"{$full_url}\">";
487 - $anchorclose = "</a><br />";
488 - if( $this->img->mustRender() ) {
489 - $showLink = true;
490 - } else {
491 - $anchorclose .= "\n$anchoropen{$msg}</a>";
492 - }
493 - } else {
494 - $url = $this->img->getViewURL();
495 - $showLink = true;
496 - }
497 -
498 - //$anchoropen = '';
499 - //$anchorclose = '';
500 - // $width = 'auto'; //'100%';
501 - // $height = 'auto'; //'100%';
502 - $wgOut->addHTML( '<div class="fullImageLink" id="file">' .
503 - "<img border=\"0\" src=\"{$url}\" width=\"{$width}\" height=\"{$height}\" style=\"max-width: {$maxWidth}px;\" alt=\"" .
504 - htmlspecialchars( $wgRequest->getVal( 'image' ) ).'" />' .
505 - $anchoropen . $anchorclose . '</div>' );
506 - } else {
507 - #if direct link is allowed but it's not a renderable image, show an icon.
508 - if ($this->img->isSafeFile()) {
509 - $icon= $this->img->iconThumb();
510 -
511 - $wgOut->addHTML( '<div class="fullImageLink" id="file"><a href="' . $full_url . '">' .
512 - $icon->toHtml() .
513 - '</a></div>' );
514 - }
515 -
516 - $showLink = true;
517 - }
518 -
519 - if ($showLink) {
520 - $filename = wfEscapeWikiText( $this->img->getName() );
521 - $info = wfMsg( 'file-info',
522 - $sk->formatSize( $this->img->getSize() ),
523 - $this->img->getMimeType() );
524 -
525 - if (!$this->img->isSafeFile()) {
526 - $warning = wfMsg( 'mediawarning' );
527 - $wgOut->addWikiText( <<<END
528 -<div class="fullMedia">
529 -<span class="dangerousLink">[[Media:$filename|$filename]]</span>
530 -<span class="fileInfo"> ($info)</span>
531 -</div>
532 -
533 -<div class="mediaWarning">$warning</div>
534 -END
535 - );
536 - } else {
537 - $wgOut->addWikiText( <<<END
538 -<div class="fullMedia">
539 -[[Media:$filename|$filename]] <span class="fileInfo"> ($info)</span>
540 -</div>
541 -END
542 - );
543 - }
544 - }
545 -
546 - if($this->img->fromSharedDirectory) {
547 - $this->printSharedImageText();
548 - }
549 - } else {
550 - # Image does not exist
551 -
552 - $title = Title::makeTitle( NS_SPECIAL, 'Upload' );
553 - $link = $sk->makeKnownLinkObj($title, wfMsgHtml('noimage-linktext'),
554 - 'wpDestFile=' . urlencode( $this->img->getName() ) );
555 - $wgOut->addHTML( wfMsgWikiHtml( 'noimage', $link ) );
556 - }
557 -
558 - wfProfileOut( __METHOD__ );
559 - }
560 -
561 - /**
562 - * Create the TOC
563 - *
564 - * @access private
565 - *
566 - * @param bool $metadata Whether or not to show the metadata link
567 - * @return string
568 - */
569 - function showTOC( $metadata ) {
570 - global $wgLang, $wgUser;
571 -
572 - $r = '<ul id="filetoc">
573 - <li><a href="#file">' . $wgLang->getNsText( NS_IMAGE ) . '</a></li>
574 - <li><a href="#filehistory">' . wfMsgHtml( 'imagetagging-imghistory' ) . '</a></li>
575 - <li><a href="#filelinks">' . wfMsgHtml( 'imagelinks' ) . '</a></li>' .
576 - ($metadata ? '<li><a href="#metadata">' . wfMsgHtml( 'metadata' ) . '</a></li>' : '') . '
577 - <li><a href="javascript:addImageTags()">' . wfMsgHtml( 'imagetagging-addimagetag' ) . '</a>'. wfMsg('imagetagging-new') .'</li>'
578 - . '</ul>';
579 -
580 - $r .= '<div id="tagStatusDiv" style="margin: 5px 5px 10px 5px; padding: 10px; border: solid 1px #ffe222; background: #fffbe2; display: none;"><table style="background-color: #fffbe2;"><tr><td width="450" height="30" align="center" style="padding-left: 20px;"><img src="/skins/common/progress-wheel.gif" id="progress_wheel" style="display:none;"><div id="tagging_message" style="background: #fffbe2;">' . wfMsgHtml('imagetagging-tagging-instructions') . '</td><td valign="middle"><input type="button" onclick="doneAddingTags();" id="done_tagging" name="done_tagging" value="' . wfMsgHtml('imagetagging-done-button') . '" /></div></td></tr></table></div>';
581 -
582 - $r .= "<div style='position: absolute; font: verdana, sans-serif; top: 10px; left: 10px; display: none; width:284px; height:24px; padding: 4px 6px; background-color: #eeeeee; color: #444444; border: 2px solid #555555; z-index:2;' id='tagEditField'>
583 -
584 - <span style='position: absolute; left: 4px; top: 6px;'>". wfMsg('imagetagging-article') ."</span>
585 -
586 - <!-- TAH: don't use the popup just yet
587 - <select name='tagType'>
588 - <option selected>Article</option>
589 - <option>Category</option>
590 - </select>
591 - -->";
592 -
593 - $r .= "<input style='position: absolute; left: 189px; top: 6px; width: 39px; height: 20px;' type='submit' name='". wfMsgHtml('imagetagging-tag-button') ."' value='" . wfMsgHtml('imagetagging-tag-button') . "' onclick='submitTag()'/>";
594 - $r .= "<input style='position: absolute; left: 232px; top: 6px; width: 60px; height: 20px;' type='button' name='" . wfMsgHtml('imagetagging-tagcancel-button') . "' value='" . wfMsgHtml('imagetagging-tagcancel-button') . "' onclick='hideTagBox()'/>";
595 -
596 - $r .= "<input type='text' style='position: absolute; left: 46px; top: 6px; background-color:white; width: 140px; height:18px;' name='articleTag' id='articleTag' value='' title='". wfMsgHtml('imagetagging-articletotag') ."' onkeyup='typeTag(event);' />";
597 -
598 - $r .= '</div>';
599 -
600 - $r .= '<div id="popup" style="position:absolute; background-color: #eeeeee; top: 0px; left: 0px; z-index:3; visibility:hidden;"></div>';
601 -
602 - #$r .= '</div>';
603 -
604 - // TAH: adding this to grab edit tokens from javascript
605 - $token = $wgUser->editToken();
606 - $r .= "<input type=\"hidden\" value=\"$token\" name=\"wpEditToken\" id=\"wpEditToken\" />\n";
607 - $r .= "<input type=\"hidden\" id=\"addingtagmessage\" value=\"" . wfMsg('imagetagging-addingtag') . "\">\n";
608 - $r .= "<input type=\"hidden\" id=\"removingtagmessage\" value=\"" . wfMsg('imagetagging-removingtag') . "\">\n";
609 - $r .= "<input type=\"hidden\" id=\"addtagsuccessmessage\" value=\"" . wfMsg('imagetagging-addtagsuccess') . "\">\n";
610 - $r .= "<input type=\"hidden\" id=\"removetagsuccessmessage\" value=\"" . wfMsg('imagetagging-removetagsuccess') . "\">\n";
611 -
612 - $r .= "<input type=\"hidden\" id=\"oneactionatatimemessage\" value=\"" . wfMsg('imagetagging-oneactionatatimemessage') . "\">\n";
613 - $r .= "<input type=\"hidden\" id=\"canteditneedloginmessage\" value=\"" . wfMsg('imagetagging-canteditneedloginmessage') . "\">\n";
614 - $r .= "<input type=\"hidden\" id=\"canteditothermessage\" value=\"" . wfMsg('imagetagging-canteditothermessage') . "\">\n";
615 - $r .= "<input type=\"hidden\" id=\"oneuniquetagmessage\" value=\"" . wfMsg('imagetagging-oneuniquetagmessage') . "\">\n";
616 -
617 - return $r;
618 - }
619 - }
620 -
621 -}
Index: trunk/extensions/ImageTagging/SpecialTaggedImages.php
@@ -1,240 +0,0 @@
2 -<?php
3 -
4 -/**
5 - * @package MediaWiki
6 - * @subpackage SpecialPage
7 - */
8 -
9 -define('TAGGEDIMGS_PER_PAGE', 12);
10 -
11 -$wgSpecialPages['TaggedImages'] = 'TaggedImages';
12 -
13 -/**
14 - * Photos tagged gallery
15 - *
16 - * Add images to the gallery using add(), then render that list to HTML using toHTML().
17 - */
18 -class TaggedImages extends SpecialPage {
19 -
20 - var $mQuery, $mImages;
21 -
22 - /**
23 - * Create a new tagged images object.
24 - */
25 - function TaggedImages() {
26 - global $wgLang, $wgAllowRealName, $wgRequest, $wgOut;
27 -
28 - $wgOut->addScript("<style type=\"text/css\">/*<![CDATA[*/ @import \"$GLOBALS[wgScriptPath]/extensions/ImageTagging/img_tagging.css?$GLOBALS[wgStyleVersion]\"; /*]]>*/</style>\n");
29 -
30 - $this->mQuery = preg_replace( "/[\"'<>]/", "", $wgRequest->getText('q') );
31 - $this->mStartPage = preg_replace( "/[\"'<>]/", "", $wgRequest->getVal('page') );
32 - $this->mCount = 0;
33 - if ( ! $this->mStartPage )
34 - $this->mStartPage = 0;
35 - $this->mImages = array();
36 -
37 - SpecialPage::SpecialPage('TaggedImages');
38 - }
39 -
40 - /**
41 - * Start doing stuff
42 - * @access public
43 - */
44 - function execute() {
45 - global $wgDBname, $wgOut;
46 -
47 - wfProfileIn( __METHOD__ );
48 -
49 - $db =& wfGetDB(DB_SLAVE);
50 -
51 - $WHERECLAUSE = '';
52 - if ($this->mQuery) {
53 - $WHERECLAUSE = " WHERE article_tag='$this->mQuery'";
54 - }
55 -
56 - $imagetable = $db->tableName( 'image' );
57 - $imagetagstable = $db->tableName( 'imagetags' );
58 -
59 - $SQL = "SELECT img_name, img_timestamp FROM $imagetable WHERE img_name IN (SELECT img_name FROM $imagetagstable $WHERECLAUSE) ORDER BY img_timestamp DESC";
60 -
61 - $SQL = $db->LimitResult($SQL, TAGGEDIMGS_PER_PAGE, $this->mStartPage * TAGGEDIMGS_PER_PAGE);
62 -
63 - $res = $db->query($SQL);
64 - while ($o = $db->fetchObject($res)) {
65 - $img = Image::newFromName($o->img_name);
66 - $this->add($img, '');
67 - }
68 - $db->freeResult($res);
69 -
70 - $res = $db->query("SELECT COUNT(img_name) as img_count FROM $imagetagstable".
71 - ( $this->mQuery ? " WHERE article_tag='" . $this->mQuery . "'" : "" ) .
72 - " GROUP BY article_tag");
73 - if ( $o = $db->fetchObject($res) ) {
74 - $this->mCount = $o->img_count;
75 - }
76 - $db->freeResult($res);
77 -
78 - $wgOut->setPageTitle( wfMsg('imagetagging-taggedimages-title', $this->mQuery ? $this->mQuery : "all" ) );
79 - $wgOut->setRobotpolicy('noindex,nofollow');
80 - $wgOut->addHTML($this->toHTML());
81 -
82 - wfProfileOut( __METHOD__ );
83 - }
84 -
85 - /**
86 - * Add an image to the gallery.
87 - *
88 - * @param Image $image Image object that is added to the gallery
89 - * @param string $html Additional HTML text to be shown. The name and size of the image are always shown.
90 - */
91 - function add( $image, $html='' ) {
92 - $this->mImages[] = array( &$image, $html );
93 - }
94 -
95 - /**
96 - * Add an image at the beginning of the gallery.
97 - *
98 - * @param Image $image Image object that is added to the gallery
99 - * @param string $html Additional HTML text to be shown. The name and size of the image are always shown.
100 - */
101 - function insert( $image, $html='' ) {
102 - array_unshift( $this->mImages, array( &$image, $html ) );
103 - }
104 -
105 - /**
106 - * isEmpty() returns true if the gallery contains no images
107 - */
108 - function isEmpty() {
109 - return empty( $this->mImages );
110 - }
111 -
112 - function pagerStatusHTML() {
113 - wfProfileIn( __METHOD__ );
114 -
115 - $numPages = $this->mCount / TAGGEDIMGS_PER_PAGE;
116 -
117 - if (!$this->mQuery) $this->mQuery = "all";
118 -
119 - $queryTitle = Title::newFromText($this->mQuery, NS_MAIN);
120 -
121 - $html = wfMsg('imagetagging-taggedimages-displaying', $this->mStartPage*TAGGEDIMGS_PER_PAGE + 1, min(($this->mStartPage+1)*TAGGEDIMGS_PER_PAGE,$this->mCount), $this->mCount, '<a href="' . $queryTitle->getLocalURL() . '">' . $this->mQuery . '</a>');
122 -
123 - wfProfileOut( __METHOD__ );
124 - return $html;
125 - }
126 -
127 - function pageNoLink($pageNum, $pageText, $hrefPrefix, $cur) {
128 - if ( $cur == false )
129 - $html = '<a href="'. $hrefPrefix . $pageNum . '">' . $pageText . '</a>';
130 - else
131 - $html = '<b>' . $pageText . '</b>';
132 -
133 - $html .= '&nbsp;';
134 - return $html;
135 - }
136 -
137 - function pagerHTML($topBottom) {
138 - global $wgOut;
139 -
140 - $titleObj = Title::makeTitle( NS_SPECIAL, 'TaggedImages' );
141 -
142 - $maxPages = 5; // 5 real pagers
143 - $numPages = ceil($this->mCount / TAGGEDIMGS_PER_PAGE);
144 -
145 - if ( $numPages <= 1 ) return '';
146 -
147 - $html = '<span id="{$topBottom}pager" class="pager" style="float: right; text-align: right; right: 30px;">';
148 -
149 - $hrefPrefix = $titleObj->escapeLocalURL("q=" . $this->mQuery . "&page=");
150 -
151 - // build prev button
152 - if ( $this->mStartPage - 1 >= 0 ) {
153 - $html .= $this->pageNoLink($this->mStartPage-1, wfMsg('allpagesprev'), $hrefPrefix, false);
154 - }
155 -
156 - // build page # buttons
157 - for ( $i=$this->mStartPage-2; $i < $this->mStartPage + $maxPages; $i++ ) {
158 - if ( $i >= $numPages ) break;
159 - if ( $i < 0 ) continue;
160 -
161 - $html .= $this->pageNoLink($i, $i+1, $hrefPrefix, ($this->mStartPage == $i));
162 - }
163 -
164 - // build next button
165 - if ( $this->mStartPage < $numPages-1 ) {
166 - $html .= $this->pageNoLink($this->mStartPage+1, wfMsg('allpagesnext'), $hrefPrefix, false);
167 - }
168 -
169 - $html .= '</span>';
170 -
171 - return $html;
172 - }
173 -
174 - /**
175 - * Return a HTML representation of the image gallery
176 - *
177 - * For each image in the gallery, display
178 - * - a thumbnail
179 - * - the image name
180 - * - the additional text provided when adding the image
181 - * - the size of the image
182 - *
183 - */
184 - function toHTML() {
185 - global $wgLang, $wgUser, $wgOut;
186 -
187 - $sk = $wgUser->getSkin();
188 -
189 - $s = '<div>';
190 - $s .= $this->pagerStatusHTML();
191 - $s .= $this->pagerHTML('top');
192 - $s .= '</div>';
193 -
194 - $s .= '<table class="gallery" cellspacing="0" cellpadding="0">';
195 - $i = 0;
196 - foreach ( $this->mImages as $pair ) {
197 - $img =& $pair[0];
198 - $text = $pair[1];
199 -
200 - $name = $img->getName();
201 - $nt = $img->getTitle();
202 -
203 - // Not an image. Just print the name and skip.
204 - if ( $nt->getNamespace() != NS_IMAGE ) {
205 - $s .= '<td><div class="gallerybox" style="height: 152px;">' .
206 - htmlspecialchars( $nt->getText() ) . '</div></td>' . (($i%4==3) ? "</tr>\n" : '');
207 - $i++;
208 - continue;
209 - }
210 -
211 - // TODO
212 - // $ul = $sk->makeLink( $wgContLang->getNsText( Namespace::getUser() ) . ":{$ut}", $ut );
213 -
214 - $nb = '';
215 - $textlink = $this->mShowFilename ?
216 - $sk->makeKnownLinkObj( $nt, htmlspecialchars( $wgLang->truncate( $nt->getText(), 20, '...' ) ) ) . "<br />\n" :
217 - '';
218 -
219 - $s .= ($i%4==0) ? '<tr>' : '';
220 - $thumb = $img->getThumbnail( 120, 120 );
221 - $vpad = floor( ( 150 - $thumb->height ) /2 ) - 2;
222 - $s .= '<td><div class="gallerybox">' . '<div class="thumb" style="padding: ' . $vpad . 'px 0;">';
223 -
224 - # ATTENTION: The newline after <div class="gallerytext"> is needed to accommodate htmltivdy which
225 - # in version 4.8.6 generated crackpot html in its absence, see:
226 - # http://bugzilla.wikimedia.org/show_bug.cgi?id=1765 -Ævar
227 - $s .= $sk->makeKnownLinkObj( $nt, $thumb->toHtml() ) . '</div><div class="gallerytext">' . "\n" .
228 - $textlink . $text . $nb .
229 - '</div>';
230 - $s .= "</div></td>\n";
231 - $s .= ($i%4==3) ? '</tr>' : '';
232 - $i++;
233 - }
234 - if ( $i %4 != 0 ) {
235 - $s .= "</tr>\n";
236 - }
237 - $s .= '</table>';
238 - $s .= $this->pagerHTML('bottom');
239 - return $s;
240 - }
241 -} //class
Index: trunk/extensions/ImageTagging/ImageTagging_body.php
@@ -0,0 +1,238 @@
 2+<?php
 3+
 4+/**
 5+ * @package MediaWiki
 6+ * @subpackage SpecialPage
 7+ */
 8+
 9+define('TAGGEDIMGS_PER_PAGE', 12);
 10+
 11+/**
 12+ * Photos tagged gallery
 13+ *
 14+ * Add images to the gallery using add(), then render that list to HTML using toHTML().
 15+ */
 16+class TaggedImages extends SpecialPage {
 17+
 18+ var $mQuery, $mImages;
 19+
 20+ /**
 21+ * Create a new tagged images object.
 22+ */
 23+ function TaggedImages() {
 24+ global $wgLang, $wgAllowRealName, $wgRequest, $wgOut;
 25+
 26+ $wgOut->addScript("<style type=\"text/css\">/*<![CDATA[*/ @import \"$GLOBALS[wgScriptPath]/extensions/ImageTagging/img_tagging.css?$GLOBALS[wgStyleVersion]\"; /*]]>*/</style>\n");
 27+
 28+ $this->mQuery = preg_replace( "/[\"'<>]/", "", $wgRequest->getText('q') );
 29+ $this->mStartPage = preg_replace( "/[\"'<>]/", "", $wgRequest->getVal('page') );
 30+ $this->mCount = 0;
 31+ if ( ! $this->mStartPage )
 32+ $this->mStartPage = 0;
 33+ $this->mImages = array();
 34+
 35+ SpecialPage::SpecialPage('TaggedImages');
 36+ }
 37+
 38+ /**
 39+ * Start doing stuff
 40+ * @access public
 41+ */
 42+ function execute() {
 43+ global $wgDBname, $wgOut;
 44+
 45+ wfProfileIn( __METHOD__ );
 46+
 47+ $db =& wfGetDB(DB_SLAVE);
 48+
 49+ $WHERECLAUSE = '';
 50+ if ($this->mQuery) {
 51+ $WHERECLAUSE = " WHERE article_tag='$this->mQuery'";
 52+ }
 53+
 54+ $imagetable = $db->tableName( 'image' );
 55+ $imagetagstable = $db->tableName( 'imagetags' );
 56+
 57+ $SQL = "SELECT img_name, img_timestamp FROM $imagetable WHERE img_name IN (SELECT img_name FROM $imagetagstable $WHERECLAUSE) ORDER BY img_timestamp DESC";
 58+
 59+ $SQL = $db->LimitResult($SQL, TAGGEDIMGS_PER_PAGE, $this->mStartPage * TAGGEDIMGS_PER_PAGE);
 60+
 61+ $res = $db->query($SQL);
 62+ while ($o = $db->fetchObject($res)) {
 63+ $img = Image::newFromName($o->img_name);
 64+ $this->add($img, '');
 65+ }
 66+ $db->freeResult($res);
 67+
 68+ $res = $db->query("SELECT COUNT(img_name) as img_count FROM $imagetagstable".
 69+ ( $this->mQuery ? " WHERE article_tag='" . $this->mQuery . "'" : "" ) .
 70+ " GROUP BY article_tag");
 71+ if ( $o = $db->fetchObject($res) ) {
 72+ $this->mCount = $o->img_count;
 73+ }
 74+ $db->freeResult($res);
 75+
 76+ $wgOut->setPageTitle( wfMsg('imagetagging-taggedimages-title', $this->mQuery ? $this->mQuery : "all" ) );
 77+ $wgOut->setRobotpolicy('noindex,nofollow');
 78+ $wgOut->addHTML($this->toHTML());
 79+
 80+ wfProfileOut( __METHOD__ );
 81+ }
 82+
 83+ /**
 84+ * Add an image to the gallery.
 85+ *
 86+ * @param Image $image Image object that is added to the gallery
 87+ * @param string $html Additional HTML text to be shown. The name and size of the image are always shown.
 88+ */
 89+ function add( $image, $html='' ) {
 90+ $this->mImages[] = array( &$image, $html );
 91+ }
 92+
 93+ /**
 94+ * Add an image at the beginning of the gallery.
 95+ *
 96+ * @param Image $image Image object that is added to the gallery
 97+ * @param string $html Additional HTML text to be shown. The name and size of the image are always shown.
 98+ */
 99+ function insert( $image, $html='' ) {
 100+ array_unshift( $this->mImages, array( &$image, $html ) );
 101+ }
 102+
 103+ /**
 104+ * isEmpty() returns true if the gallery contains no images
 105+ */
 106+ function isEmpty() {
 107+ return empty( $this->mImages );
 108+ }
 109+
 110+ function pagerStatusHTML() {
 111+ wfProfileIn( __METHOD__ );
 112+
 113+ $numPages = $this->mCount / TAGGEDIMGS_PER_PAGE;
 114+
 115+ if (!$this->mQuery) $this->mQuery = "all";
 116+
 117+ $queryTitle = Title::newFromText($this->mQuery, NS_MAIN);
 118+
 119+ $html = wfMsg('imagetagging-taggedimages-displaying', $this->mStartPage*TAGGEDIMGS_PER_PAGE + 1, min(($this->mStartPage+1)*TAGGEDIMGS_PER_PAGE,$this->mCount), $this->mCount, '<a href="' . $queryTitle->getLocalURL() . '">' . $this->mQuery . '</a>');
 120+
 121+ wfProfileOut( __METHOD__ );
 122+ return $html;
 123+ }
 124+
 125+ function pageNoLink($pageNum, $pageText, $hrefPrefix, $cur) {
 126+ if ( $cur == false )
 127+ $html = '<a href="'. $hrefPrefix . $pageNum . '">' . $pageText . '</a>';
 128+ else
 129+ $html = '<b>' . $pageText . '</b>';
 130+
 131+ $html .= '&nbsp;';
 132+ return $html;
 133+ }
 134+
 135+ function pagerHTML($topBottom) {
 136+ global $wgOut;
 137+
 138+ $titleObj = Title::makeTitle( NS_SPECIAL, 'TaggedImages' );
 139+
 140+ $maxPages = 5; // 5 real pagers
 141+ $numPages = ceil($this->mCount / TAGGEDIMGS_PER_PAGE);
 142+
 143+ if ( $numPages <= 1 ) return '';
 144+
 145+ $html = '<span id="{$topBottom}pager" class="pager" style="float: right; text-align: right; right: 30px;">';
 146+
 147+ $hrefPrefix = $titleObj->escapeLocalURL("q=" . $this->mQuery . "&page=");
 148+
 149+ // build prev button
 150+ if ( $this->mStartPage - 1 >= 0 ) {
 151+ $html .= $this->pageNoLink($this->mStartPage-1, wfMsg('allpagesprev'), $hrefPrefix, false);
 152+ }
 153+
 154+ // build page # buttons
 155+ for ( $i=$this->mStartPage-2; $i < $this->mStartPage + $maxPages; $i++ ) {
 156+ if ( $i >= $numPages ) break;
 157+ if ( $i < 0 ) continue;
 158+
 159+ $html .= $this->pageNoLink($i, $i+1, $hrefPrefix, ($this->mStartPage == $i));
 160+ }
 161+
 162+ // build next button
 163+ if ( $this->mStartPage < $numPages-1 ) {
 164+ $html .= $this->pageNoLink($this->mStartPage+1, wfMsg('allpagesnext'), $hrefPrefix, false);
 165+ }
 166+
 167+ $html .= '</span>';
 168+
 169+ return $html;
 170+ }
 171+
 172+ /**
 173+ * Return a HTML representation of the image gallery
 174+ *
 175+ * For each image in the gallery, display
 176+ * - a thumbnail
 177+ * - the image name
 178+ * - the additional text provided when adding the image
 179+ * - the size of the image
 180+ *
 181+ */
 182+ function toHTML() {
 183+ global $wgLang, $wgUser, $wgOut;
 184+
 185+ $sk = $wgUser->getSkin();
 186+
 187+ $s = '<div>';
 188+ $s .= $this->pagerStatusHTML();
 189+ $s .= $this->pagerHTML('top');
 190+ $s .= '</div>';
 191+
 192+ $s .= '<table class="gallery" cellspacing="0" cellpadding="0">';
 193+ $i = 0;
 194+ foreach ( $this->mImages as $pair ) {
 195+ $img =& $pair[0];
 196+ $text = $pair[1];
 197+
 198+ $name = $img->getName();
 199+ $nt = $img->getTitle();
 200+
 201+ // Not an image. Just print the name and skip.
 202+ if ( $nt->getNamespace() != NS_IMAGE ) {
 203+ $s .= '<td><div class="gallerybox" style="height: 152px;">' .
 204+ htmlspecialchars( $nt->getText() ) . '</div></td>' . (($i%4==3) ? "</tr>\n" : '');
 205+ $i++;
 206+ continue;
 207+ }
 208+
 209+ // TODO
 210+ // $ul = $sk->makeLink( $wgContLang->getNsText( Namespace::getUser() ) . ":{$ut}", $ut );
 211+
 212+ $nb = '';
 213+ $textlink = $this->mShowFilename ?
 214+ $sk->makeKnownLinkObj( $nt, htmlspecialchars( $wgLang->truncate( $nt->getText(), 20, '...' ) ) ) . "<br />\n" :
 215+ '';
 216+
 217+ $s .= ($i%4==0) ? '<tr>' : '';
 218+ $thumb = $img->getThumbnail( 120, 120 );
 219+ $vpad = floor( ( 150 - $thumb->height ) /2 ) - 2;
 220+ $s .= '<td><div class="gallerybox">' . '<div class="thumb" style="padding: ' . $vpad . 'px 0;">';
 221+
 222+ # ATTENTION: The newline after <div class="gallerytext"> is needed to accommodate htmltivdy which
 223+ # in version 4.8.6 generated crackpot html in its absence, see:
 224+ # http://bugzilla.wikimedia.org/show_bug.cgi?id=1765 -Ævar
 225+ $s .= $sk->makeKnownLinkObj( $nt, $thumb->toHtml() ) . '</div><div class="gallerytext">' . "\n" .
 226+ $textlink . $text . $nb .
 227+ '</div>';
 228+ $s .= "</div></td>\n";
 229+ $s .= ($i%4==3) ? '</tr>' : '';
 230+ $i++;
 231+ }
 232+ if ( $i %4 != 0 ) {
 233+ $s .= "</tr>\n";
 234+ }
 235+ $s .= '</table>';
 236+ $s .= $this->pagerHTML('bottom');
 237+ return $s;
 238+ }
 239+} //class
Property changes on: trunk/extensions/ImageTagging/ImageTagging_body.php
___________________________________________________________________
Added: svn:eol-style
1240 + native
Index: trunk/extensions/ImageTagging/ImageTagging.i18n.php
@@ -5,7 +5,6 @@
66 * @addtogroup Extensions
77 */
88
9 -
109 $messages = array();
1110
1211 /** English
@@ -13,6 +12,8 @@
1413 * @author Tristan Harris
1514 */
1615 $messages['en'] = array(
 16+ 'taggedimages' => 'Tagged Images',
 17+ 'imagetagging-desc' => 'Lets a user select regions of an embedded image and associate a page with that region',
1718 'imagetagging-addimagetag' => 'Tag this Image',
1819 'imagetagging-article' => 'Page:',
1920 'imagetagging-articletotag' => 'Page to tag',
@@ -42,5 +43,4 @@
4344 'imagetagging-taggedimages-title' => 'Images of "$1"',
4445 'imagetagging-taggedimages-displaying' => 'Displaying $1 - $2 of $3 images of "$4"',
4546 'imagetagging-taggedimages-total' => '"$1"; image(s) total',
46 - 'imagetagging-taggedimages' => 'Tagged Images',
4747 );
Index: trunk/extensions/ImageTagging/ImageTagging.php
@@ -0,0 +1,620 @@
 2+<?php
 3+/**
 4+ * ImageTagging extension by Wikia, Inc.
 5+ * Lets a user select regions of an embedded image and associate an article with that region
 6+ *
 7+ * @author Tristan Harris
 8+ * @author Tomasz Klim
 9+ * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
 10+ */
 11+
 12+$wgHooks['UnknownAction'][] = 'addTag';
 13+$wgHooks['UnknownAction'][] = 'removeTag';
 14+$wgHooks['UnknownAction'][] = 'tagSearch';
 15+
 16+$wgExtensionFunctions[] = 'wfImageTagPageSetup';
 17+$wgExtensionCredits['other'][] = array(
 18+ 'name' => 'Image Tagging',
 19+ 'author' => 'Wikia, Inc. (Tristan Harris, and Tomasz Klim)',
 20+ 'version' => '1.0',
 21+ 'url' => 'http://www.mediawiki.org/wiki/Extension:ImageTagging',
 22+ 'description' => 'Lets a user select regions of an embedded image and associate a page with that region',
 23+ 'descriptionmsg' => 'imagetagging-desc',
 24+);
 25+
 26+// other hooks to try: 'ParserAfterTidy', ...
 27+#$wgHooks['OutputPageBeforeHTML'][] = 'wfCheckArticleImageTags';
 28+$wgHooks['ArticleFromTitle'][] = 'wfArticleFromTitle';
 29+
 30+$dir = dirname(__FILE__) . '/';
 31+$wgAutoloadClasses['TaggedImages'] = $dir . 'ImageTagging_body.php';
 32+$wgExtensionMessagesFiles['ImageTagging'] = $dir . 'ImageTagging.i18n.php';
 33+$wgSpecialPages['TaggedImages'] = 'TaggedImages';
 34+
 35+/********************
 36+ * End Trie Handlers
 37+ ********************/
 38+
 39+function wfCheckArticleImageTags($outputPage, $text) {
 40+ global $wgOut, $wgDBname, $wgTitle;
 41+
 42+ if ( $outputPage->isArticle() ) {
 43+ $db =& wfGetDB(DB_SLAVE);
 44+ $res = $db->query("SELECT article_tag, tag_rect, unique_id, COUNT(article_tag) AS count FROM ".
 45+ $db->tableName('imagetags').
 46+ " WHERE article_tag='" . addslashes($wgTitle->getText()). "' GROUP BY article_tag" );
 47+
 48+ if ($o = $db->fetchObject($res)) {
 49+ $taggedImagesObj = Title::newFromText('TaggedImages', NS_SPECIAL);
 50+ $titleText = $wgTitle->getText();
 51+
 52+ $wgOut->addHTML('
 53+ <a href="' . $taggedImagesObj->getLocalUrl('q='.$titleText) . '">
 54+ <span style="position:absolute;
 55+ z-index:1;
 56+ border:none;
 57+ background:none;
 58+ right:30px;
 59+ top:3.7em;
 60+ float:right;
 61+ margin:0.0em;
 62+ padding:0.0em;
 63+ line-height:1.7em; /*1.5em*/
 64+ text-align:right;
 65+ text-indent:0;
 66+ font-size:100%;
 67+ text-transform:none;
 68+ white-space:nowrap;" id="coordinates" class="plainlinksneverexpand">
 69+ ' . wfMsg('imagetagging-imagetag-seemoreimages', $titleText, $o->count) .
 70+ '</span></a>');
 71+ }
 72+ }
 73+ return true;
 74+}
 75+
 76+// TKL 2006-03-07: it doesn't work in new MediaWiki, modification required in includes/Wiki.php (class name change only)
 77+// $wgNamespaceTemplates[NS_IMAGE] = 'ImageTagPage';
 78+
 79+function addTag($action, $article) {
 80+ if($action != 'addTag') return true;
 81+
 82+ global $wgRequest, $wgTitle, $wgDBname, $wgOut, $wgUser;
 83+
 84+ wfProfileIn( __METHOD__ );
 85+
 86+ $wgOut->setArticleBodyOnly(true);
 87+
 88+ $tagRect = $wgRequest->getText('rect');
 89+ $tagName = $wgRequest->getText('tagName');
 90+ $imgName = $wgRequest->getText('imgName');
 91+ $userText = $wgUser->getName();
 92+
 93+ $tagRect = preg_replace( "/[\"'<>]/", "", $tagRect );
 94+ $tagName = preg_replace( "/[\"'<>]/", "", $tagName );
 95+ $imgName = preg_replace( "/[\"'<>]/", "", $imgName );
 96+
 97+ $img = Image::newFromName($imgName);
 98+ if ($img) {
 99+ $imgTitle = $img->getTitle();
 100+
 101+ wfPurgeTitle($imgTitle);
 102+
 103+ $db =& wfGetDB(DB_MASTER);
 104+ $db->insert('imagetags',
 105+ array(
 106+ 'img_page_id' => 0,
 107+ 'img_name' => $imgName,
 108+ 'article_tag' => $tagName,
 109+ 'tag_rect' => $tagRect,
 110+ 'user_text' => $userText)
 111+ );
 112+
 113+ $wgOut->clearHTML();
 114+ $wgOut->addHTML("<!-- added tag for image $imgName to database! -->");
 115+ $wgOut->addHTML( wfGetImageTags($img, $imgName) );
 116+
 117+ $logPage = new LogPage( 'tag' );
 118+ $link = basename( $img->title->getLocalURL() );
 119+ $logComment = wfMsg('imagetagging-log-tagged', $link, $imgName, $tagName, $userText);
 120+ $logPage->addEntry( 'tag', $imgTitle, $logComment);
 121+
 122+ $enotif = new EmailNotification;
 123+ $enotif->notifyOnPageChange($wgUser, $imgTitle, wfTimestampNow(), $logComment, false);
 124+ } else {
 125+ $wgOut->clearHTML();
 126+ $wgOut->addHTML("<!-- ERROR: img named $imgName -->
 127+ <script type='text/javascript'>
 128+ alert(\"Error adding tag!\");
 129+ </script>");
 130+ }
 131+ wfProfileOut( __METHOD__ );
 132+ return false;
 133+}
 134+
 135+function removeTag($action, $article) {
 136+ if ($action != 'removeTag') return true;
 137+
 138+ global $wgRequest, $wgTitle, $wgOut, $wgDBname, $wgUser;
 139+
 140+ wfProfileIn( __METHOD__ );
 141+
 142+ $wgOut->setArticleBodyOnly(true);
 143+
 144+ $tagID = $wgRequest->getVal('tagID');
 145+ $tagName = $wgRequest->getText('tagName');
 146+ $imgName = $wgRequest->getText('imgName');
 147+ $userText = $wgUser->getName();
 148+
 149+ $tagID = preg_replace( "/[\"'<>]/", "", $tagID );
 150+ $tagName = preg_replace( "/[\"'<>]/", "", $tagName );
 151+ $imgName = preg_replace( "/[\"'<>]/", "", $imgName );
 152+
 153+ $img = Image::newFromName($imgName);
 154+ if ($img) {
 155+ $imgTitle = $img->getTitle();
 156+
 157+ wfPurgeTitle($imgTitle);
 158+
 159+ $db =& wfGetDB(DB_MASTER);
 160+ $db->delete('imagetags', array('unique_id' => $tagID));
 161+
 162+ $wgOut->clearHTML();
 163+ $wgOut->addHTML("<!-- removed tag to database! -->");
 164+ $wgOut->addHTML( wfGetImageTags($img, $imgName) );
 165+
 166+ $logPage = new LogPage( 'tag' );
 167+ $logComment = wfMsg('imagetagging-logentry', $tagName, $userText);
 168+ $logPage->addEntry( 'tag', $imgTitle, $logComment);
 169+
 170+ $enotif = new EmailNotification;
 171+ $enotif->notifyOnPageChange($wgUser, $imgTitle, wfTimestampNow(), $logComment, false);
 172+ } else {
 173+ $wgOut->clearHTML();
 174+ $wgOut->addHTML("<!-- ERROR: img named $imgName -->
 175+ <script type='text/javascript'>
 176+ alert(\"Error removing tag!\");
 177+ </script>");
 178+ }
 179+
 180+ wfProfileOut( __METHOD__ );
 181+ return false;
 182+}
 183+
 184+function tagSearch($action, $article) {
 185+ if($action != 'tagSearch') return true;
 186+
 187+ global $wgRequest, $wgTitle, $wgDBname, $wgOut, $wgUser;
 188+
 189+ wfProfileIn( __METHOD__ );
 190+
 191+ $wgOut->setArticleBodyOnly(true);
 192+
 193+ $query = $wgRequest->getText('q');
 194+ $query = preg_replace( "/[\"'<>]/", "", $query );
 195+
 196+ $search = SearchEngine::create();
 197+ $search->setLimitOffset( 10, 0 );
 198+ $search->setNamespaces( array(NS_MAIN) );
 199+ $search->showRedirects = true;
 200+ $titleMatches = $search->searchTitle( $query );
 201+
 202+ $numResults = ( $titleMatches ? $titleMatches->numRows() : 0 );
 203+ if ( $numResults > 0 )
 204+ $wgOut->addHTML(wfTagSearchShowMatches($titleMatches));
 205+
 206+ #echo "numResults: " . $numResults . ", query: " . $query;
 207+
 208+ wfProfileOut( __METHOD__ );
 209+ return false;
 210+}
 211+
 212+/**
 213+ * @param SearchResultSet $matches
 214+ * @param string $terms partial regexp for highlighting terms
 215+ */
 216+function wfTagSearchShowMatches( &$matches ) {
 217+ global $wgContLang;
 218+
 219+ wfProfileIn( __METHOD__ );
 220+
 221+ $tm = $wgContLang->convertForSearchResult( $matches->termMatches() );
 222+ $terms = implode( '|', $tm );
 223+
 224+ $out = "<searchresults>\n";
 225+
 226+ while( $result = $matches->next() ) {
 227+ $out .= wfTagSearchHitXML( $result, $terms );
 228+ }
 229+ $out .= "</searchresults>\n";
 230+
 231+ // convert the whole thing to desired language variant
 232+ $out = $wgContLang->convert( $out );
 233+
 234+ wfProfileOut( __METHOD__ );
 235+ return $out;
 236+}
 237+
 238+/**
 239+ * Format a single hit result
 240+ * @param SearchResult $result
 241+ * @param string $terms partial regexp for highlighting terms
 242+ */
 243+function wfTagSearchHitXML( $result, $terms ) {
 244+ global $wgUser, $wgContLang;
 245+
 246+ wfProfileIn( __METHOD__ );
 247+
 248+ $t = $result->getTitle();
 249+ if( is_null( $t ) ) {
 250+ wfProfileOut( __METHOD__ );
 251+ return "<!-- Broken link in search result -->\n";
 252+ }
 253+ $sk =& $wgUser->getSkin();
 254+
 255+ $contextlines = 5;
 256+ $contextchars = 50;
 257+
 258+ $link = $sk->makeKnownLinkObj( $t );
 259+ $revision = Revision::newFromTitle( $t );
 260+ $text = $revision->getText();
 261+
 262+ $lines = explode( "\n", $text );
 263+
 264+ $max = intval( $contextchars ) + 1;
 265+ $pat1 = "/(.*)($terms)(.{0,$max})/i";
 266+
 267+ $lineno = 0;
 268+
 269+ $extract = '';
 270+ foreach ( $lines as $line ) {
 271+ if ( 0 == $contextlines ) {
 272+ break;
 273+ }
 274+ ++$lineno;
 275+ if ( ! preg_match( $pat1, $line, $m ) ) {
 276+ continue;
 277+ }
 278+ $contextlines--;
 279+ $pre = $wgContLang->truncate( $m[1], -$contextchars, '...' );
 280+
 281+ if ( count( $m ) < 3 ) {
 282+ $post = '';
 283+ } else {
 284+ $post = $wgContLang->truncate( $m[3], $contextchars, '...' );
 285+ }
 286+
 287+ $found = $m[2];
 288+
 289+ $line = htmlspecialchars( $pre . $found . $post );
 290+ $pat2 = '/(' . $terms . ")/i";
 291+ $line = preg_replace( $pat2, "<span class='searchmatch'>\\1</span>", $line );
 292+
 293+ $extract .= "<br /><small>{$lineno}: {$line}</small>\n";
 294+ }
 295+
 296+ wfProfileOut( __METHOD__ );
 297+ return "<result>\n<link>{$link}</link>\n<context>{$extract}</context>\n</result>\n";
 298+}
 299+
 300+function wfPurgeTitle($title) {
 301+ global $wgUseSquid;
 302+
 303+ wfProfileIn( __METHOD__ );
 304+
 305+ $title->invalidateCache();
 306+
 307+ if ( $wgUseSquid ) {
 308+ // Commit the transaction before the purge is sent
 309+ $dbw =& wfGetDB( DB_MASTER );
 310+ $dbw->immediateCommit();
 311+
 312+ // Send purge
 313+ $update = SquidUpdate::newSimplePurge( $title );
 314+ $update->doUpdate();
 315+ }
 316+
 317+ wfProfileOut( __METHOD__ );
 318+}
 319+
 320+function wfGetImageTags($img, $imgName) {
 321+ global $wgDBname;
 322+ global $wgUser;
 323+ global $wgOut;
 324+
 325+ wfProfileIn( __METHOD__ );
 326+
 327+ $sk = $wgUser->getSkin();
 328+ $db =& wfGetDB(DB_SLAVE);
 329+ $db->selectDB($wgDBname);
 330+ $res = $db->select(
 331+ array("imagetags"),
 332+ array("article_tag", "tag_rect", "unique_id"),
 333+ array("img_name" => $imgName),
 334+ __METHOD__ );
 335+
 336+ $html = '';
 337+ $wgOut->addHTML("<!-- this many image tags: " . count($res) . " from img " . $img->name . " -->");
 338+ while ($o = $db->fetchObject($res)) {
 339+ if ( strlen($html) > 0 )
 340+ $html .= ', ';
 341+
 342+ $wgOut->addHTML("<!-- tag rect: " . $o->tag_rect . ", tag title: " . $o->article_tag . ", unique_id: " . $o->unique_id . "-->");
 343+
 344+ $span = '<span id="' . $o->article_tag . '-tag" onmouseout="hideTagBox()" onmouseover="tagBoxPercent(' . $o->tag_rect . ', false)">';
 345+
 346+ #echo "article tag: " . $o->article_tag . "\n";
 347+ $articleTitle = Title::newFromText($o->article_tag);
 348+
 349+ #$articleLink = '<a href="' . $articleTitle->escapeFullURL() . '" onmouseout="hideTagBox()">' . $o->article_tag . '</a>';
 350+ $articleLink = $sk->makeLinkObj($articleTitle);
 351+
 352+ $specialImagesTitle = Title::newFromText("Special:TaggedImages");
 353+
 354+ $imagesLink = '<a onmouseover="tagBoxPercent(' . $o->tag_rect . ', false)" onmouseout="hideTagBox()" href="' . $specialImagesTitle->escapeFullURL("q=".$o->article_tag) . '">' . wfMsgHtml('imagetagging-images') . '</a>';
 355+
 356+ $removeLink = '<a href="#" onclick="removeTag(' . $o->unique_id . ', this, \'' . addslashes( $o->article_tag ) . '\'); return false;">' . wfMsgHtml('imagetagging-removetag') . '</a>';
 357+
 358+ $html .= $span . $articleLink . ' (' . $imagesLink . ' | ' . $removeLink . ')</span>';
 359+ }
 360+ $db->freeResult($res);
 361+
 362+ if ( $html )
 363+ $html = wfMsg('imagetagging-inthisimage', $html);
 364+
 365+ wfProfileOut( __METHOD__ );
 366+ return $html;
 367+}
 368+
 369+function wfArticleFromTitle( &$title, &$article ) {
 370+ global $wgUser;
 371+
 372+ wfProfileIn( __METHOD__ );
 373+
 374+ if ( NS_IMAGE == $title->getNamespace() && !$wgUser->isBlocked() ) {
 375+ $article = new ImageTagPage( $title );
 376+ }
 377+
 378+ wfProfileOut( __METHOD__ );
 379+ return true;
 380+}
 381+
 382+function wfImageTagPageSetup() {
 383+ global $wgLogTypes;
 384+
 385+ $wgLogTypes[] = 'tag';
 386+ wfLoadExtensionMessages('ImageTagging');
 387+
 388+ class ImageTagPage extends ImagePage {
 389+ function openShowImage() {
 390+ global $wgOut, $wgUser, $wgServer, $wgStyleVersion, $wgJsMimeType, $wgScriptPath;
 391+
 392+ wfProfileIn( __METHOD__ );
 393+
 394+ global $wgJsMimeType, $wgScriptPath;
 395+ $wgOut->addScript("<script type=\"{$wgJsMimeType}\" src=\"$wgScriptPath/extensions/ImageTagging/img_tagging.js?$wgStyleVersion\"></script>\n" );
 396+ $wgOut->addScript("<script type=\"{$wgJsMimeType}\" src=\"$wgScriptPath/extensions/ImageTagging/json.js?$wgStyleVersion\"></script>\n" );
 397+
 398+ $imgName = $this->getTitle()->getText();
 399+ $wgOut->addHTML("<input type='hidden' value='$imgName' id='imgName' />");
 400+ $wgOut->addHTML("<input type='hidden' value='$wgScriptPath/extensions/ImageTagging' id='imgPath' />");
 401+
 402+ if ( $wgUser->isLoggedIn() )
 403+ $wgOut->addHTML("<input type='hidden' value='1' id='userLoggedIn'/>");
 404+
 405+ if ( $wgUser->isAllowed('edit') &&
 406+ $this->mTitle->userCanEdit() &&
 407+ ( $this->mTitle->isProtected('edit') == false || in_array( 'sysop', $wgUser->getGroups() ) ) )
 408+ $wgOut->addHTML("<input type='hidden' value='1' id='canEditPage'/>");
 409+
 410+ $this->modifiedImagePageOpenShowImage();
 411+
 412+ if ( $this->img->exists() ) {
 413+ $tagList = wfGetImageTags($this->img, $imgName);
 414+
 415+ #if ( $tagList )
 416+ $wgOut->addHTML("<div id='tagListDiv'><span id='tagList'>$tagList</span></div>");
 417+ }
 418+
 419+ wfProfileOut( __METHOD__ );
 420+ }
 421+
 422+ function modifiedImagePageOpenShowImage() {
 423+ global $wgOut, $wgUser, $wgImageLimits, $wgRequest, $wgUseImageResize;
 424+
 425+ wfProfileIn( __METHOD__ );
 426+
 427+ $full_url = $this->img->getURL();
 428+ $anchoropen = '';
 429+ $anchorclose = '';
 430+
 431+ if( $wgUser->getOption( 'imagesize' ) == '' ) {
 432+ $sizeSel = User::getDefaultOption( 'imagesize' );
 433+ } else {
 434+ $sizeSel = intval( $wgUser->getOption( 'imagesize' ) );
 435+ }
 436+ if( !isset( $wgImageLimits[$sizeSel] ) ) {
 437+ $sizeSel = User::getDefaultOption( 'imagesize' );
 438+ }
 439+ $max = $wgImageLimits[$sizeSel];
 440+ $maxWidth = $max[0];
 441+ $maxHeight = $max[1];
 442+ $maxWidth = 600;
 443+ $maxHeight = 460;
 444+ $sk = $wgUser->getSkin();
 445+
 446+ if ( $this->img->exists() ) {
 447+ # image
 448+ $width = $this->img->getWidth();
 449+ $height = $this->img->getHeight();
 450+ $showLink = false;
 451+
 452+ if ( $this->img->allowInlineDisplay() and $width and $height) {
 453+ # image
 454+
 455+ # "Download high res version" link below the image
 456+ $msg = wfMsgHtml('show-big-image', $width, $height, intval( $this->img->getSize()/1024 ) );
 457+
 458+ # We'll show a thumbnail of this image
 459+ if ( $width > $maxWidth || $height > $maxHeight ) {
 460+ # Calculate the thumbnail size.
 461+ # First case, the limiting factor is the width, not the height.
 462+ if ( $width / $height >= $maxWidth / $maxHeight ) {
 463+ $height = round( $height * $maxWidth / $width);
 464+ $width = $maxWidth;
 465+ # Note that $height <= $maxHeight now.
 466+ } else {
 467+ $newwidth = floor( $width * $maxHeight / $height);
 468+ $height = round( $height * $newwidth / $width );
 469+ $width = $newwidth;
 470+ # Note that $height <= $maxHeight now, but might not be identical
 471+ # because of rounding.
 472+ }
 473+
 474+ if( $wgUseImageResize ) {
 475+ $thumbnail = $this->img->getThumbnail( $width );
 476+ if ( $thumbnail == null ) {
 477+ $url = $this->img->getViewURL();
 478+ } else {
 479+ $url = $thumbnail->getURL();
 480+ }
 481+ } else {
 482+ # No resize ability? Show the full image, but scale
 483+ # it down in the browser so it fits on the page.
 484+ $url = $this->img->getViewURL();
 485+ }
 486+ $anchoropen = "<a href=\"{$full_url}\">";
 487+ $anchorclose = "</a><br />";
 488+ if( $this->img->mustRender() ) {
 489+ $showLink = true;
 490+ } else {
 491+ $anchorclose .= "\n$anchoropen{$msg}</a>";
 492+ }
 493+ } else {
 494+ $url = $this->img->getViewURL();
 495+ $showLink = true;
 496+ }
 497+
 498+ //$anchoropen = '';
 499+ //$anchorclose = '';
 500+ // $width = 'auto'; //'100%';
 501+ // $height = 'auto'; //'100%';
 502+ $wgOut->addHTML( '<div class="fullImageLink" id="file">' .
 503+ "<img border=\"0\" src=\"{$url}\" width=\"{$width}\" height=\"{$height}\" style=\"max-width: {$maxWidth}px;\" alt=\"" .
 504+ htmlspecialchars( $wgRequest->getVal( 'image' ) ).'" />' .
 505+ $anchoropen . $anchorclose . '</div>' );
 506+ } else {
 507+ #if direct link is allowed but it's not a renderable image, show an icon.
 508+ if ($this->img->isSafeFile()) {
 509+ $icon= $this->img->iconThumb();
 510+
 511+ $wgOut->addHTML( '<div class="fullImageLink" id="file"><a href="' . $full_url . '">' .
 512+ $icon->toHtml() .
 513+ '</a></div>' );
 514+ }
 515+
 516+ $showLink = true;
 517+ }
 518+
 519+ if ($showLink) {
 520+ $filename = wfEscapeWikiText( $this->img->getName() );
 521+ $info = wfMsg( 'file-info',
 522+ $sk->formatSize( $this->img->getSize() ),
 523+ $this->img->getMimeType() );
 524+
 525+ if (!$this->img->isSafeFile()) {
 526+ $warning = wfMsg( 'mediawarning' );
 527+ $wgOut->addWikiText( <<<END
 528+<div class="fullMedia">
 529+<span class="dangerousLink">[[Media:$filename|$filename]]</span>
 530+<span class="fileInfo"> ($info)</span>
 531+</div>
 532+
 533+<div class="mediaWarning">$warning</div>
 534+END
 535+ );
 536+ } else {
 537+ $wgOut->addWikiText( <<<END
 538+<div class="fullMedia">
 539+[[Media:$filename|$filename]] <span class="fileInfo"> ($info)</span>
 540+</div>
 541+END
 542+ );
 543+ }
 544+ }
 545+
 546+ if($this->img->fromSharedDirectory) {
 547+ $this->printSharedImageText();
 548+ }
 549+ } else {
 550+ # Image does not exist
 551+
 552+ $title = Title::makeTitle( NS_SPECIAL, 'Upload' );
 553+ $link = $sk->makeKnownLinkObj($title, wfMsgHtml('noimage-linktext'),
 554+ 'wpDestFile=' . urlencode( $this->img->getName() ) );
 555+ $wgOut->addHTML( wfMsgWikiHtml( 'noimage', $link ) );
 556+ }
 557+
 558+ wfProfileOut( __METHOD__ );
 559+ }
 560+
 561+ /**
 562+ * Create the TOC
 563+ *
 564+ * @access private
 565+ *
 566+ * @param bool $metadata Whether or not to show the metadata link
 567+ * @return string
 568+ */
 569+ function showTOC( $metadata ) {
 570+ global $wgLang, $wgUser;
 571+
 572+ $r = '<ul id="filetoc">
 573+ <li><a href="#file">' . $wgLang->getNsText( NS_IMAGE ) . '</a></li>
 574+ <li><a href="#filehistory">' . wfMsgHtml( 'imagetagging-imghistory' ) . '</a></li>
 575+ <li><a href="#filelinks">' . wfMsgHtml( 'imagelinks' ) . '</a></li>' .
 576+ ($metadata ? '<li><a href="#metadata">' . wfMsgHtml( 'metadata' ) . '</a></li>' : '') . '
 577+ <li><a href="javascript:addImageTags()">' . wfMsgHtml( 'imagetagging-addimagetag' ) . '</a>'. wfMsg('imagetagging-new') .'</li>'
 578+ . '</ul>';
 579+
 580+ $r .= '<div id="tagStatusDiv" style="margin: 5px 5px 10px 5px; padding: 10px; border: solid 1px #ffe222; background: #fffbe2; display: none;"><table style="background-color: #fffbe2;"><tr><td width="450" height="30" align="center" style="padding-left: 20px;"><img src="/skins/common/progress-wheel.gif" id="progress_wheel" style="display:none;"><div id="tagging_message" style="background: #fffbe2;">' . wfMsgHtml('imagetagging-tagging-instructions') . '</td><td valign="middle"><input type="button" onclick="doneAddingTags();" id="done_tagging" name="done_tagging" value="' . wfMsgHtml('imagetagging-done-button') . '" /></div></td></tr></table></div>';
 581+
 582+ $r .= "<div style='position: absolute; font: verdana, sans-serif; top: 10px; left: 10px; display: none; width:284px; height:24px; padding: 4px 6px; background-color: #eeeeee; color: #444444; border: 2px solid #555555; z-index:2;' id='tagEditField'>
 583+
 584+ <span style='position: absolute; left: 4px; top: 6px;'>". wfMsg('imagetagging-article') ."</span>
 585+
 586+ <!-- TAH: don't use the popup just yet
 587+ <select name='tagType'>
 588+ <option selected>Article</option>
 589+ <option>Category</option>
 590+ </select>
 591+ -->";
 592+
 593+ $r .= "<input style='position: absolute; left: 189px; top: 6px; width: 39px; height: 20px;' type='submit' name='". wfMsgHtml('imagetagging-tag-button') ."' value='" . wfMsgHtml('imagetagging-tag-button') . "' onclick='submitTag()'/>";
 594+ $r .= "<input style='position: absolute; left: 232px; top: 6px; width: 60px; height: 20px;' type='button' name='" . wfMsgHtml('imagetagging-tagcancel-button') . "' value='" . wfMsgHtml('imagetagging-tagcancel-button') . "' onclick='hideTagBox()'/>";
 595+
 596+ $r .= "<input type='text' style='position: absolute; left: 46px; top: 6px; background-color:white; width: 140px; height:18px;' name='articleTag' id='articleTag' value='' title='". wfMsgHtml('imagetagging-articletotag') ."' onkeyup='typeTag(event);' />";
 597+
 598+ $r .= '</div>';
 599+
 600+ $r .= '<div id="popup" style="position:absolute; background-color: #eeeeee; top: 0px; left: 0px; z-index:3; visibility:hidden;"></div>';
 601+
 602+ #$r .= '</div>';
 603+
 604+ // TAH: adding this to grab edit tokens from javascript
 605+ $token = $wgUser->editToken();
 606+ $r .= "<input type=\"hidden\" value=\"$token\" name=\"wpEditToken\" id=\"wpEditToken\" />\n";
 607+ $r .= "<input type=\"hidden\" id=\"addingtagmessage\" value=\"" . wfMsg('imagetagging-addingtag') . "\">\n";
 608+ $r .= "<input type=\"hidden\" id=\"removingtagmessage\" value=\"" . wfMsg('imagetagging-removingtag') . "\">\n";
 609+ $r .= "<input type=\"hidden\" id=\"addtagsuccessmessage\" value=\"" . wfMsg('imagetagging-addtagsuccess') . "\">\n";
 610+ $r .= "<input type=\"hidden\" id=\"removetagsuccessmessage\" value=\"" . wfMsg('imagetagging-removetagsuccess') . "\">\n";
 611+
 612+ $r .= "<input type=\"hidden\" id=\"oneactionatatimemessage\" value=\"" . wfMsg('imagetagging-oneactionatatimemessage') . "\">\n";
 613+ $r .= "<input type=\"hidden\" id=\"canteditneedloginmessage\" value=\"" . wfMsg('imagetagging-canteditneedloginmessage') . "\">\n";
 614+ $r .= "<input type=\"hidden\" id=\"canteditothermessage\" value=\"" . wfMsg('imagetagging-canteditothermessage') . "\">\n";
 615+ $r .= "<input type=\"hidden\" id=\"oneuniquetagmessage\" value=\"" . wfMsg('imagetagging-oneuniquetagmessage') . "\">\n";
 616+
 617+ return $r;
 618+ }
 619+ }
 620+
 621+}
Property changes on: trunk/extensions/ImageTagging/ImageTagging.php
___________________________________________________________________
Added: svn:eol-style
1622 + native

Status & tagging log