Initial commit
This commit is contained in:
71
app/classes/config.php
Normal file
71
app/classes/config.php
Normal file
@ -0,0 +1,71 @@
|
||||
<?php
|
||||
/**
|
||||
* classes/config.php
|
||||
*
|
||||
* This class handles all the hard-coded configurations.
|
||||
*
|
||||
* @version 3.0
|
||||
* @author Joey Kimsey <Joey@thetempusproject.com>
|
||||
* @link https://TheTempusProject.com/Core
|
||||
* @license https://opensource.org/licenses/MIT [MIT LICENSE]
|
||||
*/
|
||||
namespace TheTempusProject\Classes;
|
||||
|
||||
use TheTempusProject\Houdini\Classes\Forms;
|
||||
use TheTempusProject\Canary\Canary as Debug;
|
||||
use TheTempusProject\Bedrock\Functions\Check;
|
||||
use TheTempusProject\Bedrock\Functions\Input;
|
||||
use TheTempusProject\Bedrock\Classes\Config as BedrockConfig;
|
||||
|
||||
class Config extends BedrockConfig {
|
||||
public static function getFieldEditHtml( $name, $includeProtected = false ) {
|
||||
// @todo: includeProtected is unused here
|
||||
$node = self::get( $name );
|
||||
if ( empty( $node ) ) {
|
||||
return;
|
||||
}
|
||||
if ( true === $node['protected'] ) {
|
||||
return;
|
||||
}
|
||||
$fieldname = str_ireplace( '/', '-', $name );
|
||||
$html = Forms::getFormFieldHtml(
|
||||
$fieldname,
|
||||
$node['pretty'],
|
||||
$node['type'],
|
||||
$node['value'],
|
||||
);
|
||||
return $html;
|
||||
}
|
||||
|
||||
public static function getCategoryEditHtml( $category ) {
|
||||
$html = '';
|
||||
if ( self::$config === false ) {
|
||||
Debug::warn( 'Config not loaded.' );
|
||||
return;
|
||||
}
|
||||
if ( empty( self::$config[$category] ) ) {
|
||||
Debug::warn( "Config category not found: $category" );
|
||||
return;
|
||||
}
|
||||
$categoryHeader = '<div class="form-group"><label>' . ucfirst( $category ) . ':</label><hr></div>';
|
||||
foreach ( self::$config[$category] as $field => $node ) {
|
||||
$html .= self::getFieldEditHtml( $category . '/' . $field );
|
||||
}
|
||||
if ( !empty( $html ) ) {
|
||||
$html = $categoryHeader . $html;
|
||||
}
|
||||
return $html;
|
||||
}
|
||||
|
||||
public static function getEditHtml() {
|
||||
if ( self::$config === false ) {
|
||||
Debug::warn( 'Config not loaded.' );
|
||||
return;
|
||||
}
|
||||
$html = '';
|
||||
foreach ( self::$config as $category => $fields ) {
|
||||
$html .= self::getCategoryEditHtml( $category );
|
||||
}
|
||||
return $html;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user