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

fix ecmfile tooltip #30993

Merged
merged 38 commits into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
0f43ba6
Update ecmfiles.class.php
frederic34 Sep 17, 2024
26919d6
Update ecm.lang
frederic34 Sep 17, 2024
a284bed
Update ecmfiles.class.php
frederic34 Sep 17, 2024
6bbc773
Merge branch 'develop' into patch-10
frederic34 Sep 21, 2024
2ce59af
Merge branch 'develop' into patch-10
frederic34 Sep 23, 2024
3b5fd1f
Merge branch 'develop' into patch-10
frederic34 Sep 23, 2024
711f027
add translations
frederic34 Sep 24, 2024
43ac48d
Merge remote-tracking branch 'upstream/develop' into patch-10
frederic34 Sep 24, 2024
19a470a
wip
frederic34 Sep 24, 2024
4770446
wip
frederic34 Sep 25, 2024
a6e10e0
Merge branch 'develop' into patch-10
frederic34 Sep 27, 2024
9f3f741
Merge branch 'develop' into patch-10
frederic34 Oct 4, 2024
b22e852
Merge branch 'develop' into patch-10
frederic34 Oct 6, 2024
225c9ea
enhance tooltip
frederic34 Oct 7, 2024
22bbf79
fix
frederic34 Oct 7, 2024
7725a1e
Merge remote-tracking branch 'upstream/develop' into patch-10
frederic34 Oct 7, 2024
774cea6
fix
frederic34 Oct 7, 2024
be1840a
fix
frederic34 Oct 7, 2024
7cf27f1
fix ajaxtooltip
frederic34 Oct 7, 2024
47a2013
Merge remote-tracking branch 'upstream/develop' into patch-10
frederic34 Oct 7, 2024
5e18cb3
fix picto
frederic34 Oct 12, 2024
095efc4
fix picto
frederic34 Oct 12, 2024
5e2c1f7
Merge remote-tracking branch 'upstream/develop' into patch-10
frederic34 Oct 12, 2024
f9078cb
fix sql
frederic34 Oct 12, 2024
c083ac1
tooltip
frederic34 Oct 13, 2024
c2f7eaf
tooltip
frederic34 Oct 13, 2024
883d0f9
Merge remote-tracking branch 'upstream/develop' into patch-10
frederic34 Oct 13, 2024
088afd7
test
frederic34 Oct 13, 2024
81cb14e
Merge branch 'develop' into patch-10
frederic34 Oct 13, 2024
d83f101
Merge branch 'develop' into patch-10
frederic34 Oct 13, 2024
c642e14
Merge branch 'develop' into patch-10
frederic34 Oct 14, 2024
1cac4c2
Merge branch 'develop' into patch-10
frederic34 Oct 20, 2024
b58551e
Merge branch 'develop' into patch-10
frederic34 Oct 23, 2024
cdf8767
Merge branch 'develop' into patch-10
frederic34 Oct 24, 2024
c6d4cc5
Merge remote-tracking branch 'upstream/develop' into patch-10
frederic34 Oct 31, 2024
2595599
Merge remote-tracking branch 'upstream/develop' into patch-10
frederic34 Oct 31, 2024
ed1cb9f
Merge branch 'develop' into patch-10
frederic34 Nov 1, 2024
75c2aca
Merge branch 'develop' into patch-10
frederic34 Nov 5, 2024
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
1 change: 1 addition & 0 deletions dev/translation/ignore_translation_keys.lst
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,7 @@ Free
FreeLegalTextOnReceptions
FrequencyPer_
FromPublicEmail
FullPathOrig
Function_getNextValue_InModuleNotWorking
Gantt
GeneratePDF
Expand Down
2 changes: 1 addition & 1 deletion htdocs/comm/propal/class/propal.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -3724,7 +3724,7 @@ public function getTooltipContentArray($params)
return ['optimize' => $langs->trans("Proposal")];
}
if ($user->hasRight('propal', 'lire')) {
$datas['picto'] = img_picto('', $this->picto).' <u class="paddingrightonly">'.$langs->trans("Proposal").'</u>';
$datas['picto'] = img_picto('', $this->picto, '', 0, 0, 0, '', 'paddingrightonly').'<u>'.$langs->trans("Proposal").'</u>';
if (isset($this->status)) {
$datas['status'] = ' '.$this->getLibStatut(5);
}
Expand Down
2 changes: 1 addition & 1 deletion htdocs/commande/class/commande.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -3788,7 +3788,7 @@ public function getTooltipContentArray($params)
}

