ERROR in Nesting. Depth -1 from %s, %s: %d [%s]
",
$file, $func, $line, $msg);
}
$func_elapsed = sprintf("%9.4f", $elapsed - $timeFuncs[$nest]);
break;
default:
$flag = 1;
$pre = " | ";
break;
}
if (strlen($AppRoot) && strpos($file, $AppRoot) >= 0) {
$file = substr($file, strlen($AppRoot));
}
// if ($nest < 0)
// $nest = 0;
// + Elapsed,
// | + Function Elapsed
// | | +tag, +nest,
// | | | | +type,
// | | | | | +timestamp,
// | | | | | | +file, +line,
// | | | | | | | | +whitespace
// | | | | | | | | | +flag
// | | | | | | | | | | +function,
// | | | | | | | | | | | +user text.
$o = sprintf("%9.4f, %9s, %03d, %2d, %s, %s, %-26s, %5s, %s%s%-24s, %s",
$elapsed,
$func_elapsed,
$tag,
$nest,
$flag,
date("H:i.s"),
$file,
$line,
str_repeat(" ",$nest), $pre, $func,
$msg);
// Uncomment these when you need to see the details from the command line, but don't
// want to generate the tracefile.
//
//if (!count($_SESSION)) // && $flag == TR_ENTRY) // zero if running from a command shell
// printf("%s\n", $o);
if (TRACELOG) {
$fh = @fopen(TRACEPATH . "/" . TRACEFILE, "at");
if ($fh) {
if ($flag == TR_ENTRY && $func == "")
fprintf($fh, "\r\n\r\n");
fprintf($fh, "%s\n", $o);
fclose($fh);
} else {
echo "Configuration Error, cannot write to trace file [" . TRACEPATH ."/" . TRACEFILE . "\n";
}
}
// Track the stack depth
if ($flag == TR_ENTRY)
$nest++;
}
function deleteFilesWithWildcard($directory, $pattern) {
TraceProgram(__FILE__, __FUNCTION__, __LINE__, "del($directory, $pattern)", TR_ENTRY);
if (!is_dir($directory)) {
throw new InvalidArgumentException("Directory does not exist: $directory");
}
$searchPath = rtrim($directory, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . $pattern;
$files = glob($searchPath);
if ($files === false) {
throw new RuntimeException("Error reading files with glob()");
}
// Delete each file
foreach ($files as $file) {
if (is_file($file)) { // Ensure it's a file, not a directory
if (@unlink($file)) {
TraceProgram(__FILE__, __FUNCTION__, __LINE__, "Deleted $file");
} else {
TraceProgram(__FILE__, __FUNCTION__, __LINE__, "Delete Failed on $file");
}
}
}
TraceProgram(__FILE__, __FUNCTION__, __LINE__, "", TR_EXIT);
}
function GetFolderUp(string $path): ?string {
TraceProgram(__FILE__, __FUNCTION__, __LINE__, "", TR_ENTRY);
if (trim($path) === '') { // Basic validation
return null; // Empty path
}
$normalizedPath = str_replace(['\\', '/'], DIRECTORY_SEPARATOR, $path); // Normalize slashes for cross-platform compatibility
$parent = dirname($normalizedPath); // Use dirname to get one level up
if ($parent === '.' || $parent === DIRECTORY_SEPARATOR) { // If dirname returns '.' for relative paths, handle it
$parent = null; // No parent directory
}
TraceProgram(__FILE__, __FUNCTION__, __LINE__, $parent, TR_EXIT);
return $parent;
}
function GetPrevEvent($curItem = '') {
global $EventsPath, $EventFormFields;
TraceProgram(__FILE__, __FUNCTION__, __LINE__, "", TR_ENTRY);
$prevEvent = '';
$ref = ($curItem != '') ? $curItem : date("Y-m-d");
$events = GetDocMap($EventsPath, $EventFormFields, 'ProgramDate');
TraceProgram(__FILE__, __FUNCTION__, __LINE__, "$ref: " . print_r($events, true));
foreach (array_keys($events) as $event) {
if ($ref > $event) {
$prevEvent = $event;
}
}
TraceProgram(__FILE__, __FUNCTION__, __LINE__, $prevEvent, TR_EXIT);
return $prevEvent;
}
function GetNextEvent($curItem = '') {
global $EventsPath, $EventFormFields;
TraceProgram(__FILE__, __FUNCTION__, __LINE__, "", TR_ENTRY);
$nextEvent = '';
$ref = ($curItem != '') ? $curItem : date("Y-m-d");
$events = GetDocMap($EventsPath, $EventFormFields, 'ProgramDate');
foreach (array_keys($events) as $event) {
if ($nextEvent == '') {
if (($curItem == '') && ($ref <= $event)) {
$nextEvent = $event;
} else if (($curItem != '') && ($ref < $event)) {
$nextEvent = $event;
}
}
}
TraceProgram(__FILE__, __FUNCTION__, __LINE__, "[$nextEvent]", TR_EXIT);
return $nextEvent;
}
function EmitForm($formFields, $formData, $pathToArtifacts, $thisItem, $showNavigation = false) {
global $PlacesPath, $PlaceFormFields;
global $ProgChairPath, $ProgChairFormFields;
TraceProgram(__FILE__, __FUNCTION__, __LINE__, "$pathToArtifacts, $thisItem", TR_ENTRY);
$CK_EditorFieldIDs = array();
$showHR = false;
printf("
| %s Navigate %s | ||||||||||
| \n", $key, $data['Label']); $value = ($formData[$key]) ?? $formFields[$key]['Default']; TraceProgram(__FILE__, __FUNCTION__, __LINE__, "[$value]"); switch ($data['FieldType']) { case 'text': if ($formFields[$key]['RW'] == 'W') { printf(" | \n", $key, $key, $value, $formFields[$key]['Placeholder']); } else { printf(" | %s | \n", $value, $key, $key, $value, $formFields[$key]['Placeholder']); } break; case 'date': printf("\n"); if ($formFields[$key]['RW'] == 'W') { printf("\n", $key, $key, $value, ($formFields[$key]['RW'] != 'W') ? 'disabled' : ''); } else { printf("%s | \n", DateToMDY($value), $key, $key, $value); } printf("\n"); break; case 'time': printf("\n", $key, $key, $value); break; case 'bool': printf(" | \n", $key, $key, ($value) ? "checked" : ""); break; case 'html': printf(" | %s | \n", $key, $key, $value); $CK_EditorFieldIDs[] = $key; break; case 'pix': printf("\n",
$key, $key, $key
);
if (isset($formData[$key])) {
$pix = $formData[$key];
TraceProgram(__FILE__, __FUNCTION__, __LINE__, "key: $key, " . $pix);
$fqfn = ($pix != '') ? $pathToArtifacts . '/' . $pix : '';
if (!file_exists($fqfn)) {
$pix = $fqfn = '';
}
} else {
$pix = $fqfn = '';
}
TraceProgram(__FILE__, __FUNCTION__, __LINE__, "pathToArtifacts: $pathToArtifacts, fqfn: $fqfn");
printf(" | \n");
break;
case 'chair':
TraceProgram(__FILE__, __FUNCTION__, __LINE__, "pathToArtifacts: $pathToArtifacts");
//TraceProgram(__FILE__, __FUNCTION__, __LINE__, print_r($formFields, true));
$map = GetDocMap($ProgChairPath, $ProgChairFormFields, 'ProgramChair');
TraceProgram(__FILE__, __FUNCTION__, __LINE__, print_r($map, true));
TraceProgram(__FILE__, __FUNCTION__, __LINE__, print_r($formData, true));
printf("\n"); printf(" | "); break; case 'place': TraceProgram(__FILE__, __FUNCTION__, __LINE__, "pathToArtifacts: $pathToArtifacts, 'placeName'"); //TraceProgram(__FILE__, __FUNCTION__, __LINE__, print_r($formFields, true)); $map = GetDocMap($PlacesPath, $PlaceFormFields, 'PlaceName'); TraceProgram(__FILE__, __FUNCTION__, __LINE__, print_r($map, true)); TraceProgram(__FILE__, __FUNCTION__, __LINE__, print_r($formData, true)); printf("\n"); printf(" | "); break; default: TraceProgram(__FILE__, __FUNCTION__, __LINE__, "unexpected path from '" . $data['FieldType'] . "'"); break; } //printf("\t%s | \n", $data['FieldType']); printf("
|
$title $sub |
Go Admin |
| %s Navigate %s | ||||||||
| \n", $key, $data['Label']); $value = $evData[$key] ?? $EventFormFields[$key]['Default']; switch ($data['FieldType']) { case 'text': printf(" | %s | \n", $value); break; case 'date': printf("%s | \n", DateToMDY($value)); break; case 'time': printf("%s | \n", TimeTo12HR($value)); break; case 'bool': printf("\n", $key, ($value) ? "checked" : ""); break; case 'html': printf(" | %s | \n", $value); break; case 'pix': TraceProgram(__FILE__, __FUNCTION__, __LINE__, "$key, $value"); $pix = $value; $fqfn = ($pix != '') ? $EventPath . '/' . $pix : ''; TraceProgram(__FILE__, __FUNCTION__, __LINE__, "$pix, $fqfn, $EventPath"); if (file_exists($fqfn)) { TraceProgram(__FILE__, __FUNCTION__, __LINE__, "EventPath: $EventPath, fqfn: $fqfn"); printf("%s | \n", $value); break; case 'place': $refPlaceName = $evData[$key] ?? ''; printf("\n");
//printf("%s ", $refPlaceName); $placeHash = GetDocMap($PlacesPath, $PlaceFormFields, 'PlaceName'); //printf(" %s", print_r($placeHash, true)); foreach ($placeHash as $folder => $placeName) { // TraceProgram(__FILE__, __FUNCTION__, __LINE__, $formData[$key] . ", $folder => $placeName"); if ($placeName == $refPlaceName) { //printf("%s, %s ", $placeName, $folder); EmitPlace($folder); } } printf(" | \n");
break;
default:
break;
}
printf("|