Revert "Multiple file upload handling."

This reverts commit 260f00d60b.

As mentioned in
260f00d60b (comment_8367)

Reverting this merge until the bugs are fixed and there is a general
agreement on the need for this enhancement.
This commit is contained in:
Sarven Capadisli 2010-03-31 10:57:20 +02:00
parent 21a835596c
commit 534c12e540
5 changed files with 49 additions and 72 deletions

View File

@ -164,25 +164,22 @@ class NewnoticeAction extends Action
$replyto = 'false'; $replyto = 'false';
} }
$uploads = array(); $upload = null;
foreach($_FILES as $name => $value) { $upload = MediaFile::fromUpload('attach');
if(substr($name, 0, 6) == "attach") {
$upload = MediaFile::fromUpload($name); if (isset($upload)) {
if (isset($upload)) {
$content_shortened .= ' ' . $upload->shortUrl(); $content_shortened .= ' ' . $upload->shortUrl();
}
} if (Notice::contentTooLong($content_shortened)) {
}
if (Notice::contentTooLong($content_shortened)) {
foreach($uploads as $upload) {
$upload->delete(); $upload->delete();
$this->clientError(
sprintf(
_('Max notice size is %d chars, including attachment URL.'),
Notice::maxContent()
)
);
} }
$this->clientError(
sprintf(
_('Max notice size is %d chars, including attachment URL.'),
Notice::maxContent()
)
);
} }
$options = array('reply_to' => ($replyto == 'false') ? null : $replyto); $options = array('reply_to' => ($replyto == 'false') ? null : $replyto);
@ -200,10 +197,12 @@ class NewnoticeAction extends Action
$notice = Notice::saveNew($user->id, $content_shortened, 'web', $options); $notice = Notice::saveNew($user->id, $content_shortened, 'web', $options);
foreach($uploads as $upload) { if (isset($upload)) {
$upload->attachToNotice($notice); $upload->attachToNotice($notice);
} }
if ($this->boolean('ajax')) { if ($this->boolean('ajax')) {
header('Content-Type: text/xml;charset=utf-8'); header('Content-Type: text/xml;charset=utf-8');
$this->xw->startDocument('1.0', 'UTF-8'); $this->xw->startDocument('1.0', 'UTF-8');

View File

@ -30,8 +30,7 @@ var SN = { // StatusNet
CounterBlackout: false, CounterBlackout: false,
MaxLength: 140, MaxLength: 140,
PatternUsername: /^[0-9a-zA-Z\-_.]*$/, PatternUsername: /^[0-9a-zA-Z\-_.]*$/,
HTTP20x30x: [200, 201, 202, 203, 204, 205, 206, 300, 301, 302, 303, 304, 305, 306, 307], HTTP20x30x: [200, 201, 202, 203, 204, 205, 206, 300, 301, 302, 303, 304, 305, 306, 307]
UploadCounter: 0
}, },
S: { // Selector S: { // Selector
@ -173,7 +172,6 @@ var SN = { // StatusNet
FormNoticeXHR: function(form) { FormNoticeXHR: function(form) {
SN.C.I.NoticeDataGeo = {}; SN.C.I.NoticeDataGeo = {};
form.append('<input type="hidden" name="ajax" value="1"/>'); form.append('<input type="hidden" name="ajax" value="1"/>');
form.ajaxForm({ form.ajaxForm({
dataType: 'xml', dataType: 'xml',
timeout: '60000', timeout: '60000',
@ -230,10 +228,9 @@ var SN = { // StatusNet
} }
else { else {
if (parseInt(xhr.status) === 0 || jQuery.inArray(parseInt(xhr.status), SN.C.I.HTTP20x30x) >= 0) { if (parseInt(xhr.status) === 0 || jQuery.inArray(parseInt(xhr.status), SN.C.I.HTTP20x30x) >= 0) {
form.resetForm(); form
SN.U.NoticeClearAttachments(form); .resetForm()
SN.C.I.UploadCounter = 0; .find('#'+SN.C.S.NoticeDataAttachSelected).remove();
SN.U.NoticeNewAttachment($('fieldset', form));
SN.U.FormNoticeEnhancements(form); SN.U.FormNoticeEnhancements(form);
} }
else { else {
@ -290,9 +287,8 @@ var SN = { // StatusNet
} }
} }
form.resetForm(); form.resetForm();
SN.U.NoticeClearAttachments(form); form.find('#'+SN.C.S.NoticeInReplyTo).val('');
SN.C.I.UploadCounter = 0; form.find('#'+SN.C.S.NoticeDataAttachSelected).remove();
SN.U.NoticeNewAttachment($('fieldset', form));
SN.U.FormNoticeEnhancements(form); SN.U.FormNoticeEnhancements(form);
} }
}, },
@ -313,11 +309,6 @@ var SN = { // StatusNet
} }
}); });
}, },
NoticeClearAttachments: function(form) {
$('input:file', form).remove();
$('div[class=' + SN.C.S.Success + ']', form).remove();
},
NoticeReply: function() { NoticeReply: function() {
if ($('#'+SN.C.S.NoticeDataText).length > 0 && $('#content .notice_reply').length > 0) { if ($('#'+SN.C.S.NoticeDataText).length > 0 && $('#content .notice_reply').length > 0) {
@ -477,31 +468,25 @@ var SN = { // StatusNet
} }
}, },
NoticeDataAttach: function(NDANum) { NoticeDataAttach: function() {
NDA = $('#'+SN.C.S.NoticeDataAttach+NDANum); NDA = $('#'+SN.C.S.NoticeDataAttach);
NDA.change(function() { NDA.change(function() {
S = '<div id="'+SN.C.S.NoticeDataAttachSelected+SN.C.I.UploadCounter+'" class="'+SN.C.S.Success+'"><code>'+$(this).val()+'</code> <button class="close">&#215;</button></div>'; S = '<div id="'+SN.C.S.NoticeDataAttachSelected+'" class="'+SN.C.S.Success+'"><code>'+$(this).val()+'</code> <button class="close">&#215;</button></div>';
$('#'+SN.C.S.FormNotice).append(S); NDAS = $('#'+SN.C.S.NoticeDataAttachSelected);
if (NDAS.length > 0) {
$('#'+SN.C.S.NoticeDataAttachSelected+SN.C.I.UploadCounter+' button').click(function(){ NDAS.replaceWith(S);
$('#'+this.parentNode.getAttribute("id")).remove(); }
$('#'+this.parentNode.getAttribute("id").replace("_selected", "")).remove(); else {
$('#'+SN.C.S.FormNotice).append(S);
}
$('#'+SN.C.S.NoticeDataAttachSelected+' button').click(function(){
$('#'+SN.C.S.NoticeDataAttachSelected).remove();
NDA.val(''); NDA.val('');
return false; return false;
}); });
SN.C.I.UploadCounter++;
NDA.attr('style', 'display: none;');
SN.U.NoticeNewAttachment(NDA.parent());
$('#notice_data-attach-label').attr('for', SN.C.S.NoticeDataAttach+SN.C.I.UploadCounter);
}); });
}, },
NoticeNewAttachment: function(parent) {
NEWFILE = '<input id="'+SN.C.S.NoticeDataAttach+SN.C.I.UploadCounter+'" class="attach" type="file" name="attach'+SN.C.I.UploadCounter+'" title="'+NoticeAttachment_text.AttachFile+'"/>';
parent.append(NEWFILE);
SN.U.NoticeDataAttach(SN.C.I.UploadCounter);
},
NoticeLocationAttach: function() { NoticeLocationAttach: function() {
var NLat = $('#'+SN.C.S.NoticeLat).val(); var NLat = $('#'+SN.C.S.NoticeLat).val();
@ -735,7 +720,7 @@ var SN = { // StatusNet
SN.U.FormNoticeEnhancements($(this)); SN.U.FormNoticeEnhancements($(this));
}); });
SN.U.NoticeDataAttach(""); SN.U.NoticeDataAttach();
} }
}, },

