Add APP_NAME constant

Improved issue display
Add component::prepend
Add switches to form html
Updated form html to Bootstrap 5.
Updated navigation html to Bootstrap 5.
This commit is contained in:
Joey Kimsey
2025-01-21 20:46:13 -05:00
parent d9e61d3f8f
commit 61589b35ff
6 changed files with 84 additions and 29 deletions

View File

@ -57,17 +57,36 @@ class Navigation extends Template {
self::$menus_array[ $menuName ][] = self::normalizeLinkArray( $link );
}
public static function getMenuLinks( $menuName ) {
if ( !isset( self::$menus_array[ $menuName ] ) ) {
Debug::debug( 'menu link mot found, creating new:' . $menuName);
return false;
}
$out = [];
foreach ( self::$menus_array[ $menuName ] as $key => $item) {
$filter = $item['filter'];
if ( ! empty( $filter ) ) {
$input = '{' . strtoupper($item['filter']) . '}testing{/' . strtoupper($item['filter']) . '}';
$output = Filters::apply( $input );
// 20 years later and a zero 'location' still gets me....
if ( ! stripos( $output, 'esting' ) ) {
continue;
}
}
$out[] = (object) $item;
}
return $out;
}
public static function getListItem( $link, $class = '' ) {
$link = self::normalizeLinkArray( $link );
if ( empty( $link ) ) {
return '';
}
if ( ! empty( $class ) ) {
$class = ' class="' . $class . '"';
}
// this is a good idea but it breaks active page select because the regex is not equipped to deal with the inclusion of a 'class' field in the list items field
// $list_item_class = ''; # the class for individual list items
$data = '<li'.$class.'><a href="' . $link['url'] . '">' . $link['text'] . '</a></li>';
$data = '<li class="'.$class.' nav-item"><a href="' . $link['url'] . '" class="nav-link">' . $link['text'] . '</a></li>';
if ( !empty( $link['filter'] ) ) {
$data = '{' . strtoupper($link['filter']) . '}'.$data.'{/' . strtoupper($link['filter']) . '}';
$data = Filters::apply( $data );
@ -88,8 +107,8 @@ class Navigation extends Template {
foreach ( $link['url'] as $key => $sub_link ) {
$sub_list .= self::getListItem( $sub_link, 'submenu' );
}
$list .= '<li>
<a href="javascript:;" data-toggle="collapse" data-target="#menu-collapse-' . self::$collapse_count . '">
$list .= '<li class="nav-item">
<a href="javascript:;" class="nav-link" data-toggle="collapse" data-target="#menu-collapse-' . self::$collapse_count . '">
' . $link['text'] . '<i class="fa fa-fw fa-caret-down"></i>
</a>
<ul id="menu-collapse-' . self::$collapse_count . '" class="collapse">' . $sub_list . '</ul>
@ -120,7 +139,6 @@ class Navigation extends Template {
}
if ( !empty( $previousCrumb ) ) {
$allCrumbs .= ' <b>></b> ';
$previousCrumb = trim( $previousCrumb ) . '/' . $crumb;
} else {
$previousCrumb = $crumb;
@ -132,25 +150,27 @@ class Navigation extends Template {
'view' === substr( $crumb, 0, 4 ) ||
$url === Routes::getRequestUrl() ||
'edit' === substr( $crumb, 0, 4 ) ) {
$allCrumbs .= '<b>' . ucfirst( $crumb ) . '</b>';
$allCrumbs .= '<li class="breadcrumb-item active" aria-current="page">' . ucfirst( $crumb ) . '</li>';
break;
}
$allCrumbs .= '<a href="' . $url . '">' . ucfirst( $crumb ) . '</a>';
$allCrumbs .= '<li class="breadcrumb-item"><a href="' . $url . '" class="text-decoration-none atb-green">' . ucfirst( $crumb ) . '</a></li>';
}
Components::set( $breadcrumb_component, $allCrumbs );
$nav = '';
$nav .= '<nav aria-label="breadcrumb">';
$nav .= ' <ol class="breadcrumb">';
$nav .= ' ' . $allCrumbs;
$nav .= ' </ol>';
$nav .= '</nav>';
Components::set( $breadcrumb_component, $nav );
}
/**
* This function parses either given html or the current page content and sets
* the current active page to selected within an html list.
*
* @param string $menu - The name of the view you wish to add. can be any arbitrary value if $view is
* provided.
* @param string $selectString - The string/url you are searching for, default model/controller is used if none is
* provided.
* @param string $menu - The name of the view you wish to add. can be any arbitrary value if $view is provided.
* @param string $selectString - The string/url you are searching for, default model/controller is used if none is provided.
* @param string $view - The html you want parsed, view is generated from menu name if $view is left blank
*
* @return string|bool - returns bool if the menu was added to the page content or
* returns the parsed view if one was provided with the
* function call.