Index: branches/REL1_16/extensions/GeeQuBox/GeeQuBox.php |
— | — | @@ -47,7 +47,7 @@ |
48 | 48 | */ |
49 | 49 | class GeeQuBox { |
50 | 50 | |
51 | | - private $_page; |
| 51 | + private static $_page; |
52 | 52 | private $_hasGallery; |
53 | 53 | |
54 | 54 | public function gqbAddLightBox( $page ) { |
— | — | @@ -55,7 +55,7 @@ |
56 | 56 | return false; |
57 | 57 | |
58 | 58 | try { |
59 | | - $this->_page = $page; |
| 59 | + self::$_page = $page; |
60 | 60 | $this->_gqbReplaceHref( $page ); |
61 | 61 | $this->_gqbAddScripts( $page ); |
62 | 62 | return true; |
— | — | @@ -83,10 +83,11 @@ |
84 | 84 | global $wgExtensionAssetsPath; |
85 | 85 | |
86 | 86 | $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(){ |
91 | 92 | $j("div.gallerybox a.image").lightBox({ |
92 | 93 | imageLoading: "'. $eDir .'images/lightbox-ico-loading.gif", |
93 | 94 | imageBtnClose: "'. $eDir .'images/lightbox-btn-close.gif", |
— | — | @@ -113,12 +114,11 @@ |
114 | 115 | * approach but there doesn't seem to be an alternative approach.) |
115 | 116 | */ |
116 | 117 | private function _gqbReplaceHref() { |
117 | | - $page = $this->_page->getHTML(); |
118 | 118 | $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()); |
120 | 120 | |
121 | | - $this->_page->clearHTML(); |
122 | | - $this->_page->addHTML( $replaced ); |
| 121 | + self::$_page->clearHTML(); |
| 122 | + self::$_page->addHTML( $replaced ); |
123 | 123 | } |
124 | 124 | |
125 | 125 | private static function _gqbReplaceMatches( $matches ) { |
— | — | @@ -127,9 +127,10 @@ |
128 | 128 | $image = wfFindFile( $titleObj, false, false, true ); |
129 | 129 | $realwidth = (Integer) $image->getWidth(); |
130 | 130 | $width = ( $realwidth > $wgGqbDefaultWidth ) ? $wgGqbDefaultWidth : $realwidth; |
131 | | - // do not create a thumbnail when the image is smaller than the default width requested |
132 | 131 | $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"'; |
134 | 135 | } |
135 | 136 | |
136 | 137 | /* |