Extension talk:BrowseImages

From MediaWiki.org
Jump to navigation Jump to search

Error using groups with MW 1.12[edit]

I tried this extension with MW 1.12 with $wgBrowseImagesGroupMode = true, and I get errors on the first and last pages of the group, and 2 errors if the group only has 1 picture in it. The errors are on lines 47 and 49 of the browseimages.class.php, and the error is always "Undefined offset: 1". It looks like it is having trouble determining when to disable the 'previous' and 'next' tabs. Any ideas would be much appreciated. DdDave 17:20, 20 April 2009 (UTC)

I did some fixes to the code for the group mode. Please check if you still get errors now. Roberthaenel 07:18, 21 April 2009 (UTC)
The errors are gone. Thanks. The only small bug is that the previous and next tabs are not being disabled. By clicking the 'previous' tab on the first image or the 'next' tab on the last image the link goes back to the root wiki path without any page specified so it takes you back to the main page. This extension is exactly what I was looking for, thanks for creating it. DdDave 13:16, 21 April 2009 (UTC)
I modified the code slightly to disable the correct tabs at the beginning and end of the group, and it seems to work on my MW1.12 installation. It's probably not the best or most efficient way, but it did the trick for me. Here's a code snippet of the new contentActionsHook function from the BrowseImages.class.php file. I added a new if statement.
	public static function contentActionsHook( &$content_actions) {
		global $wgTitle;
		if ( $wgTitle->getNamespace() == NS_IMAGE ) {
			foreach( array( 'prev' => '<', 'next' => '>' ) as $kind => $op ) {
				$link = self::getLink( $wgTitle, $op );
				$class = $link ? false : 'inactive';
                		$action = $kind . 'img';
                		if ($link != "") {
                    			$content_actions[$action] = array(
						'class' => $class,
						'text' => htmlspecialchars( wfMsg( "browseimages-{$kind}" ) ),
                        			'href' => $link
		return true;

DdDave 15:22, 22 April 2009 (UTC)

Great that it works for you now! You could also evaluate the 'class' attribute of the link via CSS to hide the next/prev links. As you can see in the code (2 lines before your if statement) the list element containing the link gets the class 'inactive' when it's not defined (=there is no previous or next image). I use something like this in my stylesheet for example:
#ca-previmg.inactive, #ca-nextimg.inactive {
	display: none;

Roberthaenel 19:50, 25 April 2009 (UTC)

Works for me[edit]

There is not much discussion here, so I guess it is working for everyone else too. However, since the main page does not mention any versions I thought I would post that it is working for me with MediaWiki

Product Version
MediaWiki 1.16.0
PHP 5.2.14(cgi-fcgi)
MySQL 5.1.47-communitiy-log

--From David

Thanks for the heads up