<?php
/**
 * Sports Leagues :: Shortcode > Teams.
 *
 * @since   0.5.5
 * @package Sports_Leagues
 */

/**
 * Sports Leagues :: Shortcode > Teams.
 *
 * @since 0.5.5
 * @since 0.14.1 Refactored to extend Sports_Leagues_Shortcode_Base.
 */
class Sports_Leagues_Shortcode_Teams extends Sports_Leagues_Shortcode_Base {

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

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

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

	/**
	 * Get default attribute values.
	 *
	 * @return array
	 * @since 0.14.1
	 */
	protected function get_defaults(): array {
		return [
			'stage_id'       => '',
			'layout'         => '',
			'logo_height'    => '50px',
			'logo_width'     => '50px',
			'exclude_ids'    => '',
			'include_ids'    => '',
			'show_team_name' => '1',
		];
	}

	/**
	 * Get documentation URL.
	 *
	 * @return string
	 * @since 0.14.1
	 */
	protected function get_docs_url(): string {
		return 'https://anwppro.userecho.com/knowledge-bases/6/articles/150-teams-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 [
			// Data Selection Section
			[
				'type'  => 'section_header',
				'label' => __( 'Data Selection', 'sports-leagues' ),
			],
			[
				'type'     => 'selector',
				'name'     => 'stage_id',
				'label'    => __( 'Tournament Stage', 'sports-leagues' ),
				'entity'   => 'stage',
				'multiple' => false,
			],
			[
				'type'        => 'selector',
				'name'        => 'include_ids',
				'label'       => __( 'Include Teams', 'sports-leagues' ),
				'entity'      => 'team',
				'multiple'    => true,
				'description' => __( 'If this option is set, "Tournament Stage" option will be ignored.', 'sports-leagues' ),
			],
			[
				'type'     => 'selector',
				'name'     => 'exclude_ids',
				'label'    => __( 'Exclude Teams', 'sports-leagues' ),
				'entity'   => 'team',
				'multiple' => true,
			],

			// Display Options Section
			[
				'type'  => 'section_header',
				'label' => __( 'Display Options', 'sports-leagues' ),
			],
			[
				'type'    => 'select',
				'name'    => 'layout',
				'label'   => __( 'Layout', 'sports-leagues' ),
				'default' => '',
				'options' => [
					''     => __( 'Custom Height and Width', 'sports-leagues' ),
					'2col' => __( '2 Columns', 'sports-leagues' ),
					'3col' => __( '3 Columns', 'sports-leagues' ),
					'4col' => __( '4 Columns', 'sports-leagues' ),
					'6col' => __( '6 Columns', 'sports-leagues' ),
				],
			],
			[
				'type'        => 'text',
				'name'        => 'logo_height',
				'label'       => __( 'Logo Height', 'sports-leagues' ),
				'default'     => '50px',
				'description' => __( 'Height value with units. Example: "50px" or "3rem".', 'sports-leagues' ),
			],
			[
				'type'        => 'text',
				'name'        => 'logo_width',
				'label'       => __( 'Logo Width', 'sports-leagues' ),
				'default'     => '50px',
				'description' => __( 'Width value with units. Example: "50px" or "3rem".', 'sports-leagues' ),
			],
			[
				'type'    => 'yes_no',
				'name'    => 'show_team_name',
				'label'   => __( 'Show Team Name', 'sports-leagues' ),
				'default' => '1',
			],
		];
	}
}
