r47844 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r47843‎ | r47844 | r47845 >
Date:21:09, 26 February 2009
Author:yaron
Status:deferred
Tags:
Comment:
Added new "default form" input
Modified paths:
  • /trunk/extensions/SemanticForms/specials/SF_CreateProperty.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticForms/specials/SF_CreateProperty.php
@@ -24,7 +24,7 @@
2525 }
2626 }
2727
28 -function createPropertyText($property_type, $allowed_values_str) {
 28+function createPropertyText($property_type, $default_form, $allowed_values_str) {
2929 global $smwgContLang;
3030
3131 wfLoadExtensionMessages('SemanticForms');
@@ -38,6 +38,12 @@
3939 $type_tag = "[[{$spec_props[SMW_SP_HAS_TYPE]}::$property_type]]";
4040 }
4141 $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+ }
4248 if ($allowed_values_str != '') {
4349 $text .= "\n\n" . wfMsgForContent('sf_property_allowedvals');
4450 // replace the comma substitution character that has no chance of
@@ -69,6 +75,7 @@
7076 # cycle through the query values, setting the appropriate local variables
7177 $property_name = $wgRequest->getVal('property_name');
7278 $property_type = $wgRequest->getVal('property_type');
 79+ $default_form = $wgRequest->getVal('default_form');
7380 $allowed_values = $wgRequest->getVal('values');
7481
7582 $save_button_text = wfMsg('savearticle');
@@ -85,7 +92,7 @@
8693 # redirect to wiki interface
8794 $wgOut->setArticleBodyOnly(true);
8895 $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);
9097 // HTML-encode
9198 $full_text = str_replace('"', '"', $full_text);
9299 $text = SFUtils::printRedirectForm($title, $full_text, "", $save_page, $preview_page, false, false, false, null, null);
@@ -97,8 +104,13 @@
98105 $datatype_labels = $smwgContLang->getDatatypeLabels();
99106
100107 $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+ }
103115 }
104116
105117 END;
@@ -115,15 +127,20 @@
116128 <p>$name_label <input size="25" name="property_name" value="">
117129 <span style="color: red;">$property_name_error_str</span>
118130 $type_label
119 - <select id="property_dropdown" name="property_type" onChange="toggleAllowedValues();">
 131+ <select id="property_dropdown" name="property_type" onChange="toggleDefaultForm(this.value);">
120132 END;
121133 foreach ($datatype_labels as $label) {
122134 $text .= " <option>$label</option>\n";
123135 }
124136
 137+ $default_form_input = wfMsg('sf_createproperty_linktoform');
125138 $values_input = wfMsg('sf_createproperty_allowedvalsinput');
126139 $text .=<<<END
127140 </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>
128145 <div id="allowed_values" style="margin-bottom: 15px;">
129146 <p>$values_input</p>
130147 <p><input size="80" name="values" value=""></p>

Status & tagging log