Skip to content

Commit

Permalink
[GSOC-FUQT] Advanced File Uploader: Adding default values for the adv…
Browse files Browse the repository at this point in the history
…anced settings for fuqt.

Dev: fixed preview for fuqt

git-svn-id: file:///Users/Shitiz/Downloads/lssvn/source/limesurvey_dev@8914 b72ed6b6-b9f8-46b5-92b4-906544132732
  • Loading branch information
Amit Shanker committed Jul 9, 2010
1 parent 1ccc68f commit e8c0ae7
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 10 deletions.
8 changes: 6 additions & 2 deletions common.php
Expand Up @@ -4225,14 +4225,16 @@ function questionAttributes($returnByName=false)
'category'=>$clang->gT('Other'),
'sortorder'=>124,
"inputtype"=>"integer",
'default'=>10240,
"help"=>$clang->gT("The surveyee cannot upload a single file larger than this size"),
"caption"=>$clang->gT("Maximum file size allowed"));
"caption"=>$clang->gT("Maximum file size allowed (in KB)"));

$qattributes["max_num_of_files"]=array(
"types"=>"|",
'category'=>$clang->gT('Other'),
'sortorder'=>126,
"inputtype"=>"integer",
'default'=>1,
"help"=>$clang->gT("Maximum number of files that the surveyee can upload for this question"),
"caption"=>$clang->gT("Max number of files"));

Expand All @@ -4241,6 +4243,7 @@ function questionAttributes($returnByName=false)
'category'=>$clang->gT('Other'),
'sortorder'=>128,
"inputtype"=>"integer",
'default'=>0,
"help"=>$clang->gT("Minimum number of files that the surveyee must upload for this question"),
"caption"=>$clang->gT("Min number of files"));

Expand All @@ -4249,8 +4252,9 @@ function questionAttributes($returnByName=false)
'category'=>$clang->gT('Other'),
'sortorder'=>130,
"inputtype"=>"textarea",
'default'=>"png, gif, doc, odt",
"help"=>$clang->gT("Allowed file types in comma separated format. e.g. pdf, doc, odt"),
"caption"=>$clang->gT("Allowed file types"));
"caption"=>$clang->gT("Allowed file types (eg: pdf, doc, odt)"));


//This builds a more useful array (don't modify)
Expand Down
2 changes: 1 addition & 1 deletion group.php
Expand Up @@ -415,7 +415,7 @@

$hiddenfieldnames=implode("|", $inputnames);

if ($upload_file)
if (isset($upload_file) && $upload_file)
echo "<form enctype=\"multipart/form-data\" method='post' action='{$_SERVER['PHP_SELF']}' id='limesurvey' name='limesurvey' autocomplete='off'>
<!-- INPUT NAMES -->
<input type='hidden' name='fieldnames' value='{$hiddenfieldnames}' id='fieldnames' />\n";
Expand Down
2 changes: 1 addition & 1 deletion index.php
Expand Up @@ -778,7 +778,7 @@
if (isset($move) || isset($_POST['saveprompt']))
{
require_once("save.php");

// RELOAD THE ANSWERS INCASE SOMEONE ELSE CHANGED THEM
if ($thissurvey['active'] == "Y" && $thissurvey['allowsave'] == "Y")
{
Expand Down
17 changes: 12 additions & 5 deletions qanda.php
Expand Up @@ -3505,7 +3505,7 @@ function do_file_upload($ia)
<script type='text/javascript'>
$(function() {
$('a').click(function(e) {
$('#upload').click(function(e) {
e.preventDefault();
var \$this = $(this);
var horizontalPadding = 30;
Expand Down Expand Up @@ -3536,10 +3536,17 @@ function copyJSON(jsonstring, filecount) {
}
</script>";

$answer .= "<a class='upload' href='uploader.php?minfiles=".$minfiles."&maxfiles=".$maxfiles."&ia=".$ia[1]."&maxfilesize=".$maxfilesize."&allowed_filetypes=".$allowed_filetypes."' >Open Uploader</a><br />";
$currentdir = getcwd();
$pos = stripos($currentdir, "admin");

if ($pos)
$answer .= "<a id='upload' href='../uploader.php?minfiles=".$minfiles."&maxfiles=".$maxfiles."&ia=".$ia[1]."&maxfilesize=".$maxfilesize."&allowed_filetypes=".$allowed_filetypes."'&preview=1 >Upload files</a><br /><br /><br />";
else
$answer .= "<h2><a id='upload' href='uploader.php?minfiles=".$minfiles."&maxfiles=".$maxfiles."&ia=".$ia[1]."&maxfilesize=".$maxfilesize."&allowed_filetypes=".$allowed_filetypes."'&preview=0 >Upload files</a></h2><br /><br /><br />";

$answer .= "<input type='text' id='".$ia[1]."' name='".$ia[1]."' value='".$_SESSION[$ia[1]]."' />";
$answer .= "<input type='text' id='".$ia[1]."_filecount' name='".$ia[1]."_filecount' value='0' />";

/*
$answer = '<table border="0" cellpadding="10" cellspacing="10" align="center">
<tr>
Expand All @@ -3551,7 +3558,7 @@ function copyJSON(jsonstring, filecount) {
</tr>
<tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>
<tbody>';
for ($i = 1; $i <= $maxfiles; $i++) {
$answer .= '<tr>
<td>
Expand All @@ -3572,7 +3579,7 @@ function copyJSON(jsonstring, filecount) {
.$clang->gT("Answer").'" ></input></td>
</tr>'
.'<tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>';
}
}
*/
// --> END NEW FEATURE - SAVE

Expand Down
3 changes: 3 additions & 0 deletions upload.php
Expand Up @@ -5,6 +5,7 @@
$size=$_FILES['uploadfile']['size'];
$valid_extensions = $_POST['valid_extensions'];
$maxfilesize = $_POST['maxfilesize'];
$preview = $_POST['preview'];

$valid_extensions_array = explode(",", $valid_extensions);

Expand Down Expand Up @@ -45,6 +46,8 @@
"ext" => $ext,
"msg" => "The file has been successfuly uploaded"
);
if ($preview == 0)
unlink($_FILES['uploadfile']['tmp_name']);
echo json_encode($return);
}
// if there was some error, report error message
Expand Down
5 changes: 4 additions & 1 deletion uploader.php
Expand Up @@ -117,7 +117,8 @@
name: 'uploadfile',
data: {
valid_extensions : $('#allowed_filetypes').val(),
maxfilesize : $('#maxfilesize').val()
maxfilesize : $('#maxfilesize').val(),
preview : $('#preview').val()
},
onSubmit : function(file, ext){

Expand Down Expand Up @@ -312,11 +313,13 @@ function addNotice(notice) {
<input type="hidden" id="maxfiles" value="<?php echo $_GET['maxfiles'] ?>" />
<input type="hidden" id="maxfilesize" value="<?php echo $_GET['maxfilesize'] ?>" />
<input type="hidden" id="allowed_filetypes" value="<?php echo $_GET['allowed_filetypes'] ?>" />
<input type="hidden" id="preview" value="<?php echo $_GET['preview'] ?>" />
<input type="hidden" id="licount" value="0" />
<input type="hidden" id="filecount" value="0" />

<!-- The upload button -->
<div id="button1" class="button" align="center">Upload</div>
<p>You can upload <?php echo $_GET['allowed_filetypes']; ?> under <?php echo $_GET['maxfilesize']; ?> KB each</p>

<!-- The list of uploaded files -->
<ul id="listfiles"></ul>
Expand Down

0 comments on commit e8c0ae7

Please sign in to comment.