Index: trunk/extensions/SemanticForms/includes/SF_Utils.inc |
— | — | @@ -74,21 +74,22 @@ |
75 | 75 | global $sfgScriptPath; |
76 | 76 | $text =<<<END |
77 | 77 | <p style="position: absolute; left: 45%; top: 45%;"><img src="$sfgScriptPath/skins/loading.gif" /></p> |
78 | | - <form id="editform" name="editform" method="post" action="$new_url"> |
79 | | - <input type="hidden" name="wpTextbox1" id="wpTextbox1" value="$page_contents" /> |
80 | | - <input type="hidden" name="wpSummary" value="$edit_summary" /> |
81 | | - <input type="hidden" name="wpStarttime" value="$start_time" /> |
82 | | - <input type="hidden" name="wpEdittime" value="$edit_time" /> |
83 | | - <input type="hidden" name="wpEditToken" value="$token" /> |
84 | | - <input type="hidden" name="$action" /> |
85 | 78 | |
86 | 79 | END; |
| 80 | + $form_body = ' ' . Xml::element('input', array('type' => 'hidden', 'name' => 'wpTextbox1', 'id' => 'wpTextbox1', 'value' => $page_contents), null) . "\n"; |
| 81 | + $form_body .= ' ' . Xml::element('input', array('type' => 'hidden', 'name' => 'wpSummary', 'value' => $edit_summary), null) . "\n"; |
| 82 | + $form_body .= ' ' . Xml::element('input', array('type' => 'hidden', 'name' => 'wpStarttime', 'value' => $start_time), null) . "\n"; |
| 83 | + $form_body .= ' ' . Xml::element('input', array('type' => 'hidden', 'name' => 'wpEdittime', 'value' => $edit_time), null) . "\n"; |
| 84 | + $form_body .= ' ' . Xml::element('input', array('type' => 'hidden', 'name' => 'wpEditToken', 'value' => $token), null) . "\n"; |
| 85 | + $form_body .= ' ' . Xml::element('input', array('type' => 'hidden', 'name' => $action), null) . "\n"; |
| 86 | + |
87 | 87 | if ($is_minor_edit) |
88 | | - $text .= ' <input type="hidden" name="wpMinoredit">' . "\n"; |
| 88 | + $form_body .= ' ' . Xml::element('input', array('type' => 'hidden', 'name' => 'wpMinorEdit'), null) . "\n"; |
89 | 89 | if ($watch_this) |
90 | | - $text .= ' <input type="hidden" name="wpWatchthis">' . "\n"; |
| 90 | + $form_body .= ' ' . Xml::element('input', array('type' => 'hidden', 'name' => 'wpWatchthis'), null) . "\n"; |
| 91 | + $text .= Xml::tags('form', array('id' => 'editform', 'name' => 'editform', 'method' => 'post', 'action' => $new_url), $form_body); |
| 92 | + |
91 | 93 | $text .=<<<END |
92 | | - </form> |
93 | 94 | <script type="text/javascript"> |
94 | 95 | window.onload = function() { |
95 | 96 | document.editform.submit(); |
— | — | @@ -178,28 +179,6 @@ |
179 | 180 | } |
180 | 181 | |
181 | 182 | /** |
182 | | - * A helper function to generate a property object given its name, |
183 | | - * since the class for properties changed from Title to |
184 | | - * SMWPropertyValue in SMW 1.4 |
185 | | - */ |
186 | | - static function createProperty($property_name) { |
187 | | - if (class_exists('SMWPropertyValue')) |
188 | | - return SMWPropertyValue::makeProperty($property_name); |
189 | | - else |
190 | | - return Title::makeTitleSafe(SMW_NS_PROPERTY, $property_name); |
191 | | - } |
192 | | - |
193 | | - /** |
194 | | - * Same idea as createProperty() |
195 | | - */ |
196 | | - static function getPropertyName($property) { |
197 | | - if ($property instanceof Title) |
198 | | - return $property->getText(); |
199 | | - else // $property instanceof SMWPropertyValue |
200 | | - return $property->getWikiValue(); |
201 | | - } |
202 | | - |
203 | | - /** |
204 | 183 | * Return an array of all form names on this wiki |
205 | 184 | */ |
206 | 185 | static function getAllForms() { |
— | — | @@ -222,16 +201,12 @@ |
223 | 202 | global $sfgContLang; |
224 | 203 | $namespace_labels = $sfgContLang->getNamespaces(); |
225 | 204 | $form_label = $namespace_labels[SF_NS_FORM]; |
226 | | - $str = <<<END |
227 | | - $form_label: |
228 | | - <select name="form"> |
229 | | - |
230 | | -END; |
231 | 205 | $form_names = SFUtils::getAllForms(); |
| 206 | + $select_body = ""; |
232 | 207 | foreach ($form_names as $form_name) { |
233 | | - $str .= " <option>$form_name</option>\n"; |
| 208 | + $select_body .= ' ' . Xml::element('option', null, $form_name) . "\n"; |
234 | 209 | } |
235 | | - $str .= " </select>\n"; |
| 210 | + $str = " $form_label:" . Xml::tags('select', array('name' => 'form'), $select_body) . "\n"; |
236 | 211 | return $str; |
237 | 212 | } |
238 | 213 | |
— | — | @@ -247,7 +222,7 @@ |
248 | 223 | $store = smwfGetStore(); |
249 | 224 | $requestoptions = new SMWRequestOptions(); |
250 | 225 | $requestoptions->limit = $sfgMaxAutocompleteValues; |
251 | | - $property = SFUtils::createProperty($property_name); |
| 226 | + $property = SMWPropertyValue::makeProperty($property_name); |
252 | 227 | $data_values = $store->getPropertyValues(null, $property, $requestoptions); |
253 | 228 | $values = array(); |
254 | 229 | foreach ($data_values as $dv) { |