View File

@ -189,14 +189,10 @@ class NoticeForm extends Form
} }
if (common_config('attachments', 'uploads')) { if (common_config('attachments', 'uploads')) {
$this->out->element('label', array('id' => 'notice_data-attach-label', $this->out->element('label', array('for' => 'notice_data-attach'),_('Attach'));
'class' => 'attach-label',
'for' => 'notice_data-attach'),
_('Attach'));
$this->out->element('input', array('id' => 'notice_data-attach', $this->out->element('input', array('id' => 'notice_data-attach',
'class' => 'attach',
'type' => 'file', 'type' => 'file',
'name' => 'attach0', 'name' => 'attach',
'title' => _('Attach a file'))); 'title' => _('Attach a file')));
$this->out->hidden('MAX_FILE_SIZE', common_config('attachments', 'file_quota')); $this->out->hidden('MAX_FILE_SIZE', common_config('attachments', 'file_quota'));
} }
@ -216,10 +212,8 @@ class NoticeForm extends Form
$this->out->checkbox('notice_data-geo', _('Share my location'), true); $this->out->checkbox('notice_data-geo', _('Share my location'), true);
$this->out->elementEnd('div'); $this->out->elementEnd('div');
$this->out->inlineScript(' var NoticeDataGeo_text = {'. $this->out->inlineScript(' var NoticeDataGeo_text = {'.
'ShareDisable: ' .json_encode(_('Do not share my location')).','. 'ShareDisable: "'._('Do not share my location').'",'.
'ErrorTimeout: ' .json_encode(_('Sorry, retrieving your geo location is taking longer than expected, please try again later')). 'ErrorTimeout: "'._('Sorry, retrieving your geo location is taking longer than expected, please try again later').'"'.
'} ; var NoticeAttachment_text = {'.
'AttachFile: ' . json_encode(_('Attach a file')) .
'}'); '}');
} }

