<?php // $file = /home/bluedoor/www/dev/wp-content/plugins/yooessentials/modules/source/providers/Xml/config-url.json

return [
  'name' => 'xml-url', 
  'title' => 'Remote XML', 
  'description' => 'Source based on a XML stream.', 
  'group' => 'Structured Data', 
  'collection' => 'XML', 
  'icon' => $filter->apply('url', '~yooessentials_url/modules/source/providers/Xml/icon.svg', $file), 
  'endpoints' => [
    'presave' => 'yooessentials/source/xml'
  ], 
  'fields' => [
    'name' => [
      'label' => 'Name', 
      'description' => 'A name to identify this source.', 
      'attrs' => [
        'autofocus' => true, 
        'placeholder' => 'Remote XML'
      ]
    ], 
    'url' => [
      'label' => 'URL', 
      'description' => 'The URL to the XML stream.'
    ], 
    'requires_auth' => [
      'text' => 'Requires Authentication', 
      'type' => 'checkbox', 
      'default' => false
    ], 
    'auth' => [
      'label' => 'Authentication', 
      'description' => 'The authentication credentials.', 
      'type' => 'yooessentials-connected-auth', 
      'show' => 'requires_auth', 
      'connections' => [
        'basic-auth' => [], 
        'api-key' => []
      ]
    ], 
    'xpath' => [
      'label' => 'XPath Filter', 
      'description' => 'Optional XPath filter to narrow down the XML. For example <code>/channel/item</code>. See <a href=\'https://en.wikipedia.org/wiki/XPath\' target=\'blank\'>Wikipedia</a> for more info.'
    ], 
    'data_types' => [
      'label' => 'Data Types', 
      'type' => 'yooessentials-repeatable-compact', 
      'show' => 'url', 
      'description' => 'Optionally map the XML types to a specific Data Type which will enable specific type rendering options during layout mapping.', 
      'fields' => [
        '_grid' => [
          'type' => 'grid', 
          'width' => '1-2', 
          'fields' => [
            'sourceType' => [
              'label' => 'XML Type', 
              'type' => 'yooessentials-select-dropdown-async', 
              'endpoint' => 'yooessentials/source/xml/metadata'
            ], 
            'destinationType' => [
              'label' => 'Data Type', 
              'type' => 'select', 
              'options' => [
                'String' => 'String', 
                'Date' => 'Date', 
                'Int' => 'Int', 
                'Image' => 'Image', 
                'Url' => 'Url'
              ]
            ]
          ]
        ], 
        'date_format' => [
          'attrs' => [
            'placeholder' => 'Date Format . Example: d/m/Y H:i:s'
          ], 
          'type' => 'data-list', 
          'divider' => true, 
          'options' => [
            'Fri, 16 Dec 2022 11:15:31 GMT' => 'D, d M Y H:i:s e', 
            'Aug 6, 1999 (M j, Y)' => 'M j, Y', 
            'August 06, 1999 (F d, Y)' => 'F d, Y', 
            '08/06/1999 (m/d/Y)' => 'm/d/Y', 
            '08.06.1999 (m.d.Y)' => 'm.d.Y', 
            '6 Aug, 1999 (j M, Y)' => 'j M, Y', 
            'Tuesday, Aug 06 (l, M d)' => 'l, M d'
          ], 
          'show' => 'destinationType == \'Date\''
        ]
      ]
    ], 
    'cache_default' => $config->get('yooessentials.source.fields.cache_default')
  ]
];
