Browse Source

Touch ups and clean ups

nsITobin 3 years ago
parent
commit
626b3ab0b6
2 changed files with 19 additions and 20 deletions
  1. 8 9
      fundamentals.php
  2. 11 11
      index.php

+ 8 - 9
fundamentals.php

@@ -184,15 +184,14 @@ if (!function_exists('str_contains')) {
 * @dep XML_TAG
 * @dep JSON_ENCODE_FLAGS
 **********************************************************************************************************************/
-function gfError($aValue, $aPHPError = false, $aDisableExternalOutput = null) { 
+function gfError($aValue, $aPHPError = false, $aExternalOutput = null) { 
   $pageHeader = array(
     'default' => 'Unable to Comply',
-    'fatal'   => 'Fatal Error',
     'php'     => 'PHP Error',
     'output'  => 'Output'
   );
 
-  $externalOutput = !$aDisableExternalOutput ?? function_exists('gfGenContent');
+  $externalOutput = !$aExternalOutput ?? function_exists('gfGenContent');
   $isCLI = (php_sapi_name() == "cli");
   $isOutput = false;
 
@@ -223,7 +222,7 @@ function gfError($aValue, $aPHPError = false, $aDisableExternalOutput = null) {
       gfGenContent($ePrefix, $eMessage, true, false, true);
     }
     
-    gfGenContent($ePrefix, $eMessage);
+    gfGenContent($ePrefix, $eMessage, null, null, true);
   }
   elseif ($isCLI) {
     print('========================================' . NEW_LINE .
@@ -285,7 +284,7 @@ function gfSuperVar($aVarType, $aVarValue, $aFalsy = null) {
   $varType = UNDERSCORE . strtoupper($aVarType);
 
   // General variable absolute null check unless falsy is allowed
-  if ($varType == "_VAR" || $varType == "_DIRECT"){
+  if ($varType == "_CHECK" || $varType == "_VAR" || $varType == "_DIRECT"){
     $rv = $aVarValue ?? null;
 
     if ($rv && !$aFalsy) {
@@ -380,7 +379,7 @@ function gfHeader($aHeader) {
 **********************************************************************************************************************/
 // This function sends a redirect header
 function gfRedirect($aURL) {
-  header('Location: ' . $aURL , true, 302);
+  header('Location: ' . $aURL, true, 302);
   
   // We are done here
   exit();
@@ -478,8 +477,8 @@ function gfStripRootPath($aPath) {
 function gfGetDomain($aHost, $aReturnSub = null) {
   $host = gfExplodeString(DOT, $aHost);
   $domainSlice = $aReturnSub ? array_slice($host, 0, -2) : array_slice($host, -2, 2);
-  $domainString = implode(DOT, $domainSlice);
-  return $domainString;
+  $rv = implode(DOT, $domainSlice);
+  return $rv;
 }
 
 /**********************************************************************************************************************
@@ -642,7 +641,7 @@ function gfWriteFile($aData, $aFile, $aRenameFile = null) {
 * Generate a random hexadecimal string
 *
 * @param $aLength   Desired number of final chars
-* @returns          Random hexadecimal string of desired lenth
+* @returns          Random hexadecimal string of desired length
 **********************************************************************************************************************/
 function gfHexString($aLength = 40) {
   if ($aLength <= 1) {

+ 11 - 11
index.php

@@ -30,9 +30,9 @@ require_once('./fundamentals.php');
 /**********************************************************************************************************************
 * Basic Content Generation using the Special Component's Template
 ***********************************************************************************************************************/
-function gfGenContent($aMetadata, $aLegacy = null, $aTextBox = null, $aList = null, $aError = null) {
+function gfGenContent($aMetadata, $aLegacyContent = null, $aTextBox = null, $aList = null, $aError = null) {
   $ePrefix = __FUNCTION__ . DASH_SEPARATOR;
-  $skinPath = '/skin/default/';
+  $skinPath = '/skin/default';
 
   // Anonymous functions
   $contentIsStringish = function($aContent) {
@@ -44,7 +44,7 @@ function gfGenContent($aMetadata, $aLegacy = null, $aTextBox = null, $aList = nu
            $aContent . '</textarea>';
   };
 
-  $template = gfReadFile(DOT . $skinPath . 'template.xhtml');
+  $template = gfReadFile(DOT . $skinPath . SLASH . 'template.xhtml');
 
   if (!$template) {
     gfError($ePrefix . 'Special Template is busted...', null, true);
@@ -60,7 +60,7 @@ function gfGenContent($aMetadata, $aLegacy = null, $aTextBox = null, $aList = nu
     '{$SOFTWARE_VERSION}' => SOFTWARE_VERSION,
   );
 
-  if ($aLegacy) {
+  if ($aLegacyContent) {
     if (is_array($aMetadata)) {
       gfError($ePrefix . 'aMetadata may not be an array in legacy mode.');
     }
@@ -69,21 +69,21 @@ function gfGenContent($aMetadata, $aLegacy = null, $aTextBox = null, $aList = nu
       gfError($ePrefix . 'You cannot use both textbox and list');
     }
 
-    if ($contentIsStringish($aLegacy)) {
-      $aLegacy = var_export($aLegacy, true);
+    if ($contentIsStringish($aLegacyContent)) {
+      $aLegacyContent = var_export($aLegacyContent, true);
       $aTextBox = true;
       $aList = false;
     }
 
     if ($aTextBox) {
-      $aLegacy = $textboxContent($aLegacy);
+      $aLegacyContent = $textboxContent($aLegacyContent);
     }
     elseif ($aList) {
-      // We are using an unordered list so put aLegacy in there
-      $aLegacy = '<ul><li>' . $aLegacy . '</li><ul>';
+      // We are using an unordered list so put aLegacyContent in there
+      $aLegacyContent = '<ul><li>' . $aLegacyContent . '</li><ul>';
     }
 
-    if ($GLOBALS['gaRuntime']['qTestCase'] ?? null) {
+    if (!$aError && ($GLOBALS['gaRuntime']['qTestCase'] ?? null)) {
       $pageSubsts['{$PAGE_TITLE}'] = 'Test Case' . DASH_SEPARATOR . $GLOBALS['gaRuntime']['qTestCase'];
 
       foreach ($GLOBALS['gaRuntime']['siteMenu'] ?? EMPTY_ARRAY as $_key => $_value) {
@@ -94,7 +94,7 @@ function gfGenContent($aMetadata, $aLegacy = null, $aTextBox = null, $aList = nu
       $pageSubsts['{$PAGE_TITLE}'] = $aMetadata;
     }
 
-    $pageSubsts['{$PAGE_CONTENT}'] = $aLegacy;
+    $pageSubsts['{$PAGE_CONTENT}'] = $aLegacyContent;
   }
   else {
     if ($aTextBox || $aList) {