# You must use a tab-size of 4 spaces to edit this file.
---
zenario__library:
    panels:
        documents:
            priv: _PRIV_VIEW_DOCUMENTS
            item:
                css_class: zenario_file_item
            title: Hierarchical documents
            db_items:
                table: |
                    [[DB_PREFIX]]documents AS d
                    LEFT JOIN [[DB_PREFIX]]files AS f ON d.file_id = f.id
                id_column: d.id
                client_side: true
                max_limit: 1000
            
            panel_type: hierarchy_documents
            #panel_type: hierarchy_with_lazy_load
            
            reorder:
                column: ordinal
                hierarchy_view_mode: parent_ids_and_ordinals
                lazy_load: true
            
            hierarchy:
                column: folder_id
            
            disable_periodic_refresh: true
            default_sort_column: name
            no_items_message: There are no documents or folders

            refiners:
                public_documents_only:
                    sql: '(d.type = "folder" OR d.privacy = "public")'
                folders_only:
                    sql: 'd.type = "folder"'

            columns:
                id:
                    title: ID
                    format: id
                    searchable: true
                    db_column: d.id
                    align_right: true
                    width: xxsmall
                file_id:
                    title: fileID
                    db_column: f.id
                    hidden: true
                ordinal:
                    title: Ordinal
                    db_column: d.ordinal
                    align_right: true
                    width: xxsmall
                type:
                    searchable: false
                    db_column: d.type
                folder_id:
                    db_column: d.folder_id
                    align_right: true
                    width: xxsmall
                path:
                    title: Path
                    searchable: false
                    always_show: true
                    width: xlarge
                name:
                    title: Name
                    db_column: "concat(ifNull(d.filename, \'\'), ifNull(d.folder_name, \'\'))"
                    width: xxlarge
                    searchable: true
                    show_by_default: true
                    css_class: 'zenario_document_title'
                    
                    document_line_number: 1
                filename:
                    db_column: d.filename
                
                folder_name:
                    title: Folder
                    show_by_default: true
                    db_column: |
                        (
                            SELECT d2.folder_name
                            FROM [[DB_PREFIX]]documents d2
                            WHERE d.folder_id = d2.id
                        )
                filesize:
                    title: Filesize
                    db_column: f.size
                    width: small
                    show_by_default: true
                    document_line_number: 1
                    
                privacy:
                    title: Privacy
                    db_column: d.privacy
                    show_by_default: true
                    css_class: "zenario_document_sub_fields"
                    
                    format: enum
                    values:
                        offline: Offline
                        public: Public
                        private: Private
                    
                    document_line_number: 2
                short_checksum:
                    title: Short checksum
                    searchable: true
                    ascii_only: true
                    show_by_default: true
                    db_column: f.short_checksum
                    hidden: false
                    css_class: "zenario_document_sub_fields"
                    
                    document_line_number: 2
                date_uploaded:
                    title: Date uploaded
                    db_column: d.file_datetime
                    show_by_default: true
                    css_class: "zenario_document_sub_fields"
                    
                    document_line_number: 2
                extract_wordcount:
                    title: Extract wordcount
                    db_column: d.extract_wordcount
                    show_by_default: true
                    css_class: "zenario_document_sub_fields"
                    
                    document_line_number: 2
                extract_snippet:
                    title: extract snippet
                    db_column: SUBSTR(extract, 1, 40) as extract
                    hidden: true
                folder_file_count: {}
                has_image:
                    db_column: d.thumbnail_id
                    width: xxsmall
                    format: yes_or_no
                plaintext_extract_details:
                    title: Extract text
                    width: xxlarge
                mime_type:
                    hidden: true
                    db_column: f.mime_type
            
            bold_columns_in_list_view: name
            
            label_format_for_picked_items: |
                [[full_path_label]]
            
            collection_buttons:
                upload:
                    priv: _PRIV_EDIT_DOCUMENTS
                    label: Upload documents
                    css_class: zenario_create_a_new
                    hide_on_filter: true
                    hide_on_refiner: folders_only
                    admin_box:
                        path: zenario_document_upload
                add_folder:
                    priv: _PRIV_EDIT_DOCUMENTS
                    label: Create a folder
                    css_class: zenario_create_a_new
                    hide_on_filter: true
                    admin_box:
                        path: zenario_document_folder
                
            item_buttons:
                upload:
                    priv: _PRIV_EDIT_DOCUMENTS
                    label: Upload to selected folder
                    css_class: zenario_create_a_new
                    hide_on_filter: true
                    hide_on_refiner: folders_only
                    admin_box:
                        path: zenario_document_upload
                    with_columns_set:
                        traits.is_folder: true
                add_folder:
                    priv: _PRIV_EDIT_DOCUMENTS
                    label: Create subfolder
                    css_class: zenario_create_a_new
                    hide_on_filter: true
                    admin_box:
                        path: zenario_document_folder
                        key:
                            add_folder: true
                    with_columns_set:
                        traits.is_folder: true
                
                view_tags:
                    priv: _PRIV_EDIT_DOCUMENTS
                    hide_in_select_mode: true
                    label: Edit document metadata
                    multiple_select: false
                    without_columns_set:
                        traits.is_folder: true
                    admin_box:
                        path: zenario_document_properties
                actions_dropdown:
                    label: Actions
                    multiple_select: true
                    hide_when_children_are_not_visible: true                
                rename:
                    priv: _PRIV_EDIT_DOCUMENTS
                    parent: actions_dropdown
                    hide_in_select_mode: true
                    label: Rename
                    multiple_select: false
                    admin_box:
                        path: zenario_document_rename
                    with_columns_set:
                        traits.is_folder: true
                open:
                    parent: actions_dropdown
                    label: Open file
                    multiple_select: false
                    hide_in_select_mode: true
                    without_columns_set:
                        traits.is_folder: true
                    onclick: |
                        var item = zenarioO.selectedItemDetails();
                        window.open(URLBasePath + 'zenario/file.php?usage=documents&showInWindow=1&document_id=' + item.id);
                        return false;
                download:
                    parent: actions_dropdown
                    hide_in_select_mode: true
                    label: Download
                    multiple_select: false
                    without_columns_set:
                        traits.is_folder: true
                    ajax:
                        confirm:
                            download: true
                            message: 'Are you sure you wish to download the file "[[name]]"?'
                            message_type: warning
                            button_message: Download
                            cancel_button_message: Cancel
                generate_public_link:
                    priv: _PRIV_EDIT_DOCUMENTS
                    parent: actions_dropdown
                    hide_in_select_mode: false
                    label: Make public
                    multiple_select: true
                    without_columns_set:
                        traits.is_folder: true
                        traits.public: true
                    ajax: 
                        confirm:
                            message: Are you sure you want to make this document public? This will generate a public link to the document, with which it will be accessible by anyone.
                            multiple_select_message: Are you sure you want to make these documents public? This will generate public links to each document, with which they will be accessible by anyone.
                            button_message: Make public
                            cancel_button_message: Cancel
                            message_type: question
                        request: 
                            generate_public_link: true
                            
                make_document_private:
                    priv: _PRIV_EDIT_DOCUMENTS
                    parent: actions_dropdown
                    hide_in_select_mode: false
                    label: Make private
                    multiple_select: true
                    without_columns_set:
                        traits.is_folder: true
                        traits.private: true
                    ajax: 
                        confirm:
                            message: Are you sure you want to make this document private?
                            multiple_select_message: Are you sure you want to make these documents private?
                            button_message: Make private
                            cancel_button_message: Cancel
                            message_type: question
                        request: 
                            make_document_private: true
                            
                view_public_link:
                    parent: actions_dropdown
                    hide_in_select_mode: false
                    label: View public link
                    multiple_select: false
                    with_columns_set:
                        traits.public: true
                    without_columns_set:
                        traits.is_folder: true
                    ajax: 
                        request: 
                            generate_public_link: true
                advanced_dropdown:
                    label: Advanced
                    multiple_select: true
                    hide_when_children_are_not_visible: true
                remove_metadata:
                    priv: _PRIV_EDIT_DOCUMENTS
                    parent: advanced_dropdown
                    hide_in_select_mode: true
                    label: Remove all metadata
                    multiple_select: true
                    without_columns_set:
                        traits.is_folder: true
                    ajax: 
                        confirm: 
                            message: "Are you sure you want to remove all of the metadata from the document \"[[name]]\"?"
                            multiple_select_message: "Are you sure you want tto remove all of the metadata from the selected documents?"
                            message_type: warning
                            button_message: Delete
                            cancel_button_message: Cancel
                        request: 
                            remove_metadata: true
                rescan_extract:
                    priv: _PRIV_EDIT_DOCUMENTS
                    parent: advanced_dropdown
                    hide_in_select_mode: true
                    visible_if: |
                        item.mime_type == "application/pdf"
                        && zenarioA.siteSettings.pdftotext_path 
                        && zenarioA.siteSettings.ghostscript_path
                    label: Rescan text/image extract
                    without_columns_set:
                        traits.is_folder: true
                    ajax:
                        confirm: 
                            message: | 
                                Are you sure you want to rescan the text and thumbnail? 
                                
                                If you are using a custom thumbnail image it will be lost.
                            message_type: warning
                            button_message: 'Ok'
                            cancel_button_message: Cancel
                        request: 
                            rescan: true
                rescan_image:
                    priv: _PRIV_EDIT_DOCUMENTS
                    parent: advanced_dropdown
                    hide_in_select_mode: true
                    visible_if: |
                        ["image/jpeg", "image/webp", "image/png", "image/gif"].indexOf(item.mime_type) !== -1
                    label: Rescan thumbnail
                    without_columns_set:
                        traits.is_folder: true
                    ajax:
                        confirm: 
                            message: | 
                                Are you sure you want to rescan the thumbnail? 
                                
                                If you are using a custom thumbnail image it will be lost.
                            message_type: warning
                            button_message: 'Ok'
                            cancel_button_message: Cancel
                        request: 
                            rescan_image: true
                    
                rescan_text:
                    priv: _PRIV_EDIT_DOCUMENTS
                    parent: advanced_dropdown
                    hide_in_select_mode: true
                    visible_if: |
                        item.name.match(/.doc$/i) ||
                        item.name.match(/.docx$/i) && zenarioA.siteSettings.antiword_path ||
                        item.name.match(/.pdf$/i) && zenarioA.siteSettings.pdftotext_path
                    label: Rescan text
                    without_columns_set:
                        traits.is_folder: true
                    ajax:
                        request: 
                            rescan_text: true
                move_documents:
                    priv: _PRIV_EDIT_DOCUMENTS
                    parent: actions_dropdown
                    hide_in_select_mode: true
                    label: Move to folder...
                    multiple_select_label: Move to folder...
                    multiple_select: true
                    admin_box:
                        path: zenario_document_move
                
                upload_replacement_document:
                    priv: _PRIV_EDIT_DOCUMENTS
                    parent: actions_dropdown
                    hide_in_select_mode: true
                    visible_if: |
                        item.type != 'folder'
                    label: Upload a replacement
                    admin_box:
                        path: zenario_upload_replacement_document
                
                delete_file:
                    priv: _PRIV_EDIT_DOCUMENTS
                    hide_in_select_mode: true
                    label: Delete
                    multiple_select: true
                    without_columns_set:
                        traits.is_folder: true
                    ajax: 
                        class_name: zenario_common_features
                        confirm: 
                            message: "Are you sure you want to delete the document \"[[name]]\"?"
                            multiple_select_message: "Are you sure you want to delete the selected documents?"
                            message_type: warning
                            button_message: Delete
                            cancel_button_message: Cancel
                        request: 
                            delete: true
                make_offline:
                    priv: _PRIV_EDIT_DOCUMENTS
                    parent: actions_dropdown
                    hide_in_select_mode: false
                    label: Make offline
                    multiple_select: true
                    without_columns_set:
                        traits.is_folder: true
                        traits.offline: true
                    ajax: 
                        confirm:
                            message: | 
                                Are you sure you want to make this document offline? 
                                                                
                                This will remove all public links to the document. Anyone with the URL will be unable to access it.
                            multiple_select_message: |
                                Are you sure you want to make these documents offline? 
                                                                
                                This will remove all public links to the documents. Anyone with the URLs will be unable to access them.
                            button_message: Make offline
                            cancel_button_message: Cancel
                            message_type: question
                        request: 
                            make_offline: true
                #The "Copy to document content items" button is disabled for now, as there is a bug
                #where a document file might get permanently deleted. Awaiting a fix.
                # copy_to_document_content_items:
