From 42fa8304ddb811b0f725f245130f70c0f5e86a6c Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Tue, 04 Nov 2025 06:12:02 +0000
Subject: [PATCH] =Refactored LoginManager to be more extensible and configurable, as well as an AjaxRateLimiter

---
 inc/helpers/renderFields.php |  105 +++++++++++++++++++++++++---------------------------
 1 files changed, 50 insertions(+), 55 deletions(-)

diff --git a/inc/helpers/renderFields.php b/inc/helpers/renderFields.php
index 2e31338..16bb348 100644
--- a/inc/helpers/renderFields.php
+++ b/inc/helpers/renderFields.php
@@ -4,6 +4,8 @@
 	exit;
 }
 
+use JVBase\managers\CacheManager;
+use JVBase\meta\MetaForm;
 use JVBase\meta\MetaManager;
 
 /**
@@ -57,7 +59,7 @@
  */
 function jvbRenderLinks(int $ID, MetaManager|null $meta = null):string
 {
-    $cache = new JVBase\managers\CacheManager('bio-'.$ID, WEEK_IN_SECONDS);
+    $cache = CacheManager::for('bio-'.$ID, WEEK_IN_SECONDS);
     $key = 'links';
     $cached = $cache->get($key);
     if ($cached) {
@@ -134,12 +136,12 @@
  */
 function jvbRenderContactInfo(int $ID, MetaManager|null $meta = null):string
 {
-    $cache = new JVBase\managers\CacheManager('bio-'.$ID, WEEK_IN_SECONDS);
+    $cache = CacheManager::for('bio-'.$ID, WEEK_IN_SECONDS);
     $key = 'contact';
-//    $cached = $cache->get($key);
-//    if($cached){
-//        return $cached;
-//    }
+    $cached = $cache->get($key);
+    if($cached){
+        return $cached;
+    }
     if (!$meta) {
         $meta = jvbGetMeta($ID);
     }
@@ -444,34 +446,10 @@
 			</div>
 		</template>
 		<template class="uploadItem">
-			<div class="item upload">
-				<div class="preview">
-					<?php jvbRenderProgressBar('',true) ?>
-					<input type="checkbox" class="upload-select" name="select-item" id="select-item">
-					<label for="select-item" aria-label="Select image">
-						<img>
-						<video></video>
-						<span></span>
-					</label>
-					<div class="item-actions row btw">
-						<div class="radio-button">
-							<input type="radio" class="featured btn" name="featured" id="featured" hidden>
-							<label for="featured">
-								<?=jvbIcon('star')?>
-								<?=jvbIcon('star', ['style' => 'fill'])?>
-								<span class="screen-reader-text">Set as featured image</span>
-							</label>
-						</div>
-
-						<button type="button" data-action="delete-upload" title="Remove from Group">
-							<?=jvbIcon('delete')?>
-						</button>
-					</div>
-				</div>
-				<details>
-					<summary class="row btw"><?=jvbIcon('edit')?><span>Edit Image Info</span></summary>
-				</details>
-			</div>
+			<?php
+			$form = new MetaForm();
+			$form->renderImagePreview();
+			?>
 		</template>
 		<template class="restoreNotification">
 			<dialog class="restore-uploads">
@@ -544,41 +522,58 @@
 		<?php
 	}
 	if (wp_script_is('jvb-selector')) {
-		\JVBase\forms\TaxonomySelector::class::outputSelector();
+		\JVBase\forms\TaxonomySelector::class::outputSelectorModal();
 	}
 }
 
-function jvbImageMeta(int|null $ID = null, string $title = '', string $alt = '', string $caption = ''):string
+function jvbImageMeta(int|null $ID = null, string $title = '', string $alt = '', string $caption = '', array $fields = []):string
 {
+	$form = new MetaForm();
+	$dataID = ($ID) ? ['image-id' => $ID] : false;
+	$addID = ($ID) ? '-'.$ID : '';
 
-	$dataID = ($ID) ? ' data-image-id="'.$ID.'"' : '';
-	$ID = ($ID) ? '-'.$ID : '';
+	$fields = array_merge([
+		'image_data'	=> [
+			'type'	=> 'group',
+			'wrap'	=> 'details',
+			'label'	=> 'Image Info',
+			'hint'	=> 'These will be automatically generated if left blank.',
+			'fields'	=> [
+				'image-title'.$addID => [
+					'type'	=> 'text',
+					'label'	=> 'Image Title',
+					'value'	=> $title,
+					'data'	=> $dataID
+				],
+				'image-alt-text'.$addID => [
+					'type'	=> 'text',
+					'label'	=> 'Alt Text',
+					'value'	=> $alt,
+					'hint'	=> 'Alt text helps the visually impaired, as well as some benefits for SEO.',
+					'data'	=> $dataID
+				],
+				'image-caption'.$addID => [
+					'type'	=> 'textarea',
+					'value'	=> $caption,
+					'label'	=> 'Image Caption',
+					'data'	=> $dataID
+				]
+			]
+		]
+	], $fields);
 
-	return '<div class="upload-meta"'.$dataID.'>
-		<div class="field">
-			<label for="image-title'.$ID.'">Image Title</label>
-			<input type="text" id="image-title'.$ID.'" name="image-title'.$ID.'" value="'.$title.'">
-		</div>
-		<div class="field">
-			<label for="image-alt-text'.$ID.'">Image Alt Text</label>
-			<input type="text" id="image-alt-text'.$ID.'" name="image-alt-text'.$ID.'" value="'.$alt.'">
-			<p class="hint">Alt text helps the visually impaired, as well as some benefits for SEO.</p>
-		</div>
-		<div class="field">
-			<label for="image-caption'.$ID.'">Image Caption</label>
-			<textarea id="image-caption'.$ID.'" name="image-caption'.$ID.'">'.$caption.'</textarea>
-		</div>
-		<p class="hint">These will be automatically generated if left blank.</p>
-	</div>';
+
+	return $form->render('image_data',null, $fields,false, true);
 }
 
 
+
 function jvbLocationLinks(array $location): string {
 	if (empty($location['address'])) {
 		return '';
 	}
 
-	$cache = new \JVBase\managers\CacheManager('location');
+	$cache = CacheManager::for('locations');
 	$key = $cache->generateKey($location);
 
 	$cached = false;

--
Gitblit v1.10.0