diff --git a/htdocs/admin/modulehelp.php b/htdocs/admin/modulehelp.php index e76627c296583c2a1dcebfac131fb9666ec8f1ce..5b42844324884432312b508c7d65969938504d8b 100644 --- a/htdocs/admin/modulehelp.php +++ b/htdocs/admin/modulehelp.php @@ -338,7 +338,7 @@ if ($mode == 'desc') $text.='<br>'; $moduledesclong=$objMod->getDescLong(); - if ($moduledesclong) $text.='<br><hr><br>'.$moduledesclong.'<br>'; + if ($moduledesclong) $text.='<br><hr><div class="moduledesclong">'.$moduledesclong.'<div>'; } if ($mode == 'feature') diff --git a/htdocs/core/lib/parsemd.lib.php b/htdocs/core/lib/parsemd.lib.php index 17e64f6543e037e1c1920f5cf83a461869aac929..1eb962463c0d6b797f0f2261a35d392daa2f53b9 100644 --- a/htdocs/core/lib/parsemd.lib.php +++ b/htdocs/core/lib/parsemd.lib.php @@ -24,12 +24,22 @@ /** * Function to parse MD content into HTML * - * @param string $content MD content - * @param string $parser 'parsedown' or 'nl2br' - * @return string Parsed content + * @param string $content MD content + * @param string $parser 'parsedown' or 'nl2br' + * @param string $replaceimagepath Replace path to image with another path. Exemple: ('doc/'=>'xxx/aaa/') + * @return string Parsed content */ -function dolMd2Html($content, $parser='parsedown') +function dolMd2Html($content, $parser='parsedown',$replaceimagepath=null) { + if (is_array($replaceimagepath)) + { + foreach($replaceimagepath as $key => $val) + { + $keytoreplace = ']('.$key; + $valafter = ']('.$val; + $content = preg_replace('/'.preg_quote($keytoreplace,'/').'/m', $valafter, $content); + } + } if ($parser == 'parsedown') { include DOL_DOCUMENT_ROOT.'/includes/parsedown/Parsedown.php'; diff --git a/htdocs/core/modules/DolibarrModules.class.php b/htdocs/core/modules/DolibarrModules.class.php index 84538801adde8d7cf096a5a08df68db13d51ea9e..48ce35f1532c22cb5a5e2213982cff876db906cd 100644 --- a/htdocs/core/modules/DolibarrModules.class.php +++ b/htdocs/core/modules/DolibarrModules.class.php @@ -582,26 +582,68 @@ class DolibarrModules // Can not be abstract, because we need to insta } /** - * Gives the translated module description if translation exists in admin.lang or the default module description + * Gives the long description of a module. First check README-la_LA.md then README.md + * If not markdown files found, it return translated value of the key ->descriptionlong. * - * @return string Translated module description + * @return string Long description of a module */ function getDescLong() { global $langs; $langs->load("admin"); - if (empty($this->descriptionlong)) return ''; + include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + include_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php'; + + $filefound= false; - // If module description translation does not exist using its unique id, we can use its name to find translation - if (is_array($this->langfiles)) + // Define path to file README.md. + // First check README-la_LA.md then README.md + $pathoffile = dol_buildpath(strtolower($this->name).'/README-'.$langs->defaultlang.'.md', 0); + if (dol_is_file($pathoffile)) { - foreach($this->langfiles as $val) + $filefound = true; + } + if (! $filefound) + { + $pathoffile = dol_buildpath(strtolower($this->name).'/README.md', 0); + if (dol_is_file($pathoffile)) { - if ($val) $langs->load($val); + $filefound = true; } } - return $langs->trans($this->descriptionlong); + + if ($filefound) // Mostly for external modules + { + $content = file_get_contents($pathoffile); + + if ((float) DOL_VERSION >= 6.0) + { + @include_once DOL_DOCUMENT_ROOT.'/core/lib/parsemd.lib.php'; + $content = dolMd2Html($content, 'parsedown', array('doc/'=>dol_buildpath('cabinetmed/doc/', 1))); + } + else + { + $content = nl2br($content); + } + } + else // Mostly for internal modules + { + if (! empty($this->descriptionlong)) + { + if (is_array($this->langfiles)) + { + foreach($this->langfiles as $val) + { + if ($val) $langs->load($val); + } + } + + $content = $langs->trans($this->descriptionlong); + } + } + + return $content; } /** diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index 3d6e8868bece0ba7cf6570a555eb060834b765fb..26a0c8d21ed863c2d9c6c1a61130daa50f186569 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -632,6 +632,13 @@ div.myavailability { margin-bottom: 12px; } +/* For the long description of module */ +.moduledesclong p img, .moduledesclong p a img { + max-width: 90% !important; + height: auto !important; +} + + /* DOL_XXX for future usage (when left menu has been removed). If we do not use datatable */ /*.table-responsive { width: calc(100% - 330px); diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index aae0fd7f6772e1dd7b995a25ca39f4700a275e77..c930b82dd8cf32a80e9a4caf62bc9cac1eef309c 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -640,6 +640,13 @@ div.myavailability { margin-bottom: 12px; } +/* For the long description of module */ +.moduledesclong p img,.moduledesclong p a img { + max-width: 90% !important; + height: auto !important; +} + + /* DOL_XXX for future usage (when left menu has been removed). If we do not use datatable */ /*.table-responsive { width: calc(100% - 330px);