fixes to support composer / packagist
This commit is contained in:
@ -1,7 +1,9 @@
|
||||
# Contribution Guidelines for TempusDebugger
|
||||
Contributing to TempusDebugger 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.
|
||||
# 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
|
||||
@ -12,6 +14,7 @@ Contributing to TempusDebugger is completely voluntary and should follow all of
|
||||
- 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.
|
||||
@ -20,6 +23,7 @@ Contributing to TempusDebugger is completely voluntary and should follow all of
|
||||
- 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.
|
||||
@ -27,6 +31,7 @@ Whenever a dependency is updated or added, pull requests must include a section
|
||||
- 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:
|
||||
@ -38,7 +43,7 @@ New classes must be prefaced with a doc-block following this style:
|
||||
*
|
||||
* @version 3.0
|
||||
* @author Joey Kimsey <Joey@thetempusproject.com>
|
||||
* @link https://TheTempusProject.com/TempusDebugger
|
||||
* @link https://TheTempusProject.com/Houdini
|
||||
* @license https://opensource.org/licenses/MIT [MIT LICENSE]
|
||||
*/
|
||||
```
|
||||
@ -56,6 +61,7 @@ From top to bottom:
|
||||
`@link http://link.com`
|
||||
|
||||
### Functions
|
||||
|
||||
Functions must be prefaced with a doc-block following this style:
|
||||
```
|
||||
/**
|
||||
@ -80,9 +86,9 @@ From top to bottom:
|
||||
`@return [type] - description`
|
||||
|
||||
## Creating a Pull Request
|
||||
This is a simple explanation of how to create a pull request for changes to TempusDebugger. 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.
|
||||
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/TempusDebugger/compare)
|
||||
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.
|
21
LICENSE
Normal file
21
LICENSE
Normal file
@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2024 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
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
11
README.md
11
README.md
@ -1,12 +1,17 @@
|
||||
# Houdini
|
||||
Houdini is a php templating engine designed in conjunction with [The Tempus Project](https://thetempusproject.com). Honestly, I do not know how to explain it other than to show you.
|
||||
|
||||
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.
|
||||
|
||||
This functionality applies to several commonly utilized page components such as navigation, forms, pagination, interface and more.
|
||||
|
||||
## Installation
|
||||
You can install houdini either using composer or its included autoload functionality
|
||||
|
||||
You can install houdini either using composer or its included autoload functionality in the bin folder.
|
||||
|
||||
## Usage
|
||||
|
||||
### Components
|
||||
### Email
|
||||
### Filters
|
||||
### Forms
|
||||
### Issues
|
||||
@ -14,5 +19,5 @@ You can install houdini either using composer or its included autoload functiona
|
||||
### Pagination
|
||||
### Views
|
||||
|
||||
## Settings
|
||||
## Constants / Settings
|
||||
|
||||
|
@ -13,14 +13,8 @@ namespace TheTempusProject\Houdini;
|
||||
|
||||
use TheTempusProject\Hermes\Classes\Autoloader;
|
||||
|
||||
if ( ! defined('HOUDINI_ROOT_DIRECTORY' ) ) {
|
||||
define('HOUDINI_ROOT_DIRECTORY', dirname(__DIR__) . DIRECTORY_SEPARATOR);
|
||||
}
|
||||
if ( ! defined('HOUDINI_CONFIG_DIRECTORY' ) ) {
|
||||
define('HOUDINI_CONFIG_DIRECTORY', BEDROCK_ROOT_DIRECTORY . 'config' . DIRECTORY_SEPARATOR);
|
||||
}
|
||||
if ( ! defined('HOUDINI_CONSTANTS_LOADED' ) ) {
|
||||
require_once HOUDINI_CONFIG_DIRECTORY . 'constants.php';
|
||||
require_once dirname( __DIR__ ) . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'constants.php';
|
||||
}
|
||||
|
||||
$autoloader = new Autoloader;
|
||||
|
@ -1,219 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* classes/email.php
|
||||
*
|
||||
* This is our class for constructing and sending various kinds of emails.
|
||||
*
|
||||
* @version 3.0
|
||||
* @author Joey Kimsey <Joey@thetempusproject.com>
|
||||
* @link https://TheTempusProject.com/Core
|
||||
* @license https://opensource.org/licenses/MIT [MIT LICENSE]
|
||||
*/
|
||||
namespace TheTempusProject\Houdini\Classes;
|
||||
|
||||
use TheTempusProject\Houdini\Classes\Views;
|
||||
use TheTempusProject\Bedrock\Classes\Config;
|
||||
use TheTempusProject\Canary\Canary as Debug;
|
||||
use TheTempusProject\Hermes\Functions\Route as Routes;
|
||||
|
||||
class Email {
|
||||
private static $header = null;
|
||||
private static $subject = null;
|
||||
private static $title = null;
|
||||
private static $message = null;
|
||||
private static $unsub = false;
|
||||
private static $useTemplate = false;
|
||||
private static $footer = null;
|
||||
private static $debug = false;
|
||||
|
||||
/**
|
||||
* Sends pre-constructed email templates. Useful for modifying the
|
||||
* entire theme or layout of the system generated emails.
|
||||
*
|
||||
* @param string $email - The email you are sending to.
|
||||
* @param string $type - The template you wish to send.
|
||||
* @param string|array $params - Any special parameters that may be required from your individual email template.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function send( $email, $type, $params = null, $flags = null ) {
|
||||
if ( !empty( $flags ) ) {
|
||||
if ( is_array( $flags ) ) {
|
||||
foreach ( $flags as $key => $value ) {
|
||||
switch ( $key ) {
|
||||
case 'template':
|
||||
if ( $value == true ) {
|
||||
self::$useTemplate = true;
|
||||
}
|
||||
break;
|
||||
case 'unsubscribe':
|
||||
if ( $value == true ) {
|
||||
self::$unsub = true;
|
||||
}
|
||||
break;
|
||||
case 'debug':
|
||||
if ( $value == true ) {
|
||||
self::$debug = false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
self::build();
|
||||
switch ( $type ) {
|
||||
case 'debug':
|
||||
self::$subject = 'Please Confirm your email at {SITENAME}';
|
||||
self::$title = 'Almost Done';
|
||||
self::$message = 'Please click or copy-paste this link to confirm your registration: <a href="{BASE}register/confirm/{PARAMS}">Confirm Your Email</a>';
|
||||
break;
|
||||
|
||||
case 'confirmation':
|
||||
self::$subject = 'Please Confirm your email at {SITENAME}';
|
||||
self::$title = 'Almost Done';
|
||||
self::$message = 'Please click or copy-paste this link to confirm your registration: <a href="{BASE}register/confirm/{PARAMS}">Confirm Your Email</a>';
|
||||
break;
|
||||
|
||||
case 'install':
|
||||
self::$subject = 'Notification from {SITENAME}';
|
||||
self::$title = 'Installation Success';
|
||||
self::$message = 'This is just a simple email to notify you that you have successfully installed The Tempus Project framework!';
|
||||
break;
|
||||
|
||||
case 'passwordChange':
|
||||
self::$subject = 'Security Notice from {SITENAME}';
|
||||
self::$title = 'Password Successfully Changed';
|
||||
self::$message = 'Recently your password on {SITENAME} was changed. If you are the one who changed the password, please ignore this email.';
|
||||
break;
|
||||
|
||||
case 'emailChangeNotice':
|
||||
self::$subject = 'Account Update from {SITENAME}';
|
||||
self::$title = 'Email Updated';
|
||||
self::$message = 'This is a simple notification to let you know your email has been changed at {SITENAME}.';
|
||||
break;
|
||||
|
||||
case 'emailChange':
|
||||
self::$subject = 'Account Update from {SITENAME}';
|
||||
self::$title = 'Confirm your E-mail';
|
||||
self::$message = 'Please click or copy-paste this link to confirm your new Email: <a href="{BASE}register/confirm/{PARAMS}">Confirm Your Email</a>';
|
||||
break;
|
||||
|
||||
case 'emailNotify':
|
||||
self::$subject = 'Account Update from {SITENAME}';
|
||||
self::$title = 'Email Updated';
|
||||
self::$message = 'You recently changed your email address on {SITENAME}.';
|
||||
break;
|
||||
|
||||
case 'forgotPassword':
|
||||
self::$subject = 'Reset Instructions for {SITENAME}';
|
||||
self::$title = 'Reset your Password';
|
||||
self::$message = 'You recently requested information to change your password at {SITENAME}.<br>Your password reset code is: {PARAMS}<br> Please click or copy-paste this link to reset your password: <a href="{BASE}register/reset/{PARAMS}">Password Reset</a>';
|
||||
break;
|
||||
|
||||
case 'forgotUsername':
|
||||
self::$subject = 'Account Update from {SITENAME}';
|
||||
self::$title = 'Account Details';
|
||||
self::$message = 'Your username for {SITENAME} is {PARAMS}.';
|
||||
break;
|
||||
|
||||
case 'subscribe':
|
||||
self::$subject = 'Thanks for Subscribing';
|
||||
self::$title = 'Thanks for Subscribing!';
|
||||
self::$message = 'Thank you for subscribing to updates from {SITENAME}. If you no longer wish to receive these emails, you can un-subscribe using the link below.';
|
||||
self::$unsub = true;
|
||||
break;
|
||||
|
||||
case 'unsubInstructions':
|
||||
self::$subject = 'Unsubscribe Instructions';
|
||||
self::$title = 'We are sad to see you go';
|
||||
self::$message = 'If you would like to be un-subscribed from future emails from {SITENAME} simply click the link below.<br><br><a href="{BASE}home/unsubscribe/{EMAIL}/{PARAMS}">Click here to unsubscribe</a>';
|
||||
self::$unsub = true;
|
||||
break;
|
||||
|
||||
case 'unsubscribe':
|
||||
self::$subject = 'Unsubscribed';
|
||||
self::$title = 'We are sad to see you go';
|
||||
self::$message = 'This is just a notification that you have successfully been unsubscribed from future emails from {SITENAME}.';
|
||||
break;
|
||||
|
||||
case 'contact':
|
||||
self::$subject = $params['subject'];
|
||||
self::$title = $params['title'];
|
||||
self::$message = $params['message'];
|
||||
break;
|
||||
|
||||
default:
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
if ( self::$useTemplate ) {
|
||||
$data = new \stdClass();
|
||||
if ( self::$unsub ) {
|
||||
$data->UNSUB = Views::simpleView( 'email.unsubscribe' );
|
||||
} else {
|
||||
$data->UNSUB = '';
|
||||
}
|
||||
// $data->LOGO = Config::getValue('main/logo');
|
||||
$data->SITENAME = Config::getValue( 'main/name' );
|
||||
$data->EMAIL = $email;
|
||||
if ( !is_array( $params ) ) {
|
||||
$data->PARAMS = $params;
|
||||
} else {
|
||||
foreach ( $params as $key => $value ) {
|
||||
$data->$key = $value;
|
||||
}
|
||||
}
|
||||
$data->MAIL_FOOT = Views::simpleView( 'email.foot' );
|
||||
$data->MAIL_TITLE = self::$title;
|
||||
$data->MAIL_BODY = Template::parse( self::$message, $data );
|
||||
$subject = Template::parse( self::$subject, $data );
|
||||
$body = Views::simpleView( 'email.template', $data );
|
||||
} else {
|
||||
$subject = self::$subject;
|
||||
$body = '<h1>' . self::$title . '</h1>' . self::$message;
|
||||
}
|
||||
|
||||
if ( !is_object( $email ) ) {
|
||||
$email = (object) [
|
||||
(object) [ 'email' => $email ],
|
||||
];
|
||||
}
|
||||
|
||||
$error = false;
|
||||
foreach ( $email as $data ) {
|
||||
if ( !mail( $data->email, $subject, $body, self::$header ) ) {
|
||||
Debug::error( 'Failed to send email. emailSubject: ' . $subject . ' emailRecipientEmail: ' . $data->email );
|
||||
Debug::error( var_export( error_get_last(), true ) );
|
||||
$error = true;
|
||||
}
|
||||
}
|
||||
if ( $error ) {
|
||||
return false;
|
||||
}
|
||||
Debug::info( "Email sent: $type." );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for the header.
|
||||
*/
|
||||
public static function build() {
|
||||
if ( empty( self::$header ) ) {
|
||||
self::$header = 'From: ' . Config::getValue( 'main/name' ) . ' <' . EMAIL_FROM_EMAIL . ">\r\n";
|
||||
self::$header .= "MIME-Version: 1.0\r\n";
|
||||
self::$header .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
|
||||
$url = parse_url( Routes::getAddress(), PHP_URL_HOST );
|
||||
$parts = explode( '.', $url );
|
||||
$count = count( $parts );
|
||||
if ( $count > 2 ) {
|
||||
$host = $parts[$count - 2] . '.' . $parts[$count - 1];
|
||||
} else {
|
||||
$host = $url;
|
||||
}
|
||||
if ( self::$debug ) {
|
||||
self::$header .= 'CC: ' . DEBUG_EMAIL . "\r\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,224 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* core/template/pagination.php
|
||||
*
|
||||
* This class is for managing template pagination.
|
||||
*
|
||||
* @version 3.0
|
||||
* @author Joey Kimsey <Joey@thetempusproject.com>
|
||||
* @link https://TheTempusProject.com/Core
|
||||
* @license https://opensource.org/licenses/MIT [MIT LICENSE]
|
||||
*/
|
||||
namespace TheTempusProject\Houdini\Classes;
|
||||
|
||||
use TheTempusProject\Houdini\Classes\Template;
|
||||
use TheTempusProject\Hermes\Functions\Route as Routes;
|
||||
use TheTempusProject\Bedrock\Functions\Input;
|
||||
use TheTempusProject\Bedrock\Classes\Config;
|
||||
use TheTempusProject\Bedrock\Functions\Check;
|
||||
use TheTempusProject\Canary\Canary as Debug;
|
||||
|
||||
class Pagination extends Template {
|
||||
//The settings that will not change
|
||||
public static $paginationSettings = [];
|
||||
|
||||
//The instance for each generation
|
||||
public static $instance = null;
|
||||
|
||||
public function __construct() {
|
||||
if ( empty( self::$paginationSettings['limit'] ) ) {
|
||||
$this->loadSettings();
|
||||
}
|
||||
// check for user settings
|
||||
if ( empty( self::$paginationSettings['perPage'] ) ) {
|
||||
self::$paginationSettings['perPage'] = DEFAULT_RESULTS_PER_PAGE;
|
||||
if ( ( !empty( self::$paginationSettings['userPerPage'] ) ) && ( self::$paginationSettings['userPerPage'] <= self::$paginationSettings['maxPerPage'] ) ) {
|
||||
self::$paginationSettings['perPage'] = self::$paginationSettings['userPerPage'];
|
||||
}
|
||||
}
|
||||
// The query minimum and maximum based on current page and page limit
|
||||
if ( self::$paginationSettings['currentPage'] == 1 ) {
|
||||
self::$paginationSettings['min'] = 0;
|
||||
} else {
|
||||
self::$paginationSettings['min'] = ( ( self::$paginationSettings['currentPage'] - 1 ) * self::$paginationSettings['perPage'] );
|
||||
}
|
||||
// if ( self::$paginationSettings['currentPage'] == 1 ) {
|
||||
self::$paginationSettings['max'] = self::$paginationSettings['perPage'];
|
||||
// } else {
|
||||
// self::$paginationSettings['max'] = ( self::$paginationSettings['currentPage'] * self::$paginationSettings['perPage'] );
|
||||
// }
|
||||
// The query limit based on our settings here
|
||||
self::$paginationSettings['limit'] = [self::$paginationSettings['min'], self::$paginationSettings['max']];
|
||||
}
|
||||
|
||||
private static function loadSettings() {
|
||||
Debug::log( 'Loading Pagination Settings.' );
|
||||
// hard cap built into system for displaying results
|
||||
self::$paginationSettings['maxPerPage'] = MAX_RESULTS_PER_PAGE;
|
||||
|
||||
// hard cap built into system retrieving results
|
||||
self::$paginationSettings['maxQuery'] = Config::getValue( 'database/dbMaxQuery' );
|
||||
|
||||
// Set max query to the lowest of the three settings since this will modify how many results are possible.
|
||||
if ( self::$paginationSettings['maxQuery'] <= self::$paginationSettings['maxPerPage'] ) {
|
||||
self::$paginationSettings['maxPerPage'] = self::$paginationSettings['maxQuery'];
|
||||
}
|
||||
|
||||
// Check for results request to set/modify the perPage setting
|
||||
if ( Input::exists( 'results' ) ) {
|
||||
if ( Check::ID( Input::get( 'results' ) ) ) {
|
||||
if ( Input::get( 'results' ) <= self::$paginationSettings['maxPerPage'] ) {
|
||||
self::$paginationSettings['perPage'] = Input::get( 'results' );
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( empty( self::$paginationSettings['perPage'] ) ) {
|
||||
self::$paginationSettings['perPage'] = self::$paginationSettings['maxPerPage'];
|
||||
}
|
||||
|
||||
// Check for pagination in get
|
||||
if ( Input::exists( 'page' ) ) {
|
||||
if ( Check::ID( Input::get( 'page' ) ) ) {
|
||||
self::$paginationSettings['currentPage'] = (int) Input::get( 'page' );
|
||||
} else {
|
||||
self::$paginationSettings['currentPage'] = 1;
|
||||
}
|
||||
} else {
|
||||
self::$paginationSettings['currentPage'] = 1;
|
||||
}
|
||||
|
||||
if ( ( self::$paginationSettings['currentPage'] - 3 ) > 1 ) {
|
||||
self::$paginationSettings['firstPage'] = ( self::$paginationSettings['currentPage'] - 2 );
|
||||
} else {
|
||||
self::$paginationSettings['firstPage'] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
public static function generate() {
|
||||
// account for empty values here instead of inside the script.
|
||||
Debug::log( 'Creating new Pagination Instance.' );
|
||||
self::$instance = new self();
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
public static function updatePaginationTotal( $count ) {
|
||||
if ( empty( self::$paginationSettings ) ) {
|
||||
self::generate();
|
||||
}
|
||||
if ( Check::id( $count ) ) {
|
||||
Debug::log( 'Pagination: Updating results count' );
|
||||
self::$paginationSettings['results'] = $count;
|
||||
self::$paginationSettings['totalPages'] = ceil( ( self::$paginationSettings['results'] / self::$paginationSettings['perPage'] ) );
|
||||
if ( ( self::$paginationSettings['currentPage'] + 3 ) < self::$paginationSettings['totalPages'] ) {
|
||||
self::$paginationSettings['lastPage'] = self::$paginationSettings['currentPage'] + 3;
|
||||
} else {
|
||||
self::$paginationSettings['lastPage'] = self::$paginationSettings['totalPages'];
|
||||
}
|
||||
Debug::info( 'Pagination: results update completed.' );
|
||||
} else {
|
||||
Debug::info( 'Pagination: results update failed.' );
|
||||
}
|
||||
}
|
||||
|
||||
public static function paginate() {
|
||||
$pageData = [];
|
||||
if ( self::firstPage() != 1 ) {
|
||||
$data[1]['ACTIVEPAGE'] = '';
|
||||
$data[1]['PAGENUMBER'] = 1;
|
||||
$data[1]['LABEL'] = 'First';
|
||||
$pageData[1] = (object) $data[1];
|
||||
}
|
||||
for ( $x = self::firstPage(); $x < self::lastPage(); $x++ ) {
|
||||
if ( $x == self::currentPage() ) {
|
||||
$active = ' class="active"';
|
||||
} else {
|
||||
$active = '';
|
||||
}
|
||||
$data[$x]['ACTIVEPAGE'] = $active;
|
||||
$data[$x]['PAGENUMBER'] = $x;
|
||||
$data[$x]['LABEL'] = $x;
|
||||
$pageData[$x] = (object) $data[$x];
|
||||
}
|
||||
if ( self::lastPage() <= self::totalPages() ) {
|
||||
$x = self::totalPages();
|
||||
if ( $x == self::currentPage() ) {
|
||||
$active = ' class="active"';
|
||||
} else {
|
||||
$active = '';
|
||||
}
|
||||
$data[$x]['ACTIVEPAGE'] = $active;
|
||||
$data[$x]['PAGENUMBER'] = $x;
|
||||
$data[$x]['LABEL'] = 'Last';
|
||||
$pageData[$x] = (object) $data[$x];
|
||||
}
|
||||
$pageData = (object) $pageData;
|
||||
|
||||
if ( self::totalPages() <= 1 ) {
|
||||
Components::set( 'PAGINATION', 'no pagination' );
|
||||
} else {
|
||||
Components::set( 'PAGINATION', Views::simpleView( 'nav.pagination', $pageData ) );
|
||||
}
|
||||
}
|
||||
|
||||
public static function updatePrefs( $pageLimit ) {
|
||||
if ( Check::id( $pageLimit ) ) {
|
||||
Debug::log( 'Pagination: Updating user pref' );
|
||||
self::$paginationSettings['userPerPage'] = $pageLimit;
|
||||
} else {
|
||||
Debug::info( 'Pagination: User pref update failed.' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Getters
|
||||
*/
|
||||
public static function getMin() {
|
||||
if ( isset( self::$paginationSettings['min'] ) ) {
|
||||
return self::$paginationSettings['min'];
|
||||
} else {
|
||||
Debug::info( 'Pagination: Min not found' );
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
public static function getMax() {
|
||||
if ( isset( self::$paginationSettings['max'] ) ) {
|
||||
return self::$paginationSettings['max'];
|
||||
} else {
|
||||
Debug::info( 'Pagination: Max not found' );
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
public static function perPage() {
|
||||
if ( !empty( self::$paginationSettings['perPage'] ) ) {
|
||||
return self::$paginationSettings['perPage'];
|
||||
}
|
||||
}
|
||||
public static function firstPage() {
|
||||
if ( !empty( self::$paginationSettings['firstPage'] ) ) {
|
||||
return self::$paginationSettings['firstPage'];
|
||||
} else {
|
||||
Debug::info( 'Pagination: firstPage not found' );
|
||||
}
|
||||
}
|
||||
public static function lastPage() {
|
||||
if ( !empty( self::$paginationSettings['lastPage'] ) ) {
|
||||
return self::$paginationSettings['lastPage'];
|
||||
} else {
|
||||
Debug::info( 'Pagination: lastPage not found' );
|
||||
}
|
||||
}
|
||||
public static function totalPages() {
|
||||
if ( !empty( self::$paginationSettings['totalPages'] ) ) {
|
||||
return self::$paginationSettings['totalPages'];
|
||||
} else {
|
||||
Debug::info( 'Pagination: totalPages not found' );
|
||||
}
|
||||
}
|
||||
public static function currentPage() {
|
||||
if ( !empty( self::$paginationSettings['currentPage'] ) ) {
|
||||
return self::$paginationSettings['currentPage'];
|
||||
} else {
|
||||
Debug::info( 'Pagination: currentPage not found' );
|
||||
}
|
||||
}
|
||||
}
|
@ -16,15 +16,12 @@ namespace TheTempusProject\Houdini\Classes;
|
||||
|
||||
use TheTempusProject\Canary\Canary as Debug;
|
||||
use TheTempusProject\Hermes\Functions\Route as Routes;
|
||||
use TheTempusProject\Bedrock\Functions\Token;
|
||||
use TheTempusProject\Bedrock\Functions\Date;
|
||||
use TheTempusProject\Bedrock\Classes\Config;
|
||||
use TheTempusProject\Bedrock\Classes\CustomException;
|
||||
// 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;
|
||||
use TheTempusProject\Houdini\Classes\Issues;
|
||||
use TheTempusProject\Houdini\Classes\Pagination;
|
||||
|
||||
class Template {
|
||||
private static $follow = true;
|
||||
@ -45,7 +42,6 @@ class Template {
|
||||
Components::set( 'ROOT_ADDRESS', Routes::getAddress() );
|
||||
Components::set( 'TITLE', '' );
|
||||
Components::set( 'PAGE_DESCRIPTION', '' );
|
||||
Components::set( 'TOKEN', Token::generate() );
|
||||
Components::set( 'BASE', Routes::getAddress() );
|
||||
Debug::gend();
|
||||
}
|
||||
@ -112,7 +108,7 @@ class Template {
|
||||
return self::loadTemplate( $location, $name );
|
||||
}
|
||||
}
|
||||
new CustomException( 'template', $docLocation );
|
||||
// new CustomException( 'template', $docLocation );
|
||||
}
|
||||
|
||||
/**
|
||||
@ -130,7 +126,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;
|
||||
@ -206,10 +202,7 @@ class Template {
|
||||
self::buildRobot();
|
||||
self::buildHeaders();
|
||||
if ( empty( self::$templateLocation ) ) {
|
||||
self::setTemplate( Config::getValue( 'main/template' ) );
|
||||
}
|
||||
if ( empty( self::$templateLocation ) ) {
|
||||
self::setTemplate( Config::getValue( 'main/template' ) );
|
||||
// throw an error here @todo
|
||||
return;
|
||||
}
|
||||
if ( !Debug::status( 'render' ) ) {
|
||||
@ -322,6 +315,7 @@ 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;
|
||||
@ -346,7 +340,8 @@ class Template {
|
||||
if ( empty( $data[2] ) ) {
|
||||
return '';
|
||||
}
|
||||
return Date::formatTimestamp( $data[1], $data[2] );
|
||||
return $data[2]; // @todo need a way to decouple this from houdini to bedrock
|
||||
// return Date::formatTimestamp( $data[1], $data[2] );
|
||||
},
|
||||
$template
|
||||
);
|
||||
|
@ -4,23 +4,38 @@
|
||||
"description": "Php functions that aid in creating, managing, and displaying frontend components.",
|
||||
"license": "MIT",
|
||||
"minimum-stability": "dev",
|
||||
"keywords": ["php","tools","frontend","thetempusproject"],
|
||||
"homepage": "https://github.com/TheTempusProject/Houdini",
|
||||
"authors": [
|
||||
"keywords":
|
||||
[
|
||||
"php",
|
||||
"tools",
|
||||
"frontend",
|
||||
"thetempusproject"
|
||||
],
|
||||
"homepage": "https://git.thetempusproject.com/the-tempus-project/houdini",
|
||||
"authors":
|
||||
[
|
||||
{
|
||||
"name": "Joey Kimsey",
|
||||
"email": "Joey@thetempusproject.com",
|
||||
"homepage": "https://TheTempusProject.com",
|
||||
"homepage": "https://JoeyKimsey.com",
|
||||
"role": "Lead Developer"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=8.1.0"
|
||||
"require":
|
||||
{
|
||||
"php": ">=8.1.0",
|
||||
"thetempusproject/canary": ">=1.0",
|
||||
"thetempusproject/hermes": ">=1.0"
|
||||
},
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
"autoload":
|
||||
{
|
||||
"classmap":
|
||||
[
|
||||
"classes"
|
||||
],
|
||||
"files":
|
||||
[
|
||||
"config/constants.php"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
|
109
composer.lock
generated
Normal file
109
composer.lock
generated
Normal file
@ -0,0 +1,109 @@
|
||||
{
|
||||
"_readme": [
|
||||
"This file locks the dependencies of your project to a known state",
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "a5f3c6aec6567c9b48b59eecc9588183",
|
||||
"packages": [
|
||||
{
|
||||
"name": "thetempusproject/canary",
|
||||
"version": "dev-main",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://git.thetempusproject.com/the-tempus-project/canary",
|
||||
"reference": "be5589533f8c1d0b1c28bac8829333f0077c698d"
|
||||
},
|
||||
"require": {
|
||||
"php": ">=8.1.0"
|
||||
},
|
||||
"default-branch": true,
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"files": [
|
||||
"config/constants.php",
|
||||
"bin/canary.php"
|
||||
],
|
||||
"classmap": [
|
||||
"classes"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Joey Kimsey",
|
||||
"email": "Joey@thetempusproject.com",
|
||||
"homepage": "https://JoeyKimsey.com",
|
||||
"role": "Lead Developer"
|
||||
}
|
||||
],
|
||||
"description": "Functionality for tracking, logging, and sending log messages to chrome for debugging.",
|
||||
"homepage": "https://git.thetempusproject.com/the-tempus-project/canary",
|
||||
"keywords": [
|
||||
"debugging",
|
||||
"php",
|
||||
"thetempusproject",
|
||||
"tools"
|
||||
],
|
||||
"time": "2024-08-08T05:18:19+00:00"
|
||||
},
|
||||
{
|
||||
"name": "thetempusproject/hermes",
|
||||
"version": "dev-main",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://git.thetempusproject.com/the-tempus-project/hermes",
|
||||
"reference": "e38f8debefb7097b15cb479184dc869e3e3111c0"
|
||||
},
|
||||
"require": {
|
||||
"php": ">=8.1.0"
|
||||
},
|
||||
"default-branch": true,
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"files": [
|
||||
"config/constants.php"
|
||||
],
|
||||
"classmap": [
|
||||
"classes",
|
||||
"functions"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Joey Kimsey",
|
||||
"email": "Joey@thetempusproject.com",
|
||||
"homepage": "https://JoeyKimsey.com",
|
||||
"role": "Lead Developer"
|
||||
}
|
||||
],
|
||||
"description": "Php functions that aid in routing and redirecting; requests and responses.",
|
||||
"homepage": "https://git.thetempusproject.com/the-tempus-project/hermes",
|
||||
"keywords": [
|
||||
"php",
|
||||
"routing",
|
||||
"thetempusproject",
|
||||
"tools"
|
||||
],
|
||||
"time": "2024-08-08T05:24:32+00:00"
|
||||
}
|
||||
],
|
||||
"packages-dev": [],
|
||||
"aliases": [],
|
||||
"minimum-stability": "dev",
|
||||
"stability-flags": [],
|
||||
"prefer-stable": false,
|
||||
"prefer-lowest": false,
|
||||
"platform": {
|
||||
"php": ">=8.1.0"
|
||||
},
|
||||
"platform-dev": [],
|
||||
"plugin-api-version": "2.3.0"
|
||||
}
|
@ -1,10 +1,12 @@
|
||||
<?php
|
||||
// Directories
|
||||
if ( !defined( 'HOUDINI_ROOT_DIRECTORY' ) ) {
|
||||
if ( ! defined( 'HOUDINI_ROOT_DIRECTORY' ) ) {
|
||||
define( 'HOUDINI_ROOT_DIRECTORY', dirname( __DIR__ ) . DIRECTORY_SEPARATOR );
|
||||
}
|
||||
if ( ! defined('HOUDINI_CONFIG_DIRECTORY' ) ) {
|
||||
define('HOUDINI_CONFIG_DIRECTORY', HOUDINI_ROOT_DIRECTORY . 'config' . DIRECTORY_SEPARATOR);
|
||||
if ( ! defined( 'HOUDINI_CONFIG_DIRECTORY' ) ) {
|
||||
define( 'HOUDINI_CONFIG_DIRECTORY', HOUDINI_ROOT_DIRECTORY . 'config' . DIRECTORY_SEPARATOR );
|
||||
}
|
||||
// # Tell the app all constants have been loaded.
|
||||
define( 'HOUDINI_CONSTANTS_LOADED', true );
|
||||
if ( ! defined('HOUDINI_CONSTANTS_LOADED' ) ) {
|
||||
define( 'HOUDINI_CONSTANTS_LOADED', true );
|
||||
}
|
7
notes.md
7
notes.md
@ -1,7 +0,0 @@
|
||||
|
||||
|
||||
From default Template:
|
||||
$this->cssIncludes[] = Template::parse('<link rel="stylesheet" href="{BOOTSTRAP_CDN}css/bootstrap-theme.min.css" crossorigin="anonymous">');
|
||||
$this->jsIncludes[] = Template::parse('<script language="JavaScript" crossorigin="anonymous" type="text/javascript" src="https://code.jquery.com/jquery-2.2.4.min.js"></script>');
|
||||
|
||||
|
2
vendor/.gitignore
vendored
Normal file
2
vendor/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
*
|
||||
!.gitignore
|
Reference in New Issue
Block a user