#                     parent: actions_dropdown
#                     priv: _PRIV_EDIT_DOCUMENTS
#                     hide_in_select_mode: true
#                     multiple_select: true
#                     label: Copy to document content items
#                     ajax:
#                         confirm:
#                             message: |
#                                 Copy this document to document content items?
# 
#                                 It will be created with "public" permission, but as a draft.
#                             multiple_select_message: |
#                                 Copy these documents to document content items?
# 
#                                 They will be created with "public" permission, but as a drafts.
#                             button_message: Copy
#                             cancel_button_message: Cancel
#                             message_type: question
#                         request:
#                             copy_to_document_content_items: 1
                delete_folder:
                    priv: _PRIV_EDIT_DOCUMENTS
                    hide_in_select_mode: true
                    label: Delete
                    multiple_select: false
                    with_columns_set:
                        traits.is_folder: true
                    without_columns_set:
                        traits.is_empty_folder: true
                    ajax: 
                        class_name: zenario_common_features
                        confirm: 
                            message: |
                                Are you sure you want to delete the folder "[[name]]"?
                                
                                If you DELETE this folder all [[folder_file_count]] files and folders within this folder will be DELETED.
                            message_type: warning
                            button_message: Delete
                            cancel_button_message: Cancel
                        request: 
                            delete: true
                delete_empty_folder:
                    priv: _PRIV_EDIT_DOCUMENTS
                    hide_in_select_mode: true
                    label: Delete
                    multiple_select: false
                    with_columns_set:
                        traits.is_empty_folder: true
                    ajax: 
                        class_name: zenario_common_features
                        confirm: 
                            message: |
                                Are you sure you want to delete the empty folder "[[name]]"?
                            message_type: warning
                            button_message: Delete
                            cancel_button_message: Cancel
                        request: 
                            delete: true