# You must use a tab-size of 4 spaces to edit this file.
---
zenario__modules:
    panels:
        plugins:
            key:
                skinId: ''
                moduleId: ''
                moduleIds: ''
            title: Plugin library
            select_mode_title: Select a plugin
            
            panel_type: multi_line_list_or_grid
            css_class: three_line_list_panels
            use_tall_rows: true
            
            notice:
                #This notice will be shown if there are any instances of that module
                #which are in a nest and/or slideshow.
                message: ''
                type: warning
                show: false
                html: true

            db_items:
                #If displaying nests/slideshows which contain plugins of a specific module,
                #there will be a table join and extra WHERE statement added in the PHP class.
                table: |
                    [[DB_PREFIX]]plugin_instances AS pi
                    INNER JOIN [[DB_PREFIX]]modules AS m
                       ON m.id = pi.module_id
                id_column: pi.id
                where_statement: |
                    WHERE pi.content_id = 0
                custom__exclude_nests_and_slideshows: |
                    AND pi.module_id NOT IN (
                        SELECT id
                        FROM [[DB_PREFIX]]modules
                        WHERE class_name IN ('zenario_nest', 'zenario_ajax_nest', 'zenario_slideshow')
                    )
            refiners:
                plugin:
                    sql: 'pi.module_id = [[REFINER_ID]]'
                nests:
                    title: Nest library
                    select_mode_title: Select a nest
                    sql: |
                        pi.module_id IN (SELECT id FROM [[DB_PREFIX]]modules WHERE class_name IN ('zenario_nest', 'zenario_ajax_nest'))
                slideshows:
                    title: Slideshow library
                    select_mode_title: Select a slideshow
                    sql: |
                        pi.module_id = (SELECT id FROM [[DB_PREFIX]]modules WHERE class_name = 'zenario_slideshow')
                view_nests_containing:
                    #The necessary table join and WHERE statement is added in the PHP class.
                    exists: true
                
                plugins_using_form:
                    sql: |
                        pi.id IN (
                            SELECT instance_id
                            FROM [[DB_PREFIX]]plugin_settings
                            WHERE foreign_key_to = 'user_form'
                              AND foreign_key_id = [[REFINER_ID]]
                              AND egg_id = 0
                        )
                nests_using_form:
                    sql: |
                        pi.module_id IN (SELECT id FROM [[DB_PREFIX]]modules WHERE class_name IN ('zenario_nest', 'zenario_ajax_nest'))
                        AND pi.id IN (
                            SELECT instance_id
                            FROM [[DB_PREFIX]]plugin_settings
                            WHERE foreign_key_to = 'user_form'
                              AND foreign_key_id = [[REFINER_ID]]
                              AND egg_id != 0
                        )
                
                plugins_using_image:
                    sql: |
                        pi.id IN (
                            SELECT foreign_key_id
                            FROM [[DB_PREFIX]]inline_images AS iiu
                            WHERE foreign_key_to = 'library_plugin'
                              AND image_id = [[REFINER_ID]]
                        )
                nests_using_image:
                    sql: |
                        pi.module_id IN (SELECT id FROM [[DB_PREFIX]]modules WHERE class_name IN ('zenario_nest', 'zenario_ajax_nest'))
                        AND pi.id IN (
                            SELECT foreign_key_id
                            FROM [[DB_PREFIX]]inline_images AS iiu
                            WHERE foreign_key_to = 'library_plugin'
                              AND image_id = [[REFINER_ID]]
                        )
                slideshows_using_image:
                    sql: |
                        pi.module_id = (SELECT id FROM [[DB_PREFIX]]modules WHERE class_name = 'zenario_slideshow')
                        AND pi.id IN (
                            SELECT foreign_key_id
                            FROM [[DB_PREFIX]]inline_images AS iiu
                            WHERE foreign_key_to = 'library_plugin'
                              AND image_id = [[REFINER_ID]]
                        )
                email_address_setting:
                    table_join: |
                        [[DB_PREFIX]]plugin_settings ps
                        ON pi.id = ps.instance_id
                    sql: |
                        (
                            ps.is_email_address = 1 
                            OR 
                            (
                                (ps.is_email_address IS NULL) AND (ps.name LIKE '%email%')
                            )
                        )
                        AND 
                            ps.value != ''
                        AND 
                            ps.is_content = 'synchronized_setting'
                        AND
                            ps.value REGEXP '[^@ ]+@[^. ]+(\\.[^.]+)+'
                    
            #quick_filter_buttons:
            #    module:
            #        label: 'All modules'
            #    all_modules:
            #        parent: module
            #        label: 'All modules'
            #        column: module_id
            #        value: ''
            #        remove_filter: true

            #quick_filter_buttons: 
            #    test: 
            #        label: Show most recent
            #        column: id
            #        value: 37
            
            columns:
                id:
                    format: id
                    db_column: pi.id
                    searchable: true
                    #Please note: the chop_prefix_from_search property will change
                    #to "N" when viewing nests, or to "S" when viewing slideshows.
                    chop_prefix_from_search: P
                code:
                    title: ID
                    format: id
                    always_show: true
                    db_column: pi.id
                    sort_column: pi.id
                    searchable: true
                    width: xxsmall
                name:
                    title: Plugin name
                    db_column: pi.name
                    searchable: true
                    always_show: true
                    width: xxlarge
                module_id:
                    title: Module ID
                    hidden: true
                    db_column: pi.module_id
                    format: enum
                    values: {}
                module_name:
                    parent: name
                    title: Module
                    always_show: true
                    visible_if: |
                        !tuix.key.moduleId
                    db_column: m.display_name
                    searchable: true
                    disallow_filtering: true
                module_class_name:
                    db_column: m.class_name
                nestable:
                    db_column: m.nestable
                where_used:
                    parent: name
                    title: Usage
                    show_by_default: true
                    width: xlarge
                    html: true
                    css_class: 'organizer_cell_line otherline no_italics'
                plugin_email_address:
                    title: Email
                    db_column: |
                        (
                           SELECT GROUP_CONCAT(DISTINCT ps1.value SEPARATOR ', ')
                           FROM [[DB_PREFIX]]plugin_settings ps1
                           WHERE ps1.instance_id = pi.id
                           AND
                           (
                                ps1.is_email_address = 1 
                                OR 
                                (
                                    (ps1.is_email_address IS NULL) AND (ps1.name LIKE '%email%')
                                )
                            )
                            AND 
                                ps1.value != ''
                            AND 
                                ps1.is_content = 'synchronized_setting'
                            AND
                                ps1.value REGEXP '[^@ ]+@[^. ]+(\\.[^.]+)+'
                            
                        )
                    width: xxlarge
                    ord: 100
                    show_by_default: true
                framework:
                    title: Framework
                    db_column: pi.framework
            item:
                name: Plugin
                names: Plugins
                css_class: plugin_album_instance
                link:
                    path: zenario__modules/panels/nested_plugins
                    refiner: nest
            collection_buttons:
                create:
                    priv: _PRIV_MANAGE_REUSABLE_PLUGIN
                    visible_if: |
                        tuix.key.moduleId
                    css_class: zenario_create_a_new
                    label: Create a ~plugin~
                    admin_box:
                        path: plugin_settings
                        create_another: false
                view_nests_containing:
                    label: View nests/slideshows containing this module
                    hidden: true
                    hide_on_refiner: view_nests_containing
                    link:
                        path: zenario__modules/panels/plugins
                        refiner: view_nests_containing
                create_dropdown:
                    priv: _PRIV_MANAGE_REUSABLE_PLUGIN
                    visible_if: |
                        !tuix.key.moduleId
                    css_class: zenario_create_a_new
                    hide_when_children_are_not_visible: true
                    hide_on_refiner: email_address_setting
                    label: Create a ~plugin~
            item_buttons:
                edit:
                    priv: _PRIV_VIEW_REUSABLE_PLUGIN
                    label: Edit ~plugin~ settings
                    admin_box:
                        path: plugin_settings
                # The old "CSS & framework" button, commented out now as it has been merged back into the plugin settings
                #framework_and_css:
                #    priv: _PRIV_VIEW_REUSABLE_PLUGIN
                #    label: 'CSS & framework'
                #    admin_box:
                #        path: plugin_css_and_framework
                view_dropdown:
                    label: View
                    multiple_select: true
                    hide_when_children_are_not_visible: true
                view:
                    parent: view_dropdown
                    label: Plugin's image
                    popout:
                        href: zenario/file.php?popout=1
                        options:
                            type: image
                    with_columns_set:
                        has_image: true
                    visible_if: |
                        item.module_class_name != 'zenario_nest' &&
                        item.module_class_name != 'zenario_ajax_nest' &&
                        item.module_class_name != 'zenario_slideshow'
                usage_layouts:
                    parent: view_dropdown
                    label: "Layouts using this ~plugin~"
                    visible_if_for_all_selected_items: item.usage_layouts > 0
                    hide_in_select_mode: true
                    link:
                        path: zenario__layouts/panels/layouts
                        branch: true
                        refiner: plugin_instance_usage
                    width: xsmall
                    align_right: true
                usage_item:
                    parent: view_dropdown
                    label: "Items using this ~plugin~"
                    visible_if_for_all_selected_items: item.usage_item > 0
                    hide_in_select_mode: true
                    link:
                        path: zenario__content/panels/content
                        branch: true
                        refiner: plugin_instance_usage
                    width: xsmall
                    align_right: true
                view_content_items:
                    parent: view_dropdown
                    label: Effective usage
                    visible_if_for_all_selected_items: item.usage_item > 0 || item.usage_layouts > 0
                    hide_in_select_mode: true
                    link:
                        path: zenario__content/panels/content
                        branch: true
                        refiner: plugin_instance_effective_usage
                action_dropdown:
                    label: Actions
                    multiple_select: true
                    hide_when_children_are_not_visible: true
                duplicate:
                    parent: action_dropdown
                    priv: _PRIV_MANAGE_REUSABLE_PLUGIN
                    label: Duplicate
                    admin_box:
                        path: zenario_duplicate_plugin
                delete:
                    priv: _PRIV_MANAGE_REUSABLE_PLUGIN
                    ord: 99
                    label: Delete
                    multiple_select: true
                    hide_in_select_mode: false
                    visible_if_for_all_selected_items: item.usage_item == 0 && item.usage_layouts == 0
                    ajax:
                        confirm:
                            message: |
                                Are you sure you wish to delete the ~plugin~ "[[code]] [[name]]"?
                                
                                Its settings will be deleted but any attached images will be left in the image library.
                            multiple_select_message: Are you sure you wish to delete these plugins?
                            button_message: Delete
                            cancel_button_message: Cancel
                            message_type: warning
                        request:
                            delete: "1"
                delete_used:
                    priv: _PRIV_MANAGE_REUSABLE_PLUGIN
                    ord: 99
                    label: Delete
                    hide_in_select_mode: true
                    visible_if_for_all_selected_items: item.usage_item > 0 || item.usage_layouts > 0
                    ajax:
                        confirm:
                            message: |
                                This ~plugin~ is currently used on [[usage_item]] content item(s) and [[usage_layouts]] layout(s).
                                
                                Deleting it will remove it from these content items and layouts, and this may have an immediate effect on published pages.
                                
                                Any attached images will be left in image library.
                                
                                Are you still sure you wish to delete the ~plugin~ "[[code]] [[name]]"?
                            multiple_select_message: Are you sure you wish to delete these plugins?
                            button_message: Delete
                            cancel_button_message: Cancel
                            message_type: warning
                        request:
                            delete: "1"
