Skip to content

Commit

Permalink
Item11808: perltidy them all, so people are not accidentally impacted…
Browse files Browse the repository at this point in the history
… by the new enforced rule -- Sorry Micha, could not find a way to define specific values within the file

git-svn-id: http://svn.foswiki.org/trunk/ImageGalleryPlugin@14686 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
OlivierRaginel authored and OlivierRaginel committed May 4, 2012
1 parent 3e4ffd2 commit b3bbe49
Show file tree
Hide file tree
Showing 2 changed files with 1,107 additions and 1,001 deletions.
109 changes: 62 additions & 47 deletions lib/Foswiki/Plugins/ImageGalleryPlugin.pm
Expand Up @@ -9,97 +9,112 @@
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details, published at
# GNU General Public License for more details, published at
# http://www.gnu.org/copyleft/gpl.html
#
# =========================
package Foswiki::Plugins::ImageGalleryPlugin;
use strict;

# =========================
our $VERSION = '$Rev$';
our $RELEASE = '6.00';
our $VERSION = '$Rev$';
our $RELEASE = '6.00';
our $NO_PREFS_IN_TOPIC = 1;
our $SHORTDESCRIPTION = 'Displays image gallery with auto-generated thumbnails from attachments';
our $SHORTDESCRIPTION =
'Displays image gallery with auto-generated thumbnails from attachments';
our $isInitialized;
our $igpId;
our $TranslationToken = "\2\3\2"; # SMELL arbitrary but may clash with other plugin's transtoks
our $TranslationToken =
"\2\3\2"; # SMELL arbitrary but may clash with other plugin's transtoks
our %knownGalleries;

# =========================
sub initPlugin {
#my ($topic, $web, $user, $installWeb) = @_;

if ($Foswiki::Plugins::VERSION < 1) {
&Foswiki::Func::writeWarning("Version mismatch between ImageGalleryPlugin and Plugins.pm");
return 0;
}
$igpId = 0;
$isInitialized = 0;
%knownGalleries = ();
#my ($topic, $web, $user, $installWeb) = @_;

Foswiki::Func::registerTagHandler('IMAGEGALLERY', \&renderImageGalleryPlaceholder);
Foswiki::Func::registerTagHandler('NRIMAGES', \&renderNrImages);
if ( $Foswiki::Plugins::VERSION < 1 ) {
&Foswiki::Func::writeWarning(
"Version mismatch between ImageGalleryPlugin and Plugins.pm");
return 0;
}
$igpId = 0;
$isInitialized = 0;
%knownGalleries = ();

return 1;
Foswiki::Func::registerTagHandler( 'IMAGEGALLERY',
\&renderImageGalleryPlaceholder );
Foswiki::Func::registerTagHandler( 'NRIMAGES', \&renderNrImages );

return 1;
}

# =========================
sub doInit {
return if $isInitialized;
$isInitialized = 1;
return if $isInitialized;
$isInitialized = 1;

Foswiki::Func::addToHEAD("IMAGEGALLERYPLUGIN", <<'HERE');
Foswiki::Func::addToHEAD( "IMAGEGALLERYPLUGIN", <<'HERE');
<link rel="stylesheet" href="%PUBURL%/%SYSTEMWEB%/ImageGalleryPlugin/style.css" type="text/css" media="all" />
HERE

require Foswiki::Plugins::ImageGalleryPlugin::Core;
require Foswiki::Plugins::ImageGalleryPlugin::Core;
}

# =========================
sub renderImageGalleryPlaceholder {
my ($session, $params, $theTopic, $theWeb) = @_;

doInit();

$igpId++;
$knownGalleries{$igpId} = {
core => Foswiki::Plugins::ImageGalleryPlugin::Core->new($igpId, $theTopic, $theWeb),
params => $params
};
return $TranslationToken.'IMAGEGALLERY{'.$igpId.'}'.$TranslationToken;
my ( $session, $params, $theTopic, $theWeb ) = @_;

doInit();

$igpId++;
$knownGalleries{$igpId} = {
core => Foswiki::Plugins::ImageGalleryPlugin::Core->new(
$igpId, $theTopic, $theWeb
),
params => $params
};
return
$TranslationToken
. 'IMAGEGALLERY{'
. $igpId . '}'
. $TranslationToken;
}

# =========================
sub postRenderingHandler {
# my $text = shift;

$_[0] =~ s/${TranslationToken}IMAGEGALLERY{(.*?)}$TranslationToken/renderImageGallery($1)/ge;
# my $text = shift;

$_[0] =~
s/${TranslationToken}IMAGEGALLERY{(.*?)}$TranslationToken/renderImageGallery($1)/ge;
}

# =========================
sub renderImageGallery {
my $igpId = shift;
my $igpId = shift;

my $igp = $knownGalleries{$igpId};
return '' unless $igp;
my $igp = $knownGalleries{$igpId};
return '' unless $igp;

return $igp->{core}->render($igp->{params});
return $igp->{core}->render( $igp->{params} );
}


# =========================
sub renderNrImages {
my ($session, $params, $theTopic, $theWeb) = @_;

doInit();

my $igp = Foswiki::Plugins::ImageGalleryPlugin::Core->new(undef, $theTopic, $theWeb);
if ($igp->init($params)) {
return scalar @{$igp->getImages()};
} else {
return Foswiki::Plugins::ImageGalleryPlugin::Core::renderError("can't initialize");
}
my ( $session, $params, $theTopic, $theWeb ) = @_;

doInit();

my $igp = Foswiki::Plugins::ImageGalleryPlugin::Core->new( undef, $theTopic,
$theWeb );
if ( $igp->init($params) ) {
return scalar @{ $igp->getImages() };
}
else {
return Foswiki::Plugins::ImageGalleryPlugin::Core::renderError(
"can't initialize");
}
}

1;

0 comments on commit b3bbe49

Please sign in to comment.