Index: trunk/extensions/SemanticForms/includes/SF_FormPrinter.inc |
— | — | @@ -98,7 +98,7 @@ |
99 | 99 | $this->mInputTypeHooks[$input_type] = array($function_name, $default_args); |
100 | 100 | } |
101 | 101 | |
102 | | - function formHTML($form_def, $form_submitted, $source_is_page, $existing_page_content = null, $page_title = null) { |
| 102 | + function formHTML($form_def, $form_submitted, $source_is_page, $existing_page_content = null, $page_title = null, $page_name_formula = null) { |
103 | 103 | global $wgRequest, $wgUser, $wgParser; |
104 | 104 | global $sfgTabIndex; // used to represent the current tab index in the form |
105 | 105 | global $sfgFieldNum; // used for setting various HTML IDs |
— | — | @@ -109,6 +109,7 @@ |
110 | 110 | $sfgFieldNum = 1; |
111 | 111 | $source_page_matches_this_form = false; |
112 | 112 | $form_page_title = NULL; |
| 113 | + $generated_page_name = $page_name_formula; |
113 | 114 | // $form_is_partial is true if: |
114 | 115 | // (a) 'partial' == 1 in the arguments |
115 | 116 | // (b) 'partial form' is found in the form definition |
— | — | @@ -138,7 +139,12 @@ |
139 | 140 | // disable all form elements if user doesn't have edit permission - |
140 | 141 | // two different checks are needed, because editing permissions can be |
141 | 142 | // set in different ways |
142 | | - $this->mPageTitle = Title::newFromText($page_title); |
| 143 | + // HACK - sometimes we don't know the page name in advance, but we still |
| 144 | + // need to set a title here for testing permissions |
| 145 | + if ($page_title == '') |
| 146 | + $this->mPageTitle = Title::newFromText("Semantic Forms permissions test"); |
| 147 | + else |
| 148 | + $this->mPageTitle = Title::newFromText($page_title); |
143 | 149 | if ($wgUser->isAllowed('edit') && $this->mPageTitle->userCanEdit()) { |
144 | 150 | $form_is_disabled = false; |
145 | 151 | $form_text = ""; |
— | — | @@ -624,6 +630,14 @@ |
625 | 631 | $input_name = $query_template_name . '[num][' . $field_name . ']'; |
626 | 632 | else |
627 | 633 | $input_name = $query_template_name . '[' . $field_name . ']'; |
| 634 | + |
| 635 | + // if we're creating the page name from a formula based on |
| 636 | + // form values, see if the current input is part of that formula, |
| 637 | + // and if so, substitute in the actual value |
| 638 | + if ($form_submitted && $generated_page_name != '') { |
| 639 | + $true_input_name = str_replace('_', ' ', $input_name); |
| 640 | + $generated_page_name = str_ireplace("<$true_input_name>", $cur_value, $generated_page_name); |
| 641 | + } |
628 | 642 | // disable this field if either the whole form is disabled, or |
629 | 643 | // it's a restricted field and user doesn't have sysop privileges |
630 | 644 | $is_disabled = ($form_is_disabled || |
— | — | @@ -1275,7 +1289,7 @@ |
1276 | 1290 | if($wgRequest->getCheck('partial')) |
1277 | 1291 | $data_text = $existing_page_content; |
1278 | 1292 | $javascript_text .= $fields_javascript_text; |
1279 | | - return array($form_text, $javascript_text, $data_text, $form_page_title); |
| 1293 | + return array($form_text, $javascript_text, $data_text, $form_page_title, $generated_page_name); |
1280 | 1294 | } |
1281 | 1295 | |
1282 | 1296 | function formFieldHTML($form_field, $cur_value) { |