Skip to content

Commit

Permalink
Cleanup and drop-upload
Browse files Browse the repository at this point in the history
  • Loading branch information
bloatware committed Sep 25, 2017
1 parent b106a07 commit 29b931e
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
4 changes: 2 additions & 2 deletions textpattern/include/txp_file.php
Original file line number Diff line number Diff line change
Expand Up @@ -886,8 +886,6 @@ function file_insert()
global $txp_user, $file_base_path, $file_max_upload_size;

$files = file_refactor($_FILES['thefile']);
$ids = array();
$success = $errors = array();

if ($files === false) {
// Could not get uploaded files.
Expand All @@ -897,6 +895,8 @@ function file_insert()
}

require_privs('file.edit.own');
$ids = array();
$success = $errors = array();

extract(doSlash(array_map('assert_string', gpsa(array(
'category',
Expand Down
5 changes: 3 additions & 2 deletions textpattern/lib/txplib_forms.php
Original file line number Diff line number Diff line change
Expand Up @@ -751,11 +751,12 @@ function tsi($name, $datevar, $time, $tab = 0, $id = '')

function file_refactor(&$file)
{
if (empty($file['name'])) {
$is_array = is_array($file['name']);

if (empty($file['name']) || $is_array && empty($file['name'][0])) {
return false;
}

$is_array = is_array($file['name']);
$file_array = array();
$file_count = $is_array ? count($file['name']) : 1;
$file_keys = array_keys($file);
Expand Down
9 changes: 3 additions & 6 deletions textpattern/lib/txplib_html.php
Original file line number Diff line number Diff line change
Expand Up @@ -1476,13 +1476,11 @@ function upload_form($label, $pophelp = '', $step, $event, $id = '', $max_file_s
$wraptag_class = 'inline-file-uploader';
}

if (preg_match('/^.+\[\]$/', $step)) {
if ($multiple = (bool) preg_match('/^.+\[\]$/', $step)) {
$step = substr($step, 0, -2);
$name = 'name="thefile[]" multiple="multiple"';
} else {
$name = 'name="thefile"';
}

$name = 'thefile'.($multiple ? '[]' : '');
$argv = func_get_args();

return pluggable_ui(
Expand All @@ -1500,8 +1498,7 @@ function upload_form($label, $pophelp = '', $step, $event, $id = '', $max_file_s
hInput('crit', $crit).
inputLabel(
$label_id,
// fInput('file', 'thefile', '', '', '', '', '', '', $label_id).
'<input type="file" '.$name.' id="'.txpspecialchars($label_id).'" />'.
tag_void('input', array('name' => $name, 'type' => 'file', 'required' => true, 'id' => $label_id, 'multiple' => $multiple)).
fInput('submit', '', gTxt('upload')),
$label,
array($pophelp, 'instructions_'.$pophelp),
Expand Down
6 changes: 6 additions & 0 deletions textpattern/textpattern.js
Original file line number Diff line number Diff line change
Expand Up @@ -1833,6 +1833,12 @@ textpattern.Route.add('article, file', function () {
$(document).on('change', '.posted input', function (e) {
$('#publish_now, #reset_time').prop('checked', false);
});

$('.upload-form').on('drop', function(e) {
$(this).one('change', function() {
$(this).submit()
});
});
});

// 'Clone' button on Pages, Forms, Styles panels.
Expand Down

0 comments on commit 29b931e

Please sign in to comment.