Index: trunk/extensions/SemanticForms/specials/SF_CreateProperty.php |
— | — | @@ -23,26 +23,15 @@ |
24 | 24 | function createPropertyText($property_type, $allowed_values_str) { |
25 | 25 | global $smwgContLang; |
26 | 26 | |
27 | | - $smw_version = SMW_VERSION; |
28 | | - if ($smw_version{0} == '0') { |
29 | | - $namespace_labels = $smwgContLang->getNamespaceArray(); |
30 | | - } else { |
31 | | - $namespace_labels = $smwgContLang->getNamespaces(); |
32 | | - } |
| 27 | + $namespace_labels = $smwgContLang->getNamespaces(); |
33 | 28 | if ($property_type == $namespace_labels[SMW_NS_RELATION]) { |
34 | 29 | $text = wfMsgForContent('sf_property_isrelation'); |
35 | 30 | } else { |
36 | 31 | global $smwgContLang; |
37 | 32 | $specprops = $smwgContLang->getSpecialPropertiesArray(); |
38 | | - if ($smw_version{0} == '0') { |
39 | | - $type_tag = "[[" . $specprops[SMW_SP_HAS_TYPE] . "::" . |
40 | | - $namespace_labels[SMW_NS_TYPE] . ":$property_type|$property_type]]"; |
41 | | - $text = wfMsgForContent('sf_property_isattribute', $type_tag); |
42 | | - } else { |
43 | | - $type_tag = "[[" . $specprops[SMW_SP_HAS_TYPE] . |
44 | | - "::$property_type|$property_type]]"; |
45 | | - $text = wfMsgForContent('sf_property_isproperty', $type_tag); |
46 | | - } |
| 33 | + $type_tag = "[[" . $specprops[SMW_SP_HAS_TYPE] . |
| 34 | + "::$property_type|$property_type]]"; |
| 35 | + $text = wfMsgForContent('sf_property_isproperty', $type_tag); |
47 | 36 | if ($allowed_values_str != '') { |
48 | 37 | $text .= "\n\n" . wfMsgForContent('sf_property_allowedvals'); |
49 | 38 | // replace the comma substitution character that has no chance of |
— | — | @@ -53,7 +42,7 @@ |
54 | 43 | foreach ($allowed_values_array as $i => $value) { |
55 | 44 | // replace beep with comma, trim |
56 | 45 | $value = str_replace("\a", $sfgListSeparator, trim($value)); |
57 | | - $text .= "\n* [[" . $specprops[SMW_SP_POSSIBLE_VALUE] . ":=$value]]"; |
| 46 | + $text .= "\n* [[" . $specprops[SMW_SP_POSSIBLE_VALUE] . "::$value]]"; |
58 | 47 | } |
59 | 48 | } |
60 | 49 | } |
— | — | @@ -81,13 +70,7 @@ |
82 | 71 | $property_name_error_str = wfMsg('sf_blank_error'); |
83 | 72 | } else { |
84 | 73 | # redirect to wiki interface |
85 | | - $smw_version = SMW_VERSION; |
86 | | - if ($smw_version{0} == '0') { |
87 | | - $namespace_labels = $smwgContLang->getNamespaceArray(); |
88 | | - $namespace = ($property_type == $namespace_labels[SMW_NS_RELATION]) ? SMW_NS_RELATION : SMW_NS_ATTRIBUTE; |
89 | | - } else { |
90 | | - $namespace = SMW_NS_PROPERTY; |
91 | | - } |
| 74 | + $namespace = SMW_NS_PROPERTY; |
92 | 75 | $title = Title::newFromText($property_name, $namespace); |
93 | 76 | $full_text = createPropertyText($property_type, $allowed_values); |
94 | 77 | // HTML-encode |
— | — | @@ -98,50 +81,16 @@ |
99 | 82 | } |
100 | 83 | } |
101 | 84 | |
102 | | - $smw_version = SMW_VERSION; |
103 | | - if ($smw_version{0} == '0') { |
104 | | - $all_properties = getSemanticProperties_0_7(); |
105 | | - $namespace_labels = $smwgContLang->getNamespaceArray(); |
106 | | - $datatype_labels = array( |
107 | | - $namespace_labels[SMW_NS_RELATION], |
108 | | - $smwgContLang->getDatatypeLabel('smw_string'), |
109 | | - $smwgContLang->getDatatypeLabel('smw_int'), |
110 | | - $smwgContLang->getDatatypeLabel('smw_float'), |
111 | | - $smwgContLang->getDatatypeLabel('smw_datetime'), |
112 | | - $smwgContLang->getDatatypeLabel('smw_bool'), |
113 | | - $smwgContLang->getDatatypeLabel('smw_enum'), |
114 | | - $smwgContLang->getDatatypeLabel('smw_url'), |
115 | | - $smwgContLang->getDatatypeLabel('smw_uri'), |
116 | | - $smwgContLang->getDatatypeLabel('smw_email'), |
117 | | - $smwgContLang->getDatatypeLabel('smw_temperature'), |
118 | | - $smwgContLang->getDatatypeLabel('smw_geocoordinate') |
119 | | - ); |
120 | | - $enum_str = $smwgContLang->getDatatypeLabel('smw_enum'); |
121 | | - } else { |
122 | | - $all_properties = getSemanticProperties_1_0(); |
123 | | - $datatype_labels = $smwgContLang->getDatatypeLabels(); |
124 | | - } |
| 85 | + $all_properties = getSemanticProperties(); |
| 86 | + $datatype_labels = $smwgContLang->getDatatypeLabels(); |
125 | 87 | |
126 | 88 | $javascript_text =<<<END |
127 | 89 | function toggleAllowedValues() { |
128 | 90 | var values_div = document.getElementById("allowed_values"); |
| 91 | +} |
129 | 92 | |
130 | 93 | END; |
131 | | - // add toggling of 'possible values' entry only if this is SMW 0.7 or |
132 | | - // lower; otherwise, it should always appear |
133 | | - if ($smw_version{0} == '0') { |
134 | | - $javascript_text .=<<<END |
135 | | - var prop_dropdown = document.getElementById("property_dropdown"); |
136 | | - if (prop_dropdown.value == "$enum_str") { |
137 | | - values_div.style.display = "block"; |
138 | | - } else { |
139 | | - values_div.style.display = "none"; |
140 | | - } |
141 | 94 | |
142 | | -END; |
143 | | - } |
144 | | - $javascript_text .= "}\n"; |
145 | | - |
146 | 95 | // set 'title' as hidden field, in case there's no URL niceness |
147 | 96 | global $wgContLang; |
148 | 97 | $mw_namespace_labels = $wgContLang->getNamespaces(); |
— | — | @@ -160,11 +109,10 @@ |
161 | 110 | $text .= " <option>$label</option>\n"; |
162 | 111 | } |
163 | 112 | |
164 | | - $values_input_display = ($smw_version{0} == '0') ? "display: none;" : ""; |
165 | 113 | $values_input = wfMsg('sf_createproperty_allowedvalsinput'); |
166 | 114 | $text .=<<<END |
167 | 115 | </select> |
168 | | - <div id="allowed_values" style="$values_input_display margin-bottom: 15px;"> |
| 116 | + <div id="allowed_values" style="margin-bottom: 15px;"> |
169 | 117 | <p>$values_input</p> |
170 | 118 | <p><input size="35" name="values" value=""></p> |
171 | 119 | </div> |
Index: trunk/extensions/SemanticForms/specials/SF_CreateTemplate.php |
— | — | @@ -20,7 +20,7 @@ |
21 | 21 | |
22 | 22 | SpecialPage::addPage( new SpecialPage('CreateTemplate','',true,'doSpecialCreateTemplate',false) ); |
23 | 23 | |
24 | | -// Custom sort function, used in both getSemanticProperties() functions |
| 24 | +// Custom sort function, used in getSemanticProperties() |
25 | 25 | function cmp($a, $b) { |
26 | 26 | if ($a == $b) { |
27 | 27 | return 0; |
— | — | @@ -31,37 +31,9 @@ |
32 | 32 | } |
33 | 33 | } |
34 | 34 | |
35 | | -function getSemanticProperties_0_7() { |
36 | | - $dbr = wfGetDB( DB_SLAVE ); |
| 35 | +function getSemanticProperties() { |
37 | 36 | $all_properties = array(); |
38 | 37 | |
39 | | - $res = $dbr->query("SELECT page_title FROM " . $dbr->tableName('page') . |
40 | | - " WHERE page_namespace = " . SMW_NS_ATTRIBUTE . |
41 | | - " AND page_is_redirect = 0"); |
42 | | - while ($row = $dbr->fetchRow($res)) { |
43 | | - $attribute_name = str_replace('_', ' ', $row[0]); |
44 | | - $all_properties[$attribute_name . ":="] = $attribute_name; |
45 | | - } |
46 | | - $dbr->freeResult($res); |
47 | | - |
48 | | - $res = $dbr->query("SELECT page_title FROM " . $dbr->tableName('page') . |
49 | | - " WHERE page_namespace = " . SMW_NS_RELATION . |
50 | | - " AND page_is_redirect = 0"); |
51 | | - while ($row = $dbr->fetchRow($res)) { |
52 | | - $relation_name = str_replace('_', ' ', $row[0]); |
53 | | - $all_properties[$relation_name . "::"] = $relation_name; |
54 | | - } |
55 | | - $dbr->freeResult($res); |
56 | | - |
57 | | - // sort properties list alphabetically - custom sort function is needed |
58 | | - // because the regular sort function destroys the "keys" of the array |
59 | | - uasort($all_properties, "cmp"); |
60 | | - return $all_properties; |
61 | | -} |
62 | | - |
63 | | -function getSemanticProperties_1_0() { |
64 | | - $all_properties = array(); |
65 | | - |
66 | 38 | // set limit on results - a temporary fix until SMW's getProperties() |
67 | 39 | // functions stop requiring a limit |
68 | 40 | global $smwgIP; |
— | — | @@ -119,12 +91,7 @@ |
120 | 92 | function doSpecialCreateTemplate() { |
121 | 93 | global $wgOut, $wgRequest, $wgUser, $sfgScriptPath, $wgContLang; |
122 | 94 | |
123 | | - $smw_version = SMW_VERSION; |
124 | | - if ($smw_version{0} == '0') { |
125 | | - $all_properties = getSemanticProperties_0_7(); |
126 | | - } else { |
127 | | - $all_properties = getSemanticProperties_1_0(); |
128 | | - } |
| 95 | + $all_properties = getSemanticProperties(); |
129 | 96 | |
130 | 97 | $template_name = $wgRequest->getVal('template_name'); |
131 | 98 | $template_name_error_str = ""; |