<?php
/**
 * Sports Leagues :: Shortcode > Tournament List.
 *
 * @since   0.5.17
 * @package Sports_Leagues
 */

/**
 * Sports Leagues :: Shortcode > Tournament List.
 *
 * @since 0.5.17
 * @since 0.14.1 Refactored to extend Sports_Leagues_Shortcode_Base.
 */
class Sports_Leagues_Shortcode_Tournament_List extends Sports_Leagues_Shortcode_Base {

	/**
	 * Get the shortcode tag.
	 *
	 * @return string
	 * @since 0.14.1
	 */
	protected function get_shortcode_tag(): string {
		return 'sl-tournament-list';
	}

	/**
	 * Get the shortcode key for options/hooks.
	 *
	 * @return string
	 * @since 0.14.1
	 */
	protected function get_shortcode_key(): string {
		return 'tournament-list';
	}

	/**
	 * Get the shortcode label for UI.
	 *
	 * @return string
	 * @since 0.14.1
	 */
	protected function get_shortcode_label(): string {
		return __( 'Tournament List', 'sports-leagues' );
	}

	/**
	 * Get default attribute values.
	 *
	 * @return array
	 * @since 0.14.1
	 */
	protected function get_defaults(): array {
		return [
			'status'       => '',
			'sort_by_date' => '',
			'limit'        => 0,
			'exclude_ids'  => '',
			'include_ids'  => '',
			'date_from'    => '',
			'date_to'      => '',
		];
	}

	/**
	 * Get documentation URL.
	 *
	 * @return string
	 * @since 0.14.1
	 */
	protected function get_docs_url(): string {
		return 'https://anwppro.userecho.com/knowledge-bases/6/articles/257-tournament-list-shortcode';
	}

	/**
	 * Get default preview width.
	 *
	 * @return int
	 * @since 0.14.1
	 */
	protected function get_default_preview_width(): int {
		return 700;
	}

	/**
	 * Get form field definitions.
	 *
	 * @return array
	 * @since 0.14.1
	 */
	protected function get_form_fields(): array {
		return [
			// Query Options Section
			[
				'type'  => 'section_header',
				'label' => __( 'Query Options', 'sports-leagues' ),
			],
			[
				'type'    => 'select',
				'name'    => 'status',
				'label'   => __( 'Tournament Status', 'sports-leagues' ),
				'default' => '',
				'options' => [
					''         => __( 'All', 'sports-leagues' ),
					'finished' => __( 'Finished', 'sports-leagues' ),
					'active'   => __( 'Active', 'sports-leagues' ),
					'upcoming' => __( 'Upcoming', 'sports-leagues' ),
				],
			],
			[
				'type'     => 'selector',
				'name'     => 'include_ids',
				'label'    => __( 'Include Tournaments', 'sports-leagues' ),
				'entity'   => 'tournament',
				'multiple' => true,
			],
			[
				'type'     => 'selector',
				'name'     => 'exclude_ids',
				'label'    => __( 'Exclude Tournaments', 'sports-leagues' ),
				'entity'   => 'tournament',
				'multiple' => true,
			],
			[
				'type'        => 'text',
				'name'        => 'date_from',
				'label'       => __( 'Date From', 'sports-leagues' ),
				'default'     => '',
				'description' => __( 'Format: YYYY-MM-DD', 'sports-leagues' ),
			],
			[
				'type'        => 'text',
				'name'        => 'date_to',
				'label'       => __( 'Date To', 'sports-leagues' ),
				'default'     => '',
				'description' => __( 'Format: YYYY-MM-DD', 'sports-leagues' ),
			],

			// Display Options Section
			[
				'type'  => 'section_header',
				'label' => __( 'Display Options', 'sports-leagues' ),
			],
			[
				'type'    => 'select',
				'name'    => 'sort_by_date',
				'label'   => __( 'Sort By Date', 'sports-leagues' ),
				'default' => '',
				'options' => [
					''     => __( 'none', 'sports-leagues' ),
					'asc'  => __( 'Ascending', 'sports-leagues' ),
					'desc' => __( 'Descending', 'sports-leagues' ),
				],
			],
			[
				'type'    => 'number',
				'name'    => 'limit',
				'label'   => __( 'Limit', 'sports-leagues' ),
				'default' => '0',
			],
		];
	}
}
