r60214 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r60213‎ | r60214 | r60215 >
Date:20:53, 18 December 2009
Author:yaron
Status:deferred
Tags:
Comment:
Added handling of 'super_page' (courtesy of Stefan Harwarth) and leading zeroes in generated page number (courtesy of Jack Pond)
Modified paths:
  • /trunk/extensions/SemanticForms/specials/SF_AddData.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticForms/specials/SF_AddData.php
@@ -132,11 +132,14 @@
133133 $sfgFormPrinter->formHTML($form_definition, $form_submitted, $page_is_source, $page_contents, $page_title, $page_name_formula);
134134 if ($form_submitted) {
135135 if ($page_name_formula != '') {
136 - // append a namespace, if one was specified
 136+ $target_name = $generated_page_name;
 137+ // prepend a super-page, if one was specified
 138+ if ($wgRequest->getCheck('super_page')) {
 139+ $target_name = $wgRequest->getVal('super_page') . '/' . $target_name;
 140+ }
 141+ // prepend a namespace, if one was specified
137142 if ($wgRequest->getCheck('namespace')) {
138 - $target_name = $wgRequest->getVal('namespace') . ':' . $generated_page_name;
139 - } else {
140 - $target_name = $generated_page_name;
 143+ $target_name = $wgRequest->getVal('namespace') . ':' . $target_name;
141144 }
142145 // replace "unique number" tag with one that
143146 // won't get erased by the next line
@@ -162,8 +165,13 @@
163166 $target_title = Title::newFromText(preg_replace('/{num.*}/', $title_number, $target_name));
164167 // if title number is blank,
165168 // change it to 2; otherwise,
166 - // increment it
167 - $title_number = ($title_number == "") ? 2 : $title_number + 1;
 169+ // increment it, and if necessary
 170+ // pad it with leading 0s as well
 171+ if ($title_number == "") {
 172+ $title_number = 2;
 173+ } else {
 174+ $title_number = str_pad($title_number + 1, strlen($title_number), '0', STR_PAD_LEFT);
 175+ }
168176 } while ($target_title->exists());
169177 } else {
170178 $target_title = Title::newFromText($target_name);

Status & tagging log