Compare commits
42 Commits
Author | SHA1 | Date | |
---|---|---|---|
e9c3fd84dd | |||
89d30a8d36 | |||
cfa53c9e70 | |||
39d350df06 | |||
3f2bd6869b | |||
1d9c772e73 | |||
1101055a5d | |||
98b2f8086c | |||
20f09e6789 | |||
394e752094 | |||
795784f02e | |||
b1e74f9652 | |||
bcd73d58f9 | |||
3b8e099491 | |||
e7dc2186a8 | |||
3152d180c0 | |||
42ade08306 | |||
464201cf17 | |||
983f6ed624 | |||
8cd7a6ebbc | |||
ef4818356c | |||
85ed1def88 | |||
7228e530b8 | |||
92c057ad26 | |||
feea409ac7 | |||
7518461cb9 | |||
233565dcd2 | |||
bfd23ecfe1 | |||
67f5dabfa6 | |||
1f720693d1 | |||
77988e612e | |||
3691c60590 | |||
d6a8f56f7d | |||
bbde55881e | |||
c2d7755ab7 | |||
ce77bdd1ac | |||
5cc61666fe | |||
79f21773c6 | |||
d9f0e86ce1 | |||
5b823f02f1 | |||
f80f7bed6b | |||
e3cf6beebb |
49
.gitlab-ci.yml
Normal file
49
.gitlab-ci.yml
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
stages:
|
||||||
|
- update
|
||||||
|
|
||||||
|
variables:
|
||||||
|
TIMEZONE: "America/New_York" # For the system in general
|
||||||
|
DATE_TIMEZONE: ${TIMEZONE} # For PHP
|
||||||
|
|
||||||
|
GIT_DEPTH: 1
|
||||||
|
GITLAB_API_URL: ${CI_API_V4_URL}
|
||||||
|
TARGET_BRANCH: ${CI_COMMIT_REF_NAME} # This is the branch chosen in the `Pipeline Schedule`
|
||||||
|
TARGET_REMOTE: "https://${GITLAB_USERNAME}:${GITLAB_ACCESS_TOKEN}@${CI_SERVER_HOST}/${CI_PROJECT_NAMESPACE}/${CI_PROJECT_NAME}.git"
|
||||||
|
|
||||||
|
# These could/should be overridden in an extending job:
|
||||||
|
UPDATE_BRANCH_PREFIX: "update_PHP_deps_" # Used for the update branch name, it will be followed by the datetime
|
||||||
|
GIT_USER: "DependBot" # Used for the update commit
|
||||||
|
GIT_EMAIL: "webmaster@thetempusproject.com" # Used for the update commit
|
||||||
|
GITLAB_USERNAME: "root" # Used for pushing the new branch and opening the MR
|
||||||
|
GITLAB_ACCESS_TOKEN: "glpat-PKEmivGtBfbz4DVPdhzk" # Used for pushing the new branch and opening the MR
|
||||||
|
MERGE_IF_SUCCESSFUL: "true" # Set to true, to merge automatically if the pipeline succeeds
|
||||||
|
SECONDS_BETWEEN_POOLING: 10 # Nbr of seconds between checking if the MR pipeline is successful, so then it will merge
|
||||||
|
JOB_GIT_FLAGS: ""
|
||||||
|
JOB_CURL_FLAGS: ""
|
||||||
|
JOB_COMPOSER_FLAGS: ""
|
||||||
|
|
||||||
|
composer_update:
|
||||||
|
stage: update
|
||||||
|
rules:
|
||||||
|
- if: '$CI_COMMIT_BRANCH == "main"'
|
||||||
|
image: composer:latest
|
||||||
|
interruptible: true # allows to stop the job if a newer pipeline starts, saving resources and allowing new jobs to start because job concurrency is limited
|
||||||
|
script:
|
||||||
|
- git ${JOB_GIT_FLAGS} fetch origin ${TARGET_BRANCH}
|
||||||
|
- git ${JOB_GIT_FLAGS} checkout ${TARGET_BRANCH}
|
||||||
|
- git reset --hard origin/main
|
||||||
|
- export DATE_TIME="$(date '+%Y%m%d%H%M%S')"
|
||||||
|
- export MR_BRANCH="${UPDATE_BRANCH_PREFIX}${DATE_TIME}"
|
||||||
|
- git ${JOB_GIT_FLAGS} checkout -b "${MR_BRANCH}"
|
||||||
|
- composer update ${JOB_COMPOSER_FLAGS}
|
||||||
|
- if [ "$(git diff)" == "" ]; then echo "No updates needed!"; exit 0; fi
|
||||||
|
- export TITLE="Update PHP dependencies [${DATE_TIME}]"
|
||||||
|
- git ${JOB_GIT_FLAGS} commit -a -m "${TITLE}"
|
||||||
|
- git ${JOB_GIT_FLAGS} push "${TARGET_REMOTE}" "${MR_BRANCH}"
|
||||||
|
artifacts:
|
||||||
|
paths:
|
||||||
|
- vendor/
|
||||||
|
cache:
|
||||||
|
key: ${CI_COMMIT_REF_SLUG}
|
||||||
|
paths:
|
||||||
|
- vendor/
|
@ -1,52 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* bin/autoload.php
|
|
||||||
*
|
|
||||||
* Handles the initial setup like autoloading, basic functions, constants, etc.
|
|
||||||
*
|
|
||||||
* @version 3.0
|
|
||||||
* @author Joey Kimsey <Joey@thetempusproject.com>
|
|
||||||
* @link https://TheTempusProject.com/Core
|
|
||||||
* @license https://opensource.org/licenses/MIT [MIT LICENSE]
|
|
||||||
*/
|
|
||||||
namespace TheTempusProject\Bedrock;
|
|
||||||
|
|
||||||
use TheTempusProject\Hermes\Classes\Autoloader;
|
|
||||||
|
|
||||||
if ( ! defined('BEDROCK_ROOT_DIRECTORY' ) ) {
|
|
||||||
define('BEDROCK_ROOT_DIRECTORY', dirname(__DIR__) . DIRECTORY_SEPARATOR);
|
|
||||||
}
|
|
||||||
if ( ! defined('BEDROCK_CONFIG_DIRECTORY' ) ) {
|
|
||||||
define('BEDROCK_CONFIG_DIRECTORY', BEDROCK_ROOT_DIRECTORY . 'config' . DIRECTORY_SEPARATOR);
|
|
||||||
}
|
|
||||||
if ( ! defined('BEDROCK_CONSTANTS_LOADED' ) ) {
|
|
||||||
require_once BEDROCK_CONFIG_DIRECTORY . 'constants.php';
|
|
||||||
}
|
|
||||||
if ( ! class_exists( 'TheTempusProject\Bedrock\Classes\Autoloader' ) ) {
|
|
||||||
if ( file_exists( BEDROCK_CLASSES_DIRECTORY . 'autoloader.php' ) ) {
|
|
||||||
require_once BEDROCK_CLASSES_DIRECTORY . 'autoloader.php';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ( ! class_exists( 'TheTempusProject\Bedrock\App' ) ) {
|
|
||||||
if ( file_exists( BEDROCK_ROOT_DIRECTORY . 'app.php' ) ) {
|
|
||||||
require_once BEDROCK_ROOT_DIRECTORY . 'app.php';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$autoloader = new Autoloader;
|
|
||||||
$autoloader->setRootFolder( BEDROCK_ROOT_DIRECTORY );
|
|
||||||
$autoloader->addNamespace(
|
|
||||||
'TheTempusProject\Bedrock',
|
|
||||||
'bin'
|
|
||||||
);
|
|
||||||
$autoloader->addNamespace(
|
|
||||||
'TheTempusProject\Bedrock\Classes',
|
|
||||||
'classes'
|
|
||||||
);
|
|
||||||
$autoloader->addNamespace(
|
|
||||||
'TheTempusProject\Bedrock\Functions',
|
|
||||||
'functions'
|
|
||||||
);
|
|
||||||
$autoloader->register();
|
|
||||||
|
|
||||||
define( 'BEDROCK_AUTOLOADED', true );
|
|
@ -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,87 +0,0 @@
|
|||||||
# Contribution Guidelines for Bedrock
|
|
||||||
Contributing to Bedrock 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 (with the exception of config which should be stored under config/)
|
|
||||||
- Controllers must have a constructor and destructor using the constructor and destructor methods found in resources/
|
|
||||||
- Views must be named using lowerCamelCase
|
|
||||||
|
|
||||||
## 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/Core
|
|
||||||
* @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 Bedrock. 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/Bedrock/compare)
|
|
||||||
4. Please submit all pull requests to the dev branch or they will be ignored.
|
|
@ -1,78 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* classes/custom_exception.php
|
|
||||||
*
|
|
||||||
* This class is used exclusively when throwing predefined exceptions.
|
|
||||||
* It will intercept framework thrown exceptions and deal with them however
|
|
||||||
* you choose; in most cases by logging them and taking appropriate responses
|
|
||||||
* such as redirecting to error pages.
|
|
||||||
*
|
|
||||||
* @version 3.0
|
|
||||||
* @author Joey Kimsey <Joey@thetempusproject.com>
|
|
||||||
* @link https://TheTempusProject.com/Core
|
|
||||||
* @license https://opensource.org/licenses/MIT [MIT LICENSE]
|
|
||||||
*/
|
|
||||||
namespace TheTempusProject\Bedrock\Classes;
|
|
||||||
|
|
||||||
use Exception;
|
|
||||||
use TheTempusProject\Hermes\Functions\Redirect;
|
|
||||||
use TheTempusProject\Canary\Canary as Debug;
|
|
||||||
|
|
||||||
class CustomException extends Exception {
|
|
||||||
private $originFunction = null;
|
|
||||||
private $exceptionName = null;
|
|
||||||
private $originClass = null;
|
|
||||||
private $data = null;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This function allows the application to deal with errors
|
|
||||||
* in a dynamic way by letting you customize the response
|
|
||||||
*
|
|
||||||
* @param string $type - The type of the exception being called/thrown.
|
|
||||||
* @param string $data - Any additional data being passed with the exception.
|
|
||||||
*
|
|
||||||
* @example - throw new CustomException('model'); - Calls the model-missing exception
|
|
||||||
*/
|
|
||||||
public function __construct( $type, $data = null ) {
|
|
||||||
$this->originFunction = debug_backtrace()[1]['function'];
|
|
||||||
$this->originClass = debug_backtrace()[1]['class'];
|
|
||||||
$this->exceptionName = $type;
|
|
||||||
$this->data = $data;
|
|
||||||
switch ( $type ) {
|
|
||||||
case 'model':
|
|
||||||
Debug::error( 'Model not found: ' . $data );
|
|
||||||
break;
|
|
||||||
case 'dbConnection':
|
|
||||||
Debug::error( 'Error Connecting to the database: ' . $data );
|
|
||||||
break;
|
|
||||||
case 'DB':
|
|
||||||
Debug::error( 'Unspecified database error: ' . $data );
|
|
||||||
break;
|
|
||||||
case 'view':
|
|
||||||
Debug::error( 'View not found: ' . $data );
|
|
||||||
break;
|
|
||||||
case 'controller':
|
|
||||||
Debug::error( 'Controller not found: ' . $data );
|
|
||||||
Redirect::to( 404 );
|
|
||||||
break;
|
|
||||||
case 'defaultController':
|
|
||||||
Debug::error( 'DEFAULT Controller not found: ' . $data );
|
|
||||||
Redirect::to( 404 );
|
|
||||||
break;
|
|
||||||
case 'method':
|
|
||||||
Debug::error( 'Method not found: ' . $data );
|
|
||||||
Redirect::to( 404 );
|
|
||||||
break;
|
|
||||||
case 'simpleView':
|
|
||||||
Debug::error( 'View not found: ' . $data );
|
|
||||||
break;
|
|
||||||
case 'defaultMethod':
|
|
||||||
Debug::error( 'DEFAULT Method not found: ' . $data );
|
|
||||||
Redirect::to( 404 );
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
Debug::error( 'Default exception: ' . $data );
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
2
LICENSE
2
LICENSE
@ -1,6 +1,6 @@
|
|||||||
MIT License
|
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
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
75
README.md
75
README.md
@ -1,31 +1,70 @@
|
|||||||
# Tempus Project Core
|
|
||||||
###### Developer(s): Joey Kimsey
|
|
||||||
|
|
||||||
Bedrock is the core functionality used by [The Tempus Project](https://github.com/TheTempusProject/TheTempusProject) a rapid prototyping framework. This Library can be utilized outside of the TempusProject, but the functionality has not been tested well as a stand alone library.
|
# Bedrock
|
||||||
|
|
||||||
This library utilizes the MVC architecture in addition to a custom templating engine designed to make building web applications fast and simple.
|
Bedrock is the core functionality used by [The Tempus Project](https://github.com/TheTempusProject/TheTempusProject) a rapid prototyping framework. It provides database support, configuration, base models, and base controller functionality a in addition to a host of other integrated functions.
|
||||||
|
|
||||||
**Notice: This Library is provided as is, please use at your own risk.**
|
This Library can be utilized outside of TheTempusProject, but the functionality has not been tested well as a stand-alone library.
|
||||||
|
|
||||||
## Installation and Use
|
## Installation
|
||||||
The easiest way to use Bedrock in your application is to install and initialize it via composer.
|
|
||||||
|
To install simply use the composer command:
|
||||||
|
|
||||||
|
`php composer.phar require thetempusproject/bedrock`
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
Typical usage would be through including the package via composer.
|
||||||
|
|
||||||
|
```php
|
||||||
|
|
||||||
|
namespace MyApp;
|
||||||
|
|
||||||
|
use TheTempusProject\Bedrock\Bin\Bedrock;
|
||||||
|
|
||||||
|
require_once VENDOR_DIRECTORY . 'autoload.php';
|
||||||
|
|
||||||
|
class MyApp extends Bedrock {
|
||||||
|
// "Stuff", "Things", and "What-not"
|
||||||
|
}
|
||||||
|
|
||||||
```
|
```
|
||||||
"require": {
|
|
||||||
"TheTempusProject/Bedrock": "*",
|
|
||||||
},
|
|
||||||
|
|
||||||
"autoload": {
|
If you would like to use hermes own autoloading, simply inclode the constants file and the autoload file inside `/bin/`.
|
||||||
"psr-4": {
|
|
||||||
"Bedrock\": "vendor/TheTempusProject/Bedrock"
|
```php
|
||||||
|
|
||||||
|
use TheTempusProject\Bedrock\Bin\Bedrock;
|
||||||
|
|
||||||
|
// Bedrock Constants
|
||||||
|
if ( ! defined( 'BEDROCK_CONSTANTS_LOADED' ) ) {
|
||||||
|
if ( defined( 'BEDROCK_CONFIG_DIRECTORY' ) ) {
|
||||||
|
require_once BEDROCK_CONFIG_DIRECTORY . 'constants.php';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Bedrock Autoloader (Autoloader)
|
||||||
|
if ( ! defined( 'BEDROCK_AUTOLOADED' ) ) {
|
||||||
|
if ( defined( 'BEDROCK_ROOT_DIRECTORY' ) ) {
|
||||||
|
require_once BEDROCK_ROOT_DIRECTORY . 'bin' . DIRECTORY_SEPARATOR . 'autoload.php';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class MyApp extends Bedrock {
|
||||||
|
// "Stuff", "Things", and "What-not"
|
||||||
|
}
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
If you prefer to handle auto-loading via other means, you can simply clone this repository wherever you need it. Please note, you will need to install and load the [TempusDebugger](https://github.com/thetempusproject/TempusDebugger) library in order to utilize the debug to console options.
|
### To-Do
|
||||||
|
|
||||||
### WIP:
|
|
||||||
- [ ] Expansion of PDO to allow different database types
|
- [ ] Expansion of PDO to allow different database types
|
||||||
- [ ] template stuff should really only be called from template/controllers
|
- [ ] Updates for configs and models to re-build based on a delta model, to make version changes simpler. (Migration system)
|
||||||
- [ ] Update installer to account for updates.
|
- [ ] Implement better uniformity in terms of error reporting, exceptions, logging.
|
||||||
- [ ] Implement uniformity in terms of error reporting, exceptions, logging.
|
|
||||||
|
## 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)
|
||||||
|
45
bin/autoload.php
Normal file
45
bin/autoload.php
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* bin/autoload.php
|
||||||
|
*
|
||||||
|
* Handles the initial setup like autoloading, basic functions, constants, etc.
|
||||||
|
*
|
||||||
|
* @version 1.1.2
|
||||||
|
* @author Joey Kimsey <Joey@thetempusproject.com>
|
||||||
|
* @link https://TheTempusProject.com/libraries/Bedrock
|
||||||
|
* @license https://opensource.org/licenses/MIT [MIT LICENSE]
|
||||||
|
*/
|
||||||
|
namespace TheTempusProject\Bedrock;
|
||||||
|
|
||||||
|
use TheTempusProject\Hermes\Classes\Autoloader;
|
||||||
|
|
||||||
|
if ( ! defined('BEDROCK_ROOT_DIRECTORY' ) ) {
|
||||||
|
define('BEDROCK_ROOT_DIRECTORY', dirname(__DIR__) . DIRECTORY_SEPARATOR);
|
||||||
|
}
|
||||||
|
if ( ! defined('BEDROCK_CONFIG_DIRECTORY' ) ) {
|
||||||
|
define('BEDROCK_CONFIG_DIRECTORY', BEDROCK_ROOT_DIRECTORY . 'config' . DIRECTORY_SEPARATOR);
|
||||||
|
}
|
||||||
|
if ( ! defined('BEDROCK_CONSTANTS_LOADED' ) ) {
|
||||||
|
require_once BEDROCK_CONFIG_DIRECTORY . 'constants.php';
|
||||||
|
}
|
||||||
|
if ( class_exists( 'TheTempusProject\Hermes\Classes\Autoloader' ) ) {
|
||||||
|
$autoloader = new Autoloader;
|
||||||
|
$autoloader->setRootFolder( BEDROCK_ROOT_DIRECTORY );
|
||||||
|
$autoloader->addNamespace(
|
||||||
|
'TheTempusProject\Bedrock',
|
||||||
|
'bin'
|
||||||
|
);
|
||||||
|
$autoloader->addNamespace(
|
||||||
|
'TheTempusProject\Bedrock\Classes',
|
||||||
|
'classes'
|
||||||
|
);
|
||||||
|
$autoloader->addNamespace(
|
||||||
|
'TheTempusProject\Bedrock\Functions',
|
||||||
|
'functions'
|
||||||
|
);
|
||||||
|
$autoloader->register();
|
||||||
|
}
|
||||||
|
|
||||||
|
require_once 'bedrock.php';
|
||||||
|
|
||||||
|
define( 'BEDROCK_AUTOLOADED', true );
|
@ -1,20 +1,20 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* app.php
|
* bin/bedrock.php
|
||||||
*
|
*
|
||||||
* This file parses any given url and separates it into controller,
|
* This file parses any given url and separates it into controller,
|
||||||
* method, and data. This allows the application to direct the user
|
* method, and data. This allows the application to direct the user
|
||||||
* to the desired location and provide the controller any additional
|
* to the desired location and provide the controller any additional
|
||||||
* information it may require to run.
|
* information it may require to run.
|
||||||
*
|
*
|
||||||
* @version 3.0
|
* @version 1.1.2
|
||||||
* @author Joey Kimsey <Joey@thetempusproject.com>
|
* @author Joey Kimsey <Joey@thetempusproject.com>
|
||||||
* @link https://TheTempusProject.com/Core
|
* @link https://TheTempusProject.com/libraries/Bedrock
|
||||||
* @license https://opensource.org/licenses/MIT [MIT LICENSE]
|
* @license https://opensource.org/licenses/MIT [MIT LICENSE]
|
||||||
*/
|
*/
|
||||||
namespace TheTempusProject\Bedrock\Bin;
|
namespace TheTempusProject\Bedrock\Bin;
|
||||||
|
|
||||||
use TheTempusProject\Canary\Canary as Debug;
|
use TheTempusProject\Canary\Bin\Canary as Debug;
|
||||||
use TheTempusProject\Hermes\Functions\Route as Routes;
|
use TheTempusProject\Hermes\Functions\Route as Routes;
|
||||||
use TheTempusProject\Bedrock\Functions\Input;
|
use TheTempusProject\Bedrock\Functions\Input;
|
||||||
use TheTempusProject\Bedrock\Functions\Check;
|
use TheTempusProject\Bedrock\Functions\Check;
|
||||||
@ -32,6 +32,7 @@ class Bedrock {
|
|||||||
protected $controllerObject = null;
|
protected $controllerObject = null;
|
||||||
protected $controllerClass = '';
|
protected $controllerClass = '';
|
||||||
protected $params = [];
|
protected $params = [];
|
||||||
|
protected $controllerError = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The constructor handles the entire process of parsing the url,
|
* The constructor handles the entire process of parsing the url,
|
||||||
@ -46,8 +47,8 @@ class Bedrock {
|
|||||||
Debug::group( 'Bedrock Application' );
|
Debug::group( 'Bedrock Application' );
|
||||||
ob_start();
|
ob_start();
|
||||||
self::$activeConfig = new Config( CONFIG_JSON );
|
self::$activeConfig = new Config( CONFIG_JSON );
|
||||||
set_error_handler( [ 'TheTempusProject\\Canary\\Canary', 'handle_error' ] );
|
set_error_handler( [ BEDROCK_DEFAULT_ERROR_HANDLER, 'handle_error' ] );
|
||||||
set_exception_handler( [ 'TheTempusProject\\Canary\\Canary', 'handle_exception' ] );
|
set_exception_handler( [ BEDROCK_DEFAULT_EXCEPTION_HANDLER, 'handle_exception' ] );
|
||||||
self::$controllerName = DEFAULT_CONTROLLER_CLASS;
|
self::$controllerName = DEFAULT_CONTROLLER_CLASS;
|
||||||
self::$methodName = DEFAULT_CONTROLLER_METHOD;
|
self::$methodName = DEFAULT_CONTROLLER_METHOD;
|
||||||
$this->setUrl( $url );
|
$this->setUrl( $url );
|
||||||
@ -64,55 +65,6 @@ class Bedrock {
|
|||||||
$this->setVarsFromUrlArray( $urlArray );
|
$this->setVarsFromUrlArray( $urlArray );
|
||||||
}
|
}
|
||||||
|
|
||||||
public function load() {
|
|
||||||
$this->loadController();
|
|
||||||
$this->loadPage();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getUrl() {
|
|
||||||
return Routes::getAddress() . Input::get( 'url' );
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function loadPage() {
|
|
||||||
if ( !method_exists( $this->controllerClass, self::$methodName ) ) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
Components::set( 'META_IMAGE', Routes::getAddress() . Config::getValue( 'main/logoLarge' ) );
|
|
||||||
Components::set( 'CURRENT_URL', self::getCurrentUrl() );
|
|
||||||
Components::set( 'SITENAME', Config::getValue( 'main/name' ) );
|
|
||||||
Components::set( 'AUTHOR', '<meta name="author" content="' . Config::getValue( 'main/name' ) . '">' );
|
|
||||||
call_user_func_array( [ $this->controllerObject, self::$methodName ], $this->params );
|
|
||||||
Components::set( 'TITLE', Template::parse( $this->controllerObject::$title ) );
|
|
||||||
Components::set( 'PAGE_DESCRIPTION', Template::parse( $this->controllerObject::$pageDescription ) );
|
|
||||||
Template::render();
|
|
||||||
Debug::closeAllGroups();
|
|
||||||
// self::$session->updatePage( self::getUrl() ); // where did this method go?
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function loadController() {
|
|
||||||
if ( empty( $this->controllerClass ) ) {
|
|
||||||
$this->controllerClass = (string) APP_SPACE . '\\Controllers\\' . self::$controllerName;
|
|
||||||
}
|
|
||||||
$this->controllerObject = new $this->controllerClass;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function setController( $name, $namespace ) {
|
|
||||||
$controllerClass = $namespace . ucfirst( $name );
|
|
||||||
if ( Autoloader::testLoad( $controllerClass ) ) {
|
|
||||||
$this->controllerClass = $controllerClass;
|
|
||||||
self::$controllerName = $name;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function setPage( $name ) {
|
|
||||||
$name = strtolower( $name );
|
|
||||||
if ( !method_exists( $this->controllerClass, $name ) ) {
|
|
||||||
Debug::info( 'setPage - Method not found: ' . $name );
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
self::$methodName = $name;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function setVarsFromUrlArray( $urlArray ) {
|
protected function setVarsFromUrlArray( $urlArray ) {
|
||||||
if ( !empty( $urlArray[0] ) ) {
|
if ( !empty( $urlArray[0] ) ) {
|
||||||
$urlPart = array_shift( $urlArray );
|
$urlPart = array_shift( $urlArray );
|
||||||
@ -154,6 +106,66 @@ class Bedrock {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function load() {
|
||||||
|
$this->loadController();
|
||||||
|
$this->loadPage();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getUrl() {
|
||||||
|
return Routes::getAddress() . Input::get( 'url' );
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function loadPage() {
|
||||||
|
if ( !method_exists( $this->controllerClass, self::$methodName ) ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
Components::set( 'META_IMAGE', Routes::getAddress() . Config::getValue( 'main/logoLarge' ) );
|
||||||
|
Components::set( 'CURRENT_URL', self::getCurrentUrl() );
|
||||||
|
Components::set( 'CURRENT_URL_SAFE', urlencode( self::getUrl() ) );
|
||||||
|
Components::set( 'SITENAME', Config::getValue( 'main/name' ) ?? APP_NAME );
|
||||||
|
Components::set( 'AUTHOR', '<meta name="author" content="' . Config::getValue( 'main/name' ) . '">' );
|
||||||
|
call_user_func_array( [ $this->controllerObject, self::$methodName ], $this->params );
|
||||||
|
Components::set( 'TITLE', Template::parse( $this->controllerObject::$title ) );
|
||||||
|
Components::set( 'PAGE_DESCRIPTION', Template::parse( $this->controllerObject::$pageDescription ) );
|
||||||
|
Template::render();
|
||||||
|
Debug::closeAllGroups();
|
||||||
|
// self::$session->updatePage( self::getUrl() ); // where did this method go?
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function loadController() {
|
||||||
|
if ( empty( $this->controllerClass ) ) {
|
||||||
|
$this->controllerClass = (string) APP_SPACE . '\\Controllers\\' . self::$controllerName;
|
||||||
|
}
|
||||||
|
if ( empty( $this->controllerError ) ) {
|
||||||
|
Components::set( 'TOKEN', Token::generate() );
|
||||||
|
}
|
||||||
|
$this->controllerObject = new $this->controllerClass;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function setController( $name, $namespace ) {
|
||||||
|
$controllerClass = $namespace . ucfirst( $name );
|
||||||
|
if ( Autoloader::testLoad( $controllerClass ) ) {
|
||||||
|
$this->controllerClass = $controllerClass;
|
||||||
|
self::$controllerName = $name;
|
||||||
|
} else {
|
||||||
|
$this->controllerError = 'setController - Controller not found. Name: ' . $name . ' Namespace: ' . $namespace;
|
||||||
|
Debug::info( $this->controllerError );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function setPage( $name ) {
|
||||||
|
$name = strtolower( $name );
|
||||||
|
if ( empty( $this->controllerClass ) ) {
|
||||||
|
Debug::info( 'setPage - controllerClass Empty' );
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if ( ! method_exists( $this->controllerClass, $name ) ) {
|
||||||
|
Debug::info( 'setPage - Method not found. Controller: ' . $this->controllerClass . ' Method: ' . $name );
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
self::$methodName = $name;
|
||||||
|
}
|
||||||
|
|
||||||
public static function getCurrentUrl() {
|
public static function getCurrentUrl() {
|
||||||
return Sanitize::url( Input::get( 'url' ) );
|
return Sanitize::url( Input::get( 'url' ) );
|
||||||
}
|
}
|
@ -4,16 +4,17 @@
|
|||||||
*
|
*
|
||||||
* This class handles all the hard-coded configurations.
|
* This class handles all the hard-coded configurations.
|
||||||
*
|
*
|
||||||
* @version 3.0
|
* @version 1.1.2
|
||||||
* @author Joey Kimsey <Joey@thetempusproject.com>
|
* @author Joey Kimsey <Joey@thetempusproject.com>
|
||||||
* @link https://TheTempusProject.com/Core
|
* @link https://TheTempusProject.com/libraries/Bedrock
|
||||||
* @license https://opensource.org/licenses/MIT [MIT LICENSE]
|
* @license https://opensource.org/licenses/MIT [MIT LICENSE]
|
||||||
*/
|
*/
|
||||||
namespace TheTempusProject\Bedrock\Classes;
|
namespace TheTempusProject\Bedrock\Classes;
|
||||||
|
|
||||||
use TheTempusProject\Canary\Canary as Debug;
|
use TheTempusProject\Canary\Bin\Canary as Debug;
|
||||||
use TheTempusProject\Bedrock\Functions\Check;
|
use TheTempusProject\Bedrock\Functions\Check;
|
||||||
use TheTempusProject\Bedrock\Functions\Input;
|
use TheTempusProject\Bedrock\Functions\Input;
|
||||||
|
use TheTempusProject\Bedrock\Functions\Upload;
|
||||||
|
|
||||||
class Config {
|
class Config {
|
||||||
public static $config = false;
|
public static $config = false;
|
||||||
@ -145,7 +146,19 @@ class Config {
|
|||||||
}
|
}
|
||||||
$fieldname = str_ireplace( '/', '-', $name );
|
$fieldname = str_ireplace( '/', '-', $name );
|
||||||
if ( Input::exists( $fieldname ) ) {
|
if ( Input::exists( $fieldname ) ) {
|
||||||
$this->update( $category, $field, Input::post( $fieldname ) );
|
if ( 'file' == $node['type'] ) {
|
||||||
|
$upload = Upload::image( $fieldname, IMAGE_DIRECTORY );
|
||||||
|
if ( $upload ) {
|
||||||
|
$route = str_replace( APP_ROOT_DIRECTORY, '', IMAGE_DIRECTORY );
|
||||||
|
$this->update( $category, $field, $route . Upload::last() );
|
||||||
|
} else {
|
||||||
|
Debug::error( 'There was an error with your upload.');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$this->update( $category, $field, Input::post( $fieldname ) );
|
||||||
|
}
|
||||||
|
} elseif ( 'radio' == $node['type'] ) {
|
||||||
|
$this->update( $category, $field, false );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,20 +1,20 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* core/controller.php
|
* classes/controller.php
|
||||||
*
|
*
|
||||||
* The controller handles our main template and provides the
|
* The controller handles our main template and provides the
|
||||||
* model and view functions which are the backbone of the tempus
|
* model and view functions which are the backbone of the tempus
|
||||||
* project. Used to hold and keep track of many of the variables
|
* project. Used to hold and keep track of many of the variables
|
||||||
* that support the applications execution.
|
* that support the applications execution.
|
||||||
*
|
*
|
||||||
* @version 3.0
|
* @version 1.1.2
|
||||||
* @author Joey Kimsey <Joey@thetempusproject.com>
|
* @author Joey Kimsey <Joey@thetempusproject.com>
|
||||||
* @link https://TheTempusProject.com/Core
|
* @link https://TheTempusProject.com/libraries/Bedrock
|
||||||
* @license https://opensource.org/licenses/MIT [MIT LICENSE]
|
* @license https://opensource.org/licenses/MIT [MIT LICENSE]
|
||||||
*/
|
*/
|
||||||
namespace TheTempusProject\Bedrock\Classes;
|
namespace TheTempusProject\Bedrock\Classes;
|
||||||
|
|
||||||
use TheTempusProject\Canary\Canary as Debug;
|
use TheTempusProject\Canary\Bin\Canary as Debug;
|
||||||
use TheTempusProject\Bedrock\Functions\Session;
|
use TheTempusProject\Bedrock\Functions\Session;
|
||||||
use TheTempusProject\Houdini\Classes\Issues;
|
use TheTempusProject\Houdini\Classes\Issues;
|
||||||
|
|
@ -6,17 +6,17 @@
|
|||||||
*
|
*
|
||||||
* @todo - Add more than just MySQL
|
* @todo - Add more than just MySQL
|
||||||
*
|
*
|
||||||
* @version 3.0
|
* @version 1.1.2
|
||||||
* @author Joey Kimsey <Joey@thetempusproject.com>
|
* @author Joey Kimsey <Joey@thetempusproject.com>
|
||||||
* @link https://TheTempusProject.com/Core
|
* @link https://TheTempusProject.com/libraries/Bedrock
|
||||||
* @license https://opensource.org/licenses/MIT [MIT LICENSE]
|
* @license https://opensource.org/licenses/MIT [MIT LICENSE]
|
||||||
*/
|
*/
|
||||||
namespace TheTempusProject\Bedrock\Classes;
|
namespace TheTempusProject\Bedrock\Classes;
|
||||||
|
|
||||||
use PDO;
|
use PDO;
|
||||||
use PDOException;
|
use PDOException;
|
||||||
use TheTempusProject\Houdini\Classes\Pagination;
|
use TheTempusProject\Canary\Bin\Canary as Debug;
|
||||||
use TheTempusProject\Canary\Canary as Debug;
|
use TheTempusProject\Canary\Classes\CustomException;
|
||||||
|
|
||||||
class Database {
|
class Database {
|
||||||
public static $instance = null;
|
public static $instance = null;
|
||||||
@ -91,14 +91,19 @@ class Database {
|
|||||||
$this->errorMessage = $Exception->getMessage();
|
$this->errorMessage = $Exception->getMessage();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( !$this->enabled() ) {
|
if ( ! $this->enabled() ) {
|
||||||
$this->error = true;
|
$this->error = true;
|
||||||
$this->errorMessage = 'Database disabled in config.';
|
$this->errorMessage = 'Database disabled in config.';
|
||||||
}
|
}
|
||||||
if ( $this->error === false ) {
|
if ( $this->error === false ) {
|
||||||
try {
|
try {
|
||||||
Debug::debug( 'Attempting to connect to DB with config credentials.' );
|
Debug::debug( 'Attempting to connect to DB with config credentials.' );
|
||||||
$this->pdo = new PDO( 'mysql:host=' . Config::getValue( 'database/dbHost' ) . ';dbname=' . Config::getValue( 'database/dbName' ), Config::getValue( 'database/dbUsername' ), Config::getValue( 'database/dbPassword' ) );
|
$this->pdo = new PDO(
|
||||||
|
'mysql:host=' . Config::getValue( 'database/dbHost' ) .
|
||||||
|
';dbname=' . Config::getValue( 'database/dbName' ),
|
||||||
|
Config::getValue( 'database/dbUsername' ),
|
||||||
|
Config::getValue( 'database/dbPassword' )
|
||||||
|
);
|
||||||
} catch ( PDOException $Exception ) {
|
} catch ( PDOException $Exception ) {
|
||||||
$this->error = true;
|
$this->error = true;
|
||||||
$this->errorMessage = $Exception->getMessage();
|
$this->errorMessage = $Exception->getMessage();
|
||||||
@ -274,7 +279,7 @@ class Database {
|
|||||||
foreach ( $params as $param ) {
|
foreach ( $params as $param ) {
|
||||||
$x++;
|
$x++;
|
||||||
if ( is_array( $param ) ) {
|
if ( is_array( $param ) ) {
|
||||||
dv( $param );
|
// dv( $param );
|
||||||
}
|
}
|
||||||
$this->query->bindValue( $x, $param );
|
$this->query->bindValue( $x, $param );
|
||||||
}
|
}
|
||||||
@ -349,7 +354,7 @@ class Database {
|
|||||||
}
|
}
|
||||||
$tableName = Config::getValue( 'database/dbPrefix' ) . $tableName;
|
$tableName = Config::getValue( 'database/dbPrefix' ) . $tableName;
|
||||||
$sql = "{$action} FROM `{$tableName}` WHERE ";
|
$sql = "{$action} FROM `{$tableName}` WHERE ";
|
||||||
$validOperators = ['=', '!=', '>', '<', '>=', '<=', 'LIKE', 'IS'];
|
$validOperators = ['=', '!=', '>', '<', '>=', '<=', 'LIKE', 'IS', 'IN'];
|
||||||
$validDelimiters = ['AND', 'OR'];
|
$validDelimiters = ['AND', 'OR'];
|
||||||
$values = [];
|
$values = [];
|
||||||
while ( $whereCount > 2 ) {
|
while ( $whereCount > 2 ) {
|
||||||
@ -637,10 +642,29 @@ class Database {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function search( $table, $column, $param ) {
|
public function searchColumn( $table, $column, $param ) {
|
||||||
return $this->action( 'SELECT *', $table, [$column, 'LIKE', '%' . $param . '%'] );
|
return $this->action( 'SELECT *', $table, [$column, 'LIKE', '%' . $param . '%'] );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function search( $table, $columns, $param ) {
|
||||||
|
if ( empty( $columns ) || ! is_array( $columns ) ) {
|
||||||
|
Debug::log( 'No columns provided for search' );
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
$conditions = [];
|
||||||
|
foreach ( $columns as $column ) {
|
||||||
|
$conditions[] = $column;
|
||||||
|
$conditions[] = 'LIKE';
|
||||||
|
$conditions[] = '%' . $param . '%';
|
||||||
|
$conditions[] = 'OR';
|
||||||
|
}
|
||||||
|
array_pop( $conditions );
|
||||||
|
|
||||||
|
return $this->action( 'SELECT *', $table, $conditions );
|
||||||
|
// return $this->action( 'SELECT ' . implode( ',', $columns ), $table, $conditions ); // need to find a way to casually make this the default....
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Selects data from the database.
|
* Selects data from the database.
|
||||||
*
|
*
|
@ -1,24 +1,25 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* core/database_model.php
|
* classes/DatabaseModel.php
|
||||||
*
|
*
|
||||||
* The class provides some basic functionality for models that interact
|
* The class provides some basic functionality for models that interact
|
||||||
* with the database.
|
* with the database.
|
||||||
*
|
*
|
||||||
* @version 3.0
|
* @version 1.1.2
|
||||||
* @author Joey Kimsey <Joey@thetempusproject.com>
|
* @author Joey Kimsey <Joey@thetempusproject.com>
|
||||||
* @link https://TheTempusProject.com/Core
|
* @link https://TheTempusProject.com/libraries/Bedrock
|
||||||
* @license https://opensource.org/licenses/MIT [MIT LICENSE]
|
* @license https://opensource.org/licenses/MIT [MIT LICENSE]
|
||||||
*/
|
*/
|
||||||
namespace TheTempusProject\Bedrock\Classes;
|
namespace TheTempusProject\Bedrock\Classes;
|
||||||
|
|
||||||
use TheTempusProject\Canary\Canary as Debug;
|
use TheTempusProject\Canary\Bin\Canary as Debug;
|
||||||
use TheTempusProject\Bedrock\Functions\Check;
|
use TheTempusProject\Bedrock\Functions\Check;
|
||||||
use TheTempusProject\Bedrock\Bedrock;
|
use TheTempusProject\Bedrock\Bedrock;
|
||||||
|
|
||||||
class DatabaseModel extends Model {
|
class DatabaseModel extends Model {
|
||||||
public $databaseMatrix;
|
|
||||||
public $tableName;
|
public $tableName;
|
||||||
|
public $databaseMatrix;
|
||||||
|
public $searchFields;
|
||||||
|
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
@ -190,4 +191,19 @@ class DatabaseModel extends Model {
|
|||||||
}
|
}
|
||||||
return $this->filter( $data->results() );
|
return $this->filter( $data->results() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function search($param) {
|
||||||
|
if (empty($this->searchFields)) {
|
||||||
|
Debug::log('searchFields is empty');
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
$result = self::$db->search($this->tableName, $this->searchFields, $param);
|
||||||
|
|
||||||
|
if ( $result->count() ) {
|
||||||
|
return $this->filter( $result->results() );
|
||||||
|
}
|
||||||
|
|
||||||
|
return [];
|
||||||
|
}
|
||||||
}
|
}
|
@ -1,17 +1,17 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* core/model.php
|
* classes/model.php
|
||||||
*
|
*
|
||||||
* The class provides some basic functionality for models.
|
* The class provides some basic functionality for models.
|
||||||
*
|
*
|
||||||
* @version 3.0
|
* @version 1.1.2
|
||||||
* @author Joey Kimsey <Joey@thetempusproject.com>
|
* @author Joey Kimsey <Joey@thetempusproject.com>
|
||||||
* @link https://TheTempusProject.com/Core
|
* @link https://TheTempusProject.com/libraries/Bedrock
|
||||||
* @license https://opensource.org/licenses/MIT [MIT LICENSE]
|
* @license https://opensource.org/licenses/MIT [MIT LICENSE]
|
||||||
*/
|
*/
|
||||||
namespace TheTempusProject\Bedrock\Classes;
|
namespace TheTempusProject\Bedrock\Classes;
|
||||||
|
|
||||||
use TheTempusProject\Canary\Canary as Debug;
|
use TheTempusProject\Canary\Bin\Canary as Debug;
|
||||||
use TheTempusProject\Bedrock\Classes\Config;
|
use TheTempusProject\Bedrock\Classes\Config;
|
||||||
use TheTempusProject\Bedrock\Classes\Database;
|
use TheTempusProject\Bedrock\Classes\Database;
|
||||||
|
|
||||||
@ -66,14 +66,11 @@ class Model {
|
|||||||
$ids[] = $id;
|
$ids[] = $id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $ids;
|
return [ $this->tableName => $ids ];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function uninstallResources() {
|
public function uninstallResources() {
|
||||||
// this one needs some work
|
// this one needs some work
|
||||||
// should probably save the created resource ID's or something and remove them.
|
|
||||||
// presumably this isn't a big issue because i would imagine the table is removed
|
|
||||||
// there may be future instances where you can create resources for other tables
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -1,22 +1,24 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* core/template/pagination.php
|
* classes/pagination.php
|
||||||
*
|
*
|
||||||
* This class is for managing template pagination.
|
* This class is for managing template pagination.
|
||||||
*
|
*
|
||||||
* @version 3.0
|
* @version 1.1.2
|
||||||
* @author Joey Kimsey <Joey@thetempusproject.com>
|
* @author Joey Kimsey <Joey@thetempusproject.com>
|
||||||
* @link https://TheTempusProject.com/Core
|
* @link https://TheTempusProject.com/libraries/Bedrock
|
||||||
* @license https://opensource.org/licenses/MIT [MIT LICENSE]
|
* @license https://opensource.org/licenses/MIT [MIT LICENSE]
|
||||||
*/
|
*/
|
||||||
namespace TheTempusProject\Houdini\Classes;
|
namespace TheTempusProject\Bedrock\Classes;
|
||||||
|
|
||||||
use TheTempusProject\Houdini\Classes\Template;
|
use TheTempusProject\Houdini\Classes\Template;
|
||||||
use TheTempusProject\Hermes\Functions\Route as Routes;
|
use TheTempusProject\Hermes\Functions\Route as Routes;
|
||||||
use TheTempusProject\Bedrock\Functions\Input;
|
use TheTempusProject\Bedrock\Functions\Input;
|
||||||
use TheTempusProject\Bedrock\Classes\Config;
|
use TheTempusProject\Bedrock\Classes\Config;
|
||||||
use TheTempusProject\Bedrock\Functions\Check;
|
use TheTempusProject\Bedrock\Functions\Check;
|
||||||
use TheTempusProject\Canary\Canary as Debug;
|
use TheTempusProject\Canary\Bin\Canary as Debug;
|
||||||
|
use TheTempusProject\Houdini\Classes\Components;
|
||||||
|
use TheTempusProject\Houdini\Classes\Views;
|
||||||
|
|
||||||
class Pagination extends Template {
|
class Pagination extends Template {
|
||||||
//The settings that will not change
|
//The settings that will not change
|
||||||
@ -154,7 +156,7 @@ class Pagination extends Template {
|
|||||||
$pageData = (object) $pageData;
|
$pageData = (object) $pageData;
|
||||||
|
|
||||||
if ( self::totalPages() <= 1 ) {
|
if ( self::totalPages() <= 1 ) {
|
||||||
Components::set( 'PAGINATION', 'no pagination' );
|
Components::set( 'PAGINATION', '' );
|
||||||
} else {
|
} else {
|
||||||
Components::set( 'PAGINATION', Views::simpleView( 'nav.pagination', $pageData ) );
|
Components::set( 'PAGINATION', Views::simpleView( 'nav.pagination', $pageData ) );
|
||||||
}
|
}
|
@ -6,10 +6,12 @@
|
|||||||
"minimum-stability": "dev",
|
"minimum-stability": "dev",
|
||||||
"keywords":
|
"keywords":
|
||||||
[
|
[
|
||||||
|
"thetempusproject",
|
||||||
|
"php",
|
||||||
"mvc",
|
"mvc",
|
||||||
"framework"
|
"framework"
|
||||||
],
|
],
|
||||||
"homepage": "https://git.thetempusproject.com/the-tempus-project/bedrock",
|
"homepage": "https://thetempusproject.com/libraries/bedrock",
|
||||||
"authors":
|
"authors":
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
@ -22,21 +24,21 @@
|
|||||||
"require":
|
"require":
|
||||||
{
|
{
|
||||||
"php": ">=8.1.0",
|
"php": ">=8.1.0",
|
||||||
"thetempusproject/canary": ">=1.0",
|
"thetempusproject/canary": "1.0.9",
|
||||||
"thetempusproject/hermes": ">=1.0",
|
"thetempusproject/hermes": "1.0.5",
|
||||||
"thetempusproject/houdini": ">=1.0"
|
"thetempusproject/houdini": "2.0.5"
|
||||||
},
|
},
|
||||||
"autoload":
|
"autoload":
|
||||||
{
|
{
|
||||||
"psr-4":
|
"classmap":
|
||||||
{
|
[
|
||||||
"TheTempusProject\\Bedroock\\Classes\\": "Classes",
|
"classes",
|
||||||
"TheTempusProject\\Bedroock\\Functions\\": "Functions"
|
"functions"
|
||||||
},
|
],
|
||||||
"files":
|
"files":
|
||||||
[
|
[
|
||||||
"Config/constants.php",
|
"config/constants.php",
|
||||||
"Bin/Bedrock.php"
|
"bin/bedrock.php"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
49
composer.lock
generated
49
composer.lock
generated
@ -4,29 +4,28 @@
|
|||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"content-hash": "4467bdc4b2a87dc7540fc9854ebd9384",
|
"content-hash": "8c8b2e1232989c7e9998964f1fe5fc86",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "thetempusproject/canary",
|
"name": "thetempusproject/canary",
|
||||||
"version": "dev-main",
|
"version": "1.0.9",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://git.thetempusproject.com/the-tempus-project/canary",
|
"url": "https://git.thetempusproject.com/the-tempus-project/canary",
|
||||||
"reference": "7746eb4af73f3eaba040d547904a251bbdab6977"
|
"reference": "77cef522e9919573836901eb82b59b20f453fb61"
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"php": ">=8.1.0"
|
"php": ">=8.1.0"
|
||||||
},
|
},
|
||||||
"default-branch": true,
|
|
||||||
"type": "library",
|
"type": "library",
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"files": [
|
"files": [
|
||||||
"Config/constants.php",
|
"config/constants.php",
|
||||||
"Bin/Canary.php"
|
"bin/canary.php"
|
||||||
],
|
],
|
||||||
"psr-4": {
|
"classmap": [
|
||||||
"TheTempusProject\\Canary\\Classes\\": "Classes"
|
"classes"
|
||||||
}
|
]
|
||||||
},
|
},
|
||||||
"notification-url": "https://packagist.org/downloads/",
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
"license": [
|
"license": [
|
||||||
@ -41,27 +40,27 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"description": "Functionality for tracking, logging, and sending log messages to chrome for debugging.",
|
"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": [
|
"keywords": [
|
||||||
"debugging",
|
"debugging",
|
||||||
|
"logging",
|
||||||
"php",
|
"php",
|
||||||
"thetempusproject",
|
"thetempusproject",
|
||||||
"tools"
|
"tools"
|
||||||
],
|
],
|
||||||
"time": "2024-08-09T04:35:45+00:00"
|
"time": "2025-02-04T12:16:29+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "thetempusproject/hermes",
|
"name": "thetempusproject/hermes",
|
||||||
"version": "dev-main",
|
"version": "1.0.5",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://git.thetempusproject.com/the-tempus-project/hermes",
|
"url": "https://git.thetempusproject.com/the-tempus-project/hermes",
|
||||||
"reference": "9d6a79d80be98d0e598ce08c47a98d37814d1105"
|
"reference": "802581b1d2d70877ccc75d8954b33efcc05d9371"
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"php": ">=8.1.0"
|
"php": ">=8.1.0"
|
||||||
},
|
},
|
||||||
"default-branch": true,
|
|
||||||
"type": "library",
|
"type": "library",
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"files": [
|
"files": [
|
||||||
@ -84,30 +83,30 @@
|
|||||||
"role": "Lead Developer"
|
"role": "Lead Developer"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"description": "Php functions that aid in routing and redirecting; requests and responses.",
|
"description": "This library handles redirects, provides a common backbone for routing, and can handle autoloading in cases where composer is unavailable.",
|
||||||
"homepage": "https://git.thetempusproject.com/the-tempus-project/hermes",
|
"homepage": "https://thetempusproject.com/libraries/hermes",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
|
"autoloader",
|
||||||
"php",
|
"php",
|
||||||
"routing",
|
"routing",
|
||||||
"thetempusproject",
|
"thetempusproject",
|
||||||
"tools"
|
"tools"
|
||||||
],
|
],
|
||||||
"time": "2024-08-08T05:24:32+00:00"
|
"time": "2025-02-02T23:22:15+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "thetempusproject/houdini",
|
"name": "thetempusproject/houdini",
|
||||||
"version": "dev-main",
|
"version": "2.0.5",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://git.thetempusproject.com/the-tempus-project/houdini",
|
"url": "https://git.thetempusproject.com/the-tempus-project/houdini",
|
||||||
"reference": "008d7d90230f9eee87d8dbe982e55fae433e1337"
|
"reference": "2c7538471ab1f900048ccdb2c71d6bf2bee975e0"
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"php": ">=8.1.0",
|
"php": ">=8.1.0",
|
||||||
"thetempusproject/canary": ">=1.0",
|
"thetempusproject/canary": "1.0.9",
|
||||||
"thetempusproject/hermes": ">=1.0"
|
"thetempusproject/hermes": "1.0.5"
|
||||||
},
|
},
|
||||||
"default-branch": true,
|
|
||||||
"type": "library",
|
"type": "library",
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"files": [
|
"files": [
|
||||||
@ -129,15 +128,15 @@
|
|||||||
"role": "Lead Developer"
|
"role": "Lead Developer"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"description": "Php functions that aid in creating, managing, and displaying frontend components.",
|
"description": "This library handles creating, managing, and displaying frontend components.",
|
||||||
"homepage": "https://git.thetempusproject.com/the-tempus-project/houdini",
|
"homepage": "https://thetempusproject.com/libraries/houdini",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"frontend",
|
"frontend",
|
||||||
"php",
|
"php",
|
||||||
"thetempusproject",
|
"thetempusproject",
|
||||||
"tools"
|
"tools"
|
||||||
],
|
],
|
||||||
"time": "2024-08-09T04:38:04+00:00"
|
"time": "2025-02-04T12:19:25+00:00"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"packages-dev": [],
|
"packages-dev": [],
|
||||||
|
@ -47,24 +47,30 @@
|
|||||||
}
|
}
|
||||||
// Debug
|
// Debug
|
||||||
// Log Levels
|
// Log Levels
|
||||||
if ( ! defined('CANARY_DEBUG_LEVEL_ERROR' ) ) {
|
if ( ! defined('CANARY_DEBUG_LEVEL_ERROR' ) ) {
|
||||||
define( 'CANARY_DEBUG_LEVEL_ERROR', 'error' );
|
define( 'CANARY_DEBUG_LEVEL_ERROR', 'error' );
|
||||||
}
|
}
|
||||||
if ( ! defined('CANARY_DEBUG_LEVEL_WARN' ) ) {
|
if ( ! defined('CANARY_DEBUG_LEVEL_WARN' ) ) {
|
||||||
define( 'CANARY_DEBUG_LEVEL_WARN', 'warn' );
|
define( 'CANARY_DEBUG_LEVEL_WARN', 'warn' );
|
||||||
}
|
}
|
||||||
if ( ! defined('CANARY_DEBUG_LEVEL_INFO' ) ) {
|
if ( ! defined('CANARY_DEBUG_LEVEL_INFO' ) ) {
|
||||||
define( 'CANARY_DEBUG_LEVEL_INFO', 'info' );
|
define( 'CANARY_DEBUG_LEVEL_INFO', 'info' );
|
||||||
}
|
}
|
||||||
if ( ! defined('CANARY_DEBUG_LEVEL_LOG' ) ) {
|
if ( ! defined('CANARY_DEBUG_LEVEL_LOG' ) ) {
|
||||||
define( 'CANARY_DEBUG_LEVEL_LOG', 'log' );
|
define( 'CANARY_DEBUG_LEVEL_LOG', 'log' );
|
||||||
}
|
}
|
||||||
if ( ! defined('CANARY_DEBUG_LEVEL_DEBUG' ) ) {
|
if ( ! defined('CANARY_DEBUG_LEVEL_DEBUG' ) ) {
|
||||||
define( 'CANARY_DEBUG_LEVEL_DEBUG', 'debug' );
|
define( 'CANARY_DEBUG_LEVEL_DEBUG', 'debug' );
|
||||||
}
|
}
|
||||||
if (!defined('CANARY_ENABLED')) {
|
if (!defined('CANARY_ENABLED')) {
|
||||||
define('CANARY_ENABLED', false);
|
define('CANARY_ENABLED', false);
|
||||||
}
|
}
|
||||||
|
if (!defined('BEDROCK_DEFAULT_ERROR_HANDLER')) {
|
||||||
|
define('BEDROCK_DEFAULT_ERROR_HANDLER', 'TheTempusProject\\Canary\\Bin\\Canary');
|
||||||
|
}
|
||||||
|
if (!defined('BEDROCK_DEFAULT_EXCEPTION_HANDLER')) {
|
||||||
|
define('BEDROCK_DEFAULT_EXCEPTION_HANDLER', 'TheTempusProject\\Canary\\Bin\\Canary');
|
||||||
|
}
|
||||||
if (!defined('DEBUG_EMAIL')) {
|
if (!defined('DEBUG_EMAIL')) {
|
||||||
define('DEBUG_EMAIL', 'webmaster@' . $_SERVER['HTTP_HOST']);
|
define('DEBUG_EMAIL', 'webmaster@' . $_SERVER['HTTP_HOST']);
|
||||||
}
|
}
|
||||||
@ -114,40 +120,6 @@
|
|||||||
if (!defined('BEDROCK_CONFIG_JSON')) {
|
if (!defined('BEDROCK_CONFIG_JSON')) {
|
||||||
define('BEDROCK_CONFIG_JSON', BEDROCK_CONFIG_DIRECTORY . 'config.json');
|
define('BEDROCK_CONFIG_JSON', BEDROCK_CONFIG_DIRECTORY . 'config.json');
|
||||||
}
|
}
|
||||||
// Shared Directories
|
|
||||||
if (!defined('APP_ROOT_DIRECTORY')) {
|
|
||||||
define('APP_ROOT_DIRECTORY', BEDROCK_ROOT_DIRECTORY);
|
|
||||||
}
|
|
||||||
if (!defined('CONFIG_DIRECTORY')) {
|
|
||||||
define('CONFIG_DIRECTORY', BEDROCK_CONFIG_DIRECTORY);
|
|
||||||
}
|
|
||||||
if (!defined('BIN_DIRECTORY')) {
|
|
||||||
define('BIN_DIRECTORY', BEDROCK_BIN_DIRECTORY);
|
|
||||||
}
|
|
||||||
if (!defined('VIEW_DIRECTORY')) {
|
|
||||||
define('VIEW_DIRECTORY', BEDROCK_VIEW_DIRECTORY);
|
|
||||||
}
|
|
||||||
if (!defined('ERRORS_DIRECTORY')) {
|
|
||||||
define('ERRORS_DIRECTORY', BEDROCK_ERRORS_DIRECTORY);
|
|
||||||
}
|
|
||||||
if (!defined('CLASSES_DIRECTORY')) {
|
|
||||||
define('CLASSES_DIRECTORY', BEDROCK_CLASSES_DIRECTORY);
|
|
||||||
}
|
|
||||||
if (!defined('FUNCTIONS_DIRECTORY')) {
|
|
||||||
define('FUNCTIONS_DIRECTORY', BEDROCK_FUNCTIONS_DIRECTORY);
|
|
||||||
}
|
|
||||||
if (!defined('RESOURCES_DIRECTORY')) {
|
|
||||||
define('RESOURCES_DIRECTORY', BEDROCK_RESOURCES_DIRECTORY);
|
|
||||||
}
|
|
||||||
if (!defined('TEMPLATE_DIRECTORY')) {
|
|
||||||
define('TEMPLATE_DIRECTORY', BEDROCK_ROOT_DIRECTORY . 'templates' . DIRECTORY_SEPARATOR);
|
|
||||||
}
|
|
||||||
if (!defined('UPLOAD_DIRECTORY')) {
|
|
||||||
define('UPLOAD_DIRECTORY', BEDROCK_ROOT_DIRECTORY . 'uploads' . DIRECTORY_SEPARATOR);
|
|
||||||
}
|
|
||||||
if (!defined('IMAGE_UPLOAD_DIRECTORY')) {
|
|
||||||
define('IMAGE_UPLOAD_DIRECTORY', BEDROCK_ROOT_DIRECTORY . 'images' . DIRECTORY_SEPARATOR);
|
|
||||||
}
|
|
||||||
// Files
|
// Files
|
||||||
if (!defined('COMPOSER_JSON_LOCATION')) {
|
if (!defined('COMPOSER_JSON_LOCATION')) {
|
||||||
define('COMPOSER_JSON_LOCATION', APP_ROOT_DIRECTORY . 'composer.json');
|
define('COMPOSER_JSON_LOCATION', APP_ROOT_DIRECTORY . 'composer.json');
|
||||||
@ -201,6 +173,10 @@
|
|||||||
if (!defined('TOKEN_ENABLED')) {
|
if (!defined('TOKEN_ENABLED')) {
|
||||||
define('TOKEN_ENABLED', true);
|
define('TOKEN_ENABLED', true);
|
||||||
}
|
}
|
||||||
|
// dUH
|
||||||
|
if (!defined('APP_NAME')) {
|
||||||
|
define('APP_NAME', 'Bedrock Application');
|
||||||
|
}
|
||||||
# Tell the app all constants have been loaded.
|
# Tell the app all constants have been loaded.
|
||||||
if ( ! defined('BEDROCK_CONSTANTS_LOADED' ) ) {
|
if ( ! defined('BEDROCK_CONSTANTS_LOADED' ) ) {
|
||||||
define( 'BEDROCK_CONSTANTS_LOADED', true );
|
define( 'BEDROCK_CONSTANTS_LOADED', true );
|
@ -4,15 +4,15 @@
|
|||||||
*
|
*
|
||||||
* This class is used to test various inputs.
|
* This class is used to test various inputs.
|
||||||
*
|
*
|
||||||
* @version 3.0
|
* @version 1.1.2
|
||||||
* @author Joey Kimsey <Joey@thetempusproject.com>
|
* @author Joey Kimsey <Joey@thetempusproject.com>
|
||||||
* @link https://TheTempusProject.com/Core
|
* @link https://TheTempusProject.com/libraries/Bedrock
|
||||||
* @license https://opensource.org/licenses/MIT [MIT LICENSE]
|
* @license https://opensource.org/licenses/MIT [MIT LICENSE]
|
||||||
*/
|
*/
|
||||||
namespace TheTempusProject\Bedrock\Functions;
|
namespace TheTempusProject\Bedrock\Functions;
|
||||||
|
|
||||||
use TheTempusProject\Bedrock\Classes\Config;
|
use TheTempusProject\Bedrock\Classes\Config;
|
||||||
use TheTempusProject\Canary\Canary as Debug;
|
use TheTempusProject\Canary\Bin\Canary as Debug;
|
||||||
|
|
||||||
class Check {
|
class Check {
|
||||||
private static $formValidator = null;
|
private static $formValidator = null;
|
||||||
@ -99,25 +99,25 @@ class Check {
|
|||||||
* @return {bool}
|
* @return {bool}
|
||||||
*/
|
*/
|
||||||
public static function imageUpload( $imageName ) {
|
public static function imageUpload( $imageName ) {
|
||||||
if ( !Config::getValue( 'uploads/images' ) ) {
|
if ( ! Config::getValue( 'uploads/images' ) ) {
|
||||||
self::addError( 'Image uploads are disabled.' );
|
self::addUserError( 'Image uploads are disabled.' );
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if ( !isset( $_FILES[$imageName] ) ) {
|
if ( ! isset( $_FILES[ $imageName ] ) ) {
|
||||||
self::addError( 'File not found.', $imageName );
|
self::addUserError( 'File not found.', $imageName );
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if ( $_FILES[$imageName]['error'] != 0 ) {
|
if ( $_FILES[$imageName]['error'] != 0 ) {
|
||||||
self::addError( 'File error:' . $_FILES[$imageName]['error'] );
|
self::addUserError( 'File error:' . $_FILES[$imageName]['error'] );
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if ( $_FILES[$imageName]['size'] > Config::getValue( 'uploads/maxImageSize' ) ) {
|
if ( $_FILES[$imageName]['size'] > Config::getValue( 'uploads/maxImageSize' ) ) {
|
||||||
self::addError( 'Image is too large.' );
|
self::addUserError( 'Image is too large.' );
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$fileType = strrchr( $_FILES[$imageName]['name'], '.' );
|
$fileType = strrchr( $_FILES[$imageName]['name'], '.' );
|
||||||
if ( !( in_array( $fileType, ALLOWED_IMAGE_UPLOAD_EXTENTIONS ) ) ) {
|
if ( !( in_array( $fileType, ALLOWED_IMAGE_UPLOAD_EXTENTIONS ) ) ) {
|
||||||
self::addError( 'Invalid image type', $fileType );
|
self::addUserError( 'Invalid image type', $fileType );
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
@ -6,14 +6,14 @@
|
|||||||
*
|
*
|
||||||
* @todo Better code generation.
|
* @todo Better code generation.
|
||||||
*
|
*
|
||||||
* @version 3.0
|
* @version 1.1.2
|
||||||
* @author Joey Kimsey <Joey@thetempusproject.com>
|
* @author Joey Kimsey <Joey@thetempusproject.com>
|
||||||
* @link https://TheTempusProject.com/Core
|
* @link https://TheTempusProject.com/libraries/Bedrock
|
||||||
* @license https://opensource.org/licenses/MIT [MIT LICENSE]
|
* @license https://opensource.org/licenses/MIT [MIT LICENSE]
|
||||||
*/
|
*/
|
||||||
namespace TheTempusProject\Bedrock\Functions;
|
namespace TheTempusProject\Bedrock\Functions;
|
||||||
|
|
||||||
use TheTempusProject\Canary\Canary as Debug;
|
use TheTempusProject\Canary\Bin\Canary as Debug;
|
||||||
|
|
||||||
class Code {
|
class Code {
|
||||||
/**
|
/**
|
@ -4,14 +4,14 @@
|
|||||||
*
|
*
|
||||||
* This class is used for manipulation of cookies.
|
* This class is used for manipulation of cookies.
|
||||||
*
|
*
|
||||||
* @version 3.0
|
* @version 1.1.2
|
||||||
* @author Joey Kimsey <Joey@thetempusproject.com>
|
* @author Joey Kimsey <Joey@thetempusproject.com>
|
||||||
* @link https://TheTempusProject.com/Core
|
* @link https://TheTempusProject.com/libraries/Bedrock
|
||||||
* @license https://opensource.org/licenses/MIT [MIT LICENSE]
|
* @license https://opensource.org/licenses/MIT [MIT LICENSE]
|
||||||
*/
|
*/
|
||||||
namespace TheTempusProject\Bedrock\Functions;
|
namespace TheTempusProject\Bedrock\Functions;
|
||||||
|
|
||||||
use TheTempusProject\Canary\Canary as Debug;
|
use TheTempusProject\Canary\Bin\Canary as Debug;
|
||||||
|
|
||||||
class Cookie {
|
class Cookie {
|
||||||
/**
|
/**
|
@ -4,9 +4,9 @@
|
|||||||
*
|
*
|
||||||
* This class is used to manage date inputs in a site-wide repeatable way.
|
* This class is used to manage date inputs in a site-wide repeatable way.
|
||||||
*
|
*
|
||||||
* @version 3.0
|
* @version 1.1.2
|
||||||
* @author Joey Kimsey <Joey@thetempusproject.com>
|
* @author Joey Kimsey <Joey@thetempusproject.com>
|
||||||
* @link https://TheTempusProject.com/Core
|
* @link https://TheTempusProject.com/libraries/Bedrock
|
||||||
* @license https://opensource.org/licenses/MIT [MIT LICENSE]
|
* @license https://opensource.org/licenses/MIT [MIT LICENSE]
|
||||||
*/
|
*/
|
||||||
namespace TheTempusProject\Bedrock\Functions;
|
namespace TheTempusProject\Bedrock\Functions;
|
@ -4,14 +4,14 @@
|
|||||||
*
|
*
|
||||||
* This class is used to salt, hash, and check passwords.
|
* This class is used to salt, hash, and check passwords.
|
||||||
*
|
*
|
||||||
* @version 3.0
|
* @version 1.1.2
|
||||||
* @author Joey Kimsey <Joey@thetempusproject.com>
|
* @author Joey Kimsey <Joey@thetempusproject.com>
|
||||||
* @link https://TheTempusProject.com/Core
|
* @link https://TheTempusProject.com/libraries/Bedrock
|
||||||
* @license https://opensource.org/licenses/MIT [MIT LICENSE]
|
* @license https://opensource.org/licenses/MIT [MIT LICENSE]
|
||||||
*/
|
*/
|
||||||
namespace TheTempusProject\Bedrock\Functions;
|
namespace TheTempusProject\Bedrock\Functions;
|
||||||
|
|
||||||
use TheTempusProject\Canary\Canary as Debug;
|
use TheTempusProject\Canary\Bin\Canary as Debug;
|
||||||
|
|
||||||
class Hash {
|
class Hash {
|
||||||
/**
|
/**
|
@ -4,14 +4,14 @@
|
|||||||
*
|
*
|
||||||
* This class manages and returns GET, FILE, and POST variables.
|
* This class manages and returns GET, FILE, and POST variables.
|
||||||
*
|
*
|
||||||
* @version 3.0
|
* @version 1.1.2
|
||||||
* @author Joey Kimsey <Joey@thetempusproject.com>
|
* @author Joey Kimsey <Joey@thetempusproject.com>
|
||||||
* @link https://TheTempusProject.com/Core
|
* @link https://TheTempusProject.com/libraries/Bedrock
|
||||||
* @license https://opensource.org/licenses/MIT [MIT LICENSE]
|
* @license https://opensource.org/licenses/MIT [MIT LICENSE]
|
||||||
*/
|
*/
|
||||||
namespace TheTempusProject\Bedrock\Functions;
|
namespace TheTempusProject\Bedrock\Functions;
|
||||||
|
|
||||||
use TheTempusProject\Canary\Canary as Debug;
|
use TheTempusProject\Canary\Bin\Canary as Debug;
|
||||||
|
|
||||||
class Input {
|
class Input {
|
||||||
/**
|
/**
|
||||||
@ -29,7 +29,7 @@ class Input {
|
|||||||
} elseif ( self::file( $data ) ) {
|
} elseif ( self::file( $data ) ) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
Debug::info( 'Input::exists: No input Found: '. $data );
|
Debug::log( 'Input::exists: No input Found: '. $data );
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -43,11 +43,11 @@ class Input {
|
|||||||
*/
|
*/
|
||||||
public static function file( $data ) {
|
public static function file( $data ) {
|
||||||
if ( !isset( $_FILES[$data] ) ) {
|
if ( !isset( $_FILES[$data] ) ) {
|
||||||
Debug::debug( "Input - file : $data not found." );
|
Debug::log( "Input - file : $data not found." );
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if ( $_FILES[$data]['tmp_name'] == '' ) {
|
if ( $_FILES[$data]['tmp_name'] == '' ) {
|
||||||
Debug::debug( "Input - file : $data empty." );
|
Debug::log( "Input - file : $data empty." );
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return $_FILES[$data];
|
return $_FILES[$data];
|
@ -4,9 +4,9 @@
|
|||||||
*
|
*
|
||||||
* This class is used to sanitize user input.
|
* This class is used to sanitize user input.
|
||||||
*
|
*
|
||||||
* @version 3.0
|
* @version 1.1.2
|
||||||
* @author Joey Kimsey <Joey@thetempusproject.com>
|
* @author Joey Kimsey <Joey@thetempusproject.com>
|
||||||
* @link https://TheTempusProject.com/Core
|
* @link https://TheTempusProject.com/libraries/Bedrock
|
||||||
* @license https://opensource.org/licenses/MIT [MIT LICENSE]
|
* @license https://opensource.org/licenses/MIT [MIT LICENSE]
|
||||||
*/
|
*/
|
||||||
namespace TheTempusProject\Bedrock\Functions;
|
namespace TheTempusProject\Bedrock\Functions;
|
@ -4,14 +4,14 @@
|
|||||||
*
|
*
|
||||||
* This class is used for management of session data.
|
* This class is used for management of session data.
|
||||||
*
|
*
|
||||||
* @version 3.0
|
* @version 1.1.2
|
||||||
* @author Joey Kimsey <Joey@thetempusproject.com>
|
* @author Joey Kimsey <Joey@thetempusproject.com>
|
||||||
* @link https://TheTempusProject.com/Core
|
* @link https://TheTempusProject.com/libraries/Bedrock
|
||||||
* @license https://opensource.org/licenses/MIT [MIT LICENSE]
|
* @license https://opensource.org/licenses/MIT [MIT LICENSE]
|
||||||
*/
|
*/
|
||||||
namespace TheTempusProject\Bedrock\Functions;
|
namespace TheTempusProject\Bedrock\Functions;
|
||||||
|
|
||||||
use TheTempusProject\Canary\Canary as Debug;
|
use TheTempusProject\Canary\Bin\Canary as Debug;
|
||||||
|
|
||||||
class Session {
|
class Session {
|
||||||
/**
|
/**
|
||||||
@ -21,14 +21,17 @@ class Session {
|
|||||||
* @return {bool}
|
* @return {bool}
|
||||||
*/
|
*/
|
||||||
public static function exists( $name ) {
|
public static function exists( $name ) {
|
||||||
if ( !Check::sessionName( $name ) ) {
|
if (session_status() === PHP_SESSION_NONE) {
|
||||||
|
session_start();
|
||||||
|
}
|
||||||
|
if ( ! Check::sessionName( $name ) ) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$sessionName = DEFAULT_SESSION_PREFIX . $name;
|
$sessionName = DEFAULT_SESSION_PREFIX . $name;
|
||||||
if ( isset( $_SESSION[$sessionName] ) ) {
|
if ( isset( $_SESSION[ $sessionName ] ) ) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
Debug::info("Session::exists - Session not found: $sessionName");
|
Debug::log( "Session::exists - Session not found: $sessionName" );
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -39,14 +42,14 @@ class Session {
|
|||||||
* @return {string|bool} - Returns the data from the session or false if nothing is found..
|
* @return {string|bool} - Returns the data from the session or false if nothing is found..
|
||||||
*/
|
*/
|
||||||
public static function get( $name ) {
|
public static function get( $name ) {
|
||||||
if ( !Check::sessionName( $name ) ) {
|
if ( ! Check::sessionName( $name ) ) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
$sessionName = DEFAULT_SESSION_PREFIX . $name;
|
||||||
if ( self::exists( $name ) ) {
|
if ( self::exists( $name ) ) {
|
||||||
$sessionName = DEFAULT_SESSION_PREFIX . $name;
|
return $_SESSION[ $sessionName ];
|
||||||
return $_SESSION[$sessionName];
|
|
||||||
}
|
}
|
||||||
Debug::info("Session::get - Session not found: $name");
|
Debug::log( "Session::get - Session not found: $sessionName" );
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,12 +61,15 @@ class Session {
|
|||||||
* @return {bool}
|
* @return {bool}
|
||||||
*/
|
*/
|
||||||
public static function put( $name, $data ) {
|
public static function put( $name, $data ) {
|
||||||
if ( !Check::sessionName( $name ) ) {
|
if (session_status() === PHP_SESSION_NONE) {
|
||||||
|
session_start();
|
||||||
|
}
|
||||||
|
if ( ! Check::sessionName( $name ) ) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$sessionName = DEFAULT_SESSION_PREFIX . $name;
|
$sessionName = DEFAULT_SESSION_PREFIX . $name;
|
||||||
$_SESSION[$sessionName] = $data;
|
$_SESSION[ $sessionName ] = $data;
|
||||||
Debug::info("Session: Created: $sessionName");
|
Debug::log( "Session::get - Created/Updated: $sessionName" );
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,16 +80,16 @@ class Session {
|
|||||||
* @return {bool}
|
* @return {bool}
|
||||||
*/
|
*/
|
||||||
public static function delete( $name ) {
|
public static function delete( $name ) {
|
||||||
if ( !Check::sessionName( $name ) ) {
|
if ( ! Check::sessionName( $name ) ) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
$sessionName = DEFAULT_SESSION_PREFIX . $name;
|
||||||
if ( self::exists( $name ) ) {
|
if ( self::exists( $name ) ) {
|
||||||
$sessionName = DEFAULT_SESSION_PREFIX . $name;
|
|
||||||
unset( $_SESSION[$sessionName] );
|
unset( $_SESSION[$sessionName] );
|
||||||
Debug::info("Session::deleted: $sessionName");
|
Debug::info( "Session::delete - Deleted $sessionName" );
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
Debug::error("Session::delete - Session not found.");
|
Debug::error( "Session::delete - Session not found." );
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -97,11 +103,11 @@ class Session {
|
|||||||
* @return bool|string - Returns bool if creating, and a string if the check is successful.
|
* @return bool|string - Returns bool if creating, and a string if the check is successful.
|
||||||
*/
|
*/
|
||||||
public static function checkFlash( $name ) {
|
public static function checkFlash( $name ) {
|
||||||
if ( !Check::sessionName( $name ) ) {
|
if ( ! Check::sessionName( $name ) ) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if ( self::exists( $name ) ) {
|
if ( self::exists( $name ) ) {
|
||||||
Debug::info("Session::flash - Exists");
|
Debug::log("Session::flash - Exists");
|
||||||
$session = self::get( $name );
|
$session = self::get( $name );
|
||||||
self::delete( $name );
|
self::delete( $name );
|
||||||
return $session;
|
return $session;
|
||||||
@ -110,16 +116,16 @@ class Session {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static function flash( $name, $data = null ) {
|
public static function flash( $name, $data = null ) {
|
||||||
if ( !Check::sessionName( $name ) ) {
|
if ( ! Check::sessionName( $name ) ) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if ( !empty( $data ) ) {
|
if ( ! empty( $data ) ) {
|
||||||
self::put( $name, $data );
|
self::put( $name, $data );
|
||||||
Debug::info("Session::flash - Session created.");
|
Debug::log("Session::flash - Session created.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if ( self::exists( $name ) ) {
|
if ( self::exists( $name ) ) {
|
||||||
Debug::info("Session::flash - Exists");
|
Debug::log("Session::flash - Exists");
|
||||||
$session = self::get( $name );
|
$session = self::get( $name );
|
||||||
self::delete( $name );
|
self::delete( $name );
|
||||||
return $session;
|
return $session;
|
@ -4,15 +4,15 @@
|
|||||||
*
|
*
|
||||||
* This class handles form tokens.
|
* This class handles form tokens.
|
||||||
*
|
*
|
||||||
* @version 3.0
|
* @version 1.1.2
|
||||||
* @author Joey Kimsey <Joey@thetempusproject.com>
|
* @author Joey Kimsey <Joey@thetempusproject.com>
|
||||||
* @link https://TheTempusProject.com/Core
|
* @link https://TheTempusProject.com/libraries/Bedrock
|
||||||
* @license https://opensource.org/licenses/MIT [MIT LICENSE]
|
* @license https://opensource.org/licenses/MIT [MIT LICENSE]
|
||||||
*/
|
*/
|
||||||
namespace TheTempusProject\Bedrock\Functions;
|
namespace TheTempusProject\Bedrock\Functions;
|
||||||
|
|
||||||
use TheTempusProject\Bedrock\Classes\Config;
|
use TheTempusProject\Bedrock\Classes\Config;
|
||||||
use TheTempusProject\Canary\Canary as Debug;
|
use TheTempusProject\Canary\Bin\Canary as Debug;
|
||||||
|
|
||||||
class Token {
|
class Token {
|
||||||
private static $tokenName;
|
private static $tokenName;
|
@ -6,14 +6,14 @@
|
|||||||
*
|
*
|
||||||
* @todo Add the config switches.
|
* @todo Add the config switches.
|
||||||
*
|
*
|
||||||
* @version 3.0
|
* @version 1.1.2
|
||||||
* @author Joey Kimsey <Joey@thetempusproject.com>
|
* @author Joey Kimsey <Joey@thetempusproject.com>
|
||||||
* @link https://TheTempusProject.com/Core
|
* @link https://TheTempusProject.com/libraries/Bedrock
|
||||||
* @license https://opensource.org/licenses/MIT [MIT LICENSE]
|
* @license https://opensource.org/licenses/MIT [MIT LICENSE]
|
||||||
*/
|
*/
|
||||||
namespace TheTempusProject\Bedrock\Functions;
|
namespace TheTempusProject\Bedrock\Functions;
|
||||||
|
|
||||||
use TheTempusProject\Canary\Canary as Debug;
|
use TheTempusProject\Canary\Bin\Canary as Debug;
|
||||||
|
|
||||||
class Upload {
|
class Upload {
|
||||||
public static $lastUpload = null;
|
public static $lastUpload = null;
|
Reference in New Issue
Block a user