Index: trunk/extensions/SemanticForms/INSTALL |
— | — | @@ -1,4 +1,4 @@ |
2 | | -[[Semantic Forms 0.3.5]] |
| 2 | +[[Semantic Forms 0.3.6]] |
3 | 3 | |
4 | 4 | Contents: |
5 | 5 | * Disclaimer |
Index: trunk/extensions/SemanticForms/includes/SF_TemplateField.inc |
— | — | @@ -37,24 +37,23 @@ |
38 | 38 | 'value_string', |
39 | 39 | $conditions, $fname); |
40 | 40 | if ($db->numRows( $res ) > 0) { |
41 | | - if ($row = $db->fetchObject($res)) { |
42 | | - $f->attribute_type = $row->value_string; |
43 | | - // set possible values if it's an enumeration |
44 | | - if ($f->attribute_type == $smwgContLang->smwDatatypeLabels['smw_enum']) { |
45 | | - $conditions = "subject_namespace = " . SMW_NS_ATTRIBUTE . |
46 | | - " AND subject_title = '$semantic_field_db_str' AND property_id = " . |
47 | | - SMW_SP_POSSIBLE_VALUE; |
48 | | - $res2 = $db->select( $db->tableName('smw_specialprops'), |
49 | | - 'value_string', |
50 | | - $conditions, $fname); |
51 | | - if ($db->numRows( $res2 ) > 0) { |
52 | | - while ($row = $db->fetchObject($res2)) { |
53 | | - $f->possible_values[] = $row->value_string; |
54 | | - } |
55 | | - } |
56 | | - $db->freeResult($res2); |
57 | | - } |
58 | | - } |
| 41 | + if ($row = $db->fetchObject($res)) { |
| 42 | + $f->attribute_type = $row->value_string; |
| 43 | + // set possible values if it's an enumeration |
| 44 | + if ($f->attribute_type == $smwgContLang->smwDatatypeLabels['smw_enum']) { |
| 45 | + $conditions = "subject_namespace = " . SMW_NS_ATTRIBUTE . |
| 46 | + " AND subject_title = '$semantic_field_db_str' AND property_id = " . |
| 47 | + SMW_SP_POSSIBLE_VALUE; |
| 48 | + $res2 = $db->select( $db->tableName('smw_specialprops'), |
| 49 | + 'value_string', $conditions, $fname); |
| 50 | + if ($db->numRows( $res2 ) > 0) { |
| 51 | + while ($row = $db->fetchObject($res2)) { |
| 52 | + $f->possible_values[] = $row->value_string; |
| 53 | + } |
| 54 | + } |
| 55 | + $db->freeResult($res2); |
| 56 | + } |
| 57 | + } |
59 | 58 | } |
60 | 59 | $db->freeResult($res); |
61 | 60 | } |
Index: trunk/extensions/SemanticForms/includes/SF_FormClasses.inc |
— | — | @@ -175,7 +175,8 @@ |
176 | 176 | if ($template_field->attribute_type == "") |
177 | 177 | $text .= '<p>' . wfMsg('sf_createform_fieldattrunknowntype', $attr_link_text, sffLinkText(SMW_NS_TYPE, 'String')) . "</p>\n"; |
178 | 178 | else |
179 | | - $text .= '<p>' . wfMsg('sf_createform_fieldattr', $attr_link_text, sffLinkText(SMW_NS_TYPE, $template_field->attribute_type)) . "</p>\n"; |
| 179 | + $text .= '<p>' . wfMsg('sf_createform_fieldattr', $attr_link_text, |
| 180 | + sffLinkText(SMW_NS_TYPE, $template_field->attribute_type)) . "</p>\n"; |
180 | 181 | |
181 | 182 | } elseif ($template_field->attr_or_rel == "relation") { |
182 | 183 | $rel_link_text = sffLinkText(SMW_NS_RELATION, $template_field->semantic_field); |
— | — | @@ -200,19 +201,17 @@ |
201 | 202 | } |
202 | 203 | |
203 | 204 | function createMarkup() { |
204 | | - if (! $this->is_hidden) { |
205 | | - $text = " <p>"; |
206 | | - if ($this->template_field->label != "") |
207 | | - $text .= "<strong>" . $this->template_field->label . ":</strong> "; |
208 | | - $text .= "{{{field|" . $this->template_field->field_name; |
209 | | - if ($this->is_mandatory) { |
210 | | - $text .= "|mandatory"; |
211 | | - } |
212 | | - $text .= "}}}</p>\n"; |
213 | | - return $text; |
214 | | - } else { |
215 | | - return ""; |
| 205 | + $text = " <p>"; |
| 206 | + if ($this->template_field->label != "") |
| 207 | + $text .= "<strong>" . $this->template_field->label . ":</strong> "; |
| 208 | + $text .= "{{{field|" . $this->template_field->field_name; |
| 209 | + if ($this->is_mandatory) { |
| 210 | + $text .= "|mandatory"; |
| 211 | + } elseif ($this->is_hidden) { |
| 212 | + $text .= "|hidden"; |
216 | 213 | } |
| 214 | + $text .= "}}}</p>\n"; |
| 215 | + return $text; |
217 | 216 | } |
218 | 217 | } |
219 | 218 | |
Index: trunk/extensions/SemanticForms/includes/SF_FormPrinter.inc |
— | — | @@ -64,9 +64,9 @@ |
65 | 65 | $passed_validation = true; |
66 | 66 | $data_text = ""; |
67 | 67 | $template_name = ""; |
| 68 | + $instance_was_deleted = false; |
68 | 69 | $allow_multiple = false; |
69 | 70 | $strict_parsing = false; |
70 | | - $instance_was_deleted = false; |
71 | 71 | for ($section_num = 0; $section_num < count($form_def_sections); $section_num++) { |
72 | 72 | $tif = new SFTemplateInForm(); |
73 | 73 | $start_position = 0; |
— | — | @@ -212,6 +212,7 @@ |
213 | 213 | $field_name = trim($tag_components[1]); |
214 | 214 | // cycle through the other components |
215 | 215 | $is_mandatory = false; |
| 216 | + $is_hidden = false; |
216 | 217 | $input_type = null; |
217 | 218 | $no_autocomplete = false; |
218 | 219 | $autocomplete_category = null; |
— | — | @@ -224,6 +225,8 @@ |
225 | 226 | $component = trim($tag_components[$i]); |
226 | 227 | if ($component == 'mandatory') { |
227 | 228 | $is_mandatory = true; |
| 229 | + } elseif ($component == 'hidden') { |
| 230 | + $is_hidden = true; |
228 | 231 | } else { |
229 | 232 | $sub_components = explode('=', $component); |
230 | 233 | if (count($sub_components) == 2) { |
— | — | @@ -278,9 +281,8 @@ |
279 | 282 | } |
280 | 283 | // the template display name might be different from what's in |
281 | 284 | // the query string, if a previous instance was deleted |
282 | | - if ($instance_was_deleted) { |
283 | | - $instance_num--; |
284 | | - $template_display_name = $query_template_name . '_' . $instance_num; |
| 285 | + if ($allow_multiple && $instance_was_deleted) { |
| 286 | + $template_display_name = $query_template_name . '_' . ($instance_num - 1); |
285 | 287 | } else { |
286 | 288 | $template_display_name = $full_template_name; |
287 | 289 | } |
— | — | @@ -352,7 +354,9 @@ |
353 | 355 | } else { // value is not an array |
354 | 356 | $cur_value_in_template = $cur_value; |
355 | 357 | } |
356 | | - $new_text = SFFormPrinter::formTemplateFieldHTML($template_display_name, $field_name, $instance_num, $cur_value, $is_mandatory, $input_type, $size, $num_rows, $num_cols, $no_autocomplete, $autocomplete_category, $error_str, $all_fields, $strict_parsing); |
| 358 | + $new_text = SFFormPrinter::formTemplateFieldHTML($template_display_name, $field_name, $instance_num, |
| 359 | + $cur_value, $is_mandatory, $is_hidden, $input_type, $size, $num_rows, $num_cols, $no_autocomplete, |
| 360 | + $autocomplete_category, $error_str, $all_fields, $strict_parsing); |
357 | 361 | if ($new_text) { |
358 | 362 | if (is_numeric($field_name)) { |
359 | 363 | // if the value is null, don't include it at all - |
— | — | @@ -452,7 +456,7 @@ |
453 | 457 | return array($form_text, $title, $data_text, $passed_validation); |
454 | 458 | } |
455 | 459 | |
456 | | - function formTemplateFieldHTML($template_name, $field_name, $instance_num, $cur_value, $is_mandatory, $input_type, $size, $num_rows, $num_cols, $no_autocomplete, $autocomplete_category, $error_str, $all_fields, $strict_parsing) { |
| 460 | + function formTemplateFieldHTML($template_name, $field_name, $instance_num, $cur_value, $is_mandatory, $is_hidden, $input_type, $size, $num_rows, $num_cols, $no_autocomplete, $autocomplete_category, $error_str, $all_fields, $strict_parsing) { |
457 | 461 | |
458 | 462 | // see if this field matches one of the fields defined for this template - |
459 | 463 | // if it is, use all available information about that field; if it's not, |
— | — | @@ -460,22 +464,24 @@ |
461 | 465 | // has 'strict' setting in the form definition |
462 | 466 | foreach ($all_fields as $cur_field) { |
463 | 467 | if ($field_name == $cur_field->field_name) { |
464 | | - $text = SFFormPrinter::formFieldHTML($template_name, $field_name, $cur_field, $instance_num, $cur_value, $is_mandatory, $input_type, $size, $num_rows, $num_cols, $no_autocomplete, $autocomplete_category, $error_str); |
| 468 | + $text = SFFormPrinter::formFieldHTML($template_name, $field_name, $cur_field, $instance_num, $cur_value, $is_mandatory, $is_hidden, $input_type, $size, $num_rows, $num_cols, $no_autocomplete, $autocomplete_category, $error_str); |
465 | 469 | return $text; |
466 | 470 | } |
467 | 471 | } |
468 | 472 | // if we're still here, field wasn't found |
469 | 473 | if (! $strict_parsing) { |
470 | 474 | $dummy_field = new SFTemplateField(); |
471 | | - $text = SFFormPrinter::formFieldHTML($template_name, $field_name, $dummy_field, $instance_num, $cur_value, $is_mandatory, $input_type, $size, $num_rows, $num_cols, $no_autocomplete, $autocomplete_category, $error_str); |
| 475 | + $text = SFFormPrinter::formFieldHTML($template_name, $field_name, $dummy_field, $instance_num, $cur_value, $is_mandatory, $is_hidden, $input_type, $size, $num_rows, $num_cols, $no_autocomplete, $autocomplete_category, $error_str); |
472 | 476 | return $text; |
473 | 477 | } |
474 | 478 | return null; |
475 | 479 | } |
476 | 480 | |
477 | | - function formFieldHTML($template_name, $field_name, $template_field, $instance_num, $cur_value, $is_mandatory, $input_type, $size, $num_rows, $num_cols, $no_autocomplete, $autocomplete_category, $error_str) { |
| 481 | + function formFieldHTML($template_name, $field_name, $template_field, $instance_num, $cur_value, $is_mandatory, $is_hidden, $input_type, $size, $num_rows, $num_cols, $no_autocomplete, $autocomplete_category, $error_str) { |
478 | 482 | global $smwgContLang; |
479 | | - if ($autocomplete_category != null) { |
| 483 | + if ($is_hidden) { |
| 484 | + $text = SFFormPrinter::hiddenFieldHTML($template_name, $field_name, $cur_value); |
| 485 | + } elseif ($autocomplete_category != null) { |
480 | 486 | if ($size == null) $size = 35; |
481 | 487 | $text = SFFormPrinter::textEntryWithAutocompleteHTML($size, $template_name, $field_name, $instance_num, $autocomplete_category, false, $cur_value, $error_str); |
482 | 488 | } elseif ($input_type == 'text') { |
— | — | @@ -524,7 +530,6 @@ |
525 | 531 | global $sfgMaxAutocompleteValues; |
526 | 532 | $fname = 'SFFormPrinter::createAutocompleteValuesString'; |
527 | 533 | $db = & wfGetDB( DB_SLAVE ); |
528 | | - #$limit_str = ($sfgMaxAutocompleteValues) ? "LIMIT $sfgMaxAutocompleteValues" : ""; |
529 | 534 | $sql_options = array(); |
530 | 535 | $sql_options['LIMIT'] = $sfgMaxAutocompleteValues; |
531 | 536 | // the query depends on whether this field is a relation or a category |
— | — | @@ -748,6 +753,18 @@ |
749 | 754 | return $text; |
750 | 755 | } |
751 | 756 | |
| 757 | + function hiddenFieldHTML($template_name, $field_name, $cur_value) { |
| 758 | + if ($template_name == null || $template_name == '') |
| 759 | + $input_name = $field_name; |
| 760 | + else |
| 761 | + $input_name = $template_name . '[' . $field_name . ']'; |
| 762 | + $text =<<<END |
| 763 | + <input type="hidden" name="$input_name" value="$cur_value" /> |
| 764 | + |
| 765 | +END; |
| 766 | + return $text; |
| 767 | + } |
| 768 | + |
752 | 769 | function redirectText($page_name, $data_text) { |
753 | 770 | global $wgUser, $wgRequest; |
754 | 771 | |
Index: trunk/extensions/SemanticForms/includes/SF_GlobalFunctions.php |
— | — | @@ -3,7 +3,7 @@ |
4 | 4 | * Global functions and constants for Semantic Forms. |
5 | 5 | */ |
6 | 6 | |
7 | | -define('SF_VERSION','0.3.5'); |
| 7 | +define('SF_VERSION','0.3.6'); |
8 | 8 | |
9 | 9 | $wgExtensionFunctions[] = 'sfgSetupExtension'; |
10 | 10 | |
— | — | @@ -37,7 +37,8 @@ |
38 | 38 | /**********************************************/ |
39 | 39 | /***** credits (see "Special:Version") *****/ |
40 | 40 | /**********************************************/ |
41 | | - $wgExtensionCredits['parserhook'][]= array('name'=>'Semantic Forms', 'version'=>SF_VERSION, 'author'=>'Yaron Koren', 'url'=>'http://discoursedb.org/SemanticForms/', 'description' => 'Forms for adding and editing semantic data'); |
| 41 | + $wgExtensionCredits['parserhook'][]= array('name'=>'Semantic Forms', 'version'=>SF_VERSION, 'author'=>'Yaron Koren', |
| 42 | + 'url'=>'http://discoursedb.org/SemanticForms/', 'description' => 'Forms for adding and editing semantic data'); |
42 | 43 | |
43 | 44 | return true; |
44 | 45 | } |
— | — | @@ -180,7 +181,9 @@ |
181 | 182 | */ |
182 | 183 | function sffGetDefaultForm($db, $page_title, $page_namespace) { |
183 | 184 | $default_form_relation = str_replace(' ', '_', wfMsgForContent('sf_form_relation')); |
184 | | - $sql = "SELECT DISTINCT object_title FROM {$db->tableName('smw_relations')} WHERE subject_title = '$page_title' AND subject_namespace = '" . $page_namespace . "' AND relation_title = '$default_form_relation' AND object_namespace = " . SF_NS_FORM; |
| 185 | + $sql = "SELECT DISTINCT object_title FROM {$db->tableName('smw_relations')} " . |
| 186 | + "WHERE subject_title = '$page_title' AND subject_namespace = '" . $page_namespace . |
| 187 | + "' AND relation_title = '$default_form_relation' AND object_namespace = " . SF_NS_FORM; |
185 | 188 | $res = $db->query( $sql ); |
186 | 189 | if ($db->numRows( $res ) > 0) { |
187 | 190 | $row = $db->fetchRow($res); |