Αυτό είναι ένα meta-module το οποίο αναμένεται να χρησιμοποιηθεί από τα πρότυπα πλαισίων μηνυμάτων {{mbox}}, {{ambox}}, {{cmbox}}, {{fmbox}}, {{imbox}}, {{ombox}} και {{tmbox}}. Είναι προορισμένο να χρησιμοποιηθεί από module γραμμένο σε Lua, και δε πρέπει να χρησιμοποιηθεί άμεσα από σελίδες wiki. Αν θέλετε να χρησιμοποιήσετε τις λειτουργίες αυτού του module σε κάποια σελίδα wiki, παρακαλούμε χρησιμοποιήστε κάποιο πρότυπο πλαισίων μηνυμάτων αντί αυτού.

Χρήση Επεξεργασία

Για να χρησιμοποιήσετε αυτό το module από άλλο module γραμμένο σε Lua, πρώτα χρειάζεται να το φορτώσετε.

local messageBox = require('Module:Message box')

Για να δημιουργήσετε ένα πλαίσιο μηνύματος, χρησιμοποιήστε την συνάρτηση main. Παίρνει δύο παραμέτρους: η πρώτη είναι ο τύπος του κουτιού (ως μια συμβολοσειρά), και η δεύτερη είναι μια λίστα που περιέχει τις παραμέτρους του πλαισίου.

local box = messageBox.main( boxType, {
    param1 = param1,
    param2 = param2,
    -- More parameters...
})

Υπάρχουν επτά διαθέσιμοι τύποι κουτιών:

Τύπος κουτιού Πρότυπο Πρόθεση
mbox {{mbox}} Για πλαίσια μηνυμάτων που χρησιμοποιούνται σε πολλαπλούς ονοματοχώρους
ambox {{ambox}} Για πλαίσια μηνυμάτων άρθρων
cmbox {{cmbox}} Για πλαίσια μηνυμάτων κατηγοριών
fmbox {{fmbox}} Για πλαίσια μηνυμάτων διεπαφής
imbox {{imbox}} Για πλαίσια μηνυμάτων στον ονοματοχώρο αρχείων
tmbox {{tmbox}} Για πλαίσια μηνυμάτων σελιδών συζήτησης
ombox {{ombox}} Για πλαίσια μηνυμάτων σε άλλους ονοματοχώρους

Δείτε τη σελίδα προτύπου από κάθε τύπο κουτιού για τις διαθέσιμες παραμέτρους.

Χρήση από #invoke Επεξεργασία

Εκτός από τη συνάρτηση main, το module έχει ξεχωριστές συναρτήσεις για κάθε τύπο κουτιού. Γίνονται προσβάσιμες χρησιμοποιώντας τον κώδικα {{#invoke:Message box|mbox|...}}, {{#invoke:Message box|ambox|...}}, κλπ. These will work when called from other modules, but they access code used to process arguments passed from #invoke, and so calling them will be less efficient than calling main.

Τεχνικές λεπτομέρειες Επεξεργασία

The module uses the same basic code for each of the templates listed above; the differences between each of them are configured using the data at Module:Message box/configuration. Here are the various configuration options and what they mean:

  • types - a table containing data used by the type parameter of the message box. The table keys are the values that can be passed to the type parameter, and the table values are tables containing the class and the image used by that type.
  • default - the type to use if no value was passed to the type parameter, or if an invalid value was specified.
  • showInvalidTypeError - whether to show an error if the value passed to the type parameter was invalid.
  • allowBlankParams - usually blank values are stripped from parameters passed to the module. However, whitespace is preserved for the parameters included in the allowBlankParams table.
  • allowId - whether it is possible to set an "id" attribute to the html table tag.
  • allowSmall - whether a small version of the message box can be produced with "small=yes".
  • smallParam - a custom name for the small parameter. For example, if set to "left" you can produce a small message box using "small=left".
  • smallClass - the class to use for small message boxes.
  • substCheck - whether to perform a subst check or not.
  • classes - an array of classes to use with the message box.
  • usePlainlinksParam - whether to allow "plainlinks=no" to turn off the plainlinks class.
  • imageEmptyCell - whether to use an empty <td>...</td> cell if there is no image set. This is used to preserve spacing for message boxes with a width of less than 100% of the screen.
  • imageEmptyCellStyle - whether empty image cells should be styled.
  • imageCheckBlank - whether "image=blank" results in no image being displayed.
  • imageSmallSize - usually, images used in small message boxes are set to 30x30px. This sets a custom size.
  • imageCellDiv - whether to enclose the image in a div enforcing a maximum image size.
  • useCollapsibleTextFields - whether to use text fields that can be collapsed, i.e. "issue", "fix", "talk", etc. Currently only used in ambox.
  • imageRightNone - whether imageright=none results in no image being displayed on the right-hand side of the message box.
  • sectionDefault - the default name for the "section" parameter. Depends on useCollapsibleTextFields.
  • allowMainspaceCategories - allow categorisation in the main namespace.
  • templateCategory - the name of a category to be placed on the template page.
  • templateCategoryRequireName - whether the name parameter is required to display the template category.
  • templateErrorCategory - the name of the error category to be used on the template page.
  • templateErrorParamsToCheck - an array of parameter names to check. If any are absent, the templateErrorCategory is applied to the template page.