Skip to content

Commit

Permalink
fetch 3.0 changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Maghin committed Jan 24, 2018
1 parent 715d87d commit e960f96
Show file tree
Hide file tree
Showing 19 changed files with 696 additions and 641 deletions.
3 changes: 2 additions & 1 deletion .jshintignore
Expand Up @@ -3,6 +3,7 @@ node_modules/**
phpmyfaq/admin/assets/editor/**
phpmyfaq/admin/assets/plugins/**
phpmyfaq/assets/js/libs/*.js
phpmyfaq/assets/js/modernizr.min.js
phpmyfaq/assets/js/phpmyfaq.js
phpmyfaq/assets/js/phpmyfaq.min.js
phpmyfaq/assets/js/vendor.js
phpmyfaq/assets/js/vendors.js
2 changes: 1 addition & 1 deletion .jshintrc
Expand Up @@ -39,7 +39,7 @@
"boss" : false, // true: Tolerate assignments where comparisons would be expected
"debug" : false, // true: Allow debugger statements e.g. browser breakpoints.
"eqnull" : false, // true: Tolerate use of `== null`
"esversion" : 5, // {int} Specify the ECMAScript version to which the code must adhere.
"esversion" : 6, // {int} Specify the ECMAScript version to which the code must adhere.
"moz" : false, // true: Allow Mozilla specific syntax (extends and overrides esnext features)
// (ex: `for each`, multiple try/catch, function expression…)
"evil" : false, // true: Tolerate use of `eval` and `new Function()`
Expand Down
4 changes: 3 additions & 1 deletion Gruntfile.js
Expand Up @@ -215,7 +215,9 @@ module.exports = function (grunt) {
}
},
jshint: {
jshintrc: '.jshintrc',
options: {
jshintrc: true
},
gruntfile: {
src: 'Gruntfile.js'
},
Expand Down
2 changes: 1 addition & 1 deletion phpmyfaq/admin/assets/js/groups.js
Expand Up @@ -184,7 +184,7 @@ $(document).ready(function () {
}

// remove selected members from list
selected_user_list.each(function (i, option) {
selected_user_list.each(function () {
$('#group_member_list option:selected').remove();
});
};
Expand Down
2 changes: 1 addition & 1 deletion phpmyfaq/admin/assets/js/imageupload.tinymce.plugin.js
Expand Up @@ -14,7 +14,7 @@
* @since 2015-10-18
*/

/*global tinymce:false, $:false */
/*global tinymce:false */

