Compare commits
15 Commits
Author | SHA1 | Date | |
---|---|---|---|
2c7538471a | |||
21ef1ba8c9 | |||
4c9c9b6023 | |||
4fd9d8c06c | |||
d2aea39758 | |||
c8c2e70ec8 | |||
83974a0b84 | |||
fb027a4ebc | |||
b03fc3b7dd | |||
61589b35ff | |||
d9e61d3f8f | |||
8e377d0882 | |||
ea7ea1286c | |||
1d71b4fd13 | |||
de930d00c9 |
@ -1,46 +0,0 @@
|
||||
# Contributor Covenant Code of Conduct
|
||||
|
||||
## Our Pledge
|
||||
|
||||
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
|
||||
|
||||
## Our Standards
|
||||
|
||||
Examples of behavior that contributes to creating a positive environment include:
|
||||
|
||||
* Using welcoming and inclusive language
|
||||
* Being respectful of differing viewpoints and experiences
|
||||
* Gracefully accepting constructive criticism
|
||||
* Focusing on what is best for the community
|
||||
* Showing empathy towards other community members
|
||||
|
||||
Examples of unacceptable behavior by participants include:
|
||||
|
||||
* The use of sexualized language or imagery and unwelcome sexual attention or advances
|
||||
* Trolling, insulting/derogatory comments, and personal or political attacks
|
||||
* Public or private harassment
|
||||
* Publishing others' private information, such as a physical or electronic address, without explicit permission
|
||||
* Other conduct which could reasonably be considered inappropriate in a professional setting
|
||||
|
||||
## Our Responsibilities
|
||||
|
||||
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
|
||||
|
||||
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
|
||||
|
||||
## Scope
|
||||
|
||||
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
|
||||
|
||||
## Enforcement
|
||||
|
||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at webmaster@thetempusproject.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
|
||||
|
||||
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
|
||||
|
||||
## Attribution
|
||||
|
||||
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
|
||||
|
||||
[homepage]: http://contributor-covenant.org
|
||||
[version]: http://contributor-covenant.org/version/1/4/
|
@ -1,94 +0,0 @@
|
||||
# Contribution Guidelines for Houdini
|
||||
|
||||
Contributing to Houdini is completely voluntary and should follow all of the guidelines listed here in order to ensure the highest probability of acceptance. It is highly recommended to use a php linter to automate more of this process. The project is maintained on github and all contributions need to be submitted via pull request to their specific repository under the `dev` branch. In order to contribute, simply follow the instructions for [creating a pull request](#creating-a-pull-request) below.
|
||||
|
||||
## Pull Request Requirements
|
||||
|
||||
- All revisions must follow TTP naming conventions (see [Naming Conventions](#naming-conventions) Section)
|
||||
- Include a clear and concise explanation of the features or changes included in your revision listed by file.
|
||||
- All code must follow [PSR 2](http://www.php-fig.org/psr/psr-2/) standards
|
||||
- prefer the use of [] for arrays over array()
|
||||
- All functions must be documented with the exception of controller methods (see [Documentation](#documentation) Section)
|
||||
- Controller methods may be doc-blocked when necessary for clarity (see [Documentation](#documentation) Section)
|
||||
- All new Classes must include a class level doc-block (see [Documentation](#documentation) Section)
|
||||
- Any new dependencies will have a longer validation process and should be accompanied by the required information (see [Dependencies](#dependencies) Section)
|
||||
|
||||
## Naming Conventions
|
||||
|
||||
- File names are to be lower case
|
||||
- All class names must be upper case
|
||||
- Any data being stored as a file must be saved in the `app/` directory, preferably the `app/config/` directory.
|
||||
- Controllers must have a constructor and destructor incorporating the constructor and destructor in the Resources Controller
|
||||
- (This will be an interface requirement soon)
|
||||
- Views must be named using underscores for separation and must be prefixed with view_
|
||||
|
||||
## Dependencies
|
||||
|
||||
Whenever a dependency is updated or added, pull requests must include a section that answers the following questions.
|
||||
- Why is this dependency required
|
||||
- Could this be reasonably accomplished within the app by implementing new features in a later version? explain.
|
||||
- What is the latest stable version that can be used
|
||||
- What features are absolutely necessary for your feature or modification to work
|
||||
|
||||
## Documentation
|
||||
|
||||
### Classes
|
||||
|
||||
New classes must be prefaced with a doc-block following this style:
|
||||
```
|
||||
/**
|
||||
* controllers/admin.php
|
||||
*
|
||||
* This is the admin controller.
|
||||
*
|
||||
* @version 3.0
|
||||
* @author Joey Kimsey <Joey@thetempusproject.com>
|
||||
* @link https://TheTempusProject.com/Houdini
|
||||
* @license https://opensource.org/licenses/MIT [MIT LICENSE]
|
||||
*/
|
||||
```
|
||||
|
||||
From top to bottom:
|
||||
- Filename on the second line
|
||||
- A description for the file
|
||||
- The TTP version this file was built for
|
||||
`@version 1.0`
|
||||
- The Authors name or alias and email
|
||||
`@author first last <email@link.com>`
|
||||
- A copy of the MIT license
|
||||
`@license https://opensource.org/licenses/MIT [MIT LICENSE]`
|
||||
- May include a link for more information
|
||||
`@link http://link.com`
|
||||
|
||||
### Functions
|
||||
|
||||
Functions must be prefaced with a doc-block following this style:
|
||||
```
|
||||
/**
|
||||
* Intended as a self-destruct session. If the specified session does not
|
||||
* exist, it is created. If the specified session does exist, it will be
|
||||
* destroyed and returned.
|
||||
*
|
||||
* @param string $name - Session name to be created or checked
|
||||
* @param string $string - The string to be used if session needs to be
|
||||
* created. (optional)
|
||||
*
|
||||
* @return bool|string - Returns bool if creating, and a string if the
|
||||
* check is successful.
|
||||
*/
|
||||
```
|
||||
|
||||
From top to bottom:
|
||||
- There must be a description of the functions intended usage on the second line
|
||||
- All parameters should be documented like this
|
||||
`@param [type] $name - description`
|
||||
- Any function with a return statement must also be documented as such
|
||||
`@return [type] - description`
|
||||
|
||||
## Creating a Pull Request
|
||||
This is a simple explanation of how to create a pull request for changes to Houdini. You can find a detailed walk-through on how to [create a pull request](https://help.github.com/articles/creating-a-pull-request/) on github.
|
||||
|
||||
1. First ensure you have followed all the contributing guidelines
|
||||
2. Squash your merge into a single revision. This will make it easier to view the changes as a whole.
|
||||
3. You can submit a pull request [here](https://github.com/TheTempusProject/Houdini/compare)
|
||||
4. Please submit all pull requests to the dev branch or they will be ignored.
|
2
LICENSE
2
LICENSE
@ -1,6 +1,6 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2024 Joey Kimsey
|
||||
Copyright (c) 2025 Joey Kimsey
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
52
README.md
52
README.md
@ -1,3 +1,4 @@
|
||||
|
||||
# Houdini
|
||||
|
||||
Houdini is a php templating engine designed in conjunction with [The Tempus Project](https://thetempusproject.com). This package allows you to store output as variables and plug it in to templates and formatted html either for direct display or cache assets to be rendered together as a completed page.
|
||||
@ -6,10 +7,50 @@ This functionality applies to several commonly utilized page components such as
|
||||
|
||||
## Installation
|
||||
|
||||
You can install houdini either using composer or its included autoload functionality in the bin folder.
|
||||
To install simply use the composer command:
|
||||
|
||||
`php composer.phar require thetempusproject/houdini`
|
||||
|
||||
## Usage
|
||||
|
||||
Typical usage would be through including the package via composer.
|
||||
|
||||
```php
|
||||
|
||||
require_once VENDOR_DIRECTORY . 'autoload.php';
|
||||
|
||||
use TheTempusProject\Houdini\Classes\Template;
|
||||
|
||||
new Template;
|
||||
Template::setTemplate( 'default' );
|
||||
|
||||
```
|
||||
|
||||
If you would like to use hermes autoloading, simply inclode the constants file and the autoload file inside `/bin/`.
|
||||
|
||||
```php
|
||||
|
||||
use TheTempusProject\Houdini\Classes\Template;
|
||||
|
||||
// Houdini Constants
|
||||
if ( ! defined( 'HOUDINI_CONSTANTS_LOADED' ) ) {
|
||||
if ( defined( 'HOUDINI_CONFIG_DIRECTORY' ) ) {
|
||||
require_once HOUDINI_CONFIG_DIRECTORY . 'constants.php';
|
||||
}
|
||||
}
|
||||
|
||||
// Houdini Autoloader (Autoloader)
|
||||
if ( ! defined( 'HOUDINI_AUTOLOADED' ) ) {
|
||||
if ( defined( 'HOUDINI_ROOT_DIRECTORY' ) ) {
|
||||
require_once HOUDINI_ROOT_DIRECTORY . 'bin' . DIRECTORY_SEPARATOR . 'autoload.php';
|
||||
}
|
||||
}
|
||||
|
||||
new Template;
|
||||
Template::setTemplate( 'default' );
|
||||
|
||||
```
|
||||
|
||||
### Components
|
||||
### Email
|
||||
### Filters
|
||||
@ -21,3 +62,12 @@ You can install houdini either using composer or its included autoload functiona
|
||||
|
||||
## Constants / Settings
|
||||
|
||||
|
||||
|
||||
## Issues / Bugs / Contact
|
||||
|
||||
If anyone actually uses this library and runs into any issues, feel free to contact me and I'll look into it.
|
||||
|
||||
[Joey Kimsey](mailto:Joey@thetempusproject.com) - _Lead Developer_
|
||||
|
||||
[JoeyKimsey.com](https://JoeyKimsey.com)
|
||||
|
@ -4,9 +4,9 @@
|
||||
*
|
||||
* Handles the initial setup like autoloading, basic functions, constants, etc.
|
||||
*
|
||||
* @version 3.0
|
||||
* @version 2.0.3
|
||||
* @author Joey Kimsey <Joey@thetempusproject.com>
|
||||
* @link https://TheTempusProject.com/houdini
|
||||
* @link https://TheTempusProject.com/libraries/Houdini
|
||||
* @license https://opensource.org/licenses/MIT [MIT LICENSE]
|
||||
*/
|
||||
namespace TheTempusProject\Houdini;
|
||||
|
@ -4,9 +4,9 @@
|
||||
*
|
||||
* This class is for managing template components.
|
||||
*
|
||||
* @version 3.0
|
||||
* @version 2.0.3
|
||||
* @author Joey Kimsey <Joey@thetempusproject.com>
|
||||
* @link https://TheTempusProject.com/Houdini
|
||||
* @link https://TheTempusProject.com/libraries/Houdini
|
||||
* @license https://opensource.org/licenses/MIT [MIT LICENSE]
|
||||
*/
|
||||
namespace TheTempusProject\Houdini\Classes;
|
||||
@ -36,12 +36,24 @@ class Components {
|
||||
self::$components[ $name ] = $value;
|
||||
return true;
|
||||
}
|
||||
public static function setIfNull( $name, $value = '' ) {
|
||||
if ( ! empty( self::$components[ $name ] ) ) {
|
||||
return;
|
||||
}
|
||||
if ( null == $value ) {
|
||||
$value = '';
|
||||
}
|
||||
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 );
|
||||
@ -50,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;
|
||||
}
|
||||
}
|
||||
|
@ -4,9 +4,9 @@
|
||||
*
|
||||
* This class is for managing template filters.
|
||||
*
|
||||
* @version 3.0
|
||||
* @version 2.0.3
|
||||
* @author Joey Kimsey <Joey@thetempusproject.com>
|
||||
* @link https://TheTempusProject.com/Core
|
||||
* @link https://TheTempusProject.com/libraries/Houdini
|
||||
* @license https://opensource.org/licenses/MIT [MIT LICENSE]
|
||||
*/
|
||||
namespace TheTempusProject\Houdini\Classes;
|
||||
@ -48,7 +48,20 @@ class Filters {
|
||||
}
|
||||
foreach ( self::$filters as $pattern ) {
|
||||
if ( $pattern['enabled'] || false !== $force ) {
|
||||
$data = trim( preg_replace( $pattern['match'], $pattern['replace'], $data ) );
|
||||
if ( ! empty( $pattern['callback'] ) && is_array( $pattern['callback'] ) ) {
|
||||
$result = preg_replace_callback(
|
||||
$pattern['match'],
|
||||
$pattern['callback'],
|
||||
$data
|
||||
);
|
||||
} else {
|
||||
$result = preg_replace(
|
||||
$pattern['match'],
|
||||
$pattern['replace'],
|
||||
$data
|
||||
);
|
||||
}
|
||||
$data = trim( $result );
|
||||
}
|
||||
}
|
||||
return $data;
|
||||
@ -59,14 +72,21 @@ class Filters {
|
||||
return $data;
|
||||
}
|
||||
if ( self::$filters[$name]['enabled'] || false !== $force ) {
|
||||
$data = trim(
|
||||
preg_replace(
|
||||
if ( ! empty( self::$filters[$name]['callback'] ) && is_array( self::$filters[$name]['callback'] ) ) {
|
||||
$result = preg_replace_callback(
|
||||
self::$filters[$name]['match'],
|
||||
self::$filters[$name]['callback'],
|
||||
$data
|
||||
);
|
||||
} else {
|
||||
$result = preg_replace(
|
||||
self::$filters[$name]['match'],
|
||||
self::$filters[$name]['replace'],
|
||||
$data
|
||||
)
|
||||
);
|
||||
}
|
||||
$data = trim( $result );
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
@ -78,12 +98,21 @@ class Filters {
|
||||
* @param {string} [$replace]
|
||||
* @param {bool} [$enabled] - Whether the filter should be enabled or disabled.
|
||||
*/
|
||||
public static function add( $filterName, $match, $replace, $enabled = false ) {
|
||||
public static function add( $filterName, $match, $replace, $enabled = false, $callback = false ) {
|
||||
if ( isset( self::$filters[$filterName] ) ) {
|
||||
Debug::error( "Filter already exists: $filterName" );
|
||||
return;
|
||||
}
|
||||
self::$filters[$filterName] = [
|
||||
if ( $callback === true ) {
|
||||
self::$filters[ $filterName ] = [
|
||||
'name' => $filterName,
|
||||
'match' => $match,
|
||||
'callback' => $replace,
|
||||
'enabled' => $enabled,
|
||||
];
|
||||
return;
|
||||
}
|
||||
self::$filters[ $filterName ] = [
|
||||
'name' => $filterName,
|
||||
'match' => $match,
|
||||
'replace' => $replace,
|
||||
|
@ -4,13 +4,14 @@
|
||||
*
|
||||
* This class is for managing template forms.
|
||||
*
|
||||
* @version 3.0
|
||||
* @version 2.0.3
|
||||
* @author Joey Kimsey <Joey@thetempusproject.com>
|
||||
* @link https://TheTempusProject.com/Core
|
||||
* @link https://TheTempusProject.com/libraries/Houdini
|
||||
* @license https://opensource.org/licenses/MIT [MIT LICENSE]
|
||||
*/
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -4,9 +4,9 @@
|
||||
*
|
||||
* This class is for managing template issues.
|
||||
*
|
||||
* @version 3.0
|
||||
* @version 2.0.3
|
||||
* @author Joey Kimsey <Joey@thetempusproject.com>
|
||||
* @link https://TheTempusProject.com/Core
|
||||
* @link https://TheTempusProject.com/libraries/Houdini
|
||||
* @license https://opensource.org/licenses/MIT [MIT LICENSE]
|
||||
*/
|
||||
namespace TheTempusProject\Houdini\Classes;
|
||||
@ -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>';
|
||||
|
@ -4,9 +4,9 @@
|
||||
*
|
||||
* This class is for managing template navigation including menus, pagination, and breadcrumbs.
|
||||
*
|
||||
* @version 3.0
|
||||
* @version 2.0.3
|
||||
* @author Joey Kimsey <Joey@thetempusproject.com>
|
||||
* @link https://TheTempusProject.com/Core
|
||||
* @link https://TheTempusProject.com/libraries/Houdini
|
||||
* @license https://opensource.org/licenses/MIT [MIT LICENSE]
|
||||
*/
|
||||
namespace TheTempusProject\Houdini\Classes;
|
||||
|
@ -4,9 +4,9 @@
|
||||
*
|
||||
* This class is for managing template navigation including menus, pagination, and breadcrumbs.
|
||||
*
|
||||
* @version 3.0
|
||||
* @version 2.0.3
|
||||
* @author Joey Kimsey <Joey@thetempusproject.com>
|
||||
* @link https://TheTempusProject.com/Core
|
||||
* @link https://TheTempusProject.com/libraries/Houdini
|
||||
* @license https://opensource.org/licenses/MIT [MIT LICENSE]
|
||||
*/
|
||||
namespace TheTempusProject\Houdini\Classes;
|
||||
@ -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.
|
||||
@ -166,41 +186,58 @@ class Navigation extends Template {
|
||||
$selectString = ltrim( Routes::getUri(false), '/' );
|
||||
}
|
||||
|
||||
$explodedUrl = explode( '/', $selectString );
|
||||
|
||||
$variations = [
|
||||
Routes::getRequestUrl(),
|
||||
Routes::getAddress() . $selectString,
|
||||
$selectString,
|
||||
Routes::getUri(),
|
||||
Routes::getUri(false),
|
||||
Routes::getAddress() . $selectString,
|
||||
Routes::getAddress() . $explodedUrl[0],
|
||||
$selectString,
|
||||
$explodedUrl[0],
|
||||
'/' . $explodedUrl[0],
|
||||
'/' . $explodedUrl[0] . '/',
|
||||
$explodedUrl[0] . '/index',
|
||||
'/' . $explodedUrl[0] . '/index',
|
||||
'/' . $explodedUrl[0] . '/index/',
|
||||
];
|
||||
|
||||
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 ) ) {
|
||||
$explodedUrl = explode( '/', $selectString );
|
||||
|
||||
$explodedUrlCopy = $explodedUrl;
|
||||
$variations = [];
|
||||
foreach ( $explodedUrl as $key => $section ) {
|
||||
$variations[] = Routes::getAddress() . implode( '/', $explodedUrlCopy );
|
||||
$variations[] = implode( '/', $explodedUrlCopy );
|
||||
$variations[] = '/' . implode( '/', $explodedUrlCopy );
|
||||
$variations[] = '/' . implode( '/', $explodedUrlCopy ) . '/';
|
||||
$variations[] = implode( '/', $explodedUrlCopy ) . '/index';
|
||||
$variations[] = '/' . implode( '/', $explodedUrlCopy ) . '/index';
|
||||
$variations[] = '/' . implode( '/', $explodedUrlCopy ) . '/index/';
|
||||
array_pop( $explodedUrlCopy );
|
||||
}
|
||||
|
||||
foreach ( $variations as $key => $url ) {
|
||||
$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\"><a href=\"$regSelect\" class=\"$3 active\"$4>";
|
||||
$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\"$5>";
|
||||
$view = preg_replace( $parentRegex, $expandRegex, $view );
|
||||
}
|
||||
|
||||
if ( !empty( $addToContent ) ) {
|
||||
self::$content .= $view;
|
||||
return true;
|
||||
|
@ -7,17 +7,16 @@
|
||||
* into HTML, including: bbcodes, the data replacement structure, the
|
||||
* filters, and other variables used to display application content.
|
||||
*
|
||||
* @version 3.0
|
||||
* @version 2.0.3
|
||||
* @author Joey Kimsey <Joey@thetempusproject.com>
|
||||
* @link https://TheTempusProject.com/Core
|
||||
* @link https://TheTempusProject.com/libraries/Houdini
|
||||
* @license https://opensource.org/licenses/MIT [MIT LICENSE]
|
||||
*/
|
||||
namespace TheTempusProject\Houdini\Classes;
|
||||
|
||||
use TheTempusProject\Canary\Bin\Canary as Debug;
|
||||
use TheTempusProject\Canary\Classes\CustomException;
|
||||
use TheTempusProject\Hermes\Functions\Route as Routes;
|
||||
// use TheTempusProject\Bedrock\Functions\Date;
|
||||
// use TheTempusProject\Bedrock\Classes\CustomException;
|
||||
use TheTempusProject\Houdini\Classes\Components;
|
||||
use TheTempusProject\Houdini\Classes\Forms;
|
||||
use TheTempusProject\Houdini\Classes\Filters;
|
||||
@ -37,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', '' );
|
||||
@ -50,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 );
|
||||
}
|
||||
@ -108,7 +107,7 @@ class Template {
|
||||
return self::loadTemplate( $location, $name );
|
||||
}
|
||||
}
|
||||
// new CustomException( 'template', $docLocation );
|
||||
new CustomException( 'template', $docLocation );
|
||||
}
|
||||
|
||||
/**
|
||||
@ -126,7 +125,7 @@ class Template {
|
||||
$fullPath = $path . $name . '.inc.php';
|
||||
$className = APP_SPACE . '\\Templates\\' . ucfirst( $name ) . 'Loader';
|
||||
if ( !file_exists( $fullPath ) ) {
|
||||
// new CustomException( 'templateLoader', $fullPath );
|
||||
new CustomException( 'templateLoader', $fullPath );
|
||||
} else {
|
||||
Debug::log( 'Requiring template loader: ' . $name );
|
||||
require_once $fullPath;
|
||||
@ -202,7 +201,7 @@ class Template {
|
||||
self::buildRobot();
|
||||
self::buildHeaders();
|
||||
if ( empty( self::$templateLocation ) ) {
|
||||
// throw an error here @todo
|
||||
new CustomException( 'templateLocation', self::$templateLocation );
|
||||
return;
|
||||
}
|
||||
if ( !Debug::status( 'render' ) ) {
|
||||
@ -315,7 +314,6 @@ class Template {
|
||||
* be used as components for the provided html.
|
||||
* @return string - The fully parsed html output.
|
||||
*/
|
||||
|
||||
public static function parse( $template, $data = null, $flags = null ) {
|
||||
if ( empty( $template ) ) {
|
||||
return $template;
|
||||
@ -330,22 +328,6 @@ class Template {
|
||||
$template = preg_replace( '#\{OPTION\=(.*?)\}#is', '', $template );
|
||||
}
|
||||
|
||||
//Convert any dates into preferred Date/Time format. User preference will be applied her in the future.
|
||||
// @todo - there must be something to migrate this ability from the top to the bottom when a user has a pref
|
||||
$dtc = '#{DTC(.*?)}(.*?){/DTC}#is';
|
||||
|
||||
$template = preg_replace_callback(
|
||||
$dtc,
|
||||
function ( $data ) {
|
||||
if ( empty( $data[2] ) ) {
|
||||
return '';
|
||||
}
|
||||
return $data[2]; // @todo need a way to decouple this from houdini to bedrock
|
||||
// return Date::formatTimestamp( $data[1], $data[2] );
|
||||
},
|
||||
$template
|
||||
);
|
||||
|
||||
//Run through our full list of generated filters.
|
||||
$template = Filters::apply( $template );
|
||||
|
||||
|
@ -4,14 +4,15 @@
|
||||
*
|
||||
* This class is for managing template views.
|
||||
*
|
||||
* @version 3.0
|
||||
* @version 2.0.3
|
||||
* @author Joey Kimsey <Joey@thetempusproject.com>
|
||||
* @link https://TheTempusProject.com/Core
|
||||
* @link https://TheTempusProject.com/libraries/Houdini
|
||||
* @license https://opensource.org/licenses/MIT [MIT LICENSE]
|
||||
*/
|
||||
namespace TheTempusProject\Houdini\Classes;
|
||||
|
||||
use TheTempusProject\Canary\Bin\Canary as Debug;
|
||||
use TheTempusProject\Canary\Classes\CustomException;
|
||||
|
||||
class Views extends Template {
|
||||
public static $additionalLocations = [];
|
||||
@ -34,7 +35,7 @@ class Views extends Template {
|
||||
if ( !empty( $out ) ) {
|
||||
self::$content .= $out;
|
||||
} else {
|
||||
// new CustomException( 'view', $viewName );
|
||||
new CustomException( 'view', $viewName );
|
||||
}
|
||||
}
|
||||
|
||||
@ -96,7 +97,7 @@ class Views extends Template {
|
||||
}
|
||||
}
|
||||
// @todo - this would be awesome, if i actually caught the exception anywhere :/
|
||||
// throw new CustomException('simpleView', $path);
|
||||
new CustomException('simpleView', $path);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1,17 +1,17 @@
|
||||
{
|
||||
"name": "thetempusproject/houdini",
|
||||
"type": "library",
|
||||
"description": "Php functions that aid in creating, managing, and displaying frontend components.",
|
||||
"description": "This library handles creating, managing, and displaying frontend components.",
|
||||
"license": "MIT",
|
||||
"minimum-stability": "dev",
|
||||
"keywords":
|
||||
[
|
||||
"thetempusproject",
|
||||
"php",
|
||||
"tools",
|
||||
"frontend",
|
||||
"thetempusproject"
|
||||
"frontend"
|
||||
],
|
||||
"homepage": "https://git.thetempusproject.com/the-tempus-project/houdini",
|
||||
"homepage": "https://thetempusproject.com/libraries/houdini",
|
||||
"authors":
|
||||
[
|
||||
{
|
||||
@ -24,8 +24,8 @@
|
||||
"require":
|
||||
{
|
||||
"php": ">=8.1.0",
|
||||
"thetempusproject/canary": ">=1.0",
|
||||
"thetempusproject/hermes": ">=1.0"
|
||||
"thetempusproject/canary": "1.0.9",
|
||||
"thetempusproject/hermes": "1.0.5"
|
||||
},
|
||||
"autoload":
|
||||
{
|
||||
|
36
composer.lock
generated
36
composer.lock
generated
@ -4,29 +4,28 @@
|
||||
"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": "40dc79a68776099a4256f22fbd1a1076",
|
||||
"packages": [
|
||||
{
|
||||
"name": "thetempusproject/canary",
|
||||
"version": "dev-main",
|
||||
"version": "1.0.9",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://git.thetempusproject.com/the-tempus-project/canary",
|
||||
"reference": "7ce988fbd95c0d9b975e7647f2e4d7ee3d5e3aad"
|
||||
"reference": "77cef522e9919573836901eb82b59b20f453fb61"
|
||||
},
|
||||
"require": {
|
||||
"php": ">=8.1.0"
|
||||
},
|
||||
"default-branch": true,
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"files": [
|
||||
"Config/constants.php",
|
||||
"Bin/Canary.php"
|
||||
"config/constants.php",
|
||||
"bin/canary.php"
|
||||
],
|
||||
"psr-4": {
|
||||
"TheTempusProject\\Canary\\Classes\\": "Classes"
|
||||
}
|
||||
"classmap": [
|
||||
"classes"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
@ -41,27 +40,27 @@
|
||||
}
|
||||
],
|
||||
"description": "Functionality for tracking, logging, and sending log messages to chrome for debugging.",
|
||||
"homepage": "https://git.thetempusproject.com/the-tempus-project/canary",
|
||||
"homepage": "https://thetempusproject.com/libraries/canary",
|
||||
"keywords": [
|
||||
"debugging",
|
||||
"logging",
|
||||
"php",
|
||||
"thetempusproject",
|
||||
"tools"
|
||||
],
|
||||
"time": "2024-08-10T18:58:57+00:00"
|
||||
"time": "2025-02-04T12:16:29+00:00"
|
||||
},
|
||||
{
|
||||
"name": "thetempusproject/hermes",
|
||||
"version": "dev-main",
|
||||
"version": "1.0.5",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://git.thetempusproject.com/the-tempus-project/hermes",
|
||||
"reference": "171183c0abdbbdf12b3b577821636dd1c51ec752"
|
||||
"reference": "802581b1d2d70877ccc75d8954b33efcc05d9371"
|
||||
},
|
||||
"require": {
|
||||
"php": ">=8.1.0"
|
||||
},
|
||||
"default-branch": true,
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"files": [
|
||||
@ -84,15 +83,16 @@
|
||||
"role": "Lead Developer"
|
||||
}
|
||||
],
|
||||
"description": "Php functions that aid in routing and redirecting; requests and responses.",
|
||||
"homepage": "https://git.thetempusproject.com/the-tempus-project/hermes",
|
||||
"description": "This library handles redirects, provides a common backbone for routing, and can handle autoloading in cases where composer is unavailable.",
|
||||
"homepage": "https://thetempusproject.com/libraries/hermes",
|
||||
"keywords": [
|
||||
"autoloader",
|
||||
"php",
|
||||
"routing",
|
||||
"thetempusproject",
|
||||
"tools"
|
||||
],
|
||||
"time": "2024-08-13T02:56:27+00:00"
|
||||
"time": "2025-02-02T23:22:15+00:00"
|
||||
}
|
||||
],
|
||||
"packages-dev": [],
|
||||
@ -105,5 +105,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