FIX: resource tpls directories

search resource tpls also in custom modules directories
This commit is contained in:
Josep Lluís 2019-07-29 18:17:48 +02:00 committed by GitHub
parent 11e3aa5860
commit 567c4bf97b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,6 +1,7 @@
<?php <?php
/* Copyright (C) 2013-2018 Jean-François Ferry <hello+jf@librethic.io> /* Copyright (C) 2013-2018 Jean-François Ferry <hello+jf@librethic.io>
* Copyright (C) 2016 Gilles Poirier <glgpoirier@gmail.com> * Copyright (C) 2016 Gilles Poirier <glgpoirier@gmail.com>
* Copyright (C) 2019 Josep Lluís Amador <joseplluis@lliuretic.cat>
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -474,29 +475,46 @@ else
$linked_resources = $object->getElementResources($element, $element_id, $resource_obj); $linked_resources = $object->getElementResources($element, $element_id, $resource_obj);
// Output template part (modules that overwrite templates must declare this into descriptor)
// If we have a specific template we use it $defaulttpldir='/core/tpl';
if(file_exists(dol_buildpath($path.'/core/tpl/resource_'.$element_prop['element'].'_add.tpl.php'))) $dirtpls=array_merge($conf->modules_parts['tpl'], array($defaulttpldir), array($path.$defaulttpldir));
foreach($dirtpls as $module => $reldir)
{ {
$res=include dol_buildpath($path.'/core/tpl/resource_'.$element_prop['element'].'_add.tpl.php'); if(file_exists(dol_buildpath($reldir.'/resource_'.$element_prop['element'].'_add.tpl.php')))
} {
else $tpl = dol_buildpath($reldir.'/resource_'.$element_prop['element'].'_add.tpl.php');
{ }
$res=include DOL_DOCUMENT_ROOT . '/core/tpl/resource_add.tpl.php'; else
{
$tpl = DOL_DOCUMENT_ROOT.$reldir.'/resource_add.tpl.php';
}
if (empty($conf->file->strict_mode)) {
$res=@include $tpl;
} else {
$res=include $tpl; // for debug
}
if ($res) break;
} }
if ($mode != 'add' || $resource_obj != $resource_type) if ($mode != 'add' || $resource_obj != $resource_type)
{ {
//print load_fiche_titre($langs->trans(ucfirst($element_prop['element']).'Singular')); foreach($dirtpls as $module => $reldir)
// If we have a specific template we use it
if(file_exists(dol_buildpath($path.'/core/tpl/resource_'.$element_prop['element'].'_view.tpl.php')))
{ {
$res=@include dol_buildpath($path.'/core/tpl/resource_'.$element_prop['element'].'_view.tpl.php'); if(file_exists(dol_buildpath($reldir.'/resource_'.$element_prop['element'].'_view.tpl.php')))
} {
else $tpl = dol_buildpath($reldir.'/resource_'.$element_prop['element'].'_view.tpl.php');
{ }
$res=include DOL_DOCUMENT_ROOT . '/core/tpl/resource_view.tpl.php'; else
{
$tpl = DOL_DOCUMENT_ROOT.$reldir.'/resource_view.tpl.php';
}
if (empty($conf->file->strict_mode)) {
$res=@include $tpl;
} else {
$res=include $tpl; // for debug
}
if ($res) break;
} }
} }
} }