columnsHeaderNotToDisplay = ['color']; } public function entitySelect(array $options): string { $options['columnsToDisplay'] = $options['columnsToDisplay'] ?? ['name']; $options['buttonSubmit'] = $options['buttonSubmit'] ?? [ 'text' => '', 'action' => '', 'class' => '', ]; $options['displaySelected'] = $options['displaySelected'] ?? true; $options['displayedName'] = $options['displayedName'] ?? ''; $columnJoin = ''; if (!empty($options['columnsToDisplay']['join'])) { $columnJoin = explode('.', $options['columnsToDisplay']['join']); } unset($options['columnsToDisplay']['join']); if (empty($options['display'])) { ob_start(); } echo ''; if (empty($options['display'])) { return ob_get_clean(); } return ''; } public function getColumnsForList(string $join = '', bool $small = false): array { $columns = [ 'color' => $small ? 'small-2' : 'small-1', 'name' => 'auto', 'id' => 'small-2', ]; if (!empty($join)) { $columns['join'] = $join; } return $columns; } public function getColumnsForUser(string $join = ''): array { $columns = [ 'email' => 'auto', 'name' => 'auto', 'id' => 'small-1', ]; if (!empty($join)) { $columns['join'] = $join; } return $columns; } private function displayListing( string $type, string $allSelector, string $entity, array $columnsToDisplay = [], string $displayedName = '' ): void { if (empty($displayedName)) { $displayedName = $entity; } echo '
'.esc_html( acym_translation('ACYM_'.strtoupper($type).'_'.strtoupper($displayedName)) ).'
'; $emptyMessage = acym_translation($type === 'available' ? 'ACYM_NOTHING_TO_SHOW_HERE_RIGHT_PANEL' : 'ACYM_PLEASE_CLICK_ON_THE_LEFT_PANEL'); echo '
'.esc_html($emptyMessage).'
'; //Start the listing //if it's the select listing we display the - at the start if ($type !== 'available') { echo '
'; } //We lists all the columns foreach ($columnsToDisplay as $column => $class) { echo '
'.esc_html( in_array($column, $this->columnsHeaderNotToDisplay) ? '' : acym_translation('ACYM_'.strtoupper($column)) ).'
'; } //if it's the available listing we display the + at the end if ($type === 'available') { echo '
'; } //end of listing header echo '
'; //trigger the good function depending if were in available or selected listing $functionClick = $type === 'available' ? 'selectEntity(entity.id)' : 'unselectEntity(entity.id)'; //each row of the listing echo '
'; //if it's the select listing we display the - at the start if ($type !== 'available') { echo '
'; } //Display all the value for the columns echo '
'; //if it's the available listing we display the + at the end if ($type === 'available') { echo '
'; } //End of listing with message loading and loading logo echo '
'; echo esc_html(acym_translation('ACYM_WE_ARE_LOADING_YOUR_DATA')); echo '
'; acym_loaderLogo(false); echo '
'; echo '
'; echo '
'; } }