if ($user->hasRight('commande', 'lire')) {
$datas['picto'] = img_picto('', $this->picto).' <u class="paddingrightonly">'.$langs->trans("Order").'</u>';
$datas['picto'] = img_picto('', $this->picto, '', 0, 0, 0, '', 'paddingrightonly').'<u>'.$langs->trans("Order").'</u>';
if (isset($this->statut)) {
$datas['status'] = ' '.$this->getLibStatut(5);
}
Expand Down
34 changes: 19 additions & 15 deletions htdocs/core/class/html.formfile.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -970,6 +970,9 @@ public function showdocuments($modulepart, $modulesubdir, $filedir, $urlsource,
$i = 0;
foreach ($file_list as $file) {
$i++;
require_once DOL_DOCUMENT_ROOT . '/ecm/class/ecmfiles.class.php';
$ecmfile = new EcmFiles($this->db);
$ecmfile->fetch($file['rowid']);

// Define relative path for download link (depends on module)
$relativepath = (string) $file["name"]; // Cas general
Expand All @@ -996,21 +999,22 @@ public function showdocuments($modulepart, $modulesubdir, $filedir, $urlsource,
} else {
$out .= '<span class="spanoverflow">';
}
$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)) {
$out .= ' target="_blank" rel="noopener noreferrer"';
}
$out .= ' title="'.dol_escape_htmltag($file["name"]).'"';
$out .= '>';
$out .= img_mime($file["name"], $langs->trans("File").': '.$file["name"]);
$out .= dol_trunc($file["name"], 150);
$out .= '</a>';
// $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)) {
// $out .= ' target="_blank" rel="noopener noreferrer"';
// }
// $out .= ' title="'.dol_escape_htmltag($file["name"]).'"';
// $out .= '>';
// $out .= img_mime($file["name"], $langs->trans("File").': '.$file["name"]);
// $out .= dol_trunc($file["name"], 150);
// $out .= '</a>';
$out .= $ecmfile->getNomUrl(1, $modulepart, 0, 0, ' documentdownload');
$out .= '</span>'."\n";
$out .= $imgpreview;
$out .= '</td>';
Expand Down
7 changes: 7 additions & 0 deletions htdocs/core/lib/functions.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -13230,6 +13230,13 @@ function getElementProperties($elementType)
$classname = 'Ccountry';
$table_element = 'c_country';
$subelement = '';
} elseif ($elementType == 'ecmfiles') {
$module = 'ecm';
$classpath = 'ecm/class';
$classfile = 'ecmfiles';
$classname = 'Ecmfiles';
$table_element = 'ecmfiles';
$subelement = '';
} elseif ($elementType == 'knowledgerecord') {
$module = '';
$classpath = 'knowledgemanagement/class';
Expand Down
15 changes: 6 additions & 9 deletions htdocs/ecm/class/ecmdirectory.class.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php
/* Copyright (C) 2007-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2008-2012 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
/* Copyright (C) 2007-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2008-2012 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -483,7 +483,7 @@ public function getNomUrl($withpicto = 0, $option = '', $max = 0, $more = '', $n
$result = '';
//$newref=str_replace('_',' ',$this->ref);
$newref = $this->ref;
$label = $langs->trans("ShowECMSection").': '.$newref;
$label = img_picto('', $this->picto, '', 0, 0, 0, '', 'paddingrightonly') . $langs->trans("ShowECMSection") . ': ' . $newref;
$linkclose = '"'.($more ? ' '.$more : '').' title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">';

$linkstart = '<a href="'.DOL_URL_ROOT.'/ecm/dir_card.php?section='.$this->id.$linkclose;
Expand All @@ -498,9 +498,6 @@ public function getNomUrl($withpicto = 0, $option = '', $max = 0, $more = '', $n
}
$linkend = '</a>';

//$picto=DOL_URL_ROOT.'/theme/common/treemenu/folder.gif';
$picto = 'dir';

$result .= $linkstart;
if ($withpicto) {
$result .= img_object(($notooltip ? '' : $label), $this->picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
Expand Down Expand Up @@ -614,7 +611,7 @@ public function getLibStatut($mode = 0)
public static function LibStatut($status, $mode = 0)
{
// phpcs:enable
global $langs;

return '';
}

Expand Down
78 changes: 64 additions & 14 deletions htdocs/ecm/class/ecmfiles.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
* Copyright (C) 2018 Francis Appels <francis.appels@yahoo.com>
* Copyright (C) 2019-2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -903,57 +903,106 @@ public function updateAfterRename($olddir, $newdir)
$this->db->query($sql);
}

/**
* getTooltipContentArray
* @param array<string,mixed> $params params to construct tooltip data
* @since v21
* @return array{picto?:string,ref?:string,gen_or_upload?:string}|array{optimize:string}
*/
public function getTooltipContentArray($params)
{
global $conf, $langs, $user;

$langs->load('ecm');
$datas = [];
$nofetch = !empty($params['nofetch']);

if (getDolGlobalString('MAIN_OPTIMIZEFORTEXTBROWSER')) {
return ['optimize' => $langs->trans("ShowFile")];
}
$datas['picto'] = img_picto('', $this->picto, '', 0, 0, 0, '', 'paddingrightonly') . '<u>' . $langs->trans("ShowFile") . '</u>';
if (!empty($this->ref)) {
$datas['ref'] = '<br><b>'.$langs->trans('Ref').':</b> '.$this->ref;
}
if (!empty($this->gen_or_uploaded)) {
$datas['gen_or_upload'] .= '<br><b>'.$langs->trans('GenOrUpload').':</b> '.$this->gen_or_uploaded;
}

return $datas;
}

/**
* Return a link to the object card (with optionally the picto)
*
* @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto)
* @param string $option On what the link point to
* @param string $option On what the link point to (propal, etc) module name
* @param int $notooltip 1=Disable tooltip
* @param int $maxlen Max length of visible user name
* @param string $morecss Add more css on link
* @return string String with URL
*/
public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $maxlen = 24, $morecss = '')
{
global $db, $conf, $langs;
global $dolibarr_main_authentication, $dolibarr_main_demo;
global $menumanager, $hookmanager;
global $conf, $hookmanager, $langs;

if (!empty($conf->dol_no_mouse_hover)) {
$notooltip = 1; // Force disable tooltips
}

$result = '';

$label = '<u>'.$langs->trans("File").'</u>';
$label .= '<br>';
$label .= '<b>'.$langs->trans('Ref').':</b> '.$this->ref;
$params = [
'id' => $this->id,
'objecttype' => $this->element,
'option' => $option,
'nofetch' => 1,
];
$classfortooltip = 'classfortooltip';
$dataparams = '';
if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) {
$classfortooltip = 'classforajaxtooltip';
$dataparams = ' data-params="'.dol_escape_htmltag(json_encode($params)).'"';
$label = '';
} else {
$label = implode($this->getTooltipContentArray($params));
}

