<?php
/**
 * @package GravityKit\GravityView\Preset
 */

namespace GravityKit\GravityView\Preset;

use GravityKit\GravityView\Utils\Assets;

/**
 * GravityView Default List Template.
 * Defines List (default) template.
 *
 * @since 3.0.0
 */
class DefaultList extends \GravityView_Template {

	function __construct( $id = 'default_list', $settings = [], $field_options = [], $areas = [] ) {

		$rtl = is_rtl() ? '-rtl' : '';

		$list_settings = [
			'slug'        => 'list',
			'type'        => 'custom',
			'label'       => __( 'List', 'gk-gravityview' ),
			'description' => __( 'Display items in a listing view.', 'gk-gravityview' ),
			'logo'        => Assets::url( 'presets/default-list/logo-default-list.png' ),
			'icon'        => 'data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzQiIGhlaWdodD0iMzQiIHZpZXdCb3g9IjAgMCAzNCAzNCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KICAgIDxwYXRoIGQ9Ik0zIDMzSDMxQzMyLjEwNDYgMzMgMzMgMzIuMTA0NiAzMyAzMVYzQzMzIDEuODk1NDMgMzIuMTA0NiAxIDMxIDFIM0MxLjg5NTQzIDEgMSAxLjg5NTQzIDEgM1YzMUMxIDMyLjEwNDYgMS44OTU0MyAzMyAzIDMzWiIgZmlsbD0id2hpdGUiIHN0cm9rZT0iIzJDMzMzOCIgc3Ryb2tlLXdpZHRoPSIxLjUiIHN0cm9rZS1taXRlcmxpbWl0PSIxMCIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIi8+CiAgICA8cGF0aCBkPSJNNS4zOTk5IDguMTk5OTVINi45OTk5IiBzdHJva2U9IiMyQzMzMzgiIHN0cm9rZS13aWR0aD0iMS41IiBzdHJva2UtbWl0ZXJsaW1pdD0iMTAiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIvPgogICAgPHBhdGggZD0iTTUuMzk5OSAxMy44SDYuOTk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am9pbj0icm91bmQiLz4KICAgIDxwYXRoIGQ9Ik0xMSAyNUgyNy44IiBzdHJva2U9IiMyQzMzMzgiIHN0cm9rZS13aWR0aD0iMS41IiBzdHJva2UtbWl0ZXJsaW1pdD0iMTAiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIvPgo8L3N2Zz4K',
			'css_source'  => \gravityview_css_url( 'list-view' . $rtl . '.css', GRAVITYVIEW_DIR . 'templates/css/' ),
		];

		$settings = wp_parse_args( $settings, $list_settings );

		$field_options = [
			'show_as_link' => [
				'type'     => 'checkbox',
				'label'    => __( 'Link to single entry', 'gk-gravityview' ),
				'value'    => false,
				'context'  => 'directory',
				'priority' => 1190,
				'group'    => 'display',
			],
		];

		$areas = [
			[
				'1-1' => [
					[
						'areaid'   => 'list-title',
						'title'    => __( 'Listing Title', 'gk-gravityview' ),
						'subtitle' => '',
					],
					[
						'areaid'   => 'list-subtitle',
						'title'    => __( 'Subheading', 'gk-gravityview' ),
						'subtitle' => __( 'Data placed here will be bold.', 'gk-gravityview' ),
					],
				],
				'1-3' => [
					[
						'areaid'   => 'list-image',
						'title'    => __( 'Image', 'gk-gravityview' ),
						'subtitle' => __( 'Leave empty to remove.', 'gk-gravityview' ),
					],
				],
				'2-3' => [
					[
						'areaid'   => 'list-description',
						'title'    => __( 'Other Fields', 'gk-gravityview' ),
						'subtitle' => __( 'Below the subheading, a good place for description and other data.', 'gk-gravityview' ),
					],
				],
			],
			[
				'1-2' => [
					[
						'areaid'   => 'list-footer-left',
						'title'    => __( 'Footer Left', 'gk-gravityview' ),
						'subtitle' => '',
					],
				],
				'2-2' => [
					[
						'areaid'   => 'list-footer-right',
						'title'    => __( 'Footer Right', 'gk-gravityview' ),
						'subtitle' => '',
					],
				],
			],
		];

		parent::__construct( $id, $settings, $field_options, $areas );
	}
}
