Skip to content

Commit

Permalink
Item11435:Item9916:
Browse files Browse the repository at this point in the history
   * fixed proper calculation of attachment size limit
   * fixed properly encoding url parameters
   * fixed adding the js to the head using the right ids
   * hiding image gallery settings when ImageGalleryPlugin isn't there



git-svn-id: http://svn.foswiki.org/trunk/TopicInteractionPlugin@14664 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
MichaelDaum authored and MichaelDaum committed Apr 26, 2012
1 parent 1ae6206 commit 461a95b
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 27 deletions.
7 changes: 4 additions & 3 deletions lib/Foswiki/Plugins/TopicInteractionPlugin/Core.pm
Expand Up @@ -19,6 +19,7 @@ use strict;
use Foswiki::Func ();
use Foswiki::Sandbox ();
use JSON ();
use Encode ();

use constant DEBUG => 0; # toggle me

Expand Down Expand Up @@ -197,6 +198,7 @@ sub prepareAction {
my $web = $session->{webName};

($web, $topic) = Foswiki::Func::normalizeWebTopicName($web, $topic);
#print STDERR "topic='$topic'\n";
unless (Foswiki::Func::topicExists($web, $topic)) {
printJSONRPC($response, 101, "Topic $web.$topic does not exist", $id);
return;
Expand Down Expand Up @@ -239,7 +241,7 @@ sub getRequestParams {
writeDebug("param $key=$val") unless $key eq 'POSTDATA';
}

my $queryString = $ENV{QUERY_STRING};
my $queryString = $ENV{QUERY_STRING} || '';

foreach my $item (split(/[&;]/, $queryString)) {
if ($item =~ /^(.+?)=(.*)$/ && !defined($params{$1})) {
Expand All @@ -257,11 +259,10 @@ sub urlDecode {
my $value = shift;

$value =~ s/%([\da-f]{2})/chr(hex($1))/gei;

my $session = $Foswiki::Plugins::SESSION;
my $downgradedValue = $session->UTF82SiteCharSet($value);
$value = $downgradedValue if defined $downgradedValue;

$value =~ s/^\s+//g;
$value =~ s/\s+$//g;

Expand Down
Expand Up @@ -518,9 +518,10 @@
};

/************************************************************************/
$(document).ready(function() {
$(function() {

var attachFileSizeLimit = foswiki.getPreference("TopicInteractionPlugin.attachFileSizeLimit") || 0;
attachFileSizeLimit *= 1024;

defaults = {
dragdrop: true,
Expand Down
@@ -1,4 +1,5 @@
/* pattern skin adjustments */
.foswikiAttachments table,
.foswikiLayoutTable,
.foswikiNullTable {
border-collapse: collapse;
Expand Down Expand Up @@ -27,19 +28,30 @@
border-collapse:separate;
}

.foswikiAttachments, .foswikiFormStep,
.foswikiMetaData .foswikiFormStep {
padding:0px;
border:0px;
}

.foswikiAttachments .foswikiFormSteps {
padding:20px;
}

#patternScreen .foswikiFormSteps h2 {
padding-left:0px;
padding-right:0px;
}

.foswikiAttachments table {
width:auto;
}

th {
line-height:inherit;
}

.foswikiMetaDataHelp {
display:none;
}
.patternTopicActions {
padding:12px 20px;
border-width:1px;
}
14 changes: 7 additions & 7 deletions pub/System/TopicInteractionPlugin/metadata.uncompressed.js
Expand Up @@ -447,7 +447,7 @@ jQuery(function($) {

loadDialog("#foswikiAttachmentPreviewer", "attachments::previewer");
$previewer = $("#foswikiAttachmentPreviewer"),
$previewer.find(".foswikiAttachmentName").text(decodeURI(attachmentOpts.filename));
$previewer.find(".foswikiAttachmentName").text(decodeURIComponent(attachmentOpts.filename));
$previewer.find(".foswikiPreviewContainer").load(previewUrl, function() {
setTimeout(function() {
$.unblockUI();
Expand Down Expand Up @@ -483,9 +483,9 @@ jQuery(function($) {
$hideFile = $container.find("input[name=hidefile]");

$.log("METADATA: show attachment editor");
$container.find("input[name=origfilename]").val(decodeURI(attachmentOpts.filename));
$container.find("input[name=filename]").val(decodeURI(attachmentOpts.filename));
$container.find("input[name=filecomment]").val(decodeURI(attachmentOpts.filecomment));
$container.find("input[name=origfilename]").val(decodeURIComponent(attachmentOpts.filename));
$container.find("input[name=filename]").val(decodeURIComponent(attachmentOpts.filename));
$container.find("input[name=filecomment]").val(decodeURIComponent(attachmentOpts.filecomment));
$container.find(".foswikiThumbnailContainer").empty();

$container.find(".foswikiThumbnailContainer").append(thumbnail);
Expand Down Expand Up @@ -566,12 +566,12 @@ jQuery(function($) {
width:300
},
onShow: function(dialog) {
dialog.container.find("#deleteAttachment").text(decodeURI(attachmentOpts.filename));
dialog.container.find("#deleteAttachment").text(decodeURIComponent(attachmentOpts.filename));
dialog.container.find(".foswikiThumbnailContainer").append(thumbnail);
},
onSubmit: function(dialog) {
$.blockUI({
message:"<h1>Deleting "+decodeURI(attachmentOpts.filename)+" ...</h1>",
message:"<h1>Deleting "+decodeURIComponent(attachmentOpts.filename)+" ...</h1>",
fadeIn: 0,
fadeOut: 0
});
Expand Down Expand Up @@ -615,7 +615,7 @@ jQuery(function($) {

$container.find(".foswikiMoveOne").show();
$container.find(".foswikiMoveMultiple").hide();
$container.find("input[name=filename]").val(decodeURI(attachmentOpts.filename));
$container.find("input[name=filename]").val(decodeURIComponent(attachmentOpts.filename));
$container.find(".foswikiThumbnailContainer").append(thumbnail);
},
onSubmit: function(dialog) {
Expand Down
8 changes: 3 additions & 5 deletions templates/attach.topicinteraction.tmpl
@@ -1,6 +1,9 @@
%TMPL:INCLUDE{"attach"}%
%TMPL:INCLUDE{"metadata"}%

%TMPL:DEF{"attachments::hidden"}%%URLPARAM{"attachments_hidden" default="on"}%%TMPL:END%
%TMPL:DEF{"attachments::showuploader"}%%URLPARAM{"attachments_showuploader" default="on"}%%TMPL:END%

%TMPL:DEF{"content"}%<!-- content -->
<div class="foswikiMetaData %IF{"not '%WEB%.%TOPIC%' allows 'change'" then="foswikiMetaDataNotAllowed"}%">
%BUTTON{
Expand All @@ -9,11 +12,6 @@
target="%BASEWEB%.%BASETOPIC%"
icon="cross"
}%
<h1>
<noautolink>%MAKETEXT{"Attachments at [_1]" args="%TMPL:P{"topictitle"}%"}%</noautolink>
<span class='foswikiAttachmentsCount foswikiSmall foswikiGrayText'>()</span>
</h1>
%CLEAR%
<div>%TMPL:P{"attachments"}%</div>
%TMPL:P{"metadata::css"}%
%TMPL:P{"metadata::javascript"}%
Expand Down
18 changes: 13 additions & 5 deletions templates/metadata.tmpl
Expand Up @@ -59,21 +59,26 @@
%JQREQUIRE{"tooltip, easing, ui, uploader, twisty, media"}%<!-- -->
%IF{"context FlexPaperPluginEnabled" then="$percntFLEXPAPERINIT$percnt"}%<!-- -->
%ADDTOZONE{"script"
id="NATSKIN::METADATA::JS"
id="METADATA::JS"
requires="JQUERYPLUGIN::LIVEQUERY, JQUERYPLUGIN::UI, JQUERYPLUGIN::UPLOAD"
text="<script src='%PUBURLPATH%/%SYSTEMWEB%/TopicInteractionPlugin/metadata.js'></script>"
}%<!-- -->%TMPL:END%

%{ ################################################################################ }%
%TMPL:DEF{"metadata::css"}%<!-- -->
%ADDTOZONE{"head"
tag="NATSKIN::METADATA::CSS"
id="METADATA::CSS"
requires="NATSKIN::CSS"
text="<link rel='stylesheet' href='%PUBURLPATH%/%SYSTEMWEB%/TopicInteractionPlugin/metadata.css' media='all' />"
}%<!-- -->
%TMPL:P{context="ImagePluginEnabled" then="metadata::css::imageplugin"}%<!-- -->
<!-- -->%TMPL:END%

%{ ################################################################################ }%
%TMPL:DEF{"metadata::css::imageplugin"}%<!-- -->
%ADDTOZONE{"head"
tag="IMAGEPLUGIN"
text="<link rel='stylesheet' href='%PUBURL%/%SYSTEMWEB%/ImagePlugin/style.css' media='all' />"
id="IMAGEPLUGIN"
text="<link rel='stylesheet' href='%PUBURLPATH%/%SYSTEMWEB%/ImagePlugin/style.css' media='all' />"
}%<!-- -->%TMPL:END%

%{ ################################################################################ }%
Expand Down Expand Up @@ -306,7 +311,10 @@
<select class="foswikiSelect" name="bulkaction">
<option class="foswikiOption" value="">%MAKETEXT{"Bulk action"}%</option>
<option class="foswikiOption" value="createlink">%MAKETEXT{"Insert links"}%</option>
<option class="foswikiOption" value="createimagegallery">%MAKETEXT{"Create image gallery"}%</option>
%IF{"context ImageGalleryPluginEnabled"
then=" <option class='foswikiOption' value='createimagegallery'>%MAKETEXT{"Create image gallery"}%</option>"
else="<!-- -->"
}%
<option class="foswikiOption" value="download">%MAKETEXT{"Download"}%</option>
<option class="foswikiOption" value="hide">%MAKETEXT{"Hide"}%</option>
<option class="foswikiOption" value="unhide">%MAKETEXT{"Unhide"}%</option>
Expand Down
4 changes: 1 addition & 3 deletions templates/view.topicinteraction.tmpl
Expand Up @@ -10,7 +10,5 @@
%TMPL:P{"metadata"}%
<a name="topic-actions"></a>
<div class="patternTopicActions">
<div class="patternTopicAction">
<span class="patternActionButtons">%TMPL:P{"topicactionbuttons"}%</span>
</div>
<span class="patternActionButtons">%TMPL:P{"topicactionbuttons"}%</span>
</div>%TMPL:END%

0 comments on commit 461a95b

Please sign in to comment.