<?php
namespace SabaiApps\Directories\Component\User\DirectoryType;

use SabaiApps\Directories\Component\Directory\Type\AbstractType;

class UserDirectoryType extends AbstractType {

	protected function _directoryInfo() {
		return array(
			'label'                => _x( 'User Directory', 'directories-pro' ),
			'name'                 => 'users',
			'multiple'             => false,
			'content_types'        => array( 'user' ),
			'primary_content_type' => 'user',
		);
	}

	public function directoryContentTypeInfo( $contentType ) {
		switch ( $contentType ) {
			case 'user':
				return array(
					'component'             => 'User',
					'entity_type'           => 'user',
					'suffix'                => 'usr_usr',
					'slug'                  => 'profile',
					'is_user'               => true,
					'label'                 => __( 'Users', 'directories-pro' ),
					'label_singular'        => __( 'User', 'directories-pro' ),
					'label_select'          => __( 'Select User', 'directories-pro' ),
					'label_search'          => __( 'Search Users', 'directories-pro' ),
					'label_count'           => __( '%s user', 'directories-pro' ),
					'label_count2'          => __( '%s users', 'directories-pro' ),
					'label_page'            => __( 'User: %s', 'directories-pro' ),
					'icon'                  => 'fas fa-user',
					'public'                => true,
					'properties'            => array(
						'title' => array(
							'label'           => _x( 'Name', 'person name', 'directories-pro' ),
							'required'        => true,
							'weight'          => 1,
							'widget_settings' => array(),
						),
						'email' => array(
							'label'           => __( 'E-mail Address', 'directories-pro' ),
							'required'        => true,
							'weight'          => 2,
							'widget_settings' => array( 'placeholder' => 'example@example.com' ),
						),
						'url'   => array(
							'label'           => __( 'Website URL', 'directories-pro' ),
							'required'        => false,
							'weight'          => 4,
							'widget_settings' => array( 'placeholder' => 'https://example.com/' ),
						),
					),
					'featurable'            => true,
					'entity_image'          => 'user_photo',
					'voting_enable'         => array( 'rating' ),
					'search_enable'         => true,
					'frontendsubmit_enable' => false,
					'payment_enable'        => true,
					'booking_enable'        => true,
					'search_fields'         => array(
						'keyword' => array(
							'disabled' => false,
							'settings' => array(
								'min_length' => 2,
								'match'      => 'all',
								'suggest'    => array(
									'enable'   => true,
									'settings' => array(
										'min_length' => 1,
										'post_jump'  => false,
										'post_num'   => 5,
									),
								),
								'form'       => array(
									'icon'        => 'fas fa-magnifying-glass',
									'placeholder' => 'Search for...',
									'order'       => 1,
								),
							),
						),
					),
					'fields'                => 'user_fields.php',
					'displays'              => 'user_displays.php',
					'views'                 => 'user_views.php',
					'contact_enable'        => true,
					'contact_form'          => array(
						'recipients' => array(
							0 => 'user_email',
						),
					),
					'entity_schemaorg'      => array(
						'type'       => 'Person',
						'properties' => array(
							'email'       => 'user_email',
							'url'         => 'user_url',
							'description' => 'user_description',
							'image'       => 'user_photo',
							'sameAs'      => 'field_user_social_accounts',
							'telephone'   => 'field_user_phone_number',
						),
					),
					'entity_opengraph'      => array(
						'type'       => 'profile',
						'properties' => array(
							'og__description' => 'user_description',
							'og__image'       => 'user_photo',
						),
					),
				);
		}
	}
}
