NEW Show by default README.md file found into root dir of ext module.
This commit is contained in:
parent
a5c11dc840
commit
b5e646daa0
@ -338,7 +338,7 @@ if ($mode == 'desc')
|
|||||||
$text.='<br>';
|
$text.='<br>';
|
||||||
|
|
||||||
$moduledesclong=$objMod->getDescLong();
|
$moduledesclong=$objMod->getDescLong();
|
||||||
if ($moduledesclong) $text.='<br><hr><br>'.$moduledesclong.'<br>';
|
if ($moduledesclong) $text.='<br><hr><div class="moduledesclong">'.$moduledesclong.'<div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($mode == 'feature')
|
if ($mode == 'feature')
|
||||||
|
|||||||
@ -26,10 +26,20 @@
|
|||||||
*
|
*
|
||||||
* @param string $content MD content
|
* @param string $content MD content
|
||||||
* @param string $parser 'parsedown' or 'nl2br'
|
* @param string $parser 'parsedown' or 'nl2br'
|
||||||
|
* @param string $replaceimagepath Replace path to image with another path. Exemple: ('doc/'=>'xxx/aaa/')
|
||||||
* @return string Parsed content
|
* @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')
|
if ($parser == 'parsedown')
|
||||||
{
|
{
|
||||||
include DOL_DOCUMENT_ROOT.'/includes/parsedown/Parsedown.php';
|
include DOL_DOCUMENT_ROOT.'/includes/parsedown/Parsedown.php';
|
||||||
|
|||||||
@ -582,18 +582,55 @@ 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()
|
function getDescLong()
|
||||||
{
|
{
|
||||||
global $langs;
|
global $langs;
|
||||||
$langs->load("admin");
|
$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';
|
||||||
|
|
||||||
// If module description translation does not exist using its unique id, we can use its name to find translation
|
$filefound= false;
|
||||||
|
|
||||||
|
// 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))
|
||||||
|
{
|
||||||
|
$filefound = true;
|
||||||
|
}
|
||||||
|
if (! $filefound)
|
||||||
|
{
|
||||||
|
$pathoffile = dol_buildpath(strtolower($this->name).'/README.md', 0);
|
||||||
|
if (dol_is_file($pathoffile))
|
||||||
|
{
|
||||||
|
$filefound = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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))
|
if (is_array($this->langfiles))
|
||||||
{
|
{
|
||||||
foreach($this->langfiles as $val)
|
foreach($this->langfiles as $val)
|
||||||
@ -601,7 +638,12 @@ class DolibarrModules // Can not be abstract, because we need to insta
|
|||||||
if ($val) $langs->load($val);
|
if ($val) $langs->load($val);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $langs->trans($this->descriptionlong);
|
|
||||||
|
$content = $langs->trans($this->descriptionlong);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $content;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -632,6 +632,13 @@ div.myavailability {
|
|||||||
margin-bottom: 12px;
|
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 */
|
/* DOL_XXX for future usage (when left menu has been removed). If we do not use datatable */
|
||||||
/*.table-responsive {
|
/*.table-responsive {
|
||||||
width: calc(100% - 330px);
|
width: calc(100% - 330px);
|
||||||
|
|||||||
@ -640,6 +640,13 @@ div.myavailability {
|
|||||||
margin-bottom: 12px;
|
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 */
|
/* DOL_XXX for future usage (when left menu has been removed). If we do not use datatable */
|
||||||
/*.table-responsive {
|
/*.table-responsive {
|
||||||
width: calc(100% - 330px);
|
width: calc(100% - 330px);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user