use callHook() instead of interating over hookObjects

This commit is contained in:
Uwe Steinmann 2021-04-23 09:55:25 +02:00
parent 1a114830a5
commit fd90623de4

View File

@ -79,12 +79,8 @@ class SeedDMS_Theme_Style extends SeedDMS_View_Common {
header($name . ": " . $value); header($name . ": " . $value);
} }
} }
$hookObjs = $this->getHookObjects('SeedDMS_View_Bootstrap'); if($this->hasHook('startPage'))
foreach($hookObjs as $hookObj) { $this->callHook('startPage');
if (method_exists($hookObj, 'startPage')) {
$hookObj->startPage($this);
}
}
echo "<!DOCTYPE html>\n"; echo "<!DOCTYPE html>\n";
echo "<html lang=\"en\">\n<head>\n"; echo "<html lang=\"en\">\n<head>\n";
echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n"; echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n";
@ -147,11 +143,8 @@ background-image: linear-gradient(to bottom, #882222, #111111);;
echo "<div class=\"splash\" data-type=\"".$flashmsg['type']."\"".(!empty($flashmsg['timeout']) ? ' data-timeout="'.$flashmsg['timeout'].'"': '').">".$flashmsg['msg']."</div>\n"; echo "<div class=\"splash\" data-type=\"".$flashmsg['type']."\"".(!empty($flashmsg['timeout']) ? ' data-timeout="'.$flashmsg['timeout'].'"': '').">".$flashmsg['msg']."</div>\n";
} }
echo "<div class=\"statusbar-container\"><h1>".getMLText('recent_uploads')."</h1></div>\n"; echo "<div class=\"statusbar-container\"><h1>".getMLText('recent_uploads')."</h1></div>\n";
foreach($hookObjs as $hookObj) { if($this->hasHook('startBody'))
if (method_exists($hookObj, 'startBody')) { $this->callHook('startBody');
$hookObj->startBody($this);
}
}
} /* }}} */ } /* }}} */
function htmlAddHeader($head, $type='js') { /* {{{ */ function htmlAddHeader($head, $type='js') { /* {{{ */
@ -166,13 +159,9 @@ background-image: linear-gradient(to bottom, #882222, #111111);;
function htmlEndPage($nofooter=false) { /* {{{ */ function htmlEndPage($nofooter=false) { /* {{{ */
if(!$nofooter) { if(!$nofooter) {
$hookObjs = $this->getHookObjects('SeedDMS_View_Bootstrap');
$html = $this->footNote(); $html = $this->footNote();
foreach($hookObjs as $hookObj) { if($this->hasHook('footNote'))
if (method_exists($hookObj, 'footNote')) { $html = $this->callHook('footNote', $html);
$html = $hookObj->footNote($this, $html);
}
}
echo $html; echo $html;
if($this->params['showmissingtranslations']) { if($this->params['showmissingtranslations']) {
$this->missingLanguageKeys(); $this->missingLanguageKeys();
@ -326,12 +315,8 @@ background-image: linear-gradient(to bottom, #882222, #111111);;
$menuitems['my_documents'] = array('link'=>"../out/out.MyDocuments.php?inProcess=1", 'label'=>'my_documents'); $menuitems['my_documents'] = array('link'=>"../out/out.MyDocuments.php?inProcess=1", 'label'=>'my_documents');
if ($accessobject->check_view_access('MyAccount')) if ($accessobject->check_view_access('MyAccount'))
$menuitems['my_account'] = array('link'=>"../out/out.MyAccount.php", 'label'=>'my_account'); $menuitems['my_account'] = array('link'=>"../out/out.MyAccount.php", 'label'=>'my_account');
$hookObjs = $this->getHookObjects('SeedDMS_View_Bootstrap'); if($this->hasHook('userMenuItems'))
foreach($hookObjs as $hookObj) { $menuitems = $this->callHook('userMenuItems', $menuitems);
if (method_exists($hookObj, 'userMenuItems')) {
$menuitems = $hookObj->userMenuItems($this, $menuitems);
}
}
if($menuitems) { if($menuitems) {
foreach($menuitems as $menuitem) { foreach($menuitems as $menuitem) {
echo "<li><a href=\"".$menuitem['link']."\">".getMLText($menuitem['label'])."</a></li>"; echo "<li><a href=\"".$menuitem['link']."\">".getMLText($menuitem['label'])."</a></li>";
@ -427,11 +412,8 @@ background-image: linear-gradient(to bottom, #882222, #111111);;
$menuitems['help'] = array('link'=>'../out/out.Help.php?context='.$tmp[1], 'label'=>"help"); $menuitems['help'] = array('link'=>'../out/out.Help.php?context='.$tmp[1], 'label'=>"help");
} }
/* Check if hook exists because otherwise callHook() will override $menuitems */ /* Check if hook exists because otherwise callHook() will override $menuitems */
foreach($hookObjs as $hookObj) { if($this->hasHook('globalNavigationBar'))
if (method_exists($hookObj, 'globalNavigationBar')) { $menuitems = $this->callHook('globalNavigationBar', $menuitems);
$menuitems = $hookObj->globalNavigationBar($this, $menuitems);
}
}
foreach($menuitems as $menuitem) { foreach($menuitems as $menuitem) {
if(!empty($menuitem['children'])) { if(!empty($menuitem['children'])) {
echo " <li class=\"dropdown\">\n"; echo " <li class=\"dropdown\">\n";