diff --git a/classes/components.php b/classes/components.php index 10bbcc0..a5f1b48 100644 --- a/classes/components.php +++ b/classes/components.php @@ -46,12 +46,14 @@ class Components { self::$components[ $name ] = $value; return true; } + public static function unset( $name ) { if ( isset( self::$components[ $name ] ) ) { unset( self::$components[ $name ] ); } return true; } + public static function append( $name, $value ) { if ( ! isset( self::$components[ $name ] ) ) { return self::set( $name, $value ); @@ -60,4 +62,13 @@ class Components { self::$components[ $name ] = $curr . $value; return true; } + + public static function prepend( $name, $value ) { + if ( ! isset( self::$components[ $name ] ) ) { + return self::set( $name, $value ); + } + $curr = self::$components[ $name ]; + self::$components[ $name ] = $value . $curr; + return true; + } } diff --git a/classes/forms.php b/classes/forms.php index 09cc8a8..771436b 100644 --- a/classes/forms.php +++ b/classes/forms.php @@ -11,6 +11,7 @@ */ namespace TheTempusProject\Houdini\Classes; +use TheTempusProject\Canary\Bin\Canary as Debug; use DateTimeZone; class Forms { @@ -66,6 +67,9 @@ class Forms { case 'checkbox': $fieldHtml = self::getCheckboxHtml( $fieldname, $defaultValue ); break; + case 'switch': + $fieldHtml = self::getSwitchHtml( $fieldname, $defaultValue ); + break; case 'timezone': $fieldHtml = self::getTimezoneHtml( $defaultValue ); break; @@ -76,19 +80,18 @@ class Forms { Debug::error( "unknown field type: $type" ); break; } - $out .= '
'; - $out .= ''; - $out .= '
'; + + $out .= '
'; + $out .= ''; $out .= $fieldHtml; - $out .= '
'; // @todo need to remove this or make it more generic (can't depend on bedrock anymore) if ( 'file' === $type ) { $out .= '
'; - $out .= 'User Avatar'; + $out .= 'User Avatar'; $out .= '
'; } $out .= '
'; - return $out; + return Template::parse( $out ); } public static function getTimezoneHtml( $default ) { @@ -117,7 +120,8 @@ class Forms { } else { $checked = ''; } - return ''; + return '
+
'; } public static function getTextHtml( $name, $default = '' ) { @@ -133,7 +137,8 @@ class Forms { public static function getSelectHtml( $name, $options, $default = null ) { $out = ' +
'; + return $out; + } } diff --git a/classes/issues.php b/classes/issues.php index 3c72b59..90ffc8e 100644 --- a/classes/issues.php +++ b/classes/issues.php @@ -37,6 +37,9 @@ class Issues { $child = [ $child ]; } foreach ( $child as $children ) { + if ( ! is_string( $children ) ) { + $children = var_export( $children, true ); + } $out .= '
  • ' . $children . '
  • '; } $out .= ''; diff --git a/classes/navigation.php b/classes/navigation.php index 222656e..7337079 100644 --- a/classes/navigation.php +++ b/classes/navigation.php @@ -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 = '' . $link['text'] . ''; + $data = ''; 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 .= '
  • - + $list .= '
  • '; break; } - - $allCrumbs .= '' . ucfirst( $crumb ) . ''; + $allCrumbs .= ''; } - Components::set( $breadcrumb_component, $allCrumbs ); + $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. diff --git a/classes/template.php b/classes/template.php index 4e806a4..6d65beb 100644 --- a/classes/template.php +++ b/classes/template.php @@ -36,7 +36,7 @@ class Template { */ public function __construct() { Debug::group( 'Template Constructor', 1 ); - Components::set( 'SITENAME', 'Houdini Site' ); + Components::set( 'SITENAME', APP_NAME ); Components::set( 'ROOT_URL', Routes::getRoot() ); Components::set( 'ROOT_ADDRESS', Routes::getAddress() ); Components::set( 'TITLE', '' ); @@ -49,25 +49,25 @@ class Template { Filters::add( 'issues', '#{ISSUES}(.*?){/ISSUES}#is', ( Issues::hasIssues() ? '$1' : '' ), true ); $notices = implode( '
    ', Issues::getNoticeMessages() ); if ( !empty( $notices ) ) { - $notices = ''; + $notices = ''; } Components::set( 'NOTICE', $notices ); $successes = implode( '
    ', Issues::getSuccessMessages() ); if ( !empty( $successes ) ) { - $successes = ''; + $successes = ''; } Components::set( 'SUCCESS', $successes ); $errors = implode( '
    ', Issues::getErrorMessages() ); if ( !empty( $errors ) ) { - $errors = ''; + $errors = ''; } Components::set( 'ERROR', $errors ); $infos = implode( '
    ', Issues::getInfoMessages() ); if ( !empty( $infos ) ) { - $infos = ''; + $infos = ''; } Components::set( 'INFO', $infos ); } diff --git a/config/constants.php b/config/constants.php index 17f0e2a..4b98ce3 100644 --- a/config/constants.php +++ b/config/constants.php @@ -6,6 +6,9 @@ if ( ! defined( 'HOUDINI_ROOT_DIRECTORY' ) ) { if ( ! defined( 'HOUDINI_CONFIG_DIRECTORY' ) ) { define( 'HOUDINI_CONFIG_DIRECTORY', HOUDINI_ROOT_DIRECTORY . 'config' . DIRECTORY_SEPARATOR ); } +if (!defined('APP_NAME')) { + define('APP_NAME', 'Houdini Site'); +} // # Tell the app all constants have been loaded. if ( ! defined('HOUDINI_CONSTANTS_LOADED' ) ) { define( 'HOUDINI_CONSTANTS_LOADED', true );