Skip to content

Commit

Permalink
Item11992:
Browse files Browse the repository at this point in the history
   * replaced all simplemodals with jquery-ui dialogs
   * added nullformat,nullheader,nullfooter to %ATTACHMENTS macro
   * removed dependency on !WebDAVLinkPlugin to render webdav-enabled urls 



git-svn-id: http://svn.foswiki.org/trunk/TopicInteractionPlugin@15127 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
MichaelDaum authored and MichaelDaum committed Jul 10, 2012
1 parent ddf00e3 commit 56c8b65
Show file tree
Hide file tree
Showing 11 changed files with 428 additions and 469 deletions.
10 changes: 8 additions & 2 deletions data/System/TopicInteractionPlugin.txt
@@ -1,4 +1,4 @@
%META:TOPICINFO{author="ProjectContributor" comment="reprev" date="1335457249" format="1.1" reprev="2" version="2"}%
%META:TOPICINFO{author="ProjectContributor" comment="reprev" date="1336576843" format="1.1" reprev="2" version="4"}%
---+!! %TOPIC%
%SHORTDESCRIPTION%

Expand Down Expand Up @@ -77,6 +77,9 @@ limit the number of attachments to be listed.
| =separator="..."= | format string put between each formatted attachment |
| =hidenull="on,off"= | hide/display the empty result; only the header and the footer are included \
if set to "off" and there's no attachment at the given topic |
| =nullformat="..."= | format string to be used when no attachments have been found and =hidenull= is switched off | |
| =nullheader="..."= | header string to be used when no attachments have been found and =hidenull= is switched off | |
| =nullfooter="..."= | footer string to be used when no attachments have been found and =hidenull= is switched off | |
| =sort="name,date,size,user,comment,comment:name"= | sort results by specified field |
| =reverse="on/off"= | enable reverse sorting |
| =limit="..."= | limit the number of attachments to the given number; by default show all |
Expand Down Expand Up @@ -150,9 +153,12 @@ generates:
| Release: | %$RELEASE% |
| Version: | %$VERSION% |
| Change History: | <!-- versions below in reverse order -->&nbsp; |
| 10 Jul 2012: | replaced all simplemodals with jquery-ui dialogs; \
added nullformat,nullheader,nullfooter to %ATTACHMENTS macro; \
removed dependency on !WebDAVLinkPlugin to render webdav-enabled urls |
| 08 May 2012: | fixed silent dependency on !DBCachePlugin; \
fixed integration with !PatternSkin; \
fixed dependency on Foswiki:Extensions/RenderPlugin;
fixed dependency on Foswiki:Extensions/RenderPlugin; \
fixed interaction with Foswiki:Extensions/MetaCommentPlugin |
| 26 Apr 2012: | initial release |
| Dependencies: | %$DEPENDENCIES% |
Expand Down
3 changes: 2 additions & 1 deletion lib/Foswiki/Plugins/TopicInteractionPlugin.pm
Expand Up @@ -16,9 +16,10 @@
package Foswiki::Plugins::TopicInteractionPlugin;

use strict;
use warnings;

our $VERSION = '$Rev: 1340 $';
our $RELEASE = '3.01';
our $RELEASE = '3.10';
our $SHORTDESCRIPTION = 'Improved interaction with attachments and !DataForms';
our $NO_PREFS_IN_TOPIC = 1;

