mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-12-06 17:48:25 +01:00
fix ecmfile tooltip (#30993)
* Update ecmfiles.class.php * Update ecm.lang * Update ecmfiles.class.php * add translations * wip * wip * enhance tooltip * fix * fix * fix * fix ajaxtooltip * fix picto * fix picto * fix sql * tooltip * tooltip * test
This commit is contained in:
@@ -442,6 +442,7 @@ Free
|
|||||||
FreeLegalTextOnReceptions
|
FreeLegalTextOnReceptions
|
||||||
FrequencyPer_
|
FrequencyPer_
|
||||||
FromPublicEmail
|
FromPublicEmail
|
||||||
|
FullPathOrig
|
||||||
Function_getNextValue_InModuleNotWorking
|
Function_getNextValue_InModuleNotWorking
|
||||||
Gantt
|
Gantt
|
||||||
GeneratePDF
|
GeneratePDF
|
||||||
|
|||||||
@@ -3724,7 +3724,7 @@ class Propal extends CommonObject
|
|||||||
return ['optimize' => $langs->trans("Proposal")];
|
return ['optimize' => $langs->trans("Proposal")];
|
||||||
}
|
}
|
||||||
if ($user->hasRight('propal', 'lire')) {
|
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)) {
|
if (isset($this->status)) {
|
||||||
$datas['status'] = ' '.$this->getLibStatut(5);
|
$datas['status'] = ' '.$this->getLibStatut(5);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3788,7 +3788,7 @@ class Commande extends CommonOrder
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($user->hasRight('commande', 'lire')) {
|
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)) {
|
if (isset($this->statut)) {
|
||||||
$datas['status'] = ' '.$this->getLibStatut(5);
|
$datas['status'] = ' '.$this->getLibStatut(5);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -970,6 +970,9 @@ class FormFile
|
|||||||
$i = 0;
|
$i = 0;
|
||||||
foreach ($file_list as $file) {
|
foreach ($file_list as $file) {
|
||||||
$i++;
|
$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)
|
// Define relative path for download link (depends on module)
|
||||||
$relativepath = (string) $file["name"]; // Cas general
|
$relativepath = (string) $file["name"]; // Cas general
|
||||||
@@ -996,21 +999,22 @@ class FormFile
|
|||||||
} else {
|
} else {
|
||||||
$out .= '<span class="spanoverflow">';
|
$out .= '<span class="spanoverflow">';
|
||||||
}
|
}
|
||||||
$out .= '<a class="documentdownload paddingright" ';
|
// $out .= '<a class="documentdownload paddingright" ';
|
||||||
if (getDolGlobalInt('MAIN_DISABLE_FORCE_SAVEAS') == 2) {
|
// if (getDolGlobalInt('MAIN_DISABLE_FORCE_SAVEAS') == 2) {
|
||||||
$out .= 'target="_blank" ';
|
// $out .= 'target="_blank" ';
|
||||||
}
|
// }
|
||||||
$out .= 'href="'.$documenturl.'?modulepart='.$modulepart.'&file='.urlencode($relativepath).($param ? '&'.$param : '').'"';
|
// $out .= 'href="'.$documenturl.'?modulepart='.$modulepart.'&file='.urlencode($relativepath).($param ? '&'.$param : '').'"';
|
||||||
|
|
||||||
$mime = dol_mimetype($relativepath, '', 0);
|
// $mime = dol_mimetype($relativepath, '', 0);
|
||||||
if (preg_match('/text/', $mime)) {
|
// if (preg_match('/text/', $mime)) {
|
||||||
$out .= ' target="_blank" rel="noopener noreferrer"';
|
// $out .= ' target="_blank" rel="noopener noreferrer"';
|
||||||
}
|
// }
|
||||||
$out .= ' title="'.dol_escape_htmltag($file["name"]).'"';
|
// $out .= ' title="'.dol_escape_htmltag($file["name"]).'"';
|
||||||
$out .= '>';
|
// $out .= '>';
|
||||||
$out .= img_mime($file["name"], $langs->trans("File").': '.$file["name"]);
|
// $out .= img_mime($file["name"], $langs->trans("File").': '.$file["name"]);
|
||||||
$out .= dol_trunc($file["name"], 150);
|
// $out .= dol_trunc($file["name"], 150);
|
||||||
$out .= '</a>';
|
// $out .= '</a>';
|
||||||
|
$out .= $ecmfile->getNomUrl(1, $modulepart, 0, 0, ' documentdownload');
|
||||||
$out .= '</span>'."\n";
|
$out .= '</span>'."\n";
|
||||||
$out .= $imgpreview;
|
$out .= $imgpreview;
|
||||||
$out .= '</td>';
|
$out .= '</td>';
|
||||||
|
|||||||
@@ -13230,6 +13230,13 @@ function getElementProperties($elementType)
|
|||||||
$classname = 'Ccountry';
|
$classname = 'Ccountry';
|
||||||
$table_element = 'c_country';
|
$table_element = 'c_country';
|
||||||
$subelement = '';
|
$subelement = '';
|
||||||
|
} elseif ($elementType == 'ecmfiles') {
|
||||||
|
$module = 'ecm';
|
||||||
|
$classpath = 'ecm/class';
|
||||||
|
$classfile = 'ecmfiles';
|
||||||
|
$classname = 'Ecmfiles';
|
||||||
|
$table_element = 'ecmfiles';
|
||||||
|
$subelement = '';
|
||||||
} elseif ($elementType == 'knowledgerecord') {
|
} elseif ($elementType == 'knowledgerecord') {
|
||||||
$module = '';
|
$module = '';
|
||||||
$classpath = 'knowledgemanagement/class';
|
$classpath = 'knowledgemanagement/class';
|
||||||
|
|||||||
@@ -485,7 +485,7 @@ class EcmDirectory extends CommonObject
|
|||||||
$result = '';
|
$result = '';
|
||||||
//$newref=str_replace('_',' ',$this->ref);
|
//$newref=str_replace('_',' ',$this->ref);
|
||||||
$newref = $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">';
|
$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;
|
$linkstart = '<a href="'.DOL_URL_ROOT.'/ecm/dir_card.php?section='.$this->id.$linkclose;
|
||||||
@@ -500,9 +500,6 @@ class EcmDirectory extends CommonObject
|
|||||||
}
|
}
|
||||||
$linkend = '</a>';
|
$linkend = '</a>';
|
||||||
|
|
||||||
//$picto=DOL_URL_ROOT.'/theme/common/treemenu/folder.gif';
|
|
||||||
$picto = 'dir';
|
|
||||||
|
|
||||||
$result .= $linkstart;
|
$result .= $linkstart;
|
||||||
if ($withpicto) {
|
if ($withpicto) {
|
||||||
$result .= img_object(($notooltip ? '' : $label), $this->picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
|
$result .= img_object(($notooltip ? '' : $label), $this->picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
|
||||||
@@ -616,7 +613,7 @@ class EcmDirectory extends CommonObject
|
|||||||
public static function LibStatut($status, $mode = 0)
|
public static function LibStatut($status, $mode = 0)
|
||||||
{
|
{
|
||||||
// phpcs:enable
|
// phpcs:enable
|
||||||
global $langs;
|
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -903,11 +903,39 @@ class EcmFiles extends CommonObject
|
|||||||
$this->db->query($sql);
|
$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)
|
* 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 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 $notooltip 1=Disable tooltip
|
||||||
* @param int $maxlen Max length of visible user name
|
* @param int $maxlen Max length of visible user name
|
||||||
* @param string $morecss Add more css on link
|
* @param string $morecss Add more css on link
|
||||||
@@ -915,9 +943,7 @@ class EcmFiles extends CommonObject
|
|||||||
*/
|
*/
|
||||||
public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $maxlen = 24, $morecss = '')
|
public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $maxlen = 24, $morecss = '')
|
||||||
{
|
{
|
||||||
global $db, $conf, $langs;
|
global $conf, $hookmanager, $langs;
|
||||||
global $dolibarr_main_authentication, $dolibarr_main_demo;
|
|
||||||
global $menumanager, $hookmanager;
|
|
||||||
|
|
||||||
if (!empty($conf->dol_no_mouse_hover)) {
|
if (!empty($conf->dol_no_mouse_hover)) {
|
||||||
$notooltip = 1; // Force disable tooltips
|
$notooltip = 1; // Force disable tooltips
|
||||||
@@ -925,35 +951,58 @@ class EcmFiles extends CommonObject
|
|||||||
|
|
||||||
$result = '';
|
$result = '';
|
||||||
|
|
||||||
$label = '<u>'.$langs->trans("File").'</u>';
|
$params = [
|
||||||
$label .= '<br>';
|
'id' => $this->id,
|
||||||
$label .= '<b>'.$langs->trans('Ref').':</b> '.$this->ref;
|
'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));
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
$url = DOL_URL_ROOT.'/ecm/file_card.php?id='.$this->id;
|
||||||
|
}
|
||||||
|
|
||||||
$linkclose = '';
|
$linkclose = '';
|
||||||
if (empty($notooltip)) {
|
if (empty($notooltip)) {
|
||||||
if (getDolGlobalString('MAIN_OPTIMIZEFORTEXTBROWSER')) {
|
if (getDolGlobalString('MAIN_OPTIMIZEFORTEXTBROWSER')) {
|
||||||
$label = $langs->trans("ShowProject");
|
$label = $langs->trans("ShowFile");
|
||||||
$linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
|
$linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
|
||||||
}
|
}
|
||||||
$linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"';
|
$linkclose .= ($label ? ' title="'.dol_escape_htmltag($label, 1).'"' : ' title="tocomplete"');
|
||||||
$linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"';
|
$linkclose .= $dataparams.' class="'.$classfortooltip.' '.($morecss ? ' '.$morecss : '').'"';
|
||||||
} else {
|
} else {
|
||||||
$linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
|
$linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
|
||||||
}
|
}
|
||||||
|
|
||||||
$linkstart = '<a href="'.$url.'"';
|
$linkstart = '<a href="'.$url.'"';
|
||||||
|
if (getDolGlobalInt('MAIN_DISABLE_FORCE_SAVEAS') == 2) {
|
||||||
|
$linkstart .= 'target="_blank" ';
|
||||||
|
}
|
||||||
$linkstart .= $linkclose.'>';
|
$linkstart .= $linkclose.'>';
|
||||||
$linkend = '</a>';
|
$linkend = '</a>';
|
||||||
|
|
||||||
if ($withpicto) {
|
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) {
|
if ($withpicto != 2) {
|
||||||
$result .= ' ';
|
$result .= ' ';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$result .= $linkstart.$this->ref.$linkend;
|
$result .= $linkstart.$this->filename.$linkend;
|
||||||
|
|
||||||
global $action;
|
global $action;
|
||||||
$hookmanager->initHooks(array($this->element . 'dao'));
|
$hookmanager->initHooks(array($this->element . 'dao'));
|
||||||
@@ -964,6 +1013,7 @@ class EcmFiles extends CommonObject
|
|||||||
} else {
|
} else {
|
||||||
$result .= $hookmanager->resPrint;
|
$result .= $hookmanager->resPrint;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -54,3 +54,6 @@ SucessConvertImgWebp=Images successfully duplicated
|
|||||||
SucessConvertChosenImgWebp=Chosen image successfully duplicated
|
SucessConvertChosenImgWebp=Chosen image successfully duplicated
|
||||||
ECMDirName=Dir name
|
ECMDirName=Dir name
|
||||||
ECMParentDirectory=Parent directory
|
ECMParentDirectory=Parent directory
|
||||||
|
ShowFile=Show file
|
||||||
|
FullPathOrig=Full path origin
|
||||||
|
GenOrUpload=File origin
|
||||||
|
|||||||
Reference in New Issue
Block a user