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