<?php
    if ( ! defined( 'ABSPATH' ) ) exit;

    class cloudS3StorageConfigurator {

        public function getParameter() {
            return array(
                'settings' => array(
                    'page'=>'cloud-s3-settings',
                    'section'=>'cloud_s3_main_section'
                ),
                'fields' => array(
                    array(
                        'id'=>'active_mode',
                        'name'=>__('Active mode','cloud-s3-storage'),
                        'callback'=>'active_mode_callback',
                        'type' => 'checkbox',
                        'description' => __('All images are transferred to object storage and exceptions are managed individually in the media gallery. If not selected, passive mode will be used, which transfers only the images selected in the media gallery. We recommend selecting active mode.','cloud-s3-storage')
                    ),
                    array(
                        'id'=>'active_bihost',
                        'name'=>__('Dual hosting','cloud-s3-storage'),
                        'callback'=>'bihost_mode_callback',
                        'type' => 'checkbox',
                        'description' => __('Duplicates images both on local storage and on S3. Enable this option for testing purposes or on first plugin activation to verify its functionality.','cloud-s3-storage')
                    ),
                    /*array(
                        'id'=>'active_direct_url',
                        'name'=>__('Enable direct URLs for testing','cloud-s3-storage'),
                        'callback'=>'direct_url_mode_callback',
                        'type' => 'checkbox',
                        'description' => __('To start synchronization directly without going through CLI or WordPress cron','cloud-s3-storage')
                    ),*/
                    array(
                        'id'=>'access_key',
                        'name'=>__('Access Key','cloud-s3-storage'),
                        'callback'=>'access_key_callback',
                        'type' => 'text',
                        'description' => __('Enter the Access Key value provided by your provider','cloud-s3-storage')
                    ),
                    array(
                        'id'=>'secret_key',
                        'name'=>__('Secret Key','cloud-s3-storage'),
                        'callback'=>'secret_key_callback',
                        'type' => 'text',
                        'description' => __('Enter the Secret Key value provided by your provider','cloud-s3-storage')
                    ),
                    array(
                        'id'=>'bucket_name',
                        'name'=>__('Bucket Name','cloud-s3-storage'),
                        'callback'=>'bucket_name_callback',
                        'type' => 'text',
                        'description' => __('Enter the bucket name where images will be uploaded. Please create the bucket before configuring this value.','cloud-s3-storage')
                    ),
                    array(
                        'id'=>'endpoint',
                        'name'=>__('Endpoint','cloud-s3-storage'),
                        'callback'=>'bucket_name_callback',
                        'type' => 'text',
                        'description' => __('Enter the S3 storage endpoint URL, including http or https. Example: https://mito-obj01.vhostingcloud.com','cloud-s3-storage')
                    ),
                    array(
                        'id'=>'cron_job_timing',
                        'name'=>__('Cron job frequency','cloud-s3-storage'),
                        'callback'=>'cron_job_timing_callback',
                        'type' => 'select',
                        'option' => [
                            'never'         => __('Never', 'cloud-s3-storage'),
                            'hourly'        => __('Every hour', 'cloud-s3-storage'),
                            'twicedaily'    => __('Every twelve hours (twice a day)', 'cloud-s3-storage'),
                            'daily'         => __('Once a day', 'cloud-s3-storage'),
                            'weekly'        => __('Once a week', 'cloud-s3-storage'),
                            'monthly'       => __('Once a month', 'cloud-s3-storage')
                        ],
                        'description' => __('Choose the frequency for uploading images to the S3 bucket. If set to "Never", you will need to configure a CronJob with the URL found in "Index URL:" in the "Cloud S3 Storage" section','cloud-s3-storage')                  
                    ),
                    array(
                        'id'=>'image_max_cron',
                        'name'=>__('Number of images per Cron job','cloud-s3-storage'),
                        'callback'=>'cron_job_image_max_callback',
                        'type' => 'text',
                        'description' => __('Enter how many images should be processed on each execution of the Index URL. Example: 100.','cloud-s3-storage')
                    )
                )
    
            );
        }

        public function getJS ($mode_init = true) {
            $id_array = $mode_init ? array() : cloudS3StorageImageFunction::getIdImageAttachFullVersion();

            return 
                array(
                    'cloud_s3_storage-admin-script' => array(
                        'path' => '../../assets/js/admin-script.js',
                        'required' => array('cloud-s3-settings','cloud-s3-configure')
                    ),
                    'cloud_s3_storage-admin-media-script' => array(
                        'path' => '../../assets/js/admin-media-script.js',
                        'item' => $id_array
                    )
                );
        }

        public function getCSS () {
            return 
                array(
                    'cloud_s3_storage-admin-style' => array(
                        'path' => '../../assets/css/admin-style.css'
                    )
                );
        }

    }
