Jake Vanderwerf
7 days ago 46d681c6b825d21b3f698d793c4e630c687d90ad
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' : '';