From 46d681c6b825d21b3f698d793c4e630c687d90ad Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Thu, 21 May 2026 21:41:53 +0000
Subject: [PATCH] =Major CustomBlocks.php overhaul, expanding block support and customization from the editor. theme.json should now be updated on new themes to set brand colours, etc. Also note: major change to .col vs .row alignment: simplifying it to .top .bottom vs the confusion of the differences for .col/.row .start and .a-start

---
 inc/helpers/crud.php |   40 +++++++++++++---------------------------
 1 files changed, 13 insertions(+), 27 deletions(-)

diff --git a/inc/helpers/crud.php b/inc/helpers/crud.php
index e213573..dc646c9 100644
--- a/inc/helpers/crud.php
+++ b/inc/helpers/crud.php
@@ -5,7 +5,9 @@
 }
 
 use JVBase\managers\Cache;
+use JVBase\managers\RoleManager;
 use JVBase\meta\Form;
+use JVBase\registrar\Registrar;
 
 /**
  * For whatever reason, after much testing, it seems that
@@ -57,6 +59,7 @@
 }
 
 /**
+ * @deprecated use CRUDManager.php or CRUDSkeleton.php
  * Outputs the blocks of a CRUD management in backend
  * Mainly used in news.php so far
  * @param string $content
@@ -92,10 +95,8 @@
             'label' => 'Scrapped',
         ]
     ];
-    $permission = ($content === 'news') ? 'update' : $content;
-	$permission = JVB_CONTENT[$content]['plural']??$content.'s';
-
-    $canPublish = current_user_can("publish_{$permission}");
+	$permission = JVB()->roles()->getContentPlural($content);
+    $canPublish = current_user_can("publish_{$permission}") && current_user_can('skip_moderation');
     $out = '<div class="filters">';
     if (!empty($statusFilters)) {
         $out .= '<div class="status">';
@@ -171,9 +172,6 @@
  */
 function jvbGetBulkActions(string $content):array
 {
-
-    $permission = ($content === 'news') ? 'update' : $content;
-	$permission = JVB_CONTENT[$content]['plural']??$content.'s';
     $bulkActions = [
         'publish' => [
             'icon'        => 'show',
@@ -196,7 +194,8 @@
             'disabled'    => true,
         ]
     ];
-    if (current_user_can("publish_{$permission}")) {
+	$permission = JVB()->roles()->getContentPlural($content);
+    if (current_user_can('skip_moderation') && current_user_can("publish_{$permission}")) {
         $bulkActions['publish']['disabled'] = false;
     }
     if (current_user_can("edit_{$permission}")) {
@@ -309,28 +308,15 @@
     string $postType = '',
     bool $prefix = false
 ):void {
-    switch ($contentType) {
-        case 'post':
-            $settings = JVB_CONTENT;
-            break;
-        case 'term':
-            $settings = JVB_TAXONOMY;
-            break;
-        case 'user':
-            $settings = JVB_USER;
-            break;
-        default:
-            return;
-    }
-    $sections = $settings[$postType]['sections']??[];
-    if (empty($sections)) {
+    $registrar = Registrar::getInstance($postType);
+    if (!$registrar || empty($registrar->getSections())) {
         return;
     }
 
     echo '<div class="container">';
-    $nav = '<nav class="tabs row start" role="tablist">';
+    $nav = '<nav class="tabs row left" role="tablist">';
     $i = 1;
-    foreach ($sections as $slug => $section) {
+    foreach ($registrar->getSections() as $slug => $section) {
         $nav .= '<button type="button" class="tab';
 
 		$ariaActive = 'false';
@@ -346,13 +332,13 @@
     $nav .= '</nav>';
     echo $nav;
 
-    $fields = jvbGetFields($postType);
+    $fields = Registrar::getFieldsFor($postType);
     ?>
     <form class="jvb-form" id="bio" data-form-id="bio-<?=$ID?>" data-save="bio"
           data-object-id="<?=$ID?>" data-content-type="<?=$postType?>">
         <?php
         $i = 0;
-        foreach ($sections as $slug => $section) {
+        foreach ($registrar->getSections() as $slug => $section) {
             $tabName = ($prefix) ? $ID.'-'.$slug : $slug;
 
             $class = ($i == 0) ? ' active' : '';

--
Gitblit v1.10.0