Fix hack with hook to solve a problem to let a chance of external

modules to be visible to android webview.
This commit is contained in:
Laurent Destailleur 2018-06-28 22:59:53 +02:00
parent 5de650435a
commit 66f0ee9e18
2 changed files with 19 additions and 5 deletions

View File

@ -186,7 +186,8 @@ class HookManager
'sendMail',
'sendMailAfter',
'showLinkToObjectBlock',
'setContentSecurityPolicy'
'setContentSecurityPolicy',
'setHtmlTitle'
)
)) $hooktype='addreplace';

View File

@ -1154,7 +1154,7 @@ function top_httphead($contenttype='text/html', $forcenocache=0)
*/
function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $disablejmobile=0, $disablenofollow=0)
{
global $user, $conf, $langs, $db;
global $db, $conf, $langs, $user, $hookmanager;
top_httphead();
@ -1188,9 +1188,22 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs
$appli=constant('DOL_APPLICATION_TITLE');
if (!empty($conf->global->MAIN_APPLICATION_TITLE)) $appli=$conf->global->MAIN_APPLICATION_TITLE;
if ($title && ! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/noapp/',$conf->global->MAIN_HTML_TITLE)) print '<title>'.dol_htmlentities($title).'</title>';
else if ($title) print '<title>'.dol_htmlentities($appli.' - '.$title).'</title>';
else print "<title>".dol_htmlentities($appli)."</title>";
print '<title>';
$titletoshow='';
if ($title && ! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/noapp/',$conf->global->MAIN_HTML_TITLE)) $titletoshow = dol_htmlentities($title);
else if ($title) $titletoshow = dol_htmlentities($appli.' - '.$title);
else $titletoshow = dol_htmlentities($appli);
if (! is_object($hookmanager)) $hookmanager = new HookManager($db);
$hookmanager->initHooks("main");
$parameters=array('title'=>$titletoshow);
$result=$hookmanager->executeHooks('setHtmlTitle',$parameters); // Note that $action and $object may have been modified by some hooks
if ($result > 0) $titletoshow = $hookmanager->resPrint; // Replace Title to show
else $titletoshow .= $hookmanager->resPrint; // Concat to Title to show
print $titletoshow;
print '</title>';
print "\n";
if (GETPOST('version','int')) $ext='version='.GETPOST('version','int'); // usefull to force no cache on css/js