Compare commits
36 Commits
Author | SHA1 | Date | |
---|---|---|---|
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 |
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\Bin\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
|
||||
|
||||
Copyright (c) 2024 Joey Kimsey
|
||||
Copyright (c) 2025 Joey Kimsey
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
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
|
||||
The easiest way to use Bedrock in your application is to install and initialize it via composer.
|
||||
## Installation
|
||||
|
||||
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": {
|
||||
"psr-4": {
|
||||
"Bedrock\": "vendor/TheTempusProject/Bedrock"
|
||||
If you would like to use hermes own autoloading, simply inclode the constants file and the autoload file inside `/bin/`.
|
||||
|
||||
```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
|
||||
- [ ] template stuff should really only be called from template/controllers
|
||||
- [ ] Update installer to account for updates.
|
||||
- [ ] Implement uniformity in terms of error reporting, exceptions, logging.
|
||||
- [ ] Updates for configs and models to re-build based on a delta model, to make version changes simpler. (Migration system)
|
||||
- [ ] Implement better 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,15 +1,15 @@
|
||||
<?php
|
||||
/**
|
||||
* app.php
|
||||
* bin/bedrock.php
|
||||
*
|
||||
* This file parses any given url and separates it into controller,
|
||||
* method, and data. This allows the application to direct the user
|
||||
* to the desired location and provide the controller any additional
|
||||
* information it may require to run.
|
||||
*
|
||||
* @version 3.0
|
||||
* @version 1.1.2
|
||||
* @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]
|
||||
*/
|
||||
namespace TheTempusProject\Bedrock\Bin;
|
||||
@ -32,6 +32,7 @@ class Bedrock {
|
||||
protected $controllerObject = null;
|
||||
protected $controllerClass = '';
|
||||
protected $params = [];
|
||||
protected $controllerError = false;
|
||||
|
||||
/**
|
||||
* The constructor handles the entire process of parsing the url,
|
||||
@ -64,55 +65,6 @@ class Bedrock {
|
||||
$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 ) {
|
||||
if ( !empty( $urlArray[0] ) ) {
|
||||
$urlPart = array_shift( $urlArray );
|
||||
@ -154,6 +106,65 @@ 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( '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() {
|
||||
return Sanitize::url( Input::get( 'url' ) );
|
||||
}
|
@ -4,9 +4,9 @@
|
||||
*
|
||||
* This class handles all the hard-coded configurations.
|
||||
*
|
||||
* @version 3.0
|
||||
* @version 1.1.2
|
||||
* @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]
|
||||
*/
|
||||
namespace TheTempusProject\Bedrock\Classes;
|
||||
@ -14,6 +14,7 @@ namespace TheTempusProject\Bedrock\Classes;
|
||||
use TheTempusProject\Canary\Bin\Canary as Debug;
|
||||
use TheTempusProject\Bedrock\Functions\Check;
|
||||
use TheTempusProject\Bedrock\Functions\Input;
|
||||
use TheTempusProject\Bedrock\Functions\Upload;
|
||||
|
||||
class Config {
|
||||
public static $config = false;
|
||||
@ -145,7 +146,19 @@ class Config {
|
||||
}
|
||||
$fieldname = str_ireplace( '/', '-', $name );
|
||||
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,15 +1,15 @@
|
||||
<?php
|
||||
/**
|
||||
* core/controller.php
|
||||
* classes/controller.php
|
||||
*
|
||||
* The controller handles our main template and provides the
|
||||
* model and view functions which are the backbone of the tempus
|
||||
* project. Used to hold and keep track of many of the variables
|
||||
* that support the applications execution.
|
||||
*
|
||||
* @version 3.0
|
||||
* @version 1.1.2
|
||||
* @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]
|
||||
*/
|
||||
namespace TheTempusProject\Bedrock\Classes;
|
@ -6,17 +6,17 @@
|
||||
*
|
||||
* @todo - Add more than just MySQL
|
||||
*
|
||||
* @version 3.0
|
||||
* @version 1.1.2
|
||||
* @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]
|
||||
*/
|
||||
namespace TheTempusProject\Bedrock\Classes;
|
||||
|
||||
use PDO;
|
||||
use PDOException;
|
||||
use TheTempusProject\Houdini\Classes\Pagination;
|
||||
use TheTempusProject\Canary\Bin\Canary as Debug;
|
||||
use TheTempusProject\Canary\Classes\CustomException;
|
||||
|
||||
class Database {
|
||||
public static $instance = null;
|
||||
@ -274,7 +274,7 @@ class Database {
|
||||
foreach ( $params as $param ) {
|
||||
$x++;
|
||||
if ( is_array( $param ) ) {
|
||||
dv( $param );
|
||||
// dv( $param );
|
||||
}
|
||||
$this->query->bindValue( $x, $param );
|
||||
}
|
||||
@ -637,10 +637,29 @@ class Database {
|
||||
return true;
|
||||
}
|
||||
|
||||
public function search( $table, $column, $param ) {
|
||||
public function searchColumn( $table, $column, $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.
|
||||
*
|
@ -1,13 +1,13 @@
|
||||
<?php
|
||||
/**
|
||||
* core/database_model.php
|
||||
* classes/DatabaseModel.php
|
||||
*
|
||||
* The class provides some basic functionality for models that interact
|
||||
* with the database.
|
||||
*
|
||||
* @version 3.0
|
||||
* @version 1.1.2
|
||||
* @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]
|
||||
*/
|
||||
namespace TheTempusProject\Bedrock\Classes;
|
||||
@ -17,8 +17,9 @@ use TheTempusProject\Bedrock\Functions\Check;
|
||||
use TheTempusProject\Bedrock\Bedrock;
|
||||
|
||||
class DatabaseModel extends Model {
|
||||
public $databaseMatrix;
|
||||
public $tableName;
|
||||
public $databaseMatrix;
|
||||
public $searchFields;
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
@ -190,4 +191,19 @@ class DatabaseModel extends Model {
|
||||
}
|
||||
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,12 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* core/model.php
|
||||
* classes/model.php
|
||||
*
|
||||
* The class provides some basic functionality for models.
|
||||
*
|
||||
* @version 3.0
|
||||
* @version 1.1.2
|
||||
* @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]
|
||||
*/
|
||||
namespace TheTempusProject\Bedrock\Classes;
|
@ -1,15 +1,15 @@
|
||||
<?php
|
||||
/**
|
||||
* core/template/pagination.php
|
||||
* classes/pagination.php
|
||||
*
|
||||
* This class is for managing template pagination.
|
||||
*
|
||||
* @version 3.0
|
||||
* @version 1.1.2
|
||||
* @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]
|
||||
*/
|
||||
namespace TheTempusProject\Houdini\Classes;
|
||||
namespace TheTempusProject\Bedrock\Classes;
|
||||
|
||||
use TheTempusProject\Houdini\Classes\Template;
|
||||
use TheTempusProject\Hermes\Functions\Route as Routes;
|
||||
@ -17,6 +17,8 @@ use TheTempusProject\Bedrock\Functions\Input;
|
||||
use TheTempusProject\Bedrock\Classes\Config;
|
||||
use TheTempusProject\Bedrock\Functions\Check;
|
||||
use TheTempusProject\Canary\Bin\Canary as Debug;
|
||||
use TheTempusProject\Houdini\Classes\Components;
|
||||
use TheTempusProject\Houdini\Classes\Views;
|
||||
|
||||
class Pagination extends Template {
|
||||
//The settings that will not change
|
||||
@ -154,7 +156,7 @@ class Pagination extends Template {
|
||||
$pageData = (object) $pageData;
|
||||
|
||||
if ( self::totalPages() <= 1 ) {
|
||||
Components::set( 'PAGINATION', 'no pagination' );
|
||||
Components::set( 'PAGINATION', '' );
|
||||
} else {
|
||||
Components::set( 'PAGINATION', Views::simpleView( 'nav.pagination', $pageData ) );
|
||||
}
|
@ -6,10 +6,12 @@
|
||||
"minimum-stability": "dev",
|
||||
"keywords":
|
||||
[
|
||||
"thetempusproject",
|
||||
"php",
|
||||
"mvc",
|
||||
"framework"
|
||||
],
|
||||
"homepage": "https://git.thetempusproject.com/the-tempus-project/bedrock",
|
||||
"homepage": "https://thetempusproject.com/libraries/bedrock",
|
||||
"authors":
|
||||
[
|
||||
{
|
||||
@ -22,21 +24,21 @@
|
||||
"require":
|
||||
{
|
||||
"php": ">=8.1.0",
|
||||
"thetempusproject/canary": ">=1.0",
|
||||
"thetempusproject/hermes": ">=1.0",
|
||||
"thetempusproject/houdini": ">=1.0"
|
||||
"thetempusproject/canary": "1.0.8",
|
||||
"thetempusproject/hermes": "1.0.5",
|
||||
"thetempusproject/houdini": "2.0.4"
|
||||
},
|
||||
"autoload":
|
||||
{
|
||||
"psr-4":
|
||||
{
|
||||
"TheTempusProject\\Bedroock\\Classes\\": "Classes",
|
||||
"TheTempusProject\\Bedroock\\Functions\\": "Functions"
|
||||
},
|
||||
"classmap":
|
||||
[
|
||||
"classes",
|
||||
"functions"
|
||||
],
|
||||
"files":
|
||||
[
|
||||
"Config/constants.php",
|
||||
"Bin/Bedrock.php"
|
||||
"config/constants.php",
|
||||
"bin/bedrock.php"
|
||||
]
|
||||
}
|
||||
}
|
45
composer.lock
generated
45
composer.lock
generated
@ -4,28 +4,27 @@
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "4467bdc4b2a87dc7540fc9854ebd9384",
|
||||
"content-hash": "d68a088d48d6c8f0385a138a0163cbfd",
|
||||
"packages": [
|
||||
{
|
||||
"name": "thetempusproject/canary",
|
||||
"version": "dev-main",
|
||||
"version": "1.0.8",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://git.thetempusproject.com/the-tempus-project/canary",
|
||||
"reference": "7746eb4af73f3eaba040d547904a251bbdab6977"
|
||||
"reference": "9d339b961e7702e92293757fd495cadebbc1c418"
|
||||
},
|
||||
"require": {
|
||||
"php": ">=8.1.0"
|
||||
},
|
||||
"default-branch": true,
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"files": [
|
||||
"Config/constants.php",
|
||||
"Bin/Canary.php"
|
||||
"config/constants.php",
|
||||
"bin/canary.php"
|
||||
],
|
||||
"psr-4": {
|
||||
"TheTempusProject\\Canary\\Classes\\": "Classes"
|
||||
"TheTempusProject\\Canary\\Classes\\": "classes"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
@ -41,27 +40,27 @@
|
||||
}
|
||||
],
|
||||
"description": "Functionality for tracking, logging, and sending log messages to chrome for debugging.",
|
||||
"homepage": "https://git.thetempusproject.com/the-tempus-project/canary",
|
||||
"homepage": "https://thetempusproject.com/libraries/canary",
|
||||
"keywords": [
|
||||
"debugging",
|
||||
"logging",
|
||||
"php",
|
||||
"thetempusproject",
|
||||
"tools"
|
||||
],
|
||||
"time": "2024-08-09T04:35:45+00:00"
|
||||
"time": "2025-02-03T17:39:23+00:00"
|
||||
},
|
||||
{
|
||||
"name": "thetempusproject/hermes",
|
||||
"version": "dev-main",
|
||||
"version": "1.0.5",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://git.thetempusproject.com/the-tempus-project/hermes",
|
||||
"reference": "9d6a79d80be98d0e598ce08c47a98d37814d1105"
|
||||
"reference": "802581b1d2d70877ccc75d8954b33efcc05d9371"
|
||||
},
|
||||
"require": {
|
||||
"php": ">=8.1.0"
|
||||
},
|
||||
"default-branch": true,
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"files": [
|
||||
@ -84,30 +83,30 @@
|
||||
"role": "Lead Developer"
|
||||
}
|
||||
],
|
||||
"description": "Php functions that aid in routing and redirecting; requests and responses.",
|
||||
"homepage": "https://git.thetempusproject.com/the-tempus-project/hermes",
|
||||
"description": "This library handles redirects, provides a common backbone for routing, and can handle autoloading in cases where composer is unavailable.",
|
||||
"homepage": "https://thetempusproject.com/libraries/hermes",
|
||||
"keywords": [
|
||||
"autoloader",
|
||||
"php",
|
||||
"routing",
|
||||
"thetempusproject",
|
||||
"tools"
|
||||
],
|
||||
"time": "2024-08-08T05:24:32+00:00"
|
||||
"time": "2025-02-02T23:22:15+00:00"
|
||||
},
|
||||
{
|
||||
"name": "thetempusproject/houdini",
|
||||
"version": "dev-main",
|
||||
"version": "2.0.4",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://git.thetempusproject.com/the-tempus-project/houdini",
|
||||
"reference": "3de98733ac32c0a6e1a3230cbccfa33263e399be"
|
||||
"reference": "21ef1ba8c9fed2fb6f789505671d11a10c1c344e"
|
||||
},
|
||||
"require": {
|
||||
"php": ">=8.1.0",
|
||||
"thetempusproject/canary": ">=1.0",
|
||||
"thetempusproject/hermes": ">=1.0"
|
||||
"thetempusproject/canary": "1.0.8",
|
||||
"thetempusproject/hermes": "1.0.5"
|
||||
},
|
||||
"default-branch": true,
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"files": [
|
||||
@ -129,15 +128,15 @@
|
||||
"role": "Lead Developer"
|
||||
}
|
||||
],
|
||||
"description": "Php functions that aid in creating, managing, and displaying frontend components.",
|
||||
"homepage": "https://git.thetempusproject.com/the-tempus-project/houdini",
|
||||
"description": "This library handles creating, managing, and displaying frontend components.",
|
||||
"homepage": "https://thetempusproject.com/libraries/houdini",
|
||||
"keywords": [
|
||||
"frontend",
|
||||
"php",
|
||||
"thetempusproject",
|
||||
"tools"
|
||||
],
|
||||
"time": "2024-08-09T04:56:06+00:00"
|
||||
"time": "2025-02-03T17:43:12+00:00"
|
||||
}
|
||||
],
|
||||
"packages-dev": [],
|
||||
|
@ -120,40 +120,6 @@
|
||||
if (!defined('BEDROCK_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
|
||||
if (!defined('COMPOSER_JSON_LOCATION')) {
|
||||
define('COMPOSER_JSON_LOCATION', APP_ROOT_DIRECTORY . 'composer.json');
|
||||
@ -207,6 +173,10 @@
|
||||
if (!defined('TOKEN_ENABLED')) {
|
||||
define('TOKEN_ENABLED', true);
|
||||
}
|
||||
// dUH
|
||||
if (!defined('APP_NAME')) {
|
||||
define('APP_NAME', 'Bedrock Application');
|
||||
}
|
||||
# Tell the app all constants have been loaded.
|
||||
if ( ! defined('BEDROCK_CONSTANTS_LOADED' ) ) {
|
||||
define( 'BEDROCK_CONSTANTS_LOADED', true );
|
@ -4,9 +4,9 @@
|
||||
*
|
||||
* This class is used to test various inputs.
|
||||
*
|
||||
* @version 3.0
|
||||
* @version 1.1.2
|
||||
* @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]
|
||||
*/
|
||||
namespace TheTempusProject\Bedrock\Functions;
|
||||
@ -99,25 +99,25 @@ class Check {
|
||||
* @return {bool}
|
||||
*/
|
||||
public static function imageUpload( $imageName ) {
|
||||
if ( !Config::getValue( 'uploads/images' ) ) {
|
||||
self::addError( 'Image uploads are disabled.' );
|
||||
if ( ! Config::getValue( 'uploads/images' ) ) {
|
||||
self::addUserError( 'Image uploads are disabled.' );
|
||||
return false;
|
||||
}
|
||||
if ( !isset( $_FILES[$imageName] ) ) {
|
||||
self::addError( 'File not found.', $imageName );
|
||||
if ( ! isset( $_FILES[ $imageName ] ) ) {
|
||||
self::addUserError( 'File not found.', $imageName );
|
||||
return false;
|
||||
}
|
||||
if ( $_FILES[$imageName]['error'] != 0 ) {
|
||||
self::addError( 'File error:' . $_FILES[$imageName]['error'] );
|
||||
self::addUserError( 'File error:' . $_FILES[$imageName]['error'] );
|
||||
return false;
|
||||
}
|
||||
if ( $_FILES[$imageName]['size'] > Config::getValue( 'uploads/maxImageSize' ) ) {
|
||||
self::addError( 'Image is too large.' );
|
||||
self::addUserError( 'Image is too large.' );
|
||||
return false;
|
||||
}
|
||||
$fileType = strrchr( $_FILES[$imageName]['name'], '.' );
|
||||
if ( !( in_array( $fileType, ALLOWED_IMAGE_UPLOAD_EXTENTIONS ) ) ) {
|
||||
self::addError( 'Invalid image type', $fileType );
|
||||
self::addUserError( 'Invalid image type', $fileType );
|
||||
return false;
|
||||
}
|
||||
return true;
|
@ -6,9 +6,9 @@
|
||||
*
|
||||
* @todo Better code generation.
|
||||
*
|
||||
* @version 3.0
|
||||
* @version 1.1.2
|
||||
* @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]
|
||||
*/
|
||||
namespace TheTempusProject\Bedrock\Functions;
|
@ -4,9 +4,9 @@
|
||||
*
|
||||
* This class is used for manipulation of cookies.
|
||||
*
|
||||
* @version 3.0
|
||||
* @version 1.1.2
|
||||
* @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]
|
||||
*/
|
||||
namespace TheTempusProject\Bedrock\Functions;
|
@ -4,9 +4,9 @@
|
||||
*
|
||||
* 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>
|
||||
* @link https://TheTempusProject.com/Core
|
||||
* @link https://TheTempusProject.com/libraries/Bedrock
|
||||
* @license https://opensource.org/licenses/MIT [MIT LICENSE]
|
||||
*/
|
||||
namespace TheTempusProject\Bedrock\Functions;
|
@ -4,9 +4,9 @@
|
||||
*
|
||||
* This class is used to salt, hash, and check passwords.
|
||||
*
|
||||
* @version 3.0
|
||||
* @version 1.1.2
|
||||
* @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]
|
||||
*/
|
||||
namespace TheTempusProject\Bedrock\Functions;
|
@ -4,9 +4,9 @@
|
||||
*
|
||||
* This class manages and returns GET, FILE, and POST variables.
|
||||
*
|
||||
* @version 3.0
|
||||
* @version 1.1.2
|
||||
* @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]
|
||||
*/
|
||||
namespace TheTempusProject\Bedrock\Functions;
|
||||
@ -29,7 +29,7 @@ class Input {
|
||||
} elseif ( self::file( $data ) ) {
|
||||
return true;
|
||||
} else {
|
||||
Debug::info( 'Input::exists: No input Found: '. $data );
|
||||
Debug::log( 'Input::exists: No input Found: '. $data );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -43,11 +43,11 @@ class Input {
|
||||
*/
|
||||
public static function file( $data ) {
|
||||
if ( !isset( $_FILES[$data] ) ) {
|
||||
Debug::debug( "Input - file : $data not found." );
|
||||
Debug::log( "Input - file : $data not found." );
|
||||
return false;
|
||||
}
|
||||
if ( $_FILES[$data]['tmp_name'] == '' ) {
|
||||
Debug::debug( "Input - file : $data empty." );
|
||||
Debug::log( "Input - file : $data empty." );
|
||||
return false;
|
||||
}
|
||||
return $_FILES[$data];
|
@ -4,9 +4,9 @@
|
||||
*
|
||||
* This class is used to sanitize user input.
|
||||
*
|
||||
* @version 3.0
|
||||
* @version 1.1.2
|
||||
* @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]
|
||||
*/
|
||||
namespace TheTempusProject\Bedrock\Functions;
|
@ -4,9 +4,9 @@
|
||||
*
|
||||
* This class is used for management of session data.
|
||||
*
|
||||
* @version 3.0
|
||||
* @version 1.1.2
|
||||
* @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]
|
||||
*/
|
||||
namespace TheTempusProject\Bedrock\Functions;
|
||||
@ -21,14 +21,17 @@ class Session {
|
||||
* @return {bool}
|
||||
*/
|
||||
public static function exists( $name ) {
|
||||
if ( !Check::sessionName( $name ) ) {
|
||||
if (session_status() === PHP_SESSION_NONE) {
|
||||
session_start();
|
||||
}
|
||||
if ( ! Check::sessionName( $name ) ) {
|
||||
return false;
|
||||
}
|
||||
$sessionName = DEFAULT_SESSION_PREFIX . $name;
|
||||
if ( isset( $_SESSION[$sessionName] ) ) {
|
||||
if ( isset( $_SESSION[ $sessionName ] ) ) {
|
||||
return true;
|
||||
}
|
||||
Debug::info("Session::exists - Session not found: $sessionName");
|
||||
Debug::log( "Session::exists - Session not found: $sessionName" );
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -39,14 +42,14 @@ class Session {
|
||||
* @return {string|bool} - Returns the data from the session or false if nothing is found..
|
||||
*/
|
||||
public static function get( $name ) {
|
||||
if ( !Check::sessionName( $name ) ) {
|
||||
if ( ! Check::sessionName( $name ) ) {
|
||||
return false;
|
||||
}
|
||||
$sessionName = DEFAULT_SESSION_PREFIX . $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;
|
||||
}
|
||||
|
||||
@ -58,12 +61,15 @@ class Session {
|
||||
* @return {bool}
|
||||
*/
|
||||
public static function put( $name, $data ) {
|
||||
if ( !Check::sessionName( $name ) ) {
|
||||
if (session_status() === PHP_SESSION_NONE) {
|
||||
session_start();
|
||||
}
|
||||
if ( ! Check::sessionName( $name ) ) {
|
||||
return false;
|
||||
}
|
||||
$sessionName = DEFAULT_SESSION_PREFIX . $name;
|
||||
$_SESSION[$sessionName] = $data;
|
||||
Debug::info("Session: Created: $sessionName");
|
||||
$_SESSION[ $sessionName ] = $data;
|
||||
Debug::log( "Session::get - Created/Updated: $sessionName" );
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -74,16 +80,16 @@ class Session {
|
||||
* @return {bool}
|
||||
*/
|
||||
public static function delete( $name ) {
|
||||
if ( !Check::sessionName( $name ) ) {
|
||||
if ( ! Check::sessionName( $name ) ) {
|
||||
return false;
|
||||
}
|
||||
$sessionName = DEFAULT_SESSION_PREFIX . $name;
|
||||
if ( self::exists( $name ) ) {
|
||||
$sessionName = DEFAULT_SESSION_PREFIX . $name;
|
||||
unset( $_SESSION[$sessionName] );
|
||||
Debug::info("Session::deleted: $sessionName");
|
||||
Debug::info( "Session::delete - Deleted $sessionName" );
|
||||
return true;
|
||||
}
|
||||
Debug::error("Session::delete - Session not found.");
|
||||
Debug::error( "Session::delete - Session not found." );
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -97,11 +103,11 @@ class Session {
|
||||
* @return bool|string - Returns bool if creating, and a string if the check is successful.
|
||||
*/
|
||||
public static function checkFlash( $name ) {
|
||||
if ( !Check::sessionName( $name ) ) {
|
||||
if ( ! Check::sessionName( $name ) ) {
|
||||
return false;
|
||||
}
|
||||
if ( self::exists( $name ) ) {
|
||||
Debug::info("Session::flash - Exists");
|
||||
Debug::log("Session::flash - Exists");
|
||||
$session = self::get( $name );
|
||||
self::delete( $name );
|
||||
return $session;
|
||||
@ -110,16 +116,16 @@ class Session {
|
||||
}
|
||||
|
||||
public static function flash( $name, $data = null ) {
|
||||
if ( !Check::sessionName( $name ) ) {
|
||||
if ( ! Check::sessionName( $name ) ) {
|
||||
return false;
|
||||
}
|
||||
if ( !empty( $data ) ) {
|
||||
if ( ! empty( $data ) ) {
|
||||
self::put( $name, $data );
|
||||
Debug::info("Session::flash - Session created.");
|
||||
Debug::log("Session::flash - Session created.");
|
||||
return true;
|
||||
}
|
||||
if ( self::exists( $name ) ) {
|
||||
Debug::info("Session::flash - Exists");
|
||||
Debug::log("Session::flash - Exists");
|
||||
$session = self::get( $name );
|
||||
self::delete( $name );
|
||||
return $session;
|
@ -4,9 +4,9 @@
|
||||
*
|
||||
* This class handles form tokens.
|
||||
*
|
||||
* @version 3.0
|
||||
* @version 1.1.2
|
||||
* @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]
|
||||
*/
|
||||
namespace TheTempusProject\Bedrock\Functions;
|
@ -6,9 +6,9 @@
|
||||
*
|
||||
* @todo Add the config switches.
|
||||
*
|
||||
* @version 3.0
|
||||
* @version 1.1.2
|
||||
* @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]
|
||||
*/
|
||||
namespace TheTempusProject\Bedrock\Functions;
|
Reference in New Issue
Block a user