Index: trunk/extensions/SemanticForms/specials/SF_CreateProperty.php |
— | — | @@ -24,7 +24,7 @@ |
25 | 25 | } |
26 | 26 | } |
27 | 27 | |
28 | | -function createPropertyText($property_type, $allowed_values_str) { |
| 28 | +function createPropertyText($property_type, $default_form, $allowed_values_str) { |
29 | 29 | global $smwgContLang; |
30 | 30 | |
31 | 31 | wfLoadExtensionMessages('SemanticForms'); |
— | — | @@ -38,6 +38,12 @@ |
39 | 39 | $type_tag = "[[{$spec_props[SMW_SP_HAS_TYPE]}::$property_type]]"; |
40 | 40 | } |
41 | 41 | $text = wfMsgForContent('sf_property_isproperty', $type_tag); |
| 42 | + if ($default_form != '') { |
| 43 | + global $sfgContLang; |
| 44 | + $sf_prop_labels = $sfgContLang->getPropertyLabels(); |
| 45 | + $default_form_tag = "[[{$sf_prop_labels[SF_SP_HAS_DEFAULT_FORM]}::$default_form]]"; |
| 46 | + $text .= ' ' . wfMsgForContent('sf_property_linkstoform', $default_form_tag); |
| 47 | + } |
42 | 48 | if ($allowed_values_str != '') { |
43 | 49 | $text .= "\n\n" . wfMsgForContent('sf_property_allowedvals'); |
44 | 50 | // replace the comma substitution character that has no chance of |
— | — | @@ -69,6 +75,7 @@ |
70 | 76 | # cycle through the query values, setting the appropriate local variables |
71 | 77 | $property_name = $wgRequest->getVal('property_name'); |
72 | 78 | $property_type = $wgRequest->getVal('property_type'); |
| 79 | + $default_form = $wgRequest->getVal('default_form'); |
73 | 80 | $allowed_values = $wgRequest->getVal('values'); |
74 | 81 | |
75 | 82 | $save_button_text = wfMsg('savearticle'); |
— | — | @@ -85,7 +92,7 @@ |
86 | 93 | # redirect to wiki interface |
87 | 94 | $wgOut->setArticleBodyOnly(true); |
88 | 95 | $title = Title::makeTitleSafe(SMW_NS_PROPERTY, $property_name); |
89 | | - $full_text = createPropertyText($property_type, $allowed_values); |
| 96 | + $full_text = createPropertyText($property_type, $default_form, $allowed_values); |
90 | 97 | // HTML-encode |
91 | 98 | $full_text = str_replace('"', '"', $full_text); |
92 | 99 | $text = SFUtils::printRedirectForm($title, $full_text, "", $save_page, $preview_page, false, false, false, null, null); |
— | — | @@ -97,8 +104,13 @@ |
98 | 105 | $datatype_labels = $smwgContLang->getDatatypeLabels(); |
99 | 106 | |
100 | 107 | $javascript_text =<<<END |
101 | | -function toggleAllowedValues() { |
102 | | - var values_div = document.getElementById("allowed_values"); |
| 108 | +function toggleDefaultForm(property_type) { |
| 109 | + var default_form_div = document.getElementById("default_form_div"); |
| 110 | + if (property_type == '{$datatype_labels['_wpg']}') { |
| 111 | + default_form_div.style.display = ""; |
| 112 | + } else { |
| 113 | + default_form_div.style.display = "none"; |
| 114 | + } |
103 | 115 | } |
104 | 116 | |
105 | 117 | END; |
— | — | @@ -115,15 +127,20 @@ |
116 | 128 | <p>$name_label <input size="25" name="property_name" value=""> |
117 | 129 | <span style="color: red;">$property_name_error_str</span> |
118 | 130 | $type_label |
119 | | - <select id="property_dropdown" name="property_type" onChange="toggleAllowedValues();"> |
| 131 | + <select id="property_dropdown" name="property_type" onChange="toggleDefaultForm(this.value);"> |
120 | 132 | END; |
121 | 133 | foreach ($datatype_labels as $label) { |
122 | 134 | $text .= " <option>$label</option>\n"; |
123 | 135 | } |
124 | 136 | |
| 137 | + $default_form_input = wfMsg('sf_createproperty_linktoform'); |
125 | 138 | $values_input = wfMsg('sf_createproperty_allowedvalsinput'); |
126 | 139 | $text .=<<<END |
127 | 140 | </select> |
| 141 | + <div id="default_form_div" style="padding: 5px 0 5px 0; margin: 7px 0 7px 0;"> |
| 142 | + <p>$default_form_input |
| 143 | + <input size="20" name="default_form" value=""></p> |
| 144 | + </div> |
128 | 145 | <div id="allowed_values" style="margin-bottom: 15px;"> |
129 | 146 | <p>$values_input</p> |
130 | 147 | <p><input size="80" name="values" value=""></p> |