From 3ef90d30253763fce309436dd78da16aed8b26f0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?C=C3=B4me=20Chilliet?= <come.chilliet@fusiondirectory.org>
Date: Tue, 22 Oct 2019 13:01:10 +0200
Subject: [PATCH] :ambulance: fix(core) Move clickToEdit message to the left

Also cleaned up "header" handling.
Removed print_header function which was doing two different things and
 misused in some places.

issue #6038
---
 include/class_pluglist.inc                    |  3 ++-
 include/functions.inc                         | 27 -------------------
 include/management/class_management.inc       | 11 +++++++-
 .../simpleplugin/class_simpleManagement.inc   | 11 +++++++-
 include/simpleplugin/class_simplePlugin.inc   | 11 ++++----
 plugins/generic/welcome/main.inc              |  3 ++-
 plugins/generic/welcome/welcome.tpl           |  2 --
 7 files changed, 29 insertions(+), 39 deletions(-)

diff --git a/include/class_pluglist.inc b/include/class_pluglist.inc
index 8001859ca..c1a838112 100644
--- a/include/class_pluglist.inc
+++ b/include/class_pluglist.inc
@@ -586,7 +586,8 @@ class pluglist
         $cleanup = $remove_lock = FALSE;
       }
     } catch (Exception $e) {
-      $smarty->assign('header', print_header('geticon.php?context=status&icon=dialog-error&size=32', _('Fatal error!')));
+      $smarty->assign('headline', _('Fatal error!'));
+      $smarty->assign('headline_image', 'geticon.php?context=status&icon=dialog-error&size=32');
       $display = '<h1>'._('An unrecoverable error occurred. Please contact your administator.').'</h1><p>';
       if (ini_get('display_errors') == 1) {
         $display .= nl2br(htmlentities((string)$e, ENT_COMPAT, 'UTF-8'));
diff --git a/include/functions.inc b/include/functions.inc
index 78152279a..b0c4459df 100644
--- a/include/functions.inc
+++ b/include/functions.inc
@@ -1065,33 +1065,6 @@ function check_command ($cmdline)
   return TRUE;
 }
 
-/*!
- * \brief Print plugin HTML header
- *
- * \param string $image the path of the image to be used next to the headline
- *
- * \param string $headline the headline
- *
- * \param string $info additional information to print
- *
- * \return the $display variable
- */
-function print_header ($image, $headline, $info = '')
-{
-  $smarty = get_smarty();
-  $smarty->assign('headline', $headline);
-  $smarty->assign('headline_image', $image);
-  $display = '';
-
-  if ($info != '') {
-    $display .= '<div class="pluginfo">'."\n";
-    $display .= "$info";
-    $display .= "</div>\n";
-    $display .= "<div></div>\n";
-  }
-  return $display;
-}
-
 /*!
  * \brief Put netmask in n.n.n.n format
  *
diff --git a/include/management/class_management.inc b/include/management/class_management.inc
index 0bb9b1111..0e67ce012 100644
--- a/include/management/class_management.inc
+++ b/include/management/class_management.inc
@@ -580,11 +580,20 @@ class management
    */
   protected function getHeader (): string
   {
+    global $smarty;
+
     if ($this->skipHeader) {
       return '';
     }
 
-    return print_header($this->icon, $this->title, get_object_info());
+    $smarty->assign('headline', $this->title);
+    $smarty->assign('headline_image', $this->icon);
+
+    $info = get_object_info();
+    if ($info != '') {
+      return '<div class="pluginfo">'.$info."</div>\n";
+    }
+    return '';
   }
 
   function openTabObject ($object)
diff --git a/include/simpleplugin/class_simpleManagement.inc b/include/simpleplugin/class_simpleManagement.inc
index c61471a72..de90f18a5 100644
--- a/include/simpleplugin/class_simpleManagement.inc
+++ b/include/simpleplugin/class_simpleManagement.inc
@@ -495,6 +495,8 @@ class simpleManagement
    */
   protected function getHeader ()
   {
+    global $smarty;
+
     if ($this->skipHeader) {
       return '';
     }
@@ -506,7 +508,14 @@ class simpleManagement
     if (!preg_match('/^geticon/', $plIcon)) {
       $plIcon = get_template_path($plIcon);
     }
-    return print_header($plIcon, $plTitle, get_object_info());
+    $smarty->assign('headline', $plTitle);
+    $smarty->assign('headline_image', $plIcon);
+
+    $info = get_object_info();
+    if ($info != '') {
+      return '<div class="pluginfo">'.$info."</div>\n";
+    }
+    return '';
   }
 
   /*!
diff --git a/include/simpleplugin/class_simplePlugin.inc b/include/simpleplugin/class_simplePlugin.inc
index fae13eebd..4eef41ff4 100644
--- a/include/simpleplugin/class_simplePlugin.inc
+++ b/include/simpleplugin/class_simplePlugin.inc
@@ -2121,7 +2121,7 @@ class simplePlugin implements SimpleTab
    */
   static function mainInc ($classname = NULL, $entry_dn = NULL, $tabs = FALSE, $edit_mode = TRUE, $objectType = FALSE)
   {
-    global $remove_lock, $cleanup, $display, $config, $plug, $ui;
+    global $remove_lock, $cleanup, $display, $config, $plug, $ui, $smarty;
 
     if ($classname === NULL) {
       $classname = get_called_class();
@@ -2198,7 +2198,6 @@ class simplePlugin implements SimpleTab
         }
 
         /* save changes to LDAP and disable edit mode */
-        $info = "";
         if (isset($_POST['edit_finish'])) {
           /* Perform checks */
           $message = $tabObject->save();
@@ -2215,8 +2214,6 @@ class simplePlugin implements SimpleTab
             msg_dialog::displayChecks($message);
           }
         }
-      } else {
-        $info = "";
       }
 
       /* Execute formular */
