Extension:BrowseImages/pl

From MediaWiki.org
Jump to: navigation, search
This page is a translated version of the page Extension:BrowseImages and the translation is 20% complete.

Other languages:
Deutsch • ‎English • ‎日本語 • ‎polski • ‎русский • ‎中文
Podręcznik rozszerzeń MediaWikiManual:Extensions
Crystal Clear action run.svg
BrowseImages

Status wydania:Extension status beta

RealizacjaTemplate:Extension#type User interface
OpisTemplate:Extension#description Adds links for next and previous image to the content actions menu when viewing a page in the Image namespace.
AutorzyTemplate:Extension#username Robert Hänel (roberthaeneltalk)
Ostatnia wersjaTemplate:Extension#version 0.1 (2008-04-29)
MediaWikiTemplate:Extension#mediawiki 1.11
LicencjaTemplate:Extension#license Nie określono
Pobieranie Brak linka
ParametryTemplate:Extension#parameters

$wgBrowseImagesGroupMode

Użyte hakiTemplate:Extension#hook
SkinTemplateContentActionsManual:Hooks/SkinTemplateContentActions

Przetłumacz rozszerzenie BrowseImages jeżeli jest dostępne na translatewiki.net

Sprawdź wykorzystywanie i version matrix.

What can this extension do?

This extension allows you to alphabetically browse through the images in your wiki by adding two links "Previous" and "Next" to the content actions menu when viewing a page in the Image namespace.

It also features a group mode which is useful for galleries of images whose names match the pattern Image:[some description][numbering].[extension], like for example Image:Flowers 001.jpg to Image:Flowers 199.jpg. If group mode is enabled, you can only browse within that group of images (i.e. the Previous and Next links are disabled when reaching the first and last image, respectively, of the group).

This extension is based on Extension:Back-and-ForthExtension:Back-and-Forth by Rob Church.

Download instructions

Please cut and paste the code found below and place it in $IP/extensions/BrowseImages/. Uwaga Uwaga: $IPManual:$IP stands for the root directory of your MediaWiki installation, the same directory that holds LocalSettings.phpManual:LocalSettings.php.

Instalacja

To install this extension, add the following to LocalSettings.phpManual:LocalSettings.php:

require_once("$IP/extensions/BrowseImages/BrowseImages.php");

If you want to enable the group mode, add the following line too:

$wgBrowseImagesGroupMode = true;

Kod

BrowseImages.php

<?php
#
# BrowseImages extension for MediaWiki
#
# Installation:
#	create a new directory extensions/BrowseImages and copy all files there
#	add the following to LocalSettings.php:
#	require_once( "extensions/BrowseImages/BrowseImages.php" );
#
# Options:
#	add the following line to LocalSettings.php if you want to enable group mode:
#	$wgBrowseImagesGroupMode = true;
#	group mode is useful for galleries of images whose names match the pattern
#	Image:[some description][numbering].[extension], like for example
#	'Image:Flowers 001.jpg' to 'Image:Flowers 199.jpg'
#	if group mode is enabled, you can only browse within that group of images
#

if(! defined('MEDIAWIKI')) {
	die("This is a MediaWiki extension and can not be used standalone.\n");
}

$wgAutoloadClasses['BrowseImages'] = dirname( __FILE__ ) . '/BrowseImages.class.php';
$wgExtensionMessagesFiles['BrowseImages'] = dirname(__FILE__) . '/BrowseImages.i18n.php';
$wgExtensionFunctions[] = 'efBrowseImages';
$wgExtensionCredits['other'][] = array(
	'name' => 'BrowseImages',
	'description' => 'Adds links for next and previous image to the content actions menu
		when viewing a page in the Image namespace.',
	'version' => '0.1',
	'author' => 'Robert H&auml;nel',
	'url' => 'http://www.mediawiki.org/wiki/Extension:BrowseImages'
);

function efBrowseImages() {
	global $wgHooks;
	wfLoadExtensionMessages( 'BrowseImages' );
	$wgHooks['SkinTemplateContentActions'][] = 'BrowseImages::contentActionsHook';
}

BrowseImages.class.php

<?php

class BrowseImages {

	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';
				$content_actions[$action] = array(
					'class' => $class,
					'text' => htmlspecialchars( wfMsg( "browseimages-{$kind}" ) ),
					'href' => $link
				);
			}
		}
		return true;
	}

	private static function getLink( $title, $op ) {
		global $wgBrowseImagesGroupMode;
		$dbr = wfGetDB( DB_SLAVE );
		$res = $dbr->select(
			'page',
			array( 'page_namespace', 'page_title' ),
			array(
				'page_is_redirect' => 0,
				'page_namespace' => $title->getNamespace(),
				"page_title {$op} " . $dbr->addQuotes( $title->getDBkey() ),
			),
			__METHOD__,
			array(
				'ORDER BY' => 'page_title' . ( $op == '<' ? ' DESC' : '' ),
				'LIMIT' => 1,
			)
		);
		if( $dbr->numRows( $res ) > 0 ) {
			$row = $dbr->fetchObject( $res );
			$dbr->freeResult( $res );
			$target = Title::makeTitleSafe( $row->page_namespace, $row->page_title );
			if( $target instanceof Title ) {
				if ($wgBrowseImagesGroupMode) {
					$titlegroup = '';
					$targetgroup = '';
					$regex = '/^(.+)\D\d+(\.\w+)?/';
					if (preg_match($regex, $title, $matches)) {
						$titlegroup = $matches[1];
					}
					if (preg_match($regex, $target, $matches)) {
						$targetgroup = $matches[1];
					}
					if ((!empty($titlegroup)) && ($titlegroup === $targetgroup)) {
						return $target->escapeLocalURL();
					}
				} else {
					return $target->escapeLocalURL();
				}
			}
		}
		return false;
	}

}

BrowseImages.i18n.php

<?php

$messages = array();

$messages['en'] = array(
	'browseimages-next' => 'Next',
	'browseimages-prev' => 'Previous',
);

$messages['de'] = array(
	'browseimages-next' => 'Vor',
	'browseimages-prev' => 'Zurück',
);
	
$messages['zh-tw'] = array(
	'browseimages-next' => '下一張',
	'browseimages-prev' => '前一張',
);

$messages['es'] = array(
	'browseimages-next' => 'Siguiente',
	'browseimages-prev' => 'Anterior',
);

$messages['ru'] = array(
	'browseimages-next' => 'Следующий',
	'browseimages-prev' => 'Предыдущий',
);

Zobacz też