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 | 47 ++++++++++++++++-------------------------------
1 files changed, 16 insertions(+), 31 deletions(-)
diff --git a/inc/helpers/crud.php b/inc/helpers/crud.php
index cd36f41..dc646c9 100644
--- a/inc/helpers/crud.php
+++ b/inc/helpers/crud.php
@@ -5,6 +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
@@ -56,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
@@ -91,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">';
@@ -170,9 +172,6 @@
*/
function jvbGetBulkActions(string $content):array
{
-
- $permission = ($content === 'news') ? 'update' : $content;
- $permission = JVB_CONTENT[$content]['plural']??$content.'s';
$bulkActions = [
'publish' => [
'icon' => 'show',
@@ -195,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}")) {
@@ -308,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';
@@ -345,15 +332,13 @@
$nav .= '</nav>';
echo $nav;
- $fields = jvbGetFields($postType);
-
- $meta = new JVBase\meta\MetaManager($ID, $contentType);
+ $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' : '';
@@ -383,10 +368,10 @@
if (array_key_exists('role', $config)) {
$user = get_userdata($ID);
if (in_array($config['role'], $user->roles)) {
- $meta->render('form', $field, $config);
+ echo Form::render($field, null, $config);
}
} else {
- $meta->render('form', $field, $config);
+ echo Form::render($field, null, $config);
}
}
?>
--
Gitblit v1.10.0