Clean code for top menu

This commit is contained in:
Laurent Destailleur 2022-05-02 16:47:28 +02:00
parent b7106b1731
commit 5dfd38c8f9
8 changed files with 69 additions and 31 deletions

View File

@ -231,22 +231,31 @@ function print_text_menu_entry_auguria($text, $showmode, $url, $id, $idsel, $cla
{
global $langs;
$classnameimg = str_replace('class="', 'class="tmenuimage ', $classname);
$classnametxt = str_replace('class="', 'class="tmenulabel ', $classname);
if ($showmode == 1) {
print '<a class="tmenuimage" tabindex="-1" href="'.$url.'"'.($atarget ? ' target="'.$atarget.'"' : '').' title="'.dol_escape_htmltag($text).'">';
print '<a '.$classnametxt.' tabindex="-1" href="'.$url.'"'.($atarget ? ' target="'.$atarget.'"' : '').' title="'.dol_escape_htmltag($text).'">';
print '<div class="'.$id.' '.$idsel.' topmenuimage"><span class="'.$id.' tmenuimage" id="mainmenuspan_'.$idsel.'"></span></div>';
print '</a>';
print '<a '.$classname.' id="mainmenua_'.$idsel.'" href="'.$url.'"'.($atarget ? ' target="'.$atarget.'"' : '').' title="'.dol_escape_htmltag($text).'">';
print '<span class="mainmenuaspan">';
print $text;
print '</span>';
print '</a>';
if (empty($conf->global->THEME_TOPMENU_DISABLE_TEXT)) {
print '<a '.$classnameimg.' id="mainmenua_'.$idsel.'" href="'.$url.'"'.($atarget ? ' target="'.$atarget.'"' : '').' title="'.dol_escape_htmltag($text).'">';
print '<span class="mainmenuaspan">';
print $text;
print '</span>';
print '</a>';
}
} elseif ($showmode == 2) {
print '<span '.$classnameimg.' title="'.dol_escape_htmltag($text.' - '.$langs->trans("NotAllowed")).'">';
print '<div class="'.$id.' '.$idsel.' topmenuimage tmenudisabled"><span class="'.$id.'" id="mainmenuspan_'.$idsel.'"></span></div>';
print '<a class="tmenudisabled" id="mainmenua_'.$idsel.'" href="#" title="'.dol_escape_htmltag($langs->trans("NotAllowed")).'">';
print '<span class="mainmenuaspan">';
print $text;
print '</span>';
print '</a>';
if (empty($conf->global->THEME_TOPMENU_DISABLE_TEXT)) {
print '<span '.$classnametxt.' id="mainmenua_'.$idsel.'" href="#" title="'.dol_escape_htmltag($text.' - '.$langs->trans("NotAllowed")).'">';
print '<span class="mainmenuaspan">';
print $text;
print '</span>';
print '</span>';
}
}
}

View File

@ -626,26 +626,31 @@ function print_text_menu_entry($text, $showmode, $url, $id, $idsel, $classname,
{
global $conf, $langs;
$classnameimg = str_replace('class="', 'class="tmenuimage ', $classname);
$classnametxt = str_replace('class="', 'class="tmenulabel ', $classname);
//$conf->global->THEME_TOPMENU_DISABLE_TEXT=1;
if ($showmode == 1) {
print '<a class="tmenuimage" tabindex="-1" href="'.$url.'"'.($atarget ? ' target="'.$atarget.'"' : '').' title="'.dol_escape_htmltag($text).'">';
print '<a '.$classnameimg.' tabindex="-1" href="'.$url.'"'.($atarget ? ' target="'.$atarget.'"' : '').' title="'.dol_escape_htmltag($text).'">';
print '<div class="'.$id.' '.$idsel.' topmenuimage"><span class="'.$id.' tmenuimage" id="mainmenuspan_'.$idsel.'"></span></div>';
print '</a>';
if (empty($conf->global->THEME_TOPMENU_DISABLE_TEXT)) {
print '<a '.$classname.' id="mainmenua_'.$idsel.'" href="'.$url.'"'.($atarget ? ' target="'.$atarget.'"' : '').' title="'.dol_escape_htmltag($text).'">';
print '<a '.$classnametxt.' id="mainmenua_'.$idsel.'" href="'.$url.'"'.($atarget ? ' target="'.$atarget.'"' : '').' title="'.dol_escape_htmltag($text).'">';
print '<span class="mainmenuaspan">';
print $text;
print '</span>';
print '</a>';
}
} elseif ($showmode == 2) {
print '<div class="'.$id.' '.$idsel.' topmenuimage tmenudisabled"><span class="'.$id.'" id="mainmenuspan_'.$idsel.'"></span></div>';
print '<span '.$classnameimg.' title="'.dol_escape_htmltag($text.' - '.$langs->trans("NotAllowed")).'">';
print '<div class="'.$id.' '.$idsel.' topmenuimage tmenudisabled"><span class="'.$id.' tmenuimage tmenudisabled" id="mainmenuspan_'.$idsel.'"></span></div>';
print '</span>';
if (empty($conf->global->THEME_TOPMENU_DISABLE_TEXT)) {
print '<a class="tmenudisabled" id="mainmenua_'.$idsel.'" href="#" title="'.dol_escape_htmltag($langs->trans("NotAllowed")).'">';
print '<span class="mainmenuaspan">';
print '<span '.$classnametxt.' id="mainmenua_'.$idsel.'" href="#" title="'.dol_escape_htmltag($text.' - '.$langs->trans("NotAllowed")).'">';
print '<span class="mainmenuaspan tmenudisabled">';
print $text;
print '</span>';
print '</a>';
print '</span>';
}
}
}

View File

@ -513,19 +513,32 @@ function print_text_menu_entry_empty($text, $showmode, $url, $id, $idsel, $class
{
global $conf, $langs;
$classnameimg = str_replace('class="', 'class="tmenuimage ', $classname);
$classnametxt = str_replace('class="', 'class="tmenulabel ', $classname);
if ($showmode == 1) {
print '<a class="tmenuimage" tabindex="-1" href="'.$url.'"'.($atarget ? ' target="'.$atarget.'"' : '').'>';
print '<a '.$classnameimg.' tabindex="-1" href="'.$url.'"'.($atarget ? ' target="'.$atarget.'"' : '').'>';
print '<div class="'.$id.' '.$idsel.'"><span class="'.$id.' tmenuimage" id="mainmenuspan_'.$idsel.'"></span></div>';
print '</a>';
print '<a '.$classname.' id="mainmenua_'.$idsel.'" href="'.$url.'"'.($atarget ? ' target="'.$atarget.'"' : '').'>';
print '<span class="mainmenuaspan">';
print $text;
print '</span>';
print '</a>';
if (empty($conf->global->THEME_TOPMENU_DISABLE_TEXT)) {
print '<a '.$classnametxt.' id="mainmenua_'.$idsel.'" href="'.$url.'"'.($atarget ? ' target="'.$atarget.'"' : '').'>';
print '<span class="mainmenuaspan">';
print $text;
print '</span>';
print '</a>';
}
}
if ($showmode == 2) {
print '<span '.$classnameimg.' title="'.dol_escape_htmltag($text).'">';
print '<div class="'.$id.' '.$idsel.' tmenudisabled"><span class="'.$id.'" id="mainmenuspan_'.$idsel.'"></span></div>';
print '<a class="tmenudisabled" id="mainmenua_'.$idsel.'" href="#" title="'.dol_escape_htmltag($langs->trans("NotAllowed")).'">';
print '</span>';
if (empty($conf->global->THEME_TOPMENU_DISABLE_TEXT)) {
print '<a '.$classnametxt.' id="mainmenua_'.$idsel.'" href="#" title="'.dol_escape_htmltag($langs->trans("NotAllowed")).'">';
print '<span class="mainmenuaspan">';
print $text;
print '</span>';
print '</a>';
}
}
}

View File

@ -199,7 +199,7 @@ if (is_array($results)) {
$text .= ' &nbsp; - &nbsp; <strong>'.$mysoc->name.'</strong>';
$text .= ' &nbsp; - &nbsp; <span class="nowraponall"><span class="fa fa-calendar secondary"></span> '.dol_print_date($object->date_creation).'</span>';
$text .= '</td></tr>'."\n";
$text .= '<tr><td class="textpublicpayment"><h1>'.$object->label.'</h1></td></tr>'."\n";
$text .= '<tr><td class="textpublicpayment"><h1 class="paddingleft paddingright">'.$object->label.'</h1></td></tr>'."\n";
}
print $text;

View File

@ -250,7 +250,7 @@ if (empty($text)) {
$text .= ' &nbsp; - &nbsp; <strong>'.$mysoc->name.'</strong>';
$text .= ' &nbsp; - &nbsp; <span class="nowraponall"><span class="fa fa-calendar secondary"></span> '.dol_print_date($object->date_creation).'</span>';
$text .= '</td></tr>'."\n";
$text .= '<tr><td class="textpublicpayment"><h1>'.$object->label.'</h1><br></td></tr>'."\n";
$text .= '<tr><td class="textpublicpayment"><h1 class="paddingleft paddingright">'.$object->label.'</h1><br></td></tr>'."\n";
}
print $text;

View File

@ -125,11 +125,10 @@ $search_array_options = $extrafields->getOptionalsFromPost($object->table_elemen
// Default sort order (if not yet defined by previous GETPOST)
if (!$sortfield) {
reset($object->fields); // Reset is required to avoid key() to return null.
$sortfield = "t.".key($object->fields); // Set here default search field. By default 1st field in definition.
$sortfield = "t.ref";
}
if (!$sortorder) {
$sortorder = "ASC";
$sortorder = "DESC";
}
// Initialize array of search criterias

View File

@ -2601,8 +2601,20 @@ a.tmenuimage:hover{
text-decoration: none;
}
/*
.tmenulabel:not(.menuhider), .tmenulabel:not(.menuhider):before {
display: none;
}
.tmenuimage:not(.menuhider), .tmenuimage:not(.menuhider):before {
font-size: 1.5em;
}
.tmenudiv:hover .tmenulabel:not(.menuhider), .tmenudiv:hover .tmenulabel:not(.menuhider):before {
display: initial !important;
}
.tmenudiv:hover .tmenuimage:not(.menuhider), .tmenudiv:hover .tmenulabel:not(.menuhider):before {
font-size: 1.1em !important;
}
*/
/* Do not load menu img for other if hidden to save bandwidth */

View File

@ -201,7 +201,7 @@ button.dropdown-item.global-search-item {
}
div#topmenu-global-search-dropdown, div#topmenu-quickadd-dropdown, div#topmenu-bookmark-dropdown {
line-height: 46px;
line-height: <?php echo (empty($conf->global->THEME_TOPMENU_DISABLE_IMAGE) ? '46' : '35' ); ?>px;
}
a.top-menu-dropdown-link {
padding: 8px;