Index: trunk/extensions/SemanticForms/includes/SF_FormPrinter.php |
— | — | @@ -71,9 +71,15 @@ |
72 | 72 | $defaultProperties = call_user_func( array( $inputTypeClass, 'getDefaultPropTypes' ) ); |
73 | 73 | foreach ( $defaultProperties as $propertyTypeID => $additionalValues ) { |
74 | 74 | if ( $smwgContLang != null ) { |
75 | | - $datatypeLabels = $smwgContLang->getDatatypeLabels(); |
76 | | - $datatypeLabels['enumeration'] = 'enumeration'; |
77 | | - $propertyType = $datatypeLabels[$propertyTypeID]; |
| 75 | + if ( class_exists( 'SMWDIProperty' ) ) { |
| 76 | + // For SMW 1.6+, we use the ID of each |
| 77 | + // property, instead of its label. |
| 78 | + $propertyType = $propertyTypeID; |
| 79 | + } else { |
| 80 | + $datatypeLabels = $smwgContLang->getDatatypeLabels(); |
| 81 | + $datatypeLabels['enumeration'] = 'enumeration'; |
| 82 | + $propertyType = $datatypeLabels[$propertyTypeID]; |
| 83 | + } |
78 | 84 | $this->setSemanticTypeHook( $propertyType, false, array( $inputTypeClass, 'getHTML' ), $additionalValues ); |
79 | 85 | } |
80 | 86 | $this->mDefaultInputForPropType[$propertyTypeID] = $inputTypeName; |
— | — | @@ -81,9 +87,15 @@ |
82 | 88 | $defaultPropertyLists = call_user_func( array( $inputTypeClass, 'getDefaultPropTypeLists' ) ); |
83 | 89 | foreach ( $defaultPropertyLists as $propertyTypeID => $additionalValues ) { |
84 | 90 | if ( $smwgContLang != null ) { |
85 | | - $datatypeLabels = $smwgContLang->getDatatypeLabels(); |
86 | | - $datatypeLabels['enumeration'] = 'enumeration'; |
87 | | - $propertyType = $datatypeLabels[$propertyTypeID]; |
| 91 | + if ( class_exists( 'SMWDIProperty' ) ) { |
| 92 | + // For SMW 1.6+, we use the ID of each |
| 93 | + // property, instead of its label. |
| 94 | + $propertyType = $propertyTypeID; |
| 95 | + } else { |
| 96 | + $datatypeLabels = $smwgContLang->getDatatypeLabels(); |
| 97 | + $datatypeLabels['enumeration'] = 'enumeration'; |
| 98 | + $propertyType = $datatypeLabels[$propertyTypeID]; |
| 99 | + } |
88 | 100 | $this->setSemanticTypeHook( $propertyType, true, array( $inputTypeClass, 'getHTML' ), $additionalValues ); |
89 | 101 | } |
90 | 102 | $this->mDefaultInputForPropTypeList[$propertyTypeID] = $inputTypeName; |
— | — | @@ -159,9 +171,10 @@ |
160 | 172 | |
161 | 173 | /** |
162 | 174 | * Show the set of previous deletions for the page being added. |
163 | | - * This function is copied almost exactly from EditPage::showDeletionLog() - |
164 | | - * unfortunately, neither that function nor Article::showDeletionLog() can |
165 | | - * be called from here, since they're both protected |
| 175 | + * This function is copied almost exactly from |
| 176 | + * EditPage::showDeletionLog() - unfortunately, neither that function |
| 177 | + * nor Article::showDeletionLog() can be called from here, since |
| 178 | + * they're both protected. |
166 | 179 | */ |
167 | 180 | function showDeletionLog( $out ) { |
168 | 181 | // if MW doesn't have LogEventsList defined, exit immediately |
— | — | @@ -202,8 +215,8 @@ |
203 | 216 | } |
204 | 217 | |
205 | 218 | /** |
206 | | - * Like PHP's str_replace(), but only replaces the first found instance - |
207 | | - * unfortunately, str_replace() doesn't allow for that. |
| 219 | + * Like PHP's str_replace(), but only replaces the first found |
| 220 | + * instance - unfortunately, str_replace() doesn't allow for that. |
208 | 221 | * This code is basically copied directly from |
209 | 222 | * http://www.php.net/manual/en/function.str-replace.php#86177 |
210 | 223 | * - this might make sense in the SFUtils class, if it's useful in |
— | — | @@ -253,8 +266,8 @@ |
254 | 267 | * This function is the real heart of the entire Semantic Forms |
255 | 268 | * extension. It handles two main actions: (1) displaying a form on the |
256 | 269 | * screen, given a form definition and possibly page contents (if an |
257 | | - * existing page is being edited); and (2) creating actual page contents, |
258 | | - * if the form was already submitted by the user. |
| 270 | + * existing page is being edited); and (2) creating actual page |
| 271 | + * contents, if the form was already submitted by the user. |
259 | 272 | * |
260 | 273 | * It also does some related tasks, like figuring out the page name (if |
261 | 274 | * only a page formula exists). |
— | — | @@ -285,10 +298,10 @@ |
286 | 299 | // If we have existing content and we're not in an active replacement |
287 | 300 | // situation, preserve the original content. We do this because we want |
288 | 301 | // to pass the original content on IF this is a partial form. |
289 | | - // TODO: A better approach here would be to pass the revision id of the |
| 302 | + // TODO: A better approach here would be to pass the revision ID of the |
290 | 303 | // existing page content through the replace value, which would |
291 | 304 | // minimize the html traffic and would allow us to do a concurrent |
292 | | - // update check. For now, we pass it through the hidden text field... |
| 305 | + // update check. For now, we pass it through a hidden text field. |
293 | 306 | |
294 | 307 | if ( ! $wgRequest->getCheck( 'partial' ) ) { |
295 | 308 | $original_page_content = $existing_page_content; |
— | — | @@ -300,14 +313,14 @@ |
301 | 314 | } |
302 | 315 | } |
303 | 316 | |
304 | | - // Disable all form elements if user doesn't have edit permission - |
305 | | - // two different checks are needed, because editing permissions can be |
306 | | - // set in different ways. |
307 | | - // HACK - sometimes we don't know the page name in advance, but we still |
308 | | - // need to set a title here for testing permissions |
| 317 | + // Disable all form elements if user doesn't have edit |
| 318 | + // permission - two different checks are needed, because |
| 319 | + // editing permissions can be set in different ways. |
| 320 | + // HACK - sometimes we don't know the page name in advance, but |
| 321 | + // we still need to set a title here for testing permissions. |
309 | 322 | if ( $embedded ) { |
310 | | - // if this is an embedded form (probably a 'RunQuery'), just use the |
311 | | - // name of the actual page we're on |
| 323 | + // If this is an embedded form (probably a 'RunQuery'), |
| 324 | + // just use the name of the actual page we're on. |
312 | 325 | global $wgTitle; |
313 | 326 | $this->mPageTitle = $wgTitle; |
314 | 327 | } elseif ( $page_name == '' ) { |
— | — | @@ -334,8 +347,8 @@ |
335 | 348 | $form_text = ""; |
336 | 349 | if ( $userCanEditPage || $is_query ) { |
337 | 350 | $form_is_disabled = false; |
338 | | - // Show "Your IP address will be recorded" warning if user is |
339 | | - // anonymous, and it's not a query - |
| 351 | + // Show "Your IP address will be recorded" warning if |
| 352 | + // user is anonymous, and it's not a query - |
340 | 353 | // wiki-text for bolding has to be replaced with HTML. |
341 | 354 | if ( $wgUser->isAnon() && ! $is_query ) { |
342 | 355 | $anon_edit_warning = preg_replace( "/'''(.*)'''/", "<strong>$1</strong>", wfMsg( 'anoneditwarning' ) ); |
— | — | @@ -410,9 +423,10 @@ |
411 | 424 | } // end while |
412 | 425 | $form_def_sections[] = trim( substr( $form_def, $section_start ) ); |
413 | 426 | |
414 | | - // Cycle through form definition file (and possibly an existing article |
415 | | - // as well), finding template and field declarations and replacing them |
416 | | - // with form elements, either blank or pre-populated, as appropriate. |
| 427 | + // Cycle through the form definition file, and possibly an |
| 428 | + // existing article as well, finding template and field |
| 429 | + // declarations and replacing them with form elements, either |
| 430 | + // blank or pre-populated, as appropriate. |
417 | 431 | $all_fields = array(); |
418 | 432 | $data_text = ""; |
419 | 433 | $template_name = ""; |
— | — | @@ -424,8 +438,8 @@ |
425 | 439 | $tif = new SFTemplateInForm(); |
426 | 440 | $start_position = 0; |
427 | 441 | $template_text = ""; |
428 | | - // the append is there to ensure that the original array doesn't get |
429 | | - // modified; is it necessary? |
| 442 | + // the append is there to ensure that the original |
| 443 | + // array doesn't get modified; is it necessary? |
430 | 444 | $section = " " . $form_def_sections[$section_num]; |
431 | 445 | |
432 | 446 | while ( $brackets_loc = strpos( $section, '{{{', $start_position ) ) { |
— | — | @@ -1042,7 +1056,7 @@ |
1043 | 1057 | ( $cur_value == '' || $cur_value == 'now' ) ) { |
1044 | 1058 | if ( $input_type == 'date' || $input_type == 'datetime' || |
1045 | 1059 | $input_type == 'year' || |
1046 | | - ( $input_type == '' && $form_field->template_field->field_type_id == '_dat' ) ) { |
| 1060 | + ( $input_type == '' && $form_field->template_field->property_type == '_dat' ) ) { |
1047 | 1061 | // Get current time, for the time zone specified in the wiki. |
1048 | 1062 | global $wgLocaltimezone; |
1049 | 1063 | if ( isset( $wgLocaltimezone ) ) { |
— | — | @@ -1287,11 +1301,14 @@ |
1288 | 1302 | $this->multipleTemplateInstanceTableHTML( $section ) |
1289 | 1303 | ) . "\n"; |
1290 | 1304 | |
1291 | | - // this will cause the section to be re-parsed on the next go |
| 1305 | + // This will cause the section to be |
| 1306 | + // re-parsed on the next go. |
1292 | 1307 | $section_num--; |
1293 | 1308 | } else { |
1294 | | - // This is the last instance of this template - print all the |
1295 | | - // sections necessary for adding additional instances. |
| 1309 | + // This is the last instance of this |
| 1310 | + // template - print all the sections |
| 1311 | + // necessary for adding additional |
| 1312 | + // instances. |
1296 | 1313 | $form_text .= "\t\t" . Xml::tags( 'div', |
1297 | 1314 | array( |
1298 | 1315 | 'class' => "multipleTemplateStarter", |
— | — | @@ -1468,17 +1485,17 @@ |
1469 | 1486 | $funcArgs[] = $other_args; |
1470 | 1487 | $text = call_user_func_array( $hook_values[0], $funcArgs ); |
1471 | 1488 | } else { // input type not defined in form |
1472 | | - $field_type = $template_field->field_type; |
| 1489 | + $property_type = $template_field->property_type; |
1473 | 1490 | $is_list = ( $form_field->is_list || $template_field->is_list ); |
1474 | | - if ( $field_type != '' && |
1475 | | - array_key_exists( $field_type, $this->mSemanticTypeHooks ) && |
1476 | | - isset( $this->mSemanticTypeHooks[$field_type][$is_list] ) ) { |
| 1491 | + if ( $property_type != '' && |
| 1492 | + array_key_exists( $property_type, $this->mSemanticTypeHooks ) && |
| 1493 | + isset( $this->mSemanticTypeHooks[$property_type][$is_list] ) ) { |
1477 | 1494 | $funcArgs = array(); |
1478 | 1495 | $funcArgs[] = $cur_value; |
1479 | 1496 | $funcArgs[] = $form_field->input_name; |
1480 | 1497 | $funcArgs[] = $form_field->is_mandatory; |
1481 | 1498 | $funcArgs[] = $form_field->is_disabled; |
1482 | | - $hook_values = $this->mSemanticTypeHooks[$field_type][$is_list]; |
| 1499 | + $hook_values = $this->mSemanticTypeHooks[$property_type][$is_list]; |
1483 | 1500 | $other_args = $form_field->getArgumentsForInputCall( $hook_values[1] ); |
1484 | 1501 | $funcArgs[] = $other_args; |
1485 | 1502 | $text = call_user_func_array( $hook_values[0], $funcArgs ); |