Topic on Extension talk:SimpleBatchUpload

Integrate with PageForm

4
153.96.72.51 (talkcontribs)

The extension is very good. But how to integrate with PageForm?

Ankostis (talkcontribs)

You may assign semantic-properties to uploaded files by giving a template as the 2nd argument to in the #batchupload parser-function. This template may contain annotations like that:

[[Has some property::{{PAGENAME}}]]

That way the uploaded file will be linked to the page that was created from (the page hosting the #batchupload function).

Ankostis (talkcontribs)

For future reference: i used mediawiki-javascript to have a listbox next to the uploader giving the property(ies) to set on the uploaded file page.

This is the markup on the "owner" page for the files, \where the uploaded controls is to be presented:

<!-- $wgRawHtml = true; is needed -->
<html>
<fieldset>
  <legend>Set doc topic</legend>
  <select id="doc-type" title="Document type">
    <option value="--undefined--">--generic--</option>
    <option value="Insurance">Insurance</option>
    <option value="Manual">Manual</option>
    <option value="Maintenance record">Maintenance record</option>
    <option value="Consignment note">Consignment note</option>
  </select>
</fieldset>
</html>
{{#batchupload:File template|owner={{PAGENAME}}|doctopic=}}

This is the template for the file pages:

{| class="wikitable"
! Document of:
| [[Doc of::{{{owner|Orphaned documents}}}]] 
|-
! Document topic:
| [[Doc topic::{{{doctopic|--undefined--}}}]] 
|-
|}

And this is the javascript to modify the template given in #batchupload parser-function:

$(function () {
    $('.filer-prop-selector').each(function() {
        var topic = $('select#doc-type', this);
        var uploader = $('input.fileupload', this);
        
        function update_templates() {
            var topicval = topic.val();
            
            // eg: "{{File template|owner=A page|doctopic=}}"
            var old_templates = uploader.data('text')
            
            if ( !old_templates ) {
                console.warn(`OLD: ${old_templates}, OFFICIAL: ${offval}, TOPIC: ${topicval}`);
            } else {
                var new_templates = old_templates.replace(/doctopic=([^|}]*)/, `doctopic=${topicval}`);
                
                // Set attr or dataset don't work! 
                // See: https://github.com/blueimp/jQuery-File-Upload/wiki/API
                uploader.fileupload('option', 'text', new_templates);
                //Update also 'data-text' to be visible in chrome's devtools.
                uploader.attr('data-text', new_templates);
            }
        };
        official.change(update_templates);
        topic.change(update_templates);
        update_templates();  // ensure set even if not fired.
    });
}());

// [[Category:Filer machinery]]

F.trott (talkcontribs)

Currently no integration is foreseen.

The SpecialPage could probably made includable, so you could display it on a Form and upload files, but that would be it. There is no way to transfer the names of the uploaded files to the final page.

If you a feature like this, I think you should ask for it on the PageForms discussion page (or open a Phabricator task).

Reply to "Integrate with PageForm"