From ce920364343934be1662602ca8a252711e486a32 Mon Sep 17 00:00:00 2001 From: Abbes Bahfir Date: Thu, 20 Jun 2019 23:13:46 +0100 Subject: [PATCH 1/7] new:Show object photos in modulebuilder lists with a constant to format output as user list photos --- .../template/class/myobject.class.php | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index 1b4d1c7b52d..3acc7c649f4 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -548,7 +548,23 @@ class MyObject extends CommonObject $linkend=''; $result .= $linkstart; - if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); + + list($class, $module) = explode('@', $this->picto); + $upload_dir = $conf->$module->multidir_output[$conf->entity] . "/$class/" . dol_sanitizeFileName($this->ref); + $filearray = dol_dir_list($upload_dir, "files"); + $filename = $filearray[0]['name']; + if(!empty($filename)){ + $pospoint = strpos($filearray[0]['name'], '.'); + + $pathtophoto = $class . '/' . $this->ref . '/thumbs/' . substr($filename, 0, $pospoint) . '_mini' . substr($filename, $pospoint); + if(empty($conf->global->{strtoupper($module).'_FORMATLISTPHOTOSASUSERS'})) + $result .= '
No photo
'; + else $result .= '
No photo
'; + + + $result .= ''; + } + elseif ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); if ($withpicto != 2) $result.= $this->ref; $result .= $linkend; //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : ''); From 78e44ef0774d6769d0c089d0bff9512ac50d0e94 Mon Sep 17 00:00:00 2001 From: Bahfir Abbes Date: Thu, 20 Jun 2019 23:35:35 +0100 Subject: [PATCH 2/7] Update myobject.class.php --- htdocs/modulebuilder/template/class/myobject.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index 3acc7c649f4..52335984ac8 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -24,6 +24,7 @@ // Put here all includes required by your class file require_once DOL_DOCUMENT_ROOT . '/core/class/commonobject.class.php'; +require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; //require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; //require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; From 79f6ec6facb370f762c1db3b846b38c4dd830b52 Mon Sep 17 00:00:00 2001 From: Bahfir Abbes Date: Fri, 21 Jun 2019 17:12:58 +0100 Subject: [PATCH 3/7] extend constant to objects into modules --- htdocs/modulebuilder/template/class/myobject.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index 52335984ac8..7caea9700f7 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -534,7 +534,7 @@ class MyObject extends CommonObject } $linkclose.=' title="'.dol_escape_htmltag($label, 1).'"'; $linkclose.=' class="classfortooltip'.($morecss?' '.$morecss:'').'"'; - +.'_'.$class /* $hookmanager->initHooks(array('myobjectdao')); $parameters=array('id'=>$this->id); @@ -558,7 +558,7 @@ class MyObject extends CommonObject $pospoint = strpos($filearray[0]['name'], '.'); $pathtophoto = $class . '/' . $this->ref . '/thumbs/' . substr($filename, 0, $pospoint) . '_mini' . substr($filename, $pospoint); - if(empty($conf->global->{strtoupper($module).'_FORMATLISTPHOTOSASUSERS'})) + if(empty($conf->global->{strtoupper($module.'_'.$class).'_FORMATLISTPHOTOSASUSERS'})) $result .= '
No photo
'; else $result .= '
No photo
'; From d949447670d420c123267b36a089380e423fbeda Mon Sep 17 00:00:00 2001 From: Bahfir Abbes Date: Fri, 21 Jun 2019 17:18:51 +0100 Subject: [PATCH 4/7] Update myobject.class.php --- htdocs/modulebuilder/template/class/myobject.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index 7caea9700f7..0ac92cba065 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -534,7 +534,7 @@ class MyObject extends CommonObject } $linkclose.=' title="'.dol_escape_htmltag($label, 1).'"'; $linkclose.=' class="classfortooltip'.($morecss?' '.$morecss:'').'"'; -.'_'.$class + /* $hookmanager->initHooks(array('myobjectdao')); $parameters=array('id'=>$this->id); From 2ca5532a2101e3412db99bc756f97c2f5caec323 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 2 Mar 2020 21:03:59 +0100 Subject: [PATCH 5/7] Update myobject.class.php --- .../template/class/myobject.class.php | 29 ++++++++++--------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index 0ac92cba065..f7b0f8c797c 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -24,7 +24,6 @@ // Put here all includes required by your class file require_once DOL_DOCUMENT_ROOT . '/core/class/commonobject.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; //require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; //require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; @@ -550,22 +549,26 @@ class MyObject extends CommonObject $result .= $linkstart; - list($class, $module) = explode('@', $this->picto); - $upload_dir = $conf->$module->multidir_output[$conf->entity] . "/$class/" . dol_sanitizeFileName($this->ref); - $filearray = dol_dir_list($upload_dir, "files"); - $filename = $filearray[0]['name']; - if(!empty($filename)){ - $pospoint = strpos($filearray[0]['name'], '.'); + if ($this->showphoto_on_popup) { + require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; - $pathtophoto = $class . '/' . $this->ref . '/thumbs/' . substr($filename, 0, $pospoint) . '_mini' . substr($filename, $pospoint); - if(empty($conf->global->{strtoupper($module.'_'.$class).'_FORMATLISTPHOTOSASUSERS'})) - $result .= '
No photo
'; - else $result .= '
No photo
'; + list($class, $module) = explode('@', $this->picto); + $upload_dir = $conf->$module->multidir_output[$conf->entity] . "/$class/" . dol_sanitizeFileName($this->ref); + $filearray = dol_dir_list($upload_dir, "files"); + $filename = $filearray[0]['name']; + if(!empty($filename)){ + $pospoint = strpos($filearray[0]['name'], '.'); + + $pathtophoto = $class . '/' . $this->ref . '/thumbs/' . substr($filename, 0, $pospoint) . '_mini' . substr($filename, $pospoint); + if(empty($conf->global->{strtoupper($module.'_'.$class).'_FORMATLISTPHOTOSASUSERS'})) + $result .= '
No photo
'; + else $result .= '
No photo
'; - $result .= ''; + $result .= ''; + } + elseif ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); } - elseif ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); if ($withpicto != 2) $result.= $this->ref; $result .= $linkend; //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : ''); From 86f0d6db413f97baff6e59be955dceb6d34f3b3e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 2 Mar 2020 21:06:57 +0100 Subject: [PATCH 6/7] Update myobject.class.php --- .../template/class/myobject.class.php | 34 +++++++++++-------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index f7b0f8c797c..d556e64506e 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -549,25 +549,31 @@ class MyObject extends CommonObject $result .= $linkstart; - if ($this->showphoto_on_popup) { - require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; + if (empty($this->showphoto_on_popup)) { + if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); + } else { + if ($withpicto) { + require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; - list($class, $module) = explode('@', $this->picto); - $upload_dir = $conf->$module->multidir_output[$conf->entity] . "/$class/" . dol_sanitizeFileName($this->ref); - $filearray = dol_dir_list($upload_dir, "files"); - $filename = $filearray[0]['name']; - if(!empty($filename)){ - $pospoint = strpos($filearray[0]['name'], '.'); + list($class, $module) = explode('@', $this->picto); + $upload_dir = $conf->$module->multidir_output[$conf->entity] . "/$class/" . dol_sanitizeFileName($this->ref); + $filearray = dol_dir_list($upload_dir, "files"); + $filename = $filearray[0]['name']; + if(!empty($filename)){ + $pospoint = strpos($filearray[0]['name'], '.'); - $pathtophoto = $class . '/' . $this->ref . '/thumbs/' . substr($filename, 0, $pospoint) . '_mini' . substr($filename, $pospoint); - if(empty($conf->global->{strtoupper($module.'_'.$class).'_FORMATLISTPHOTOSASUSERS'})) - $result .= '
No photo
'; - else $result .= '
No photo
'; + $pathtophoto = $class . '/' . $this->ref . '/thumbs/' . substr($filename, 0, $pospoint) . '_mini' . substr($filename, $pospoint); + if(empty($conf->global->{strtoupper($module.'_'.$class).'_FORMATLISTPHOTOSASUSERS'})) + $result .= '
No photo
'; + else $result .= '
No photo
'; - $result .= ''; + $result .= ''; + } + else { + $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); + } } - elseif ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); } if ($withpicto != 2) $result.= $this->ref; $result .= $linkend; From 7e2c2913bcbcafef864281ed74ba95289d95fc19 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 2 Mar 2020 21:13:02 +0100 Subject: [PATCH 7/7] Update myobject.class.php --- htdocs/modulebuilder/template/class/myobject.class.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index d556e64506e..ef38077e0e2 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -563,10 +563,12 @@ class MyObject extends CommonObject $pospoint = strpos($filearray[0]['name'], '.'); $pathtophoto = $class . '/' . $this->ref . '/thumbs/' . substr($filename, 0, $pospoint) . '_mini' . substr($filename, $pospoint); - if(empty($conf->global->{strtoupper($module.'_'.$class).'_FORMATLISTPHOTOSASUSERS'})) + if (empty($conf->global->{strtoupper($module.'_'.$class).'_FORMATLISTPHOTOSASUSERS'})) { $result .= '
No photo
'; - else $result .= '
No photo
'; - + } + else { + $result .= '
No photo
'; + } $result .= ''; }