install:
    tab: 0
    tabs:
        0:
            edit_mode:
                enabled: true
                on: true
            fields:
                blurb:
                    full_width: true
                    snippet:
                        html: |
                            <h1>Welcome to the Zenario installer</h1>
                            <p>This installer will take you through the steps to install Zenario. For installation help, please <a href="https://zenar.io/how-to-install-zenario" target="_blank">click here</a>.</p>
                            <p>It looks like Zenario has not yet been installed.</p>
                why:
                    pre_field_html: "Why does this message appear?"
                    type: toggle
                    redraw_onchange: true
                    full_width: true
                    visible_if: "zenarioAW.togglePressed(field, 1)"
                reason:
                    full_width: true
                    pre_field_html: |  
                        <div class="zenario_reason">
                    snippet:
                        html: "&nbsp;"
                    post_field_html: |
                        </div>
                    visible_if: zenarioAW.togglePressed(field)
                next:
                    value: Start installation
                    type: submit
                    class: begin_installation
                    full_width: true
        1:
            edit_mode:
                enabled: true
                on: true
            fields:
                blurb:
                    full_width: true
                    snippet:
                        html: |
                            <h1>Step 1: License</h1>
                            <p>Zenario can be used for free and distributed under the <a href="https://zenar.io/licensing" target="_blank">BSD Open Source License</a>.</p>
                            <p>Please read the following carefully:</p>
                license:
                    pre_field_html: |
                        <pre style="
                            height: 225px;
                            overflow-x: hidden;
                            overflow-y: scroll;
                            padding: 3px;
                        ">
                    full_width: true
                    snippet:
                        url: ""
                        cache: true
                    post_field_html: "</pre>"
                i_agree:
                    type: checkbox
                    full_width: true
                    post_field_html: |
                        <label for="i_agree">
                            I agree to the terms of the license.
                        </label>
                    note_below: |
                        Zenario comes bundled with several third-party software libraries, under the 
                            <a href="http://opensource.org/licenses/Apache-2.0" target="_blank">
                                Apache</a>,
                            <a href="http://opensource.org/licenses/terms of the BSD-3-Clause" target="_blank">
                                BSD</a>,
                            <a href="http://opensource.org/licenses/LGPL-2.1" target="_blank">
                                LGPL</a>,
                            <a href="http://opensource.org/licenses/MIT" target="_blank">
                                MIT</a> and
                            <a href="http://opensource.org/licenses/OFL-1.1" target="_blank">
                                OFL</a>
                        open source licenses.
                        You may only copy, modify or redistribute each library under the terms of its license.
                    redraw_onchange: true
                blurb2:
                    full_width: true
                    snippet:
                        html: |
                            <h1>Restore a backup, or make a new site</h1>
                            <p>You may create a new site, restore from a Zenario backup, or upgrade an existing Zenario database.</p>
                fresh_install:
                    value: Create a new site
                    type: submit
                    full_width: true
                    onclick: |
                        zenarioAW._nextLoadIsAnInstall = true;
                    disabled_if: |
                        !zenarioAW.value('i_agree')
                restore:
                    value: Restore from a backup
                    type: submit
                    same_row: true
                    disabled_if: |
                        !zenarioAW.value('i_agree')
        3:
            edit_mode:
                enabled: true
                on: true
            fields:
                description:
                    full_width: true
                    snippet:
                        html: |
                            <h1>Step 2: Your database</h1>
                            <p>You will need access to a MySQL database. This needs to be created outside of this installer, such as <a href="https://zenar.io/prepare-the-database" target="_blank">described here</a>.</p>
                            <p>Please enter connection details to your MySQL database below.</p>
                host:
                    label: "Hostname, and optional port number:"
                    type: text
                    value: localhost
                    row_class: row_form
                    return_key_presses_button: next
                port:
                    same_row: true
                    #label: "Database port number:"
                    type: text
                    placeholder: 3306
                    #note_below: 'You can leave this blank to use the default value'
                    return_key_presses_button: next
                name:
                    label: "Database name:"
                    type: text
                    row_class: row_form
                    return_key_presses_button: next
                user:
                    label: "Database username:"
                    type: text
                    row_class: row_form
                    return_key_presses_button: next
                password:
                    label: "Database password:"
                    type: password
                    row_class: row_form
                    return_key_presses_button: next
                prefix:
                    label: "Create tables with a prefix to their name (optional):"
                    type: text
                    row_class: row_form
                    return_key_presses_button: next
                multi_db_description:
                    full_width: true
                    snippet:
                        html: |
                            <h3>Configure Zenario multisite authentication?</h3>
                    
                    tooltip: |
                            Several Zenario sites can use a single "global" copy of Zenario to perform multisite administrator authentication. If you are a web agency running several client sites, this feature can be helpful.
                multi_db:
                    label: |
                            You may either install Zenario as a standalone CMS, or enter details of an existing "global" site, so administrators of that global site may also administer this new site. (If this is to be the global site, choose "standalone".)
                    type: select
                    format_onchange: true
                    value: zenario_stand
                    values:
                        zenario_standalone:
                            label: "Install a standalone copy of Zenario"
                        zenario_multisite:
                            label: "Install Zenario with multisite administrator authentication"
                multi_db_host:
                    label: " Global database hostname, and optional port number:"
                    type: text
                    value: localhost
                    row_class: row_form
                    visible_if:
                        lib.value('multi_db') == "zenario_multisite"
                    return_key_presses_button: next
                multi_db_port:
                    same_row: true
                    #label: "Database port number:"
                    type: text
                    placeholder: 3306
                    #note_below: 'You can leave this blank to use the default value'
                    visible_if:
                        lib.value('multi_db') == "zenario_multisite"
                    return_key_presses_button: next
                multi_db_name:
                    label: "Global database name:"
                    type: text
                    row_class: row_form
                    return_key_presses_button: next
                    visible_if:
                        lib.value('multi_db') == "zenario_multisite"
                multi_db_user:
                    label: "Global database username:"
                    type: text
                    row_class: row_form
                    return_key_presses_button: next
                    visible_if:
                        lib.value('multi_db') == "zenario_multisite"
                multi_db_password:
                    label: "Global database password:"
                    type: password
                    row_class: row_form
                    return_key_presses_button: next
                    visible_if:
                        lib.value('multi_db') == "zenario_multisite"
                multi_db_prefix:
                    label: "Global table prefix:"
                    type: text
                    row_class: row_form
                    return_key_presses_button: next
                    visible_if:
                        lib.value('multi_db') == "zenario_multisite"
                previous:
                    value: Back
                    type: submit
                    full_width: true
                    style: |
                        float: left;
                next:
                    value: Next
                    type: submit
                    same_row: true
                    style: |
                        float: right;
            show_errors_after_field: description
        4:
            edit_mode:
                enabled: true
                on: true
            fields:
                description:
                    full_width: true
                    snippet:
                        html: |
                            <h1>Step 3: Basic info about your site</h1>
                            <p>Please choose the default language, date format and initial appearance of your site.</p>

                            <p>For more help, <a href="https://zenar.io/run-the-zenario-installer" target="_blank">click here</a>.</p>
                
                # Old code for sample sites, commented out as we don't currently use them
                #sample:
                #    full_width: true
                #    type: radios
                #    row_class: row_form
                #    value: "0"
                
                language_id:
                    label: 'Default language for the site:'
                    type: select
                    empty_value: '-- Decide later --'
                    value: 'en'
                
                vis_date_format_short:
                    site_setting:
                        name: vis_date_format_short
                    label: 'Short date format:'
                    type: select
                    value: '%e/%c/%Y'
                    values:
                        '%e/%c/%y':
                            label: ''
                        '%e/%c/%Y':
                            label: ''
                        '%d/%m/%y':
                            label: ''
                        '%d/%m/%Y':
                            label: ''
