Yaron Koren has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/95624


Change subject: Make "minimum instances" the default number, for multi-instance 
templates.
......................................................................

Make "minimum instances" the default number, for multi-instance templates.

This applies for both creating new pages and editing existing ones - for
existing pages, it just sets the minimum; no impact if the number of
instances already exceeds that number.

Change-Id: I5ac9d79fe998b10dc493615e7a16df613e3090ab
---
M includes/SF_FormPrinter.php
1 file changed, 13 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/SemanticForms 
refs/changes/24/95624/1

diff --git a/includes/SF_FormPrinter.php b/includes/SF_FormPrinter.php
index 6a88324..8e97e51 100644
--- a/includes/SF_FormPrinter.php
+++ b/includes/SF_FormPrinter.php
@@ -611,13 +611,14 @@
                                                        // if there's at least 
one, re-parse this section of the
                                                        // definition form for 
the subsequent template instances in
                                                        // this page; if 
there's none, don't include fields at all.
-                                                       // there has to be a 
more efficient way to handle multiple
+                                                       // There has to be a 
more efficient way to handle multiple
                                                        // instances of 
templates, one that doesn't involve re-parsing
                                                        // the same tags, but I 
don't know what it is.
                                                        // (Also add 
additional, blank instances if there's a minimum
                                                        // number required in 
this form, and we haven't reached it yet.)
                                                        if ( $found_instance || 
$instance_num < $minimumInstances ) {
-                                                               $instance_num++;
+                                                               // Print 
another instance until we reach the minimum
+                                                               // instances, 
which is also the starting number.
                                                        } else {
                                                                
$all_instances_printed = true;
                                                        }
@@ -732,8 +733,17 @@
                                        // template, then delete them from the 
array, so we can get the
                                        // next group next time - the next() 
command for arrays doesn't
                                        // seem to work here.
+                                       // @TODO - This is currently called 
regardless of whether the
+                                       // input is from the form; the 
$wgRequest check doesn't do
+                                       // anything. Is that a problem?
                                        if ( ( ! $source_is_page ) && 
$allow_multiple && $wgRequest ) {
-                                               $all_instances_printed = true;
+                                               if ( $instance_num < 
$minimumInstances ) {
+                                                       // Print another 
instance until we reach the minimum
+                                                       // instances, which is 
also the starting number.
+                                                       continue;
+                                               } else {
+                                                       $all_instances_printed 
= true;
+                                               }
                                                if ( $old_template_name != 
$template_name ) {
                                                        
$all_values_for_template = $wgRequest->getArray( $query_template_name );
                                                }

-- 
To view, visit https://gerrit.wikimedia.org/r/95624
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I5ac9d79fe998b10dc493615e7a16df613e3090ab
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/SemanticForms
Gerrit-Branch: master
Gerrit-Owner: Yaron Koren <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to