r60329 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r60328‎ | r60329 | r60330 >
Date:17:28, 23 December 2009
Author:yaron
Status:deferred
Tags:
Comment:
Removed helper functions for handling SMW < 1.4, replaced some HTML with calls to Xml class functions
Modified paths:
  • /trunk/extensions/SemanticForms/includes/SF_Utils.inc (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticForms/includes/SF_Utils.inc
@@ -74,21 +74,22 @@
7575 global $sfgScriptPath;
7676 $text =<<<END
7777 <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" />
8578
8679 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+
8787 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";
8989 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+
9193 $text .=<<<END
92 - </form>
9394 <script type="text/javascript">
9495 window.onload = function() {
9596 document.editform.submit();
@@ -178,28 +179,6 @@
179180 }
180181
181182 /**
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 - /**
204183 * Return an array of all form names on this wiki
205184 */
206185 static function getAllForms() {
@@ -222,16 +201,12 @@
223202 global $sfgContLang;
224203 $namespace_labels = $sfgContLang->getNamespaces();
225204 $form_label = $namespace_labels[SF_NS_FORM];
226 - $str = <<<END
227 - $form_label:
228 - <select name="form">
229 -
230 -END;
231205 $form_names = SFUtils::getAllForms();
 206+ $select_body = "";
232207 foreach ($form_names as $form_name) {
233 - $str .= " <option>$form_name</option>\n";
 208+ $select_body .= ' ' . Xml::element('option', null, $form_name) . "\n";
234209 }
235 - $str .= " </select>\n";
 210+ $str = " $form_label:" . Xml::tags('select', array('name' => 'form'), $select_body) . "\n";
236211 return $str;
237212 }
238213
@@ -247,7 +222,7 @@
248223 $store = smwfGetStore();
249224 $requestoptions = new SMWRequestOptions();
250225 $requestoptions->limit = $sfgMaxAutocompleteValues;
251 - $property = SFUtils::createProperty($property_name);
 226+ $property = SMWPropertyValue::makeProperty($property_name);
252227 $data_values = $store->getPropertyValues(null, $property, $requestoptions);
253228 $values = array();
254229 foreach ($data_values as $dv) {

Follow-up revisions

RevisionCommit summaryAuthorDate
r73091Got 'minor edit' checkbox to work again; fix for bug introduced in r60329yaron21:44, 15 September 2010

Status & tagging log