#                       '%e.%c.%Y':
#                           label: ''
                        '%d.%m.%Y':
                            label: ''
#                       '%d-%m-%y':
#                           label: ''
#                       '%d-%m-%Y':
#                           label: ''
                        '%c/%e/%y':
                            label: ''
                        '%c/%e/%Y':
                            label: ''
#                       '%c/%d/%y':
#                           label: ''
                        '%m/%d/%y':
                            label: ''
                        '%m/%d/%Y':
                            label: ''
#                       '%Y/%m/%d':
#                           label: ''
#                       '%Y.%m.%d':
#                           label: ''
                        '%Y-%m-%d':
                            label: ''
                    validation:
                        required: Please enter a short date format.
                vis_date_format_med:
                    site_setting:
                        name: vis_date_format_med
                    label: 'Medium date format:'
                    type: select
                    value: '%e [[_MONTH_SHORT_%m]] %Y'
                    values:
                        '%e [[_MONTH_SHORT_%m]] %y':
                            label: ''
                        '%e [[_MONTH_SHORT_%m]] %Y':
                            label: ''
                        '[[_MONTH_SHORT_%m]] %e, %Y':
                            label: ''
                    validation:
                        required: Please enter a medium date format.
                vis_date_format_long:
                    site_setting:
                        name: vis_date_format_long
                    label: 'Long date format:'
                    type: select
                    value: '[[_WEEKDAY_%w]] %D [[_MONTH_LONG_%m]] %Y'
                    values:
                        '%D [[_MONTH_LONG_%m]] %Y':
                            label: ''
                        '[[_MONTH_LONG_%m]] %D, %Y':
                            label: ''
                        '[[_WEEKDAY_%w]] %D [[_MONTH_LONG_%m]] %Y':
                            label: ''
                        '[[_WEEKDAY_%w]] [[_MONTH_LONG_%m]] %D, %Y':
                            label: ''
                    note_below: >
                        Month and day names will be translated into your site's language.
                vis_timezone_settings:
                    site_setting:
                        name: zenario_timezones__default_timezone
                    label: 'Default timezone:'
                    type: select
                    empty_value: -- Select --
                    value: 'Europe/London'
                theme:
                    #full_width: true
                    label: 'Skin:'
                    pre_field_html: |
                        <div class="skin_selector selector_wrap">
                            <div>
                    type: radios
                    post_field_html: |
                        </div></div>
                
                organisation_name:
                    label: "Your site's name (e.g. your organisation's name):"
                    type: text
                    row_class: row_form
                    return_key_presses_button: next
                
                logo:
                    label: |
                            Your site's logo (optional); if adding this, please ensure the directories "cache", "public" and "private" are writeable by the web server:
                    upload:
                        multi: false
                        accept: 'image/*'
                        extensions:
                            - .gif
                            - .jpg
                            - .jpeg
                            - .png
                            - .svg
                        drag_and_drop: true
                        reorder_items: false
                    value: ''
                previous:
                    value: Back
                    type: submit
                    full_width: true
                    style: |
                        float: left;
                next:
                    value: Next
                    type: submit
                    same_row: true
                    style: |
                        float: right;
            show_errors_after_field: description
        5:
            edit_mode:
                enabled: true
                on: true
            fields:
                description:
                    full_width: true
                    snippet:
                        html: |
                            <h1>Step 4: Your administrator account</h1>
                            <p>Please enter your details so we can make your administrator account.</p>
                            <p>You can add more accounts later.</p>
                first_name:
                    label: "Your first name:"
                    type: text
                    row_class: row_form
                    return_key_presses_button: next
                    onchange: |
                        var fName = $('#first_name').val();
                        var lName = $('#last_name').val();
                        var lastChar = lName.charAt(0)
                        var userFName = fName.toLowerCase();
                        var userLName = lastChar.toLowerCase();
                        $('#username').val(userFName + userLName);
                last_name:
                    label: "Your last name:"
                    type: text
                    row_class: row_form
                    return_key_presses_button: next
                    onchange: |
                        var fName = $('#first_name').val();
                        var lName = $('#last_name').val();
                        var lastChar = lName.charAt(0)
                        var userFName = fName.toLowerCase();
                        var userLName = lastChar.toLowerCase();
                        $('#username').val(userFName + userLName);
                email:
                    label: "Your email address:"
                    type: text
                    row_class: row_form
                    return_key_presses_button: next
                username:
                    label: "Choose an admin username:"
                    type: text
                    row_class: row_form
                    return_key_presses_button: next
                password:
                    label: "Choose a password:"
                    autocomplete: "new-password"
                    type: password
                    oninput: |
                        var settings = {
                            min_extranet_user_password_length: lib.tuix.key.min_extranet_user_password_length,
                            min_extranet_user_password_score: lib.tuix.key.min_extranet_user_password_score
                        }
                        zenarioP.updatePasswordNotifier('#password', settings, '#snippet_password_message', true);
                    row_class: row_form
                    return_key_presses_button: next
                password_requirements:
                    snippet:
                        html: ""
                password_message:
                    snippet:
                        html: "&nbsp;"
                re_password:
                    label: "Re-enter your password:"
                    autocomplete: "new-password"
                    type: password
                    row_class: row_form
                    return_key_presses_button: next
                previous:
                    value: Back
                    type: submit
                    full_width: true
                    style: |
                        float: left;
                next:
                    value: Next
                    type: submit
                    same_row: true
                    style: |
                        float: right;
            show_errors_after_field: description
        6:
            edit_mode:
                enabled: true
                on: true
            fields:
                description:
                    full_width: true
                    snippet:
                        html: |
                            <h1>Step 3: Support email address</h1>
                            <p>Please enter an email address for receiving notification of system errors and database errors.</p>
                email:
                    label: "Support email address:"
                    type: text
                    row_class: row_form
                    return_key_presses_button: next
                description2:
                    full_width: true
                    snippet:
                        html: |
                            <h1>Step 4: Restore from a backup</h1>
                            <p>Please enter the path and filename of a backup file to restore.</p>
                path:
                    label: "Path:"
                    type: text
                    row_class: row_form
                    onkeyup: zenarioAW.quickValidateWelcomePage(500);
                    return_key_presses_button: next
                path_status:
                    full_width: true
                    snippet:
                        pre_field_html: |
                            <div style="text-align: right;">
                        html: "&nbsp;"
                        post_field_html: |
                            </div>
                previous:
                    value: Back
                    type: submit
                    full_width: true
                    style: |
                        float: left;
                next:
                    value: Next
                    type: submit
                    same_row: true
                    style: |
                        float: right;
            show_errors_after_field: description
        7:
            edit_mode:
                enabled: true
                on: true
            fields:
                description:
                    full_width: true
                    snippet:
                        html: |
                            <h1>Step 5: Great! Now let's save the configuration and database</h1>
                            <p>Zenario needs the settings to be written to a configuration file. Then the database will be populated, which takes a few moments. You can choose to have the site live immediately, or you can keep it only visible in administrator mode while you work on it.</p>
                            <p>This installer can populate the config file for you: to do this the file must be writeable by the web server. Alternatively, copy the text from the box below and paste it into the file manually.</p>
                            <p>The file must be located at:</p>
                zenario_siteconfig:
                    type: textarea
                    row_class: row_form
                    full_width: true
                    readonly: readonly
                copy_siteconfig_data:
                    type: button
                    css_class: zenario_gp_button
                    value: Copy siteconfig
                    onclick: |
                        $("textarea").select();
                        document.execCommand('copy');
                        $("#copy_siteconfig_data").val("Copied");
                site_enabled:
                    type: select
                    values:
                        enabled:
                            label: 'Enable the site for immediate viewing'
                        disabled:
                            label: 'Keep site disabled for the time being (only administrators may access it)'
                previous:
                    value: Back
                    type: submit
                    full_width: true
                    style: |
                        float: left;
                ive_done_it:
                    value: "I've pasted it"
                    type: submit
                    same_row: true
                    style: |
                        float: right;
                    onclick: |
                        zenarioAW._nextLoadIsAnInstall = true;
                do_it_for_me:
                    value: Do it for me
                    type: submit
                    same_row: true
                    style: |
                        float: right;
                    onclick: |
                        zenarioAW._nextLoadIsAnInstall = true;
            show_errors_after_field: description
        8:
            edit_mode:
                enabled: true
                on: true
            fields:
                description:
                    full_width: true
                    snippet:
                        html: |
                            <h1>Step 6: Installation</h1>
                            <p>We're sorry, but it looks like something went wrong there.</p>
                            <p>You can try the installation again, or go back and change your settings.</p>
                previous:
                    value: Back
                    type: submit
                    full_width: true
                    style: |
                        float: left;
                try_again:
                    value: Check Again
                    type: submit
                    same_row: true
                    style: |
                        float: right;
                    onclick: |
                        zenarioAW._nextLoadIsAnInstall = true;
            show_errors_after_field: description
