fixes to support composer / packagist
This commit is contained in:
2
LICENSE
2
LICENSE
@ -1,6 +1,6 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2023 Joey Kimsey
|
||||
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
|
||||
|
224
classes/pagination.php
Normal file
224
classes/pagination.php
Normal file
@ -0,0 +1,224 @@
|
||||
<?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' );
|
||||
}
|
||||
}
|
||||
}
|
@ -1,28 +1,42 @@
|
||||
{
|
||||
"name": "thetempusproject/bedrock",
|
||||
"type": "library",
|
||||
"description": "Tempus project core is intended as the core code used by The Tempus Project: a rapid prototyping framework. This library utilizes the MVC architecture in addition to a custom templating engine designed to make building web applications simple.",
|
||||
"description": "Bedrock is intended as the core functionality used by The Tempus Project: a rapid prototyping framework. This library utilizes the MVC architecture in addition to a custom templating engine designed to make building web applications simple.",
|
||||
"license": "MIT",
|
||||
"minimum-stability": "dev",
|
||||
"keywords": ["templating","mvc","framework"],
|
||||
"homepage": "https://TheTempusProject.com/Core",
|
||||
"authors": [
|
||||
"keywords":
|
||||
[
|
||||
"mvc",
|
||||
"framework"
|
||||
],
|
||||
"homepage": "https://git.thetempusproject.com/the-tempus-project/bedrock",
|
||||
"authors":
|
||||
[
|
||||
{
|
||||
"name": "Joey Kimsey",
|
||||
"email": "Joey@thetempusproject.com",
|
||||
"homepage": "https://TheTempusProject.com",
|
||||
"homepage": "https://JoeyKimsey.com",
|
||||
"role": "Lead Developer"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=5.4.0",
|
||||
"thetempusproject/tempusdebugger": "3.0"
|
||||
"require":
|
||||
{
|
||||
"php": ">=8.1.0",
|
||||
"thetempusproject/canary": ">=1.0",
|
||||
"thetempusproject/hermes": ">=1.0",
|
||||
"thetempusproject/houdini": ">=1.0"
|
||||
},
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
"classes",
|
||||
"core",
|
||||
"functions"
|
||||
"autoload":
|
||||
{
|
||||
"psr-4":
|
||||
{
|
||||
"TheTempusProject\\Bedroock\\Classes\\": "classes",
|
||||
"TheTempusProject\\Bedroock\\Functions\\": "functions"
|
||||
},
|
||||
"files":
|
||||
[
|
||||
"config/constants.php",
|
||||
"bin/bedrock.php"
|
||||
]
|
||||
}
|
||||
}
|
154
composer.lock
generated
Normal file
154
composer.lock
generated
Normal file
@ -0,0 +1,154 @@
|
||||
{
|
||||
"_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": "4467bdc4b2a87dc7540fc9854ebd9384",
|
||||
"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"
|
||||
},
|
||||
{
|
||||
"name": "thetempusproject/houdini",
|
||||
"version": "dev-main",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://git.thetempusproject.com/the-tempus-project/houdini",
|
||||
"reference": "b2d044da64ca1869432dc12b9c98fdb60379ffd9"
|
||||
},
|
||||
"require": {
|
||||
"php": ">=8.1.0",
|
||||
"thetempusproject/canary": ">=1.0",
|
||||
"thetempusproject/hermes": ">=1.0"
|
||||
},
|
||||
"default-branch": true,
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"files": [
|
||||
"config/constants.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": "Php functions that aid in creating, managing, and displaying frontend components.",
|
||||
"homepage": "https://git.thetempusproject.com/the-tempus-project/houdini",
|
||||
"keywords": [
|
||||
"frontend",
|
||||
"php",
|
||||
"thetempusproject",
|
||||
"tools"
|
||||
],
|
||||
"time": "2024-08-08T05:17:27+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"
|
||||
}
|
@ -202,4 +202,6 @@
|
||||
define('TOKEN_ENABLED', true);
|
||||
}
|
||||
# Tell the app all constants have been loaded.
|
||||
define( 'BEDROCK_CONSTANTS_LOADED', true );
|
||||
if ( ! defined('BEDROCK_CONSTANTS_LOADED' ) ) {
|
||||
define( 'BEDROCK_CONSTANTS_LOADED', true );
|
||||
}
|
@ -33,6 +33,7 @@ class Date {
|
||||
$dt->setTimestamp( $time );
|
||||
return $dt->format( $dateFormat );
|
||||
}
|
||||
|
||||
public static function applyTimezoneToTimestamp( $timestamp ) {
|
||||
$timestamp = intval( $timestamp );
|
||||
$date = new DateTime();
|
||||
|
2
vendor/.gitignore
vendored
Normal file
2
vendor/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
*
|
||||
!.gitignore
|
Reference in New Issue
Block a user