allowed = $allowed; } public function getFields(...$args): array { $args = $args[0]; if (!array_key_exists('integrations', $args)) { return []; } $fields = []; $settings = $args['integrations']; foreach ($settings as $slug => $setting) { if (!array_key_exists($slug, $this->allowed)){ continue; } $fields = array_merge($fields, $this->getIntegrationFields($slug, $args)); } return $fields; } public function getIntegrationFields(string $integration, $config):array { $fields = []; $fields['share_to_' . $integration] = [ 'type' => 'true_false', 'label' => 'Share to ' . $this->allowed[$integration], 'section' => 'sync', 'bulkEdit' => true, ]; $setting = $config['integrations'][$integration]; if (jvbCheck('update', $setting)) { $fields['_keep_synced_'.$integration] = [ 'type' => 'true_false', 'label' => 'Keep Synced with '. $this->allowed[$integration], 'section' => 'sync', 'condition' => [ 'field' => 'share_to_'.$integration, 'value' => 1, 'operator'=> '==', ], 'bulkEdit' => true, ]; } $fields['schedule_'.$integration] = [ 'type' => 'datetime', 'label' => 'Schedule for later?', 'condition' => [ 'field' => 'share_to_'.$integration, 'operator' => '==', 'value' => 1 ] ]; $fields["_{$integration}_item_id"] = [ 'type' => 'text', 'label' => $this->allowed[$integration].' ID', 'section' => 'sync', 'hidden' => true, ]; $fields["_{$integration}_shared_at"] = [ 'type' => 'datetime', 'label' => $this->allowed[$integration].' Shared at:', 'section' => 'sync', 'hidden' => true, ]; $fields["_{$integration}_last_sync"] = [ 'type' => 'datetime', 'label' => $this->allowed[$integration].' Last Sync', 'section' => 'sync', 'hidden' => true ]; $fields["_{$integration}_sync_status"] = [ 'type' => 'select', 'label' => 'Sync Status', 'options' => [ 'synced' => 'Synced', 'pending' => 'Pending', 'failed' => 'Failed', 'unpublished' => 'Unpublished', 'scheduled' => 'Scheduled' ], 'section' => 'sync', 'hidden' => true, ]; $integration = JVB()->connect($integration); if ($integration && $integration->hasContent()) { $type = (array_key_exists('content_type', $setting)) ? $setting['content_type'] : $integration->getDefaultContentType(); $fields = array_merge($fields,$integration->getContentTypes($type)); } return $fields; } }