Skip to content

Commit

Permalink
Item11808: reverting perltidy
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.foswiki.org/trunk/ImageGalleryPlugin@14721 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
MichaelDaum authored and MichaelDaum committed May 7, 2012
1 parent b3bbe49 commit 145a1fc
Show file tree
Hide file tree
Showing 4 changed files with 1,008 additions and 1,114 deletions.
2 changes: 1 addition & 1 deletion data/System/ImageGalleryPlugin.txt
Expand Up @@ -176,7 +176,7 @@ Note, that the $comment variable will only display =<comment>= , that is w
| 14 Nov 2008 | made format string for galleries more flexible |
| 16 Jul 2008 | don't crash on images that start with a digits pattern |
| 07 Jul 2008 | fixing use of string as hash |
| 03 Jul 2008 | applying patch by Aur�lio A. Heckert (see Bugs:Item5753); \
| 03 Jul 2008 | applying patch by Aurélio A. Heckert (see Bugs:Item5753); \
using =Resize= instead of =Scale= for higher quality thumbnails; \
hiding reddot when the user has no edit access to the target topic |
| 03 Mar 2008 | make implementation of image mage configurable, \
Expand Down
111 changes: 48 additions & 63 deletions lib/Foswiki/Plugins/ImageGalleryPlugin.pm
Expand Up @@ -9,112 +9,97 @@
# 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) = @_;

#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 = ();

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

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

return 1;
return 1;
}

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

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

# my $text = shift;

$_[0] =~
s/${TranslationToken}IMAGEGALLERY{(.*?)}$TranslationToken/renderImageGallery($1)/ge;
$_[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 145a1fc

Please sign in to comment.