tinymce.PluginManager.add('imageupload', function(editor, url) {
'use strict';
Expand Down
2 changes: 1 addition & 1 deletion phpmyfaq/admin/assets/js/user.js
Expand Up @@ -14,7 +14,7 @@
* @since 2010-05-02
*/

/*global $:false, Bloodhound: false, Handlebars: false */
/*global $:false, Bloodhound: false, Handlebars: false, getUserData: false */

/**
* Fetches the user rights as JSON object and checks the checkboxes
Expand Down
132 changes: 68 additions & 64 deletions phpmyfaq/admin/attachment.php
Expand Up @@ -77,28 +77,27 @@
if (is_null($currentAction) || !is_null($currentSave)) {
?>
<!DOCTYPE html>
<!--[if IE 9 ]> <html lang="<?php echo $PMF_LANG['metaLanguage']; ?>" class="no-js ie9"> <![endif]-->
<!--[if (gt IE 9)|!(IE)]><!--> <html lang="<?php echo $PMF_LANG['metaLanguage']; ?>" class="no-js"> <!--<![endif]-->
<html lang="<?= $PMF_LANG['metaLanguage']; ?>" class="no-js">
<head>
<meta charset="utf-8">

<title><?php echo $faqConfig->get('main.titleFAQ') ?> - powered by phpMyFAQ</title>
<base href="<?php echo $faqConfig->getDefaultUrl() ?>admin/" />
<title><?= $faqConfig->get('main.titleFAQ') ?> - powered by phpMyFAQ</title>
<base href="<?= $faqConfig->getDefaultUrl() ?>admin/">

<meta name="description" content="Only Chuck Norris can divide by zero.">
<meta name="author" content="phpMyFAQ Team">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="application-name" content="phpMyFAQ <?php echo $faqConfig->get('main.currentVersion') ?>">
<meta name="application-name" content="phpMyFAQ <?= $faqConfig->get('main.currentVersion') ?>">
<meta name="publisher" content="phpMyFAQ Team">

<link rel="stylesheet" href="assets/css/style.css?v=1">

<script src="../assets/js/modernizr.min.js"></script>
<script src="../assets/js/phpmyfaq.min.js"></script>

<link rel="shortcut icon" href="../assets/themes/<?php echo Template::getTplSetName() ?>/favicon.ico">
<link rel="shortcut icon" href="../assets/themes/<?= Template::getTplSetName() ?>/favicon.ico">
</head>
<body class="attachments">
<body class="pmf-attachment-upload">

<?php

Expand All @@ -107,24 +106,24 @@
$recordId = filter_input(INPUT_GET, 'record_id', FILTER_VALIDATE_INT);
$recordLang = filter_input(INPUT_GET, 'record_lang', FILTER_SANITIZE_STRING);
?>
<form action="attachment.php?action=save" enctype="multipart/form-data" method="post" accept-charset="utf-8">
<form action="attachment.php?action=save" enctype="multipart/form-data" method="post">
<fieldset>
<legend>
<?php echo $PMF_LANG['ad_att_addto'].' '.$PMF_LANG['ad_att_addto_2'] ?>
(max <?php echo round($faqConfig->get('records.maxAttachmentSize') / pow(1024, 2), 2) ?> MB)
<?= $PMF_LANG['ad_att_addto'].' '.$PMF_LANG['ad_att_addto_2'] ?>
(max <?= round($faqConfig->get('records.maxAttachmentSize') / pow(1024, 2), 2) ?> MB)
</legend>
<input type="hidden" name="MAX_FILE_SIZE" value="<?php echo $faqConfig->get('records.maxAttachmentSize') ?>">
<input type="hidden" name="record_id" value="<?php echo $recordId ?>">
<input type="hidden" name="record_lang" value="<?php echo $recordLang ?>">
<input type="hidden" name="MAX_FILE_SIZE" value="<?= $faqConfig->get('records.maxAttachmentSize') ?>">
<input type="hidden" name="record_id" value="<?= $recordId ?>">
<input type="hidden" name="record_lang" value="<?= $recordLang ?>">
<input type="hidden" name="save" value="TRUE">
<input type="hidden" name="csrf" value="<?php echo $user->getCsrfTokenFromSession() ?>">
<?php echo $PMF_LANG['ad_att_att'] ?>
<input type="hidden" name="csrf" value="<?= $user->getCsrfTokenFromSession() ?>">
<?= $PMF_LANG['ad_att_att'] ?>

<input name="userfile" type="file" id="fileUpload">
<input name="filesToUpload[]" type="file" id="filesToUpload" multiple>
<button class="btn btn-primary" type="submit">
<?php echo $PMF_LANG['ad_att_butt'] ?>
<?= $PMF_LANG['ad_att_butt'] ?>
</button>
<?php echo $PMF_LANG['msgAttachmentsFilesize'] ?>: <output id="filesize"></output>
<?= $PMF_LANG['msgAttachmentsFilesize'] ?>: <output id="filesize"></output>
</fieldset>
</form>
<?php
Expand All @@ -145,57 +144,62 @@
$recordLang = filter_input(INPUT_POST, 'record_lang', FILTER_SANITIZE_STRING);
?>
<p>
<strong><?php echo $PMF_LANG['ad_att_addto'].' '.$PMF_LANG['ad_att_addto_2'] ?></strong>
<strong><?= $PMF_LANG['ad_att_addto'].' '.$PMF_LANG['ad_att_addto_2'] ?></strong>
</p>
<?php
if (
is_uploaded_file($_FILES['userfile']['tmp_name']) &&
!($_FILES['userfile']['size'] > $faqConfig->get('records.maxAttachmentSize')) &&
$_FILES['userfile']['type'] !== "text/html"
) {
$att = Factory::create();
$att->setRecordId($recordId);
$att->setRecordLang($recordLang);

/*
* To add user defined key
* $att->setKey($somekey, false);
*/
try {
$uploaded = $att->save($_FILES['userfile']['tmp_name'], $_FILES['userfile']['name']);

if ($uploaded) {
echo '<p>'.$PMF_LANG['ad_att_suc'].'</p>';
} else {
throw new Exception();

$files = Factory::rearrangeUploadedFiles($_FILES['filesToUpload']);
$uploadedFiles = [];

foreach ($files as $file) {
if (
is_uploaded_file($file['tmp_name']) &&
!($file['size'] > $faqConfig->get('records.maxAttachmentSize')) &&
$file['type'] !== "text/html"
) {
$attachment = Factory::create();
$attachment->setRecordId($recordId);
$attachment->setRecordLang($recordLang);
try {
if ($attachment->save($file['tmp_name'], $file['name'])) {
echo '<p>'.$PMF_LANG['ad_att_suc'].'</p>';
} else {
throw new Exception();
}
} catch (Exception $e) {
$attachment->delete();
echo '<p>'.$PMF_LANG['ad_att_fail'].'</p>';
}
} catch (Exception $e) {
$att->delete();
echo '<p>'.$PMF_LANG['ad_att_fail'].'</p>';
$uploadedFiles[] = [
'attachmentId' => $attachment->getId(),
'fileName' => $attachment->getFilename(),
'faqId' => $recordId,
'faqLanguage' => $recordLang
];

printf(
'<p class="text-center"><a href="#" onclick="addAttachmentLink(%d, \'%s\', %d, \'%s\');">%s</a></p>',
$attachment->getId(),
$attachment->getFilename(),
$recordId,
$recordLang,
$PMF_LANG['ad_att_close']
);
} else {
printf(
'<p>%s</p>',
sprintf(
$PMF_LANG['ad_attach_4'],
round($faqConfig->get('records.maxAttachmentSize') / pow(1024, 2), 2)
)
);
}

printf(
'<p class="text-center"><a href="#" onclick="addAttachmentLink(%d, \'%s\', %d, \'%s\');">%s</a></p>',
$att->getId(),
$att->getFilename(),
$recordId,
$recordLang,
$PMF_LANG['ad_att_close']
);
} else {
printf(
'<p>%s</p>',
sprintf(
$PMF_LANG['ad_attach_4'],
round($faqConfig->get('records.maxAttachmentSize') / pow(1024, 2), 2)
)
);

printf(
'<p class="text-center"><a href="javascript:;" onclick="closeWindow();">%s</a></p>',
$PMF_LANG['ad_att_close']
);
}

printf(
'<p class="text-center"><a href="javascript:;" onclick="closeWindow();">%s</a></p>',
$PMF_LANG['ad_att_close']
);
}
if (!is_null($currentSave) && $currentSave == true && $auth &&
!$user->perm->checkRight($user->getUserId(), 'addattachment')) {
Expand Down

0 comments on commit e960f96

Please sign in to comment.