Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NEW Add option to open files in new tab #29604

Merged
merged 5 commits into from
May 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 23 additions & 7 deletions htdocs/core/class/html.formfile.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -890,7 +890,11 @@ public function showdocuments($modulepart, $modulesubdir, $filedir, $urlsource,
} else {
$out .= '<span class="spanoverflow">';
}
$out .= '<a class="documentdownload paddingright" href="'.$documenturl.'?modulepart='.$modulepart.'&file='.urlencode($relativepath).($param ? '&'.$param : '').'"';
$out .= '<a class="documentdownload paddingright" ';
if (getDolGlobalInt('MAIN_DISABLE_FORCE_SAVEAS') == 2) {
$out .= 'target="_blank" ';
}
$out .= 'href="'.$documenturl.'?modulepart='.$modulepart.'&file='.urlencode($relativepath).($param ? '&'.$param : '').'"';

$mime = dol_mimetype($relativepath, '', 0);
if (preg_match('/text/', $mime)) {
Expand Down Expand Up @@ -1081,8 +1085,8 @@ public function getDocumentsLink($modulepart, $modulesubdir, $filedir, $filter =
$out .= '<!-- html.formfile::getDocumentsLink -->'."\n";
if (!empty($file_list)) {
$out = '<dl class="dropdown inline-block">
<dt><a data-ajax="false" href="#" onClick="return false;">'.img_picto('', 'listlight', '', 0, 0, 0, '', $morecss).'</a></dt>
<dd><div class="multichoicedoc" style="position:absolute;left:100px;" ><ul class="ulselectedfields">';
<dt><a data-ajax="false" href="#" onClick="return false;">'.img_picto('', 'listlight', '', 0, 0, 0, '', $morecss).'</a></dt>
<dd><div class="multichoicedoc" style="position:absolute;left:100px;" ><ul class="ulselectedfields">';
$tmpout = '';

// Loop on each file found
Expand Down Expand Up @@ -1129,7 +1133,11 @@ public function getDocumentsLink($modulepart, $modulesubdir, $filedir, $filter =
}

// Download
$tmpout .= '<li class="nowrap"><a class="pictopreview nowrap" href="'.DOL_URL_ROOT.'/document.php?modulepart='.$modulepart.'&amp;entity='.$entity.'&amp;file='.urlencode($relativepath).'"';
$tmpout .= '<li class="nowrap"><a class="pictopreview nowrap" ';
if (getDolGlobalInt('MAIN_DISABLE_FORCE_SAVEAS') == 2) {
$tmpout .= 'target="_blank" ';
}
$tmpout .= 'href="'.DOL_URL_ROOT.'/document.php?modulepart='.$modulepart.'&amp;entity='.$entity.'&amp;file='.urlencode($relativepath).'"';
$mime = dol_mimetype($relativepath, '', 0);
if (preg_match('/text/', $mime)) {
$tmpout .= ' target="_blank" rel="noopener noreferrer"';
Expand All @@ -1141,7 +1149,7 @@ public function getDocumentsLink($modulepart, $modulesubdir, $filedir, $filter =
}
$out .= $tmpout;
$out .= '</ul></div></dd>
</dl>';
</dl>';

if (!$found) {
$out = '';
Expand Down Expand Up @@ -1373,7 +1381,11 @@ public function list_of_documents($filearray, $object, $modulepart, $param = '',

// Show file name with link to download
//print "XX".$file['name']; //$file['name'] must be utf8
print '<a class="paddingright valignmiddle" href="'.DOL_URL_ROOT.'/document.php?modulepart='.$modulepart;
print '<a class="paddingright valignmiddle" ';
if (getDolGlobalInt('MAIN_DISABLE_FORCE_SAVEAS') == 2) {
print 'target="_blank" ';
}
print 'href="'.DOL_URL_ROOT.'/document.php?modulepart='.$modulepart;
if ($forcedownload) {
print '&attachment=1';
}
Expand Down Expand Up @@ -1949,7 +1961,11 @@ public function list_of_autoecmfiles($upload_dir, $filearray, $modulepart, $para
// Check if document source has external module part, if it the case use it for module part on document.php
print '<td>';
//print "XX".$file['name']; //$file['name'] must be utf8
print '<a href="'.DOL_URL_ROOT.'/document.php?modulepart='.urlencode($modulepart);
print '<a ';
if (getDolGlobalInt('MAIN_DISABLE_FORCE_SAVEAS') == 2) {
print 'target="_blank" ';
}
print 'href="'.DOL_URL_ROOT.'/document.php?modulepart='.urlencode($modulepart);
if ($forcedownload) {
print '&attachment=1';
}
Expand Down
Loading