<?php
/**
 * Sports Leagues :: Shortcode > Standing.
 *
 * @since   0.1.0
 * @package Sports_Leagues
 */

/**
 * Sports Leagues :: Shortcode > Standing.
 *
 * @since 0.1.0
 * @since 0.14.1 Refactored to extend Sports_Leagues_Shortcode_Base.
 */
class Sports_Leagues_Shortcode_Standing extends Sports_Leagues_Shortcode_Base {

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

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

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

	/**
	 * Get default attribute values.
	 *
	 * @return array
	 * @since 0.14.1
	 */
	protected function get_defaults(): array {
		return [
			'title'               => '',
			'id'                  => '',
			'exclude_ids'         => '',
			'layout'              => '',
			'partial'             => '',
			'partitions'          => '',
			'partitions_switcher' => 1,
			'bottom_link'         => '',
			'link_text'           => '',
			'subheader_text'      => '',
			'subheader_class'     => '',
		];
	}

	/**
	 * Get documentation URL.
	 *
	 * @return string
	 * @since 0.14.1
	 */
	protected function get_docs_url(): string {
		return 'https://anwppro.userecho.com/knowledge-bases/6/articles/149-standing-table-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'             => 'select',
				'name'             => 'id',
				'label'            => __( 'Standing Table', 'sports-leagues' ),
				'options_callback' => 'get_standings',
				'default'          => '',
			],
			[
				'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'    => 'text',
				'name'    => 'title',
				'label'   => __( 'Title', 'sports-leagues' ),
				'default' => '',
			],
			[
				'type'    => 'select',
				'name'    => 'layout',
				'label'   => __( 'Layout', 'sports-leagues' ),
				'default' => '',
				'options' => [
					''     => __( 'default', 'sports-leagues' ),
					'mini' => __( 'mini', 'sports-leagues' ),
				],
			],
			[
				'type'        => 'text',
				'name'        => 'partial',
				'label'       => __( 'Show Partial Data', 'sports-leagues' ),
				'default'     => '',
				'description' => __( 'Eg.: "1-5" (show teams from 1 to 5 place), "45" - show table slice with specified team ID in the middle', 'sports-leagues' ),
			],
			[
				'type'    => 'select',
				'name'    => 'bottom_link',
				'label'   => __( 'Show link to', 'sports-leagues' ),
				'default' => '',
				'options' => [
					''           => __( 'none', 'sports-leagues' ),
					'tournament' => __( 'tournament', 'sports-leagues' ),
				],
			],
			[
				'type'    => 'text',
				'name'    => 'link_text',
				'label'   => __( 'Alternative bottom link text', 'sports-leagues' ),
				'default' => '',
			],
		];
	}
}
