Clean code
This commit is contained in:
parent
414b5e612f
commit
4a3da84098
@ -54,8 +54,8 @@ if (!isset($mode) || $mode != 'noajax') { // For ajax call
|
||||
$search_doc_ref = GETPOST('search_doc_ref', 'alpha');
|
||||
|
||||
$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
|
||||
$sortfield = GETPOST("sortfield", 'alpha');
|
||||
$sortorder = GETPOST("sortorder", 'alpha');
|
||||
$sortfield = GETPOST("sortfield", 'aZ09comma');
|
||||
$sortorder = GETPOST("sortorder", 'aZ09comma');
|
||||
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
|
||||
if (empty($page) || $page == -1) {
|
||||
$page = 0;
|
||||
@ -82,8 +82,8 @@ if (!isset($mode) || $mode != 'noajax') { // For ajax call
|
||||
//exit;
|
||||
}
|
||||
}
|
||||
} else // For no ajax call
|
||||
{
|
||||
} else {
|
||||
// For no ajax call
|
||||
$rootdirfordoc = $conf->ecm->dir_output;
|
||||
|
||||
$ecmdir = new EcmDirectory($db);
|
||||
@ -376,7 +376,7 @@ if ($type == 'directory') {
|
||||
// When we show list of files for ECM files, $filearray contains file list, and directory is defined with modulepart + section into $param
|
||||
// When we show list of files for a directory, $filearray ciontains file list, and directory is defined with modulepart + $relativepath
|
||||
//var_dump("section=".$section." title=".$title." modulepart=".$modulepart." useinecm=".$useinecm." perm=".$perm." relativepath=".$relativepath." param=".$param." url=".$url);
|
||||
$formfile->list_of_documents($filearray, '', $modulepart, $param, 1, $relativepath, $perm, $useinecm, $textifempty, $maxlengthname, $title, $url, 0, $perm);
|
||||
$formfile->list_of_documents($filearray, '', $modulepart, $param, 1, $relativepath, $perm, $useinecm, $textifempty, $maxlengthname, $title, $url, 0, $perm, '', $sortfield, $sortorder);
|
||||
}
|
||||
}
|
||||
|
||||
@ -430,6 +430,7 @@ if ($useajax || $action == 'delete') {
|
||||
}
|
||||
|
||||
if ($useajax) {
|
||||
print '<!-- ajaxdirpreview.php: js to manage preview of doc -->'."\n";
|
||||
print '<script type="text/javascript">';
|
||||
|
||||
// Enable jquery handlers on new generated HTML objects (same code than into lib_footer.js.php)
|
||||
|
||||
@ -4682,7 +4682,7 @@ class Form
|
||||
{
|
||||
global $langs, $conf;
|
||||
|
||||
$more = '<!-- formconfirm for page='.dol_escape_htmltag($page).' -->';
|
||||
$more = '<!-- formconfirm before calling page='.dol_escape_htmltag($page).' -->';
|
||||
$formconfirm = '';
|
||||
$inputok = array();
|
||||
$inputko = array();
|
||||
|
||||
@ -80,9 +80,10 @@ class FormFile
|
||||
* @param int $usewithoutform 0=Default, 1=Disable <form> and style to use in existing area
|
||||
* @param int $capture 1=Add tag capture="capture" to force use of micro or video recording to generate file. When setting this to 1, you must also provide a value for $accept.
|
||||
* @param int $disablemulti 0=Default, 1=Disable multiple file upload
|
||||
* @return int <0 if KO, >0 if OK
|
||||
* @param int $nooutput 0=Output result with print, 1=Return result
|
||||
* @return int|string <0 if KO, >0 if OK, or string if $noouput=1
|
||||
*/
|
||||
public function form_attach_new_file($url, $title = '', $addcancel = 0, $sectionid = 0, $perm = 1, $size = 50, $object = '', $options = '', $useajax = 1, $savingdocmask = '', $linkfiles = 1, $htmlname = 'formuserfile', $accept = '', $sectiondir = '', $usewithoutform = 0, $capture = 0, $disablemulti = 0)
|
||||
public function form_attach_new_file($url, $title = '', $addcancel = 0, $sectionid = 0, $perm = 1, $size = 50, $object = '', $options = '', $useajax = 1, $savingdocmask = '', $linkfiles = 1, $htmlname = 'formuserfile', $accept = '', $sectiondir = '', $usewithoutform = 0, $capture = 0, $disablemulti = 0, $nooutput = 0)
|
||||
{
|
||||
// phpcs:enable
|
||||
global $conf, $langs, $hookmanager;
|
||||
@ -102,11 +103,16 @@ class FormFile
|
||||
// TODO: Check this works with GED module, otherwise, force useajax to 0
|
||||
// TODO: This does not support option savingdocmask
|
||||
// TODO: This break feature to upload links too
|
||||
// TODO: Thisdoes not work when param nooutput=1
|
||||
return $this->_formAjaxFileUpload($object);
|
||||
} else {
|
||||
//If there is no permission and the option to hide unauthorized actions is enabled, then nothing is printed
|
||||
if (!$perm && !empty($conf->global->MAIN_BUTTON_HIDE_UNAUTHORIZED)) {
|
||||
return 1;
|
||||
if ($nooutput) {
|
||||
return '';
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
$out = "\n\n".'<!-- Start form attach new file --><div class="formattachnewfile">'."\n";
|
||||
@ -122,12 +128,12 @@ class FormFile
|
||||
// Add a param as GET parameter to detect when POST were cleaned by PHP because a file larger than post_max_size
|
||||
$url .= (strpos($url, '?') === false ? '?' : '&').'uploadform=1';
|
||||
|
||||
$out .= '<form name="'.$htmlname.'" id="'.$htmlname.'" action="'.$url.'" enctype="multipart/form-data" method="POST">';
|
||||
$out .= '<input type="hidden" name="token" value="'.newToken().'">';
|
||||
$out .= '<input type="hidden" id="'.$htmlname.'_section_dir" name="section_dir" value="'.$sectiondir.'">';
|
||||
$out .= '<input type="hidden" id="'.$htmlname.'_section_id" name="section_id" value="'.$sectionid.'">';
|
||||
$out .= '<input type="hidden" name="sortfield" value="'.GETPOST('sortfield', 'aZ09comma').'">';
|
||||
$out .= '<input type="hidden" name="sortorder" value="'.GETPOST('sortorder', 'aZ09').'">';
|
||||
$out .= '<form name="'.$htmlname.'" id="'.$htmlname.'" action="'.$url.'" enctype="multipart/form-data" method="POST">'."\n";
|
||||
$out .= '<input type="hidden" name="token" value="'.newToken().'">'."\n";
|
||||
$out .= '<input type="hidden" id="'.$htmlname.'_section_dir" name="section_dir" value="'.$sectiondir.'">'."\n";
|
||||
$out .= '<input type="hidden" id="'.$htmlname.'_section_id" name="section_id" value="'.$sectionid.'">'."\n";
|
||||
$out .= '<input type="hidden" name="sortfield" value="'.GETPOST('sortfield', 'aZ09comma').'">'."\n";
|
||||
$out .= '<input type="hidden" name="sortorder" value="'.GETPOST('sortorder', 'aZ09comma').'">'."\n";
|
||||
}
|
||||
|
||||
$out .= '<table class="nobordernopadding centpercent">';
|
||||
@ -301,13 +307,15 @@ class FormFile
|
||||
$parameters = array('socid'=>(isset($GLOBALS['socid']) ? $GLOBALS['socid'] : ''), 'id'=>(isset($GLOBALS['id']) ? $GLOBALS['id'] : ''), 'url'=>$url, 'perm'=>$perm, 'options'=>$options);
|
||||
$res = $hookmanager->executeHooks('formattachOptions', $parameters, $object);
|
||||
if (empty($res)) {
|
||||
print '<div class="'.($usewithoutform ? 'inline-block valignmiddle' : 'attacharea attacharea'.$htmlname).'">';
|
||||
print $out;
|
||||
print '</div>';
|
||||
$out = '<div class="'.($usewithoutform ? 'inline-block valignmiddle' : 'attacharea attacharea'.$htmlname).'">'.$out.'</div>';
|
||||
}
|
||||
print $hookmanager->resPrint;
|
||||
$out .= $hookmanager->resPrint;
|
||||
|
||||
return 1;
|
||||
if ($nooutput) {
|
||||
return $out;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1473,21 +1473,23 @@ function dolButtonToOpenUrlInDialogPopup($name, $label, $buttonstring, $url, $di
|
||||
|
||||
//print '<input type="submit" class="button bordertransp"'.$disabled.' value="'.dol_escape_htmltag($langs->trans("MediaFiles")).'" name="file_manager">';
|
||||
$out = '<a class="button bordertransp button_'.$name.'"'.$disabled.' title="'.dol_escape_htmltag($label).'">'.$buttonstring.'</a>';
|
||||
$out .= '<!-- Add js code to open dialog popup on dialog -->';
|
||||
$out .= '<script language="javascript">
|
||||
jQuery(document).ready(function () {
|
||||
jQuery(".button_'.$name.'").click(function () {
|
||||
var $dialog = $(\'<div></div>\').html(\'<iframe class="iframedialog" style="border: 0px;" src="'.DOL_URL_ROOT.$url.'" width="100%" height="98%"></iframe>\')
|
||||
.dialog({
|
||||
autoOpen: false,
|
||||
modal: true,
|
||||
height: (window.innerHeight - 150),
|
||||
width: \'80%\',
|
||||
title: "'.dol_escape_js($label).'"
|
||||
});
|
||||
$dialog.dialog(\'open\');
|
||||
});
|
||||
});
|
||||
</script>';
|
||||
jQuery(document).ready(function () {
|
||||
jQuery(".button_'.$name.'").click(function () {
|
||||
console.log("Open popup with jQuery(...).dialog() on URL '.dol_escape_js(DOL_URL_ROOT.$url).'")
|
||||
var $dialog = $(\'<div></div>\').html(\'<iframe class="iframedialog" style="border: 0px;" src="'.DOL_URL_ROOT.$url.'" width="100%" height="98%"></iframe>\')
|
||||
.dialog({
|
||||
autoOpen: false,
|
||||
modal: true,
|
||||
height: (window.innerHeight - 150),
|
||||
width: \'80%\',
|
||||
title: "'.dol_escape_js($label).'"
|
||||
});
|
||||
$dialog.dialog(\'open\');
|
||||
});
|
||||
});
|
||||
</script>';
|
||||
return $out;
|
||||
}
|
||||
|
||||
|
||||
@ -128,7 +128,7 @@ $nameforformuserfile = 'formuserfileecm';
|
||||
|
||||
print '<div class="inline-block valignmiddle floatright">';
|
||||
|
||||
// To attach new file
|
||||
// For to attach a new file
|
||||
if ((!empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_JS)) || !empty($section)) {
|
||||
if ((empty($section) || $section == -1) && ($module != 'medias')) {
|
||||
?>
|
||||
@ -141,10 +141,11 @@ if ((!empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE
|
||||
}
|
||||
|
||||
$sectiondir = GETPOST('file', 'alpha') ?GETPOST('file', 'alpha') : GETPOST('section_dir', 'alpha');
|
||||
|
||||
print '<!-- Start form to attach new file in filemanager.tpl.php sectionid='.$section.' sectiondir='.$sectiondir.' -->'."\n";
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
|
||||
$formfile = new FormFile($db);
|
||||
$formfile->form_attach_new_file($_SERVER["PHP_SELF"], 'none', 0, ($section ? $section : -1), $permtoupload, 48, null, '', 0, '', 0, $nameforformuserfile, '', $sectiondir);
|
||||
print $formfile->form_attach_new_file($_SERVER["PHP_SELF"], 'none', 0, ($section ? $section : -1), $permtoupload, 48, null, '', 0, '', 0, $nameforformuserfile, '', $sectiondir, 0, 0, 0, 1);
|
||||
} else {
|
||||
print ' ';
|
||||
}
|
||||
|
||||
@ -403,8 +403,10 @@ if ($sortfield) {
|
||||
if ($sortorder) {
|
||||
$backtopage .= '&sortorder='.urlencode($sortorder);
|
||||
}
|
||||
include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php';
|
||||
include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; // This manage 'sendit' action when submitting new file.
|
||||
|
||||
$backtopage = $savbacktopage;
|
||||
//var_dump($backtopage); var_dump($action);
|
||||
|
||||
if ($action == 'renamefile') { // Must be after include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; If action were renamefile, we set it to 'file_manager'
|
||||
$action = 'file_manager';
|
||||
@ -2647,7 +2649,7 @@ if (!GETPOST('hide_websitemenu')) {
|
||||
$out .= ' jQuery("#website").change(function () {';
|
||||
$out .= ' console.log("We select "+jQuery("#website option:selected").val());';
|
||||
$out .= ' if (jQuery("#website option:selected").val() == \'-2\') {';
|
||||
$out .= ' window.location.href = "'.$urltocreatenewwebsite.'";';
|
||||
$out .= ' window.location.href = "'.dol_escape_js($urltocreatenewwebsite).'";';
|
||||
$out .= ' } else {';
|
||||
$out .= ' window.location.href = "'.$_SERVER["PHP_SEFL"].'?website="+jQuery("#website option:selected").val();';
|
||||
$out .= ' }';
|
||||
@ -4039,6 +4041,7 @@ if ($action == 'editfile' || $action == 'file_manager' || $action == 'convertimg
|
||||
print '<div class="fiche"><br>';
|
||||
//print '<div class="center">'.$langs->trans("FeatureNotYetAvailable").'</center>';
|
||||
|
||||
|
||||
$module = 'medias';
|
||||
if (empty($url)) {
|
||||
$url = DOL_URL_ROOT.'/website/index.php'; // Must be an url without param
|
||||
|
||||
Loading…
Reference in New Issue
Block a user