@@ -2248,7 +2245,7 @@ class simplePlugin implements SimpleTab
         } elseif (strpos($tabObject->by_object[$tabObject->current]->aclGetPermissions(''), 'w') !== FALSE) {
           /* Only display edit button if there is at least one attribute writable */
           $display  .= '<p class="plugbottom">'."\n";
-          $info     .= '<div style="display:inline-block" class="optional"><img class="center" alt="information" '.
+          $info     .= '<div style="float:left;" class="optional"><img class="center" alt="information" '.
                     'src="geticon.php?context=status&amp;icon=dialog-information&amp;size=16"> '.
                     msgPool::clickEditToChange().'</div>';
           $display  .= '<input type="submit" name="edit" value="'.msgPool::editButton().'"/>'."\n";
@@ -2260,7 +2257,9 @@ class simplePlugin implements SimpleTab
       if (!preg_match('/^geticon/', $plIcon)) {
         $plIcon = get_template_path($plIcon);
       }
-      $display = print_header($plIcon, $plHeadline, $info).$display;
+      $smarty->assign('headline', $plHeadline);
+      $smarty->assign('headline_image', $plIcon);
+      $display = '<div class="pluginfo">'.$info."</div>\n".$display;
     }
   }
 }
diff --git a/plugins/generic/welcome/main.inc b/plugins/generic/welcome/main.inc
index 8f2a83a71..b623df5a8 100644
--- a/plugins/generic/welcome/main.inc
+++ b/plugins/generic/welcome/main.inc
@@ -21,7 +21,8 @@
 
 if (!$cleanup) {
   $smarty->assign('iconmenu', $plist->show_iconmenu());
-  $smarty->assign('header', print_header('geticon.php?context=applications&icon=config-welcome&size=48', sprintf(_('Welcome %s!'), $ui->cn)));
+  $smarty->assign('headline', sprintf(_('Welcome %s!'), $ui->cn));
+  $smarty->assign('headline_image', 'geticon.php?context=applications&icon=config-welcome&size=48');
   $smarty->assign('year', date('Y'));
   $smarty->assign('revision', FD_VERSION);
 
diff --git a/plugins/generic/welcome/welcome.tpl b/plugins/generic/welcome/welcome.tpl
index 74dddf806..b0526fad8 100644
--- a/plugins/generic/welcome/welcome.tpl
+++ b/plugins/generic/welcome/welcome.tpl
@@ -1,5 +1,3 @@
-{$header}
-
 {$iconmenu}
 
 <br/>
-- 
GitLab