View File

@ -550,19 +550,19 @@ float:left;
font-size:1.3em; font-size:1.3em;
margin-bottom:7px; margin-bottom:7px;
} }
.form_notice .attach-label, .form_notice label[for=notice_data-attach],
.form_notice .attach { .form_notice #notice_data-attach {
position:absolute; position:absolute;
top:25px; top:25px;
right:10.5%; right:10.5%;
cursor:pointer; cursor:pointer;
} }
.form_notice .attach-label { .form_notice label[for=notice_data-attach] {
text-indent:-9999px; text-indent:-9999px;
width:16px; width:16px;
height:16px; height:16px;
} }
.form_notice .attach { .form_notice #notice_data-attach {
padding:0; padding:0;
height:16px; height:16px;
} }
@ -606,7 +606,7 @@ width:81.5%;
margin-bottom:0; margin-bottom:0;
line-height:1.618; line-height:1.618;
} }
.form_notice code { .form_notice #notice_data-attach_selected code {
float:left; float:left;
width:80%; width:80%;
display:block; display:block;
@ -614,7 +614,7 @@ overflow:auto;
margin-right:2.5%; margin-right:2.5%;
font-size:1.1em; font-size:1.1em;
} }
.form_notice button.close { .form_notice #notice_data-attach_selected button.close {
float:right; float:right;
font-size:0.8em; font-size:0.8em;
} }

View File

@ -154,15 +154,14 @@ color:#333333;
.entity_actions .dialogbox input { .entity_actions .dialogbox input {
color:#000000; color:#000000;
} }
.form_notice .attach-label { .form_notice label[for=notice_data-attach] {
background-position:0 -328px; background-position:0 -328px;
} }
.form_notice .attach { .form_notice #notice_data-attach {
position: absolute;
opacity:0; opacity:0;
} }
.form_notice .attach-label, .form_notice label[for=notice_data-attach],
#export_data li a.rss, #export_data li a.rss,
#export_data li a.atom, #export_data li a.atom,
#export_data li a.foaf, #export_data li a.foaf,