r82079 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r82078‎ | r82079 | r82080 >
Date:20:53, 13 February 2011
Author:kwisatz
Status:deferred
Tags:
Comment:
Added support for file titles in GeeQuBox
Modified paths:
  • /branches/REL1_16/extensions/GeeQuBox/GeeQuBox.php (modified) (history)

Diff [purge]

Index: branches/REL1_16/extensions/GeeQuBox/GeeQuBox.php
@@ -47,7 +47,7 @@
4848 */
4949 class GeeQuBox {
5050
51 - private $_page;
 51+ private static $_page;
5252 private $_hasGallery;
5353
5454 public function gqbAddLightBox( $page ) {
@@ -55,7 +55,7 @@
5656 return false;
5757
5858 try {
59 - $this->_page = $page;
 59+ self::$_page = $page;
6060 $this->_gqbReplaceHref( $page );
6161 $this->_gqbAddScripts( $page );
6262 return true;
@@ -83,10 +83,11 @@
8484 global $wgExtensionAssetsPath;
8585
8686 $eDir = $wgExtensionAssetsPath .'/GeeQuBox/';
87 - $this->_page->includeJQuery();
88 - $this->_page->addScript( '<script type="text/javascript" src="'. $eDir .'js/jquery.lightbox-0.5.min.js"></script>' . PHP_EOL );
89 - $this->_page->addExtensionStyle( $eDir . '/css/jquery.lightbox-0.5.css', 'screen' );
90 - $this->_page->addInlineScript('$j(document).ready(function(){
 87+ self::$_page->includeJQuery();
 88+ self::$_page->addScript( '<script type="text/javascript" src="'
 89+ . $eDir . 'js/jquery.lightbox-0.5.min.js"></script>' . PHP_EOL );
 90+ self::$_page->addExtensionStyle( $eDir . '/css/jquery.lightbox-0.5.css', 'screen' );
 91+ self::$_page->addInlineScript('$j(document).ready(function(){
9192 $j("div.gallerybox a.image").lightBox({
9293 imageLoading: "'. $eDir .'images/lightbox-ico-loading.gif",
9394 imageBtnClose: "'. $eDir .'images/lightbox-btn-close.gif",
@@ -113,12 +114,11 @@
114115 * approach but there doesn't seem to be an alternative approach.)
115116 */
116117 private function _gqbReplaceHref() {
117 - $page = $this->_page->getHTML();
118118 $pattern = '~href="https://www.mediawiki.org/wiki/([^"]+)"\s*class="image"~';
119 - $replaced = preg_replace_callback($pattern,'self::_gqbReplaceMatches',$page);
 119+ $replaced = preg_replace_callback($pattern,'self::_gqbReplaceMatches',self::$_page->getHTML());
120120
121 - $this->_page->clearHTML();
122 - $this->_page->addHTML( $replaced );
 121+ self::$_page->clearHTML();
 122+ self::$_page->addHTML( $replaced );
123123 }
124124
125125 private static function _gqbReplaceMatches( $matches ) {
@@ -127,9 +127,10 @@
128128 $image = wfFindFile( $titleObj, false, false, true );
129129 $realwidth = (Integer) $image->getWidth();
130130 $width = ( $realwidth > $wgGqbDefaultWidth ) ? $wgGqbDefaultWidth : $realwidth;
131 - // do not create a thumbnail when the image is smaller than the default width requested
132131 $iPath = ( $realwidth < $wgGqbDefaultWidth ) ? $image->getURL() : $image->createThumb($width);
133 - return 'href="'. $iPath .'" class="image"'; // $image->getURL()
 132+ $title = self::$_page->parse( "'''[[:" . $titleObj->getFullText() . "|" . $titleObj->getText() . "]]'''" );
 133+
 134+ return 'href="'. $iPath .'" title="'. htmlspecialchars( $title ) .'" class="image"';
134135 }
135136
136137 /*

Status & tagging log