$url = DOL_URL_ROOT.'/ecm/file_card.php?id='.$this->id;
if ($option) {
$url = DOL_URL_ROOT.'/document.php?modulepart='.$option.'&file='.urlencode(preg_replace('/[a-zA-Z]+\//', '', $this->filepath).'/'.$this->filename).'&entity='.$this->entity;
} else {
$url = DOL_URL_ROOT.'/ecm/file_card.php?id='.$this->id;
}

$linkclose = '';
if (empty($notooltip)) {
if (getDolGlobalString('MAIN_OPTIMIZEFORTEXTBROWSER')) {
$label = $langs->trans("ShowProject");
$label = $langs->trans("ShowFile");
$linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
}
$linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"';
$linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"';
$linkclose .= ($label ? ' title="'.dol_escape_htmltag($label, 1).'"' : ' title="tocomplete"');
$linkclose .= $dataparams.' class="'.$classfortooltip.' '.($morecss ? ' '.$morecss : '').'"';
} else {
$linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
}

$linkstart = '<a href="'.$url.'"';
if (getDolGlobalInt('MAIN_DISABLE_FORCE_SAVEAS') == 2) {
$linkstart .= 'target="_blank" ';
}
$linkstart .= $linkclose.'>';
$linkend = '</a>';

if ($withpicto) {
$result .= ($linkstart.img_object(($notooltip ? '' : $label), 'label', ($notooltip ? '' : 'class="classfortooltip"')).$linkend);
if (empty($this->filename)) {
$result .= ($linkstart.img_object(($notooltip ? '' : $label), 'label', ($notooltip ? '' : 'class="paddingright"')).$linkend);
} else {
$result .= ($linkstart.img_mime($this->filename, ($notooltip ? '' : $label), ($notooltip ? '' : 'class="paddingright"')).$linkend);
}
if ($withpicto != 2) {
$result .= ' ';
}
}
$result .= $linkstart.$this->ref.$linkend;
$result .= $linkstart.$this->filename.$linkend;

global $action;
$hookmanager->initHooks(array($this->element . 'dao'));
Expand All @@ -964,6 +1013,7 @@ public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $maxlen
} else {
$result .= $hookmanager->resPrint;
}

return $result;
}

Expand Down
3 changes: 3 additions & 0 deletions htdocs/langs/en_US/ecm.lang
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,6 @@ SucessConvertImgWebp=Images successfully duplicated
SucessConvertChosenImgWebp=Chosen image successfully duplicated
ECMDirName=Dir name
ECMParentDirectory=Parent directory
ShowFile=Show file
FullPathOrig=Full path origin
GenOrUpload=File origin
Loading