Expand Down
42 changes: 27 additions & 15 deletions lib/Foswiki/Plugins/TopicInteractionPlugin/Attachments.pm
Expand Up @@ -49,15 +49,17 @@ sub handle {
my $theFormat = $params->{format};
my $theSeparator = $params->{separator};
my $theSort = $params->{sort} || $params->{order} || 'name';
my $theReverse = $params->{reverse} || 'off';
my $theHideNull = $params->{hidenull} || 'off';
my $theReverse = Foswiki::Func::isTrue($params->{reverse}, 0);
my $theHideNull = Foswiki::Func::isTrue($params->{hidenull}, 0);
my $theNullHeader = $params->{nullheader} || '';
my $theNullFormat = $params->{nullformat} || '';
my $theNullFooter = $params->{nullfooter} || '';
my $theComment = $params->{comment} || '.*';
my $theLimit = $params->{limit} || 0;
my $theSkip = $params->{skip} || 0;
my $theWarn = $params->{warn} || 'on';
#my $theWarn = Foswiki::Func::isTrue($params->{warn}, 1);
my $theInclude = $params->{include};
my $theCase = $params->{casesensitive} || 'on';
my $theCase = Foswiki::Func::isTrue($params->{casesensitive}, 1);

$theLimit =~ s/[^\d]//go;
$theLimit = 0 unless $theLimit;
Expand All @@ -75,7 +77,10 @@ sub handle {
# sort attachments
my ($meta) = Foswiki::Func::readTopic($thisWeb, $thisTopic );
my @attachments = $meta->find("FILEATTACHMENT");
return '' unless @attachments;
unless (@attachments) {
return '' if $theHideNull;
return Foswiki::Func::decodeFormatTokens($theNullHeader.$theNullFormat.$theNullFooter);
}

#%META:FILEATTACHMENT{name="cross06.jpg" attachment="cross06.jpg" attr="" comment="" date="1287484667" size="30247" user="micha" version="1"}%

Expand Down Expand Up @@ -107,7 +112,7 @@ sub handle {
@attachments = sort { $sorting{$a} cmp $sorting{$b} } @attachments;
}
}
@attachments = reverse @attachments if $theReverse eq 'on';
@attachments = reverse @attachments if $theReverse;

# collect result
my @result;
Expand All @@ -129,7 +134,7 @@ sub handle {
next unless $info->{comment} =~ /^($theComment)$/;

if ($theInclude) {
if ($theCase eq 'on') {
if ($theCase) {
next unless
$info->{name} =~ /^($theInclude)$/ ||
$info->{user} =~ /^($theInclude)$/ ||
Expand All @@ -149,11 +154,16 @@ sub handle {
}

$params->{_count} = $index;
return '' if $theHideNull eq 'on' && $index == 0;
return '' if $theHideNull && $index == 0;
$theSkip = 0 if $theSkip > $index;
$index = 0;
my $webDAVLinkPluginEnabled = Foswiki::Func::getContext()->{WebDAVLinkPluginEnabled};
my $webDAVFilter = $Foswiki::cfg{TopicInteractionPlugin}{WebDAVFilter} || qr/((xlt|xls|ppt|pps|pot|doc|dot)(x|m)?)|odc|odb|odf|odg|otg|odi|odp|otp|ods|ots|odt|odm|ott|oth|mpp/;
my $webDAVFilter = $Foswiki::cfg{TopicInteractionPlugin}{WebDAVFilter};
my $webDavUrl = $Foswiki::cfg{TopicInteractionPlugin}{WebDAVUrl} || 'webdav://$host/dav/$web/$topic_files/$attachment';
my $host = $Foswiki::cfg{DefaultUrlHost};
$host =~ s/^https?:\/+//;
$webDavUrl =~ s/\$host/$host/g;
$webDavUrl =~ s/\$web/$thisWeb/g;
$webDavUrl =~ s/\$topic/$thisTopic/g;

foreach my $attachment (@selectedAttachments) {

Expand All @@ -170,8 +180,10 @@ sub handle {
my $encName = urlEncode($info->{name});

# actions
my $webDavUrl = '%WEBDAVFOLDERURL%/' . $thisWeb . '/' . $thisTopic . '_files/' . $encName;
my $webDavAction = '<a rel="nofollow" href="' . $webDavUrl . '" ' . 'title="%MATETEXT{"edit this attachment" args="<nop>' . $info->{name} . '"}%">' . '%MAKETEXT{"edit"}%</a>';
my $thisWebDavUrl = $webDavUrl;
$thisWebDavUrl =~ s/\$attachment/$encName/g;

my $webDavAction = '<a rel="nofollow" href="' . $thisWebDavUrl . '" ' . 'title="%MATETEXT{"edit this attachment" args="<nop>' . $info->{name} . '"}%">' . '%MAKETEXT{"edit"}%</a>';

my $propsUrl = '%SCRIPTURLPATH{"attach"}%/' . $thisWeb . '/' . $thisTopic . '?filename=' . $encName . '&revInfo=1';
my $propsAction = '<a rel="nofollow" href="' . $propsUrl . '" ' . 'title="%MAKETEXT{"manage properties of [_1]" args="<nop>' . $info->{name} . '"}%">' . '%MAKETEXT{"props"}%</a>';
Expand All @@ -197,15 +209,15 @@ sub handle {
}

# use webdav urls for document types that are webdav-enabled via WebDAVLinkPlugin
if ($webDAVLinkPluginEnabled && $info->{name} =~ /\.($webDAVFilter)$/i) {
if (defined($webDAVFilter) && $info->{name} =~ /\.($webDAVFilter)$/i) {
# switch normal pubUrls to webdavUrls
$url = $webDavUrl;
$url = $thisWebDavUrl;
}

my $text = $theFormat;
$text =~ s/\$date\(([^\)]+)\)/_formatTile($info->{date}, $1)/ge;
$text =~ s/\$webdav\b/$webDavAction/g;
$text =~ s/\$webdavUrl\b/$webDavUrl/g;
$text =~ s/\$webdavUrl\b/$thisWebDavUrl/g;
$text =~ s/\$propsUrl/$propsUrl/g;
$text =~ s/\$props\b/$propsAction/g;
$text =~ s/\$moveUrl\b/$moveUrl/g;
Expand Down
14 changes: 10 additions & 4 deletions lib/Foswiki/Plugins/TopicInteractionPlugin/Config.spec
Expand Up @@ -7,10 +7,16 @@
# Note that silverlight, gears and browserplus are disabled by default as these browser extensions are mostly unsupported and/or untested.
$Foswiki::cfg{TopicInteractionPlugin}{UploadEngines} = 'html5, flash, html4';

# ---+++ WebDAV filter
# **REGEX EXPERT**
# ---+++ WebDAV
# **REGEX**
# Specify a regular expression matching fileextensions to be webdav enabled in the attachments list of a topic.
# This configuration setting will only take effect when the WebDAVLinkPlugin is enabled too.
$Foswiki::cfg{TopicInteractionPlugin}{WebDAVFilter} = qr/((xlt|xls|ppt|pps|pot|doc|dot)(x|m)?)|odc|odb|odf|odg|otg|odi|odp|otp|ods|ots|odt|odm|ott|oth|mpp/;
# By default this is undefined. Use
# <code>qr/((xlt|xls|ppt|pps|pot|doc|dot)(x|m)?)|odc|odb|odf|odg|otg|odi|odp|otp|ods|ots|odt|odm|ott|oth|mpp/</code>
# as a good coverage of the most common office document extensions.
$Foswiki::cfg{TopicInteractionPlugin}{WebDAVFilter} = undef;

# *URL M**
# Defines the uri pattern for webdav links.
$Foswiki::cfg{TopicInteractionPlugin}{WebDAVUrl} = 'webdav://$host/dav/$web/$topic_files/$attachment';

1;
1 change: 1 addition & 0 deletions lib/Foswiki/Plugins/TopicInteractionPlugin/DEPENDENCIES
Expand Up @@ -9,5 +9,6 @@ Foswiki::Plugins::MetaCommentPlugin,>=1.11,perl,Optional.
Foswiki::Plugins::MimeIconPlugin,>=1.1,perl,Required.
Foswiki::Plugins::RenderPlugin,>=3.01,perl,Required.
Archive::Zip,>=0,cpan,Required.
JSON,>=2.17,cpan,Required. Available from the CPAN archive.
ONLYIF ( $Foswiki::Plugins::VERSION < 2.1)
Foswiki::Plugins::ZonePlugin,>=3.1,perl,Required. required for Foswiki < 1.1
2 changes: 1 addition & 1 deletion lib/Foswiki/Plugins/TopicInteractionPlugin/Uploader.pm
Expand Up @@ -51,7 +51,7 @@ sub new {
documentation => "$Foswiki::cfg{SystemWebName}.TopicInteractionPlugin",
javascript => ['jquery.uploader.js'],
css => ['jquery.uploader.css'],
dependencies => ['blockui', 'scrollto', 'button', 'livequery', 'metadata', 'simplemodal', 'JavaScriptFiles/foswikiPref', 'JQUERYPLUGIN::UPLOADER::ENGINES'],
dependencies => ['blockui', 'scrollto', 'button', 'livequery', 'metadata', 'ui::dialog', 'form', 'JavaScriptFiles/foswikiPref', 'JQUERYPLUGIN::UPLOADER::ENGINES'],
@_
), $class);

Expand Down
@@ -1,6 +1,3 @@
#simplemodal-container .jqUploaderDialog {
width:600px;
}
.jqUploaderControls {
width:565px;
}
Expand Down
10 changes: 2 additions & 8 deletions pub/System/TopicInteractionPlugin/metadata.uncompressed.css
Expand Up @@ -106,10 +106,7 @@ a.foswikiAttachmentsOptionsToggle {
max-width:4.1538em; /* 54px */
max-height:4.1538em; /* 54px */
}
#simplemodal-container .foswikiThumbnail a {
width:auto;
margin:0px 0px 1em 1em;
}

.foswikiAttachments .foswikiAttachmentEditor .foswikiFormSteps {
padding:0.6923em 0.3846em 0.6923em 5.1538em; /* 9px 5px 9px 67px */
margin:-0.6923em -0.3846em;
Expand Down Expand Up @@ -231,6 +228,7 @@ a.foswikiAttachmentsOptionsToggle {
margin-top:-2px;
}

.foswikiAttachmentBulkProgressMessage,
.foswikiAttachmentBulkMessage {
display:none; /* switched on while opening the dialog */
}
Expand All @@ -239,10 +237,6 @@ a.foswikiAttachmentsOptionsToggle {
margin:0em 0em 0em 1.5em;
}

#foswikiAttachmentConfirmBulk .jqSimpleModalCancel {
margin-right:0px;
}

/* forms */
.foswikiDataForm {
margin:0px 0px 1em;
Expand Down

0 comments on commit 56c8b65

Please sign in to comment.