Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
fb027a4ebc | |||
b03fc3b7dd | |||
61589b35ff |
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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 .= '<div class="form-group">';
|
||||
$out .= '<label for="' . $fieldname . '" class="col-lg-3 control-label">' . $fieldTitle . '</label>';
|
||||
$out .= '<div class="col-lg-3">';
|
||||
|
||||
$out .= '<div class="mb-3">';
|
||||
$out .= '<label for="' . $fieldname . '" class="form-label">' . $fieldTitle . '</label>';
|
||||
$out .= $fieldHtml;
|
||||
$out .= '</div>';
|
||||
// @todo need to remove this or make it more generic (can't depend on bedrock anymore)
|
||||
if ( 'file' === $type ) {
|
||||
$out .= '<div class="col-lg-3 avatar-125" align="center">';
|
||||
$out .= '<img alt="User Avatar" src="' . $defaultValue . '" class="img-circle img-responsive">';
|
||||
$out .= '<img alt="User Avatar" src="{ROOT_URL}' . $defaultValue . '" class="img-circle img-fluid p-2">';
|
||||
$out .= '</div>';
|
||||
}
|
||||
$out .= '</div>';
|
||||
return $out;
|
||||
return Template::parse( $out );
|
||||
}
|
||||
|
||||
public static function getTimezoneHtml( $default ) {
|
||||
@ -117,7 +120,8 @@ class Forms {
|
||||
} else {
|
||||
$checked = '';
|
||||
}
|
||||
return '<input type="checkbox" class="form-control" name="' . $name . '" id="' . $name . '" value="true"' . $checked . '>';
|
||||
return '<div class="form-check"><input class="form-check-input" type="checkbox" value="true" name="' . $name . '" id="' . $name . '"' . $checked . '>
|
||||
<label class="form-check-label" for="' . $name . '">' . ucfirst($name) . '</label></div>';
|
||||
}
|
||||
|
||||
public static function getTextHtml( $name, $default = '' ) {
|
||||
@ -133,7 +137,8 @@ class Forms {
|
||||
|
||||
public static function getSelectHtml( $name, $options, $default = null ) {
|
||||
$out = '<select name="' . $name . '" id="' . $name . '" class="form-control">';
|
||||
if ( !is_string( $options ) ) {
|
||||
|
||||
if ( is_iterable( $options ) ) {
|
||||
$out .= self::getOptionsHtml( $options, $default );
|
||||
} else {
|
||||
$out .= $options;
|
||||
@ -190,4 +195,17 @@ class Forms {
|
||||
</fieldset>';
|
||||
return $out;
|
||||
}
|
||||
|
||||
public static function getSwitchHtml( $name, $default = null ) {
|
||||
$checked = '';
|
||||
|
||||
if ( ! empty( $default ) ) {
|
||||
$checked = ' checked="checked"';
|
||||
}
|
||||
|
||||
$out = '<div class="mb-3 form-check form-switch">
|
||||
<input class="form-check-input" type="checkbox" role="switch" name="' . $name . '" id="' . $name . '" value="true"' . $checked . '>
|
||||
</div>';
|
||||
return $out;
|
||||
}
|
||||
}
|
||||
|
@ -37,6 +37,9 @@ class Issues {
|
||||
$child = [ $child ];
|
||||
}
|
||||
foreach ( $child as $children ) {
|
||||
if ( ! is_string( $children ) ) {
|
||||
$children = var_export( $children, true );
|
||||
}
|
||||
$out .= '<li>' . $children . '</li>';
|
||||
}
|
||||
$out .= '</ul>';
|
||||
|
@ -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.
|
||||
@ -174,6 +194,7 @@ class Navigation extends Template {
|
||||
Routes::getUri(false),
|
||||
Routes::getAddress() . $selectString,
|
||||
Routes::getAddress() . $explodedUrl[0],
|
||||
'/' . $selectString,
|
||||
$selectString,
|
||||
$explodedUrl[0],
|
||||
'/' . $explodedUrl[0],
|
||||
@ -184,23 +205,23 @@ class Navigation extends Template {
|
||||
];
|
||||
|
||||
foreach ( $variations as $url ) {
|
||||
$regex = "#(.*)<li(?: class=\")?(.*?)(?:\")?>\s*?<a href=\"$url\"(.*)#is";
|
||||
$regex = "#(.*)<li(?: class=\")?(.*?)(?:\")?>\s*?<a href=\"$url\"(?: class=\")?(.*?)(?:\")>?#is";
|
||||
if ( preg_match( $regex, $view ) ) {
|
||||
$regSelect = $url;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ( !empty( $regSelect ) ) {
|
||||
$regSelect = preg_quote($regSelect);
|
||||
$regActive = "$1<li class=\"$2 active\"><a href=\"$regSelect\"$3";
|
||||
|
||||
if ( ! empty( $regSelect ) ) {
|
||||
$regSelect = preg_quote( $regSelect );
|
||||
$regActive = "$1<li class=\"$2\"><a href=\"$regSelect\" class=\"$3 active\">";
|
||||
$view = preg_replace( $regex, $regActive, $view );
|
||||
$parentRegex = "#(.*)class=\"collapse(.*?)<li class=\"submenu active\">\s*<a href=\"$regSelect\"(.*)#is";
|
||||
|
||||
$parentRegex = "#(.*)class=\"(.*?)collapse(.*?)<li class=\"nav-item\">\s*<a href=\"$regSelect\" class=\"submenu (.*?)\">#is";
|
||||
if ( preg_match( $parentRegex, $view ) ) {
|
||||
$expandRegex = "$1 class=\"expand$2<li class=\"submenu active\"><a href=\"$regSelect\"$3";
|
||||
$expandRegex = "$1 class=\"$2collapse show$3<li class=\"nav-item\"><a href=\"$regSelect\" class=\"submenu active $4\">";
|
||||
$view = preg_replace( $parentRegex, $expandRegex, $view );
|
||||
}
|
||||
|
||||
if ( !empty( $addToContent ) ) {
|
||||
self::$content .= $view;
|
||||
return true;
|
||||
|
@ -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( '<br>', Issues::getNoticeMessages() );
|
||||
if ( !empty( $notices ) ) {
|
||||
$notices = '<div class="alert alert-warning" role="alert">' . $notices . '</div>';
|
||||
$notices = '<div class="alert alert-warning w-100" role="alert">' . $notices . '</div>';
|
||||
}
|
||||
Components::set( 'NOTICE', $notices );
|
||||
|
||||
$successes = implode( '<br>', Issues::getSuccessMessages() );
|
||||
if ( !empty( $successes ) ) {
|
||||
$successes = '<div class="alert alert-success" role="alert">' . $successes . '</div>';
|
||||
$successes = '<div class="alert alert-success w-100" role="alert">' . $successes . '</div>';
|
||||
}
|
||||
Components::set( 'SUCCESS', $successes );
|
||||
|
||||
$errors = implode( '<br>', Issues::getErrorMessages() );
|
||||
if ( !empty( $errors ) ) {
|
||||
$errors = '<div class="alert alert-danger" role="alert">' . $errors . '</div>';
|
||||
$errors = '<div class="alert alert-danger w-100" role="alert">' . $errors . '</div>';
|
||||
}
|
||||
Components::set( 'ERROR', $errors );
|
||||
|
||||
$infos = implode( '<br>', Issues::getInfoMessages() );
|
||||
if ( !empty( $infos ) ) {
|
||||
$infos = '<div class="alert alert-info" role="alert">' . $infos . '</div>';
|
||||
$infos = '<div class="alert alert-info w-100" role="alert">' . $infos . '</div>';
|
||||
}
|
||||
Components::set( 'INFO', $infos );
|
||||
}
|
||||
|
@ -24,8 +24,8 @@
|
||||
"require":
|
||||
{
|
||||
"php": ">=8.1.0",
|
||||
"thetempusproject/canary": ">=1.0",
|
||||
"thetempusproject/hermes": ">=1.0"
|
||||
"thetempusproject/canary": "1.0.6",
|
||||
"thetempusproject/hermes": "1.0.3"
|
||||
},
|
||||
"autoload":
|
||||
{
|
||||
|
18
composer.lock
generated
18
composer.lock
generated
@ -4,20 +4,19 @@
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "a5f3c6aec6567c9b48b59eecc9588183",
|
||||
"content-hash": "22473999e0fcf4a9a664d37a38a750e7",
|
||||
"packages": [
|
||||
{
|
||||
"name": "thetempusproject/canary",
|
||||
"version": "dev-main",
|
||||
"version": "1.0.6",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://git.thetempusproject.com/the-tempus-project/canary",
|
||||
"reference": "35415fbf3c5888ccdb8a8695989176a120026c7f"
|
||||
"reference": "44b2ad688cff933964ec2ff50b408d94c7f51e40"
|
||||
},
|
||||
"require": {
|
||||
"php": ">=8.1.0"
|
||||
},
|
||||
"default-branch": true,
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"files": [
|
||||
@ -48,20 +47,19 @@
|
||||
"thetempusproject",
|
||||
"tools"
|
||||
],
|
||||
"time": "2024-08-20T10:26:09+00:00"
|
||||
"time": "2025-01-22T01:39:34+00:00"
|
||||
},
|
||||
{
|
||||
"name": "thetempusproject/hermes",
|
||||
"version": "dev-main",
|
||||
"version": "1.0.3",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://git.thetempusproject.com/the-tempus-project/hermes",
|
||||
"reference": "31c51c1a5bad2871df800c89f27ace0a49848583"
|
||||
"reference": "4b4e06a98f0f01695bda18de240bb3294d096ef4"
|
||||
},
|
||||
"require": {
|
||||
"php": ">=8.1.0"
|
||||
},
|
||||
"default-branch": true,
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"files": [
|
||||
@ -92,7 +90,7 @@
|
||||
"thetempusproject",
|
||||
"tools"
|
||||
],
|
||||
"time": "2024-08-20T10:26:47+00:00"
|
||||
"time": "2025-01-22T01:43:15+00:00"
|
||||
}
|
||||
],
|
||||
"packages-dev": [],
|
||||
@ -105,5 +103,5 @@
|
||||
"php": ">=8.1.0"
|
||||
},
|
||||
"platform-dev": [],
|
||||
"plugin-api-version": "2.6.0"
|
||||
"plugin-api-version": "2.3.0"
|
||||
}
|
||||
|
@ -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 );
|
||||
|
Reference in New Issue
Block a user