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/EmbedPlugin@14686 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
OlivierRaginel authored and OlivierRaginel committed May 4, 2012
1 parent 50ac2c0 commit 91e7971
Showing 1 changed file with 36 additions and 30 deletions.
66 changes: 36 additions & 30 deletions lib/TWiki/Plugins/EmbedPlugin.pm
Expand Up @@ -11,7 +11,7 @@
# 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
#
# =========================
Expand All @@ -37,24 +37,24 @@
# getSessionValueHandler ( $key ) 1.010 Use only in one Plugin
# setSessionValueHandler ( $key, $value ) 1.010 Use only in one Plugin
#
# initPlugin is required, all other are optional.
# initPlugin is required, all other are optional.
# For increased performance, all handlers except initPlugin are
# disabled. To enable a handler remove the leading DISABLE_ from
# the function name. Remove disabled handlers you do not need.
#
# NOTE: To interact with TWiki use the official TWiki functions
# NOTE: To interact with TWiki use the official TWiki functions
# in the TWiki::Func module. Do not reference any functions or
# variables elsewhere in TWiki!!


# =========================
package TWiki::Plugins::EmbedPlugin; # change the package name and $pluginName!!!
package TWiki::Plugins::EmbedPlugin
; # change the package name and $pluginName!!!

# =========================
use vars qw(
$web $topic $user $installWeb $VERSION $RELEASE $pluginName
$debug $exampleCfgVar
);
$web $topic $user $installWeb $VERSION $RELEASE $pluginName
$debug $exampleCfgVar
);

# This should always be $Rev$ so that TWiki can determine the checked-in
# status of the plugin. It is used by the build automation tools, so
Expand All @@ -66,36 +66,39 @@ $VERSION = '$Rev$';
# of the version number in PLUGINDESCRIPTIONS.
$RELEASE = 'Dakar';

$pluginName = 'EmbedPlugin'; # Name of this Plugin
$pluginName = 'EmbedPlugin'; # Name of this Plugin

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

# check for Plugins.pm versions
if( $TWiki::Plugins::VERSION < 1 ) {
TWiki::Func::writeWarning( "Version mismatch between $pluginName and Plugins.pm" );
if ( $TWiki::Plugins::VERSION < 1 ) {
TWiki::Func::writeWarning(
"Version mismatch between $pluginName and Plugins.pm");
return 0;
}

# Get plugin debug flag
$debug = TWiki::Func::getPreferencesFlag( "\U$pluginName\E_DEBUG" );
$debug = TWiki::Func::getPreferencesFlag("\U$pluginName\E_DEBUG");

# Get plugin preferences, the variable defined by: * Set EXAMPLE = ...
$exampleCfgVar = &TWiki::Func::getPreferencesValue( "EMPTYPLUGIN_EXAMPLE" ) || "default";
# Get plugin preferences, the variable defined by: * Set EXAMPLE = ...
$exampleCfgVar = &TWiki::Func::getPreferencesValue("EMPTYPLUGIN_EXAMPLE")
|| "default";

# Plugin correctly initialized
TWiki::Func::writeDebug( "- TWiki::Plugins::${pluginName}::initPlugin( $web.$topic ) is OK" ) if $debug;
TWiki::Func::writeDebug(
"- TWiki::Plugins::${pluginName}::initPlugin( $web.$topic ) is OK")
if $debug;
return 1;
}

# =========================
sub commonTagsHandler
{
sub commonTagsHandler {
### my ( $text, $topic, $web ) = @_; # do not uncomment, use $_[0], $_[1]... instead

TWiki::Func::writeDebug( "- ${pluginName}::commonTagsHandler( $_[2].$_[1] )" ) if $debug;
TWiki::Func::writeDebug("- ${pluginName}::commonTagsHandler( $_[2].$_[1] )")
if $debug;

# This is the place to define customized tags and variables
# Called by sub handleCommonTags, after %INCLUDE:"..."%
Expand All @@ -108,15 +111,18 @@ sub commonTagsHandler
}

# =========================
sub handleEmbed
{
my ( $theAttributes ) = @_;
my $filename = &TWiki::Func::extractNameValuePair($theAttributes, "filename");
my $width = &TWiki::Func::extractNameValuePair($theAttributes, "width") || 200;
my $height = &TWiki::Func::extractNameValuePair($theAttributes, "height") || 42;
my $autostart = &TWiki::Func::extractNameValuePair($theAttributes, "autostart") || 1;

my $string =<<EOM;
sub handleEmbed {
my ($theAttributes) = @_;
my $filename =
&TWiki::Func::extractNameValuePair( $theAttributes, "filename" );
my $width = &TWiki::Func::extractNameValuePair( $theAttributes, "width" )
|| 200;
my $height = &TWiki::Func::extractNameValuePair( $theAttributes, "height" )
|| 42;
my $autostart =
&TWiki::Func::extractNameValuePair( $theAttributes, "autostart" ) || 1;

my $string = <<EOM;
<OBJECT ID="MediaPlayer" WIDTH="$width" HEIGHT="$height"
CLASSID="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95"
STANDBY="Loading Windows Media Player components..."
Expand All @@ -129,7 +135,7 @@ sub handleEmbed
</EMBED>
</OBJECT>
EOM
$string =~ s/\n/ /g; # not allowed to have newlines else you get rendering
$string =~ s/\n/ /g; # not allowed to have newlines else you get rendering
return $string;

return "<OBJECT CLASSID=\"clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B\"
Expand Down

0 comments on commit 91e7971

Please sign in to comment.