r65399 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r65398‎ | r65399 | r65400 >
Date:15:24, 21 April 2010
Author:yaron
Status:deferred
Tags:
Comment:
Modified with stylize.php to fit MediaWiki's formatting conventions
Modified paths:
  • /trunk/extensions/SemanticForms/includes/SF_FormClasses.inc (modified) (history)
  • /trunk/extensions/SemanticForms/includes/SF_FormField.inc (modified) (history)
  • /trunk/extensions/SemanticForms/includes/SF_FormInputs.inc (modified) (history)
  • /trunk/extensions/SemanticForms/includes/SF_FormPrinter.inc (modified) (history)
  • /trunk/extensions/SemanticForms/includes/SF_FormUtils.inc (modified) (history)
  • /trunk/extensions/SemanticForms/includes/SF_LinkUtils.inc (modified) (history)
  • /trunk/extensions/SemanticForms/includes/SF_TemplateField.inc (modified) (history)
  • /trunk/extensions/SemanticForms/includes/SF_Utils.inc (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticForms/includes/SF_TemplateField.inc
@@ -17,10 +17,10 @@
1818 var $is_list;
1919 var $input_type;
2020
21 - static function create($name, $label) {
 21+ static function create( $name, $label ) {
2222 $f = new SFTemplateField();
23 - $f->field_name = trim(str_replace('\\', '', $name));
24 - $f->label = trim(str_replace('\\', '', $label));
 23+ $f->field_name = trim( str_replace( '\\', '', $name ) );
 24+ $f->label = trim( str_replace( '\\', '', $label ) );
2525 return $f;
2626 }
2727
@@ -28,21 +28,21 @@
2929 * Create an SFTemplateField object based on the corresponding field
3030 * in the template definition (which we first have to find)
3131 */
32 - static function createFromList($field_name, $all_fields, $strict_parsing) {
 32+ static function createFromList( $field_name, $all_fields, $strict_parsing ) {
3333 // see if this field matches one of the fields defined for
3434 // the template it's part of - if it is, use all available
3535 // information about that field; if it's not, either create
3636 // an object for it or not, depending on whether the
3737 // template has a 'strict' setting in the form definition
3838 $the_field = null;
39 - foreach ($all_fields as $cur_field) {
40 - if ($field_name == $cur_field->field_name) {
 39+ foreach ( $all_fields as $cur_field ) {
 40+ if ( $field_name == $cur_field->field_name ) {
4141 $the_field = $cur_field;
4242 break;
4343 }
4444 }
45 - if ($the_field == null) {
46 - if ($strict_parsing) {
 45+ if ( $the_field == null ) {
 46+ if ( $strict_parsing ) {
4747 return null;
4848 }
4949 $the_field = new SFTemplateField();
@@ -51,34 +51,34 @@
5252 }
5353
5454 function setTypeAndPossibleValues() {
55 - $proptitle = Title::makeTitleSafe(SMW_NS_PROPERTY, $this->semantic_property);
56 - if ($proptitle === NULL)
 55+ $proptitle = Title::makeTitleSafe( SMW_NS_PROPERTY, $this->semantic_property );
 56+ if ( $proptitle === NULL )
5757 return;
5858 $store = smwfGetStore();
59 - $types = $store->getPropertyValues($proptitle, SMWPropertyValue::makeUserProperty("Has type"));
 59+ $types = $store->getPropertyValues( $proptitle, SMWPropertyValue::makeUserProperty( "Has type" ) );
6060 // this returns an array of objects
61 - $allowed_values = $store->getPropertyValues($proptitle, SMWPropertyValue::makeUserProperty("Allows value"));
62 - $label_formats = $store->getPropertyValues($proptitle, SMWPropertyValue::makeUserProperty("Has field label format"));
 61+ $allowed_values = $store->getPropertyValues( $proptitle, SMWPropertyValue::makeUserProperty( "Allows value" ) );
 62+ $label_formats = $store->getPropertyValues( $proptitle, SMWPropertyValue::makeUserProperty( "Has field label format" ) );
6363 // TODO - need handling for the case of more than one type
64 - if (count($types) > 0)
 64+ if ( count( $types ) > 0 )
6565 $this->field_type = $types[0]->getWikiValue();
6666
67 - foreach ($allowed_values as $value) {
 67+ foreach ( $allowed_values as $value ) {
6868 // HTML-unencode each value
69 - $wiki_value = html_entity_decode($value->getWikiValue());
 69+ $wiki_value = html_entity_decode( $value->getWikiValue() );
7070 $this->possible_values[] = $wiki_value;
71 - if (count($label_formats) > 0) {
 71+ if ( count( $label_formats ) > 0 ) {
7272 $label_format = $label_formats[0]->getWikiValue();
73 - $prop_instance = SMWDataValueFactory::findTypeID($this->field_type);
74 - $label_value = SMWDataValueFactory::newTypeIDValue($prop_instance, $wiki_value);
75 - $label_value->setOutputFormat($label_format);
76 - $this->value_labels[$wiki_value] = html_entity_decode($label_value->getWikiValue());
 73+ $prop_instance = SMWDataValueFactory::findTypeID( $this->field_type );
 74+ $label_value = SMWDataValueFactory::newTypeIDValue( $prop_instance, $wiki_value );
 75+ $label_value->setOutputFormat( $label_format );
 76+ $this->value_labels[$wiki_value] = html_entity_decode( $label_value->getWikiValue() );
7777 }
7878 }
7979
8080 // HACK - if there were any possible values, set the field
8181 // type to be 'enumeration', regardless of what the actual type is
82 - if (count($this->possible_values) > 0) {
 82+ if ( count( $this->possible_values ) > 0 ) {
8383 $this->field_type = 'enumeration';
8484 }
8585 }
@@ -86,8 +86,8 @@
8787 /**
8888 * Called when template is parsed during the creation of a form
8989 */
90 - function setSemanticProperty($semantic_property) {
91 - $this->semantic_property = str_replace('\\', '', $semantic_property);
 90+ function setSemanticProperty( $semantic_property ) {
 91+ $this->semantic_property = str_replace( '\\', '', $semantic_property );
9292 $this->possible_values = array();
9393 // set field type and possible values, if any
9494 $this->setTypeAndPossibleValues();
@@ -97,28 +97,28 @@
9898 * Returns whether the semantic property represented by this field
9999 * has the passed-in type constant (e.g., '_str', '_wpg')
100100 */
101 - function propertyIsOfType($type_constant) {
 101+ function propertyIsOfType( $type_constant ) {
102102 global $smwgContLang;
103103 $datatypeLabels = $smwgContLang->getDatatypeLabels();
104104 $page_type = $datatypeLabels[$type_constant];
105 - return ($this->field_type == $page_type);
 105+ return ( $this->field_type == $page_type );
106106 }
107107
108 - function createTemplateText($template_name, $template_fields, $category, $aggregating_property, $aggregating_label, $template_format) {
109 - $template_header = wfMsgForContent('sf_template_docu', $template_name);
110 - $text =<<<END
 108+ function createTemplateText( $template_name, $template_fields, $category, $aggregating_property, $aggregating_label, $template_format ) {
 109+ $template_header = wfMsgForContent( 'sf_template_docu', $template_name );
 110+ $text = <<<END
111111 <noinclude>
112112 $template_header
113113 <pre>
114114
115115 END;
116116 $text .= '{{' . $template_name;
117 - if (count($template_fields) > 0) { $text .= "\n"; }
118 - foreach ($template_fields as $field) {
 117+ if ( count( $template_fields ) > 0 ) { $text .= "\n"; }
 118+ foreach ( $template_fields as $field ) {
119119 $text .= "|" . $field->field_name . "=\n";
120120 }
121 - $template_footer = wfMsgForContent('sf_template_docufooter');
122 - $text .=<<<END
 121+ $template_footer = wfMsgForContent( 'sf_template_docufooter' );
 122+ $text .= <<<END
123123 }}
124124 </pre>
125125 $template_footer
@@ -126,10 +126,10 @@
127127
128128 END;
129129 // topmost part depends on format
130 - if ($template_format == 'infobox') {
 130+ if ( $template_format == 'infobox' ) {
131131 // CSS style can't be used, unfortunately, since most MediaWiki
132132 // setups don't have an 'infobox' or comparable CSS class
133 - $text .=<<<END
 133+ $text .= <<<END
134134 {| style="width: 30em; font-size: 90%; border: 1px solid #aaaaaa; background-color: #f9f9f9; color: black; margin-bottom: 0.5em; margin-left: 1em; padding: 0.2em; float: right; clear: right; text-align:left;"
135135 ! style="text-align: center; background-color:#ccccff;" colspan="2" |<big>{{PAGENAME}}</big>
136136 |-
@@ -139,25 +139,25 @@
140140 $text .= '{| class="wikitable"' . "\n";
141141 }
142142
143 - foreach ($template_fields as $i => $field) {
144 - if ($i > 0) {
 143+ foreach ( $template_fields as $i => $field ) {
 144+ if ( $i > 0 ) {
145145 $text .= "|-\n";
146146 }
147147 $text .= "! " . $field->label . "\n";
148 - if ($field->semantic_property == null || $field->semantic_property == '') {
 148+ if ( $field->semantic_property == null || $field->semantic_property == '' ) {
149149 $text .= "| {{{" . $field->field_name . "|}}}\n";
150150 // if this field is meant to contain a list,
151151 // add on an 'arraymap' function, that will
152152 // call this semantic markup tag on every
153153 // element in the list
154 - } elseif ($field->is_list) {
 154+ } elseif ( $field->is_list ) {
155155 // find a string that's not in the semantic
156156 // field call, to be used as the variable
157157 $var = "x"; // default - use this if all the attempts fail
158 - if (strstr($field->semantic_property, $var)) {
159 - $var_options = array('y', 'z', 'xx', 'yy', 'zz', 'aa', 'bb', 'cc');
160 - foreach ($var_options as $option) {
161 - if (! strstr($field->semantic_property, $option)) {
 158+ if ( strstr( $field->semantic_property, $var ) ) {
 159+ $var_options = array( 'y', 'z', 'xx', 'yy', 'zz', 'aa', 'bb', 'cc' );
 160+ foreach ( $var_options as $option ) {
 161+ if ( ! strstr( $field->semantic_property, $option ) ) {
162162 $var = $option;
163163 break;
164164 }
@@ -171,18 +171,18 @@
172172
173173 // add a row with an inline query to this table, for aggregation, if
174174 // a property was specified
175 - if ($aggregating_property != '') {
176 - if (count($template_fields) > 0) {
 175+ if ( $aggregating_property != '' ) {
 176+ if ( count( $template_fields ) > 0 ) {
177177 $text .= "|-\n";
178178 }
179 - $text .=<<<END
 179+ $text .= <<<END
180180 ! $aggregating_label
181181 | {{#ask:[[$aggregating_property::{{SUBJECTPAGENAME}}]]|format=list}}
182182
183183 END;
184184 }
185185 $text .= "|}\n";
186 - if ($category != '') {
 186+ if ( $category != '' ) {
187187 global $wgContLang;
188188 $namespace_labels = $wgContLang->getNamespaces();
189189 $category_namespace = $namespace_labels[NS_CATEGORY];
Index: trunk/extensions/SemanticForms/includes/SF_Utils.inc
@@ -12,22 +12,22 @@
1313 static function initProperties() {
1414 global $sfgContLang;
1515 $sf_props = $sfgContLang->getPropertyLabels();
16 - if (array_key_exists(SF_SP_HAS_DEFAULT_FORM, $sf_props))
17 - SMWPropertyValue::registerProperty('_SF_DF', '__spf', $sf_props[SF_SP_HAS_DEFAULT_FORM], true);
18 - if (array_key_exists(SF_SP_HAS_ALTERNATE_FORM, $sf_props))
19 - SMWPropertyValue::registerProperty('_SF_AF', '__spf', $sf_props[SF_SP_HAS_ALTERNATE_FORM], true);
20 - if (array_key_exists(SF_SP_CREATES_PAGES_WITH_FORM, $sf_props))
21 - SMWPropertyValue::registerProperty('_SF_CP', '__spf', $sf_props[SF_SP_CREATES_PAGES_WITH_FORM], true);
22 - if (array_key_exists(SF_SP_PAGE_HAS_DEFAULT_FORM, $sf_props))
23 - SMWPropertyValue::registerProperty('_SF_PDF', '__spf', $sf_props[SF_SP_PAGE_HAS_DEFAULT_FORM], true);
24 - if (array_key_exists(SF_SP_HAS_FIELD_LABEL_FORMAT, $sf_props))
25 - SMWPropertyValue::registerProperty('_SF_FLF', '_str', $sf_props[SF_SP_HAS_FIELD_LABEL_FORMAT], true);
 16+ if ( array_key_exists( SF_SP_HAS_DEFAULT_FORM, $sf_props ) )
 17+ SMWPropertyValue::registerProperty( '_SF_DF', '__spf', $sf_props[SF_SP_HAS_DEFAULT_FORM], true );
 18+ if ( array_key_exists( SF_SP_HAS_ALTERNATE_FORM, $sf_props ) )
 19+ SMWPropertyValue::registerProperty( '_SF_AF', '__spf', $sf_props[SF_SP_HAS_ALTERNATE_FORM], true );
 20+ if ( array_key_exists( SF_SP_CREATES_PAGES_WITH_FORM, $sf_props ) )
 21+ SMWPropertyValue::registerProperty( '_SF_CP', '__spf', $sf_props[SF_SP_CREATES_PAGES_WITH_FORM], true );
 22+ if ( array_key_exists( SF_SP_PAGE_HAS_DEFAULT_FORM, $sf_props ) )
 23+ SMWPropertyValue::registerProperty( '_SF_PDF', '__spf', $sf_props[SF_SP_PAGE_HAS_DEFAULT_FORM], true );
 24+ if ( array_key_exists( SF_SP_HAS_FIELD_LABEL_FORMAT, $sf_props ) )
 25+ SMWPropertyValue::registerProperty( '_SF_FLF', '_str', $sf_props[SF_SP_HAS_FIELD_LABEL_FORMAT], true );
2626 // also initialize hardcoded English values, if it's a non-English-language wiki
27 - SMWPropertyValue::registerProperty('_SF_DF_BACKUP', '__spf', 'Has default form', true);
28 - SMWPropertyValue::registerProperty('_SF_AF_BACKUP', '__spf', 'Has alternate form', true);
29 - SMWPropertyValue::registerProperty('_SF_CP_BACKUP', '__spf', 'Creates pages with form', true);
30 - SMWPropertyValue::registerProperty('_SF_PDF_BACKUP', '__spf', 'Page has default form', true);
31 - SMWPropertyValue::registerProperty('_SF_FLF_BACKUP', '_str', 'Has field label format', true);
 27+ SMWPropertyValue::registerProperty( '_SF_DF_BACKUP', '__spf', 'Has default form', true );
 28+ SMWPropertyValue::registerProperty( '_SF_AF_BACKUP', '__spf', 'Has alternate form', true );
 29+ SMWPropertyValue::registerProperty( '_SF_CP_BACKUP', '__spf', 'Creates pages with form', true );
 30+ SMWPropertyValue::registerProperty( '_SF_PDF_BACKUP', '__spf', 'Page has default form', true );
 31+ SMWPropertyValue::registerProperty( '_SF_FLF_BACKUP', '_str', 'Has field label format', true );
3232
3333 return true;
3434 }
@@ -35,16 +35,16 @@
3636 /**
3737 * Creates HTML linking to a wiki page
3838 */
39 - static function linkText($namespace, $name, $text = NULL) {
 39+ static function linkText( $namespace, $name, $text = NULL ) {
4040 global $wgContLang;
4141
4242 $title = Title::makeTitleSafe( $namespace, $name );
43 - if ($title === NULL) {
 43+ if ( $title === NULL ) {
4444 return $name; // TODO maybe report an error here?
4545 }
4646 if ( NULL === $text ) $text = $title->getText();
4747 $l = new Linker();
48 - return $l->makeLinkObj($title, $text);
 48+ return $l->makeLinkObj( $title, $text );
4949 }
5050
5151 /**
@@ -52,44 +52,44 @@
5353 * allows pages to spoof a normal edit page, that can preview, save,
5454 * etc.
5555 */
56 - static function printRedirectForm($title, $page_contents, $edit_summary, $is_save, $is_preview, $is_diff, $is_minor_edit, $watch_this, $start_time, $edit_time) {
57 - if ($title instanceof Title)
58 - $new_url = $title->getLocalURL('action=submit');
 56+ static function printRedirectForm( $title, $page_contents, $edit_summary, $is_save, $is_preview, $is_diff, $is_minor_edit, $watch_this, $start_time, $edit_time ) {
 57+ if ( $title instanceof Title )
 58+ $new_url = $title->getLocalURL( 'action=submit' );
5959 else
6060 $new_url = $title;
6161 global $wgUser;
6262 if ( $wgUser->isLoggedIn() )
63 - $token = htmlspecialchars($wgUser->editToken());
 63+ $token = htmlspecialchars( $wgUser->editToken() );
6464 else
6565 $token = EDIT_TOKEN_SUFFIX;
6666
67 - $edit_summary = htmlspecialchars($edit_summary);
68 - if ($is_save)
 67+ $edit_summary = htmlspecialchars( $edit_summary );
 68+ if ( $is_save )
6969 $action = "wpSave";
70 - elseif ($is_preview)
 70+ elseif ( $is_preview )
7171 $action = "wpPreview";
7272 else // $is_diff
7373 $action = "wpDiff";
7474
7575 global $sfgScriptPath;
76 - $text =<<<END
 76+ $text = <<<END
7777 <p style="position: absolute; left: 45%; top: 45%;"><img src="$sfgScriptPath/skins/loading.gif" /></p>
7878
7979 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";
 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";
8686
87 - if ($is_minor_edit)
88 - $form_body .= ' ' . Xml::element('input', array('type' => 'hidden', 'name' => 'wpMinorEdit'), null) . "\n";
89 - if ($watch_this)
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);
 87+ if ( $is_minor_edit )
 88+ $form_body .= ' ' . Xml::element( 'input', array( 'type' => 'hidden', 'name' => 'wpMinorEdit' ), null ) . "\n";
 89+ if ( $watch_this )
 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 );
9292
93 - $text .=<<<END
 93+ $text .= <<<END
9494 <script type="text/javascript">
9595 window.onload = function() {
9696 document.editform.submit();
@@ -97,7 +97,7 @@
9898 </script>
9999
100100 END;
101 - wfRunHooks('sfPrintRedirectForm', array($is_save, $is_preview, $is_diff, &$text));
 101+ wfRunHooks( 'sfPrintRedirectForm', array( $is_save, $is_preview, $is_diff, &$text ) );
102102 return $text;
103103 }
104104
@@ -107,7 +107,7 @@
108108 *
109109 * Accepts an optional Parser instance, or uses $wgOut if omitted.
110110 */
111 - static function addJavascriptAndCSS($parser = NULL) {
 111+ static function addJavascriptAndCSS( $parser = NULL ) {
112112 global $wgOut, $sfgScriptPath, $sfgYUIBase, $smwgScriptPath, $wgScriptPath, $wgFCKEditorDir, $wgJsMimeType, $sfgUseFormEditPage;
113113
114114 $links = array(
@@ -142,11 +142,11 @@
143143 'href' => $smwgScriptPath . '/skins/SMW_custom.css'
144144 ),
145145 );
146 - foreach( $links as $link ) {
 146+ foreach ( $links as $link ) {
147147 if ( $parser )
148 - $parser->getOutput()->addHeadItem(Xml::element( 'link', $link ));
 148+ $parser->getOutput()->addHeadItem( Xml::element( 'link', $link ) );
149149 else
150 - $wgOut->addLink($link);
 150+ $wgOut->addLink( $link );
151151 }
152152
153153
@@ -165,17 +165,17 @@
166166 $scripts[] = "$sfgScriptPath/libs/floatbox.js";
167167 $scripts[] = "$smwgScriptPath/skins/SMW_tooltip.js";
168168 $scripts[] = "$smwgScriptPath/skins/SMW_sorttable.js";
169 - if ($wgFCKEditorDir)
 169+ if ( $wgFCKEditorDir )
170170 $scripts[] = "$wgScriptPath/$wgFCKEditorDir/fckeditor.js";
171 - foreach( $scripts as $js ) {
 171+ foreach ( $scripts as $js ) {
172172 $script = "<script type=\"$wgJsMimeType\" src=\"$js\"></script>\n";
173173 if ( $parser )
174 - $parser->getOutput()->addHeadItem($script);
 174+ $parser->getOutput()->addHeadItem( $script );
175175 else
176 - $wgOut->addScript($script);
 176+ $wgOut->addScript( $script );
177177 }
178178 if ( !$parser )
179 - $wgOut->addMeta('robots','noindex,nofollow');
 179+ $wgOut->addMeta( 'robots', 'noindex,nofollow' );
180180 }
181181
182182 /**
@@ -187,12 +187,12 @@
188188 " WHERE page_namespace = " . SF_NS_FORM .
189189 " AND page_is_redirect = 0" .
190190 " ORDER BY page_title";
191 - $res = $dbr->query($query);
 191+ $res = $dbr->query( $query );
192192 $form_names = array();
193 - while ($row = $dbr->fetchRow($res)) {
194 - $form_names[] = str_replace('_', ' ', $row[0]);
 193+ while ( $row = $dbr->fetchRow( $res ) ) {
 194+ $form_names[] = str_replace( '_', ' ', $row[0] );
195195 }
196 - $dbr->freeResult($res);
 196+ $dbr->freeResult( $res );
197197 return $form_names;
198198 }
199199
@@ -203,10 +203,10 @@
204204 $form_label = $namespace_labels[SF_NS_FORM];
205205 $form_names = SFUtils::getAllForms();
206206 $select_body = "";
207 - foreach ($form_names as $form_name) {
208 - $select_body .= ' ' . Xml::element('option', null, $form_name) . "\n";
 207+ foreach ( $form_names as $form_name ) {
 208+ $select_body .= ' ' . Xml::element( 'option', null, $form_name ) . "\n";
209209 }
210 - $str = " $form_label:" . Xml::tags('select', array('name' => 'form'), $select_body) . "\n";
 210+ $str = " $form_label:" . Xml::tags( 'select', array( 'name' => 'form' ), $select_body ) . "\n";
211211 return $str;
212212 }
213213
@@ -216,20 +216,20 @@
217217 * case-insensitive queries; for queries with a substring, the
218218 * function SFAutocompletAPI::getAllValuesForProperty() exists.
219219 */
220 - static function getAllValuesForProperty($property_name) {
 220+ static function getAllValuesForProperty( $property_name ) {
221221 global $sfgMaxAutocompleteValues;
222222
223223 $store = smwfGetStore();
224224 $requestoptions = new SMWRequestOptions();
225225 $requestoptions->limit = $sfgMaxAutocompleteValues;
226 - $property = SMWPropertyValue::makeProperty($property_name);
227 - $data_values = $store->getPropertyValues(null, $property, $requestoptions);
 226+ $property = SMWPropertyValue::makeProperty( $property_name );
 227+ $data_values = $store->getPropertyValues( null, $property, $requestoptions );
228228 $values = array();
229 - foreach ($data_values as $dv) {
 229+ foreach ( $data_values as $dv ) {
230230 // getPropertyValues() gets many repeat values - we want
231231 // only one of each value
232 - $string_value = str_replace('_', ' ', $dv->getWikiValue());
233 - if (array_search($string_value, $values) === false)
 232+ $string_value = str_replace( '_', ' ', $dv->getWikiValue() );
 233+ if ( array_search( $string_value, $values ) === false )
234234 $values[] = $string_value;
235235 }
236236 return $values;
@@ -240,51 +240,51 @@
241241 * subcategories, down a certain number of levels - heavily based on
242242 * SMW's SMWInlineQuery::includeSubcategories()
243243 */
244 - static function getAllPagesForCategory($top_category, $num_levels, $substring = null) {
245 - if (0 == $num_levels) return $top_category;
 244+ static function getAllPagesForCategory( $top_category, $num_levels, $substring = null ) {
 245+ if ( 0 == $num_levels ) return $top_category;
246246 global $sfgMaxAutocompleteValues;
247247
248248 $db = wfGetDB( DB_SLAVE );
249 - $top_category = str_replace(' ', '_', $top_category);
250 - $categories = array($top_category);
251 - $checkcategories = array($top_category);
 249+ $top_category = str_replace( ' ', '_', $top_category );
 250+ $categories = array( $top_category );
 251+ $checkcategories = array( $top_category );
252252 $pages = array();
253 - for ($level = $num_levels; $level > 0; $level--) {
 253+ for ( $level = $num_levels; $level > 0; $level-- ) {
254254 $newcategories = array();
255 - foreach ($checkcategories as $category) {
256 - if ($substring != null) {
257 - $substring = str_replace(' ', '_', strtolower($substring));
258 - $substring = str_replace('_', '\_', $substring);
259 - $substring = str_replace("'", "\'", $substring);
260 - $conditions = 'cl_to = '. $db->addQuotes($category) . " AND (LOWER(CONVERT(`page_title` USING utf8)) LIKE '" . $substring . "%' OR LOWER(CONVERT(`page_title` USING utf8)) LIKE '%\_" . $substring . "%' OR page_namespace = " . NS_CATEGORY . ")";
 255+ foreach ( $checkcategories as $category ) {
 256+ if ( $substring != null ) {
 257+ $substring = str_replace( ' ', '_', strtolower( $substring ) );
 258+ $substring = str_replace( '_', '\_', $substring );
 259+ $substring = str_replace( "'", "\'", $substring );
 260+ $conditions = 'cl_to = ' . $db->addQuotes( $category ) . " AND (LOWER(CONVERT(`page_title` USING utf8)) LIKE '" . $substring . "%' OR LOWER(CONVERT(`page_title` USING utf8)) LIKE '%\_" . $substring . "%' OR page_namespace = " . NS_CATEGORY . ")";
261261 } else {
262 - $conditions = 'cl_to = '. $db->addQuotes($category);
 262+ $conditions = 'cl_to = ' . $db->addQuotes( $category );
263263 }
264264 $res = $db->select( // make the query
265 - array('categorylinks', 'page'),
266 - array('page_title', 'page_namespace'),
267 - array('cl_from = page_id', $conditions),
 265+ array( 'categorylinks', 'page' ),
 266+ array( 'page_title', 'page_namespace' ),
 267+ array( 'cl_from = page_id', $conditions ),
268268 __METHOD__,
269 - 'SORT BY cl_sortkey');
270 - if ($res) {
271 - while ($res && $row = $db->fetchRow($res)) {
272 - if (array_key_exists('page_title', $row)) {
 269+ 'SORT BY cl_sortkey' );
 270+ if ( $res ) {
 271+ while ( $res && $row = $db->fetchRow( $res ) ) {
 272+ if ( array_key_exists( 'page_title', $row ) ) {
273273 $page_namespace = $row['page_namespace'];
274 - if ($page_namespace == NS_CATEGORY) {
 274+ if ( $page_namespace == NS_CATEGORY ) {
275275 $new_category = $row[ 'page_title' ];
276 - if (!in_array($new_category, $categories)) {
 276+ if ( !in_array( $new_category, $categories ) ) {
277277 $newcategories[] = $new_category;
278278 }
279279 } else {
280 - $cur_value = str_replace("_", " ", $row['page_title']);
281 - if (! in_array($cur_value, $pages)) {
282 - if ($substring == null)
 280+ $cur_value = str_replace( "_", " ", $row['page_title'] );
 281+ if ( ! in_array( $cur_value, $pages ) ) {
 282+ if ( $substring == null )
283283 $pages[] = $cur_value;
284284 else
285 - $pages[] = array('title' => $cur_value);
 285+ $pages[] = array( 'title' => $cur_value );
286286 }
287287 // return if we've reached the maximum number of allowed values
288 - if (count($pages) > $sfgMaxAutocompleteValues)
 288+ if ( count( $pages ) > $sfgMaxAutocompleteValues )
289289 return $pages;
290290 }
291291 }
@@ -292,17 +292,17 @@
293293 $db->freeResult( $res );
294294 }
295295 }
296 - if (count($newcategories) == 0) {
 296+ if ( count( $newcategories ) == 0 ) {
297297 return $pages;
298298 } else {
299 - $categories = array_merge($categories, $newcategories);
 299+ $categories = array_merge( $categories, $newcategories );
300300 }
301 - $checkcategories = array_diff($newcategories, array());
 301+ $checkcategories = array_diff( $newcategories, array() );
302302 }
303303 return $pages;
304304 }
305305
306 - static function getAllPagesForConcept($concept_name, $substring = null) {
 306+ static function getAllPagesForConcept( $concept_name, $substring = null ) {
307307 global $sfgMaxAutocompleteValues;
308308
309309 // TODO - substring isn't being handled. Is there a way to
@@ -314,25 +314,25 @@
315315 $requestoptions->addStringCondition($substring, SMWStringCondition::STRCOND_PRE);
316316 }
317317 */
318 - $concept = Title::makeTitleSafe(SMW_NS_CONCEPT, $concept_name);
 318+ $concept = Title::makeTitleSafe( SMW_NS_CONCEPT, $concept_name );
319319 // escape if there's a problem
320 - if ($concept == null)
 320+ if ( $concept == null )
321321 return array();
322 - $desc = new SMWConceptDescription($concept);
323 - $printout = new SMWPrintRequest(SMWPrintRequest::PRINT_THIS, "");
324 - $desc->addPrintRequest($printout);
325 - $query = new SMWQuery($desc);
326 - $query->setLimit($sfgMaxAutocompleteValues);
327 - $query_result = $store->getQueryResult($query);
 322+ $desc = new SMWConceptDescription( $concept );
 323+ $printout = new SMWPrintRequest( SMWPrintRequest::PRINT_THIS, "" );
 324+ $desc->addPrintRequest( $printout );
 325+ $query = new SMWQuery( $desc );
 326+ $query->setLimit( $sfgMaxAutocompleteValues );
 327+ $query_result = $store->getQueryResult( $query );
328328 $pages = array();
329 - while ($res = $query_result->getNext()) {
330 - $pages[] = $res[0]->getNextText(SMW_OUTPUT_WIKI);
 329+ while ( $res = $query_result->getNext() ) {
 330+ $pages[] = $res[0]->getNextText( SMW_OUTPUT_WIKI );
331331 }
332 - sort($pages);
 332+ sort( $pages );
333333 return $pages;
334334 }
335335
336 - static function getAllPagesForNamespace($namespace_name, $substring = null) {
 336+ static function getAllPagesForNamespace( $namespace_name, $substring = null ) {
337337 // cycle through all the namespace names for this language, and
338338 // if one matches the namespace specified in the form, add the
339339 // names of all the pages in that namespace to $names_array
@@ -340,45 +340,45 @@
341341 $namespaces = $wgContLang->getNamespaces();
342342 $db = wfGetDB( DB_SLAVE );
343343 $pages = array();
344 - foreach ($namespaces as $ns_code => $ns_name) {
345 - if ($ns_name == $namespace_name) {
 344+ foreach ( $namespaces as $ns_code => $ns_name ) {
 345+ if ( $ns_name == $namespace_name ) {
346346 $conditions = "page_namespace = $ns_code";
347 - if ($substring != null) {
348 - $substring = str_replace(' ', '_', strtolower($substring));
349 - $substring = str_replace('_', '\_', $substring);
350 - $substring = str_replace("'", "\'", $substring);
 347+ if ( $substring != null ) {
 348+ $substring = str_replace( ' ', '_', strtolower( $substring ) );
 349+ $substring = str_replace( '_', '\_', $substring );
 350+ $substring = str_replace( "'", "\'", $substring );
351351 $conditions .= " AND (LOWER(CONVERT(`page_title` USING utf8)) LIKE '$substring%' OR LOWER(CONVERT(`page_title` USING utf8)) LIKE '%\_$substring%')";
352352 }
353353 $sql_options['ORDER BY'] = 'page_title';
354 - $res = $db->select( $db->tableNames('page'),
 354+ $res = $db->select( $db->tableNames( 'page' ),
355355 'page_title',
356 - $conditions, __METHOD__, $sql_options);
357 - while ($row = $db->fetchRow($res)) {
358 - $cur_value = str_replace('_', ' ', $row[0]);
359 - if ($substring == null) {
 356+ $conditions, __METHOD__, $sql_options );
 357+ while ( $row = $db->fetchRow( $res ) ) {
 358+ $cur_value = str_replace( '_', ' ', $row[0] );
 359+ if ( $substring == null ) {
360360 $pages[] = $cur_value;
361361 } else {
362 - $pages[] = array('title' => $cur_value);
 362+ $pages[] = array( 'title' => $cur_value );
363363 }
364364 }
365 - $db->freeResult($res);
 365+ $db->freeResult( $res );
366366 }
367367 }
368368 return $pages;
369369 }
370370
371 - static function getValuesFromExternalURL($external_url_alias, $substring) {
 371+ static function getValuesFromExternalURL( $external_url_alias, $substring ) {
372372 global $sfgAutocompletionURLs;
373 - if (empty($sfgAutocompletionURLs)) return array();
 373+ if ( empty( $sfgAutocompletionURLs ) ) return array();
374374 $url = $sfgAutocompletionURLs[$external_url_alias];
375 - if (empty($url)) return array();
376 - $url = str_replace('<substr>', $substring, $url);
377 - $page_contents = Http::get($url);
378 - if (empty($page_contents)) return array();
379 - $data = json_decode($page_contents);
380 - if (empty($data)) return array();
 375+ if ( empty( $url ) ) return array();
 376+ $url = str_replace( '<substr>', $substring, $url );
 377+ $page_contents = Http::get( $url );
 378+ if ( empty( $page_contents ) ) return array();
 379+ $data = json_decode( $page_contents );
 380+ if ( empty( $data ) ) return array();
381381 $return_values = array();
382 - foreach ($data->sfautocomplete as $val) {
 382+ foreach ( $data->sfautocomplete as $val ) {
383383 $return_values[] = (array)$val;
384384 }
385385 return $return_values;
@@ -388,26 +388,26 @@
389389 * Parse the form definition and store the resulting HTML in the
390390 * page_props table, if caching has been specified in LocalSettings.php
391391 */
392 - function cacheFormDefinition($parser, $text) {
 392+ function cacheFormDefinition( $parser, $text ) {
393393 global $sfgCacheFormDefinitions;
394 - if (! $sfgCacheFormDefinitions)
 394+ if ( ! $sfgCacheFormDefinitions )
395395 return true;
396396
397397 $title = $parser->getTitle();
398 - if (empty($title)) return true;
399 - if ($title->getNamespace() != SF_NS_FORM) return true;
 398+ if ( empty( $title ) ) return true;
 399+ if ( $title->getNamespace() != SF_NS_FORM ) return true;
400400 // Remove <noinclude> sections and <includeonly> tags from form definition
401 - $form_def = StringUtils::delimiterReplace('<noinclude>', '</noinclude>', '', $text);
402 - $form_def = strtr($form_def, array('<includeonly>' => '', '</includeonly>' => ''));
 401+ $form_def = StringUtils::delimiterReplace( '<noinclude>', '</noinclude>', '', $text );
 402+ $form_def = strtr( $form_def, array( '<includeonly>' => '', '</includeonly>' => '' ) );
403403
404404 // parse wiki-text
405405 // add '<nowiki>' tags around every triple-bracketed form
406406 // definition element, so that the wiki parser won't touch
407407 // it - the parser will remove the '<nowiki>' tags, leaving
408408 // us with what we need
409 - $form_def = "__NOEDITSECTION__" . strtr($form_def, array('{{{' => '<nowiki>{{{', '}}}' => '}}}</nowiki>'));
410 - $dummy_title = Title::newFromText('Form definition title for caching purposes');
411 - $form_def = $parser->parse($form_def, $dummy_title, $parser->mOptions)->getText();
 409+ $form_def = "__NOEDITSECTION__" . strtr( $form_def, array( '{{{' => '<nowiki>{{{', '}}}' => '}}}</nowiki>' ) );
 410+ $dummy_title = Title::newFromText( 'Form definition title for caching purposes' );
 411+ $form_def = $parser->parse( $form_def, $dummy_title, $parser->mOptions )->getText();
412412
413413 $parser->mOutput->setProperty( 'formdefinition', $form_def );
414414 return true;
Index: trunk/extensions/SemanticForms/includes/SF_FormClasses.inc
@@ -10,28 +10,28 @@
1111 var $form_name;
1212 var $templates;
1313
14 - static function create($form_name, $templates) {
 14+ static function create( $form_name, $templates ) {
1515 $form = new SFForm();
16 - $form->form_name = ucfirst(str_replace('_', ' ', $form_name));
 16+ $form->form_name = ucfirst( str_replace( '_', ' ', $form_name ) );
1717 $form->templates = $templates;
1818 return $form;
1919 }
2020
2121 function creationHTML() {
2222 $text = "";
23 - foreach ($this->templates as $i => $ft) {
24 - $text .= $ft->creationHTML($i);
 23+ foreach ( $this->templates as $i => $ft ) {
 24+ $text .= $ft->creationHTML( $i );
2525 }
2626 return $text;
2727 }
2828
2929 function createMarkup() {
3030 $title = Title::makeTitle( SF_NS_FORM, $this->form_name );
31 - $fs = SpecialPage::getPage('FormStart');
32 - $form_start_url = SFLinkUtils::titleURLString($fs->getTitle()) . "/" . $title->getPartialURL();
33 - $form_description = wfMsgForContent('sf_form_docu', $this->form_name, $form_start_url);
 31+ $fs = SpecialPage::getPage( 'FormStart' );
 32+ $form_start_url = SFLinkUtils::titleURLString( $fs->getTitle() ) . "/" . $title->getPartialURL();
 33+ $form_description = wfMsgForContent( 'sf_form_docu', $this->form_name, $form_start_url );
3434 $form_input = "{{#forminput:form=" . $this->form_name . "}}\n";
35 - $text =<<<END
 35+ $text = <<<END
3636 <noinclude>
3737 $form_description
3838
@@ -41,11 +41,11 @@
4242 <div id="wikiPreview" style="display: none; padding-bottom: 25px; margin-bottom: 25px; border-bottom: 1px solid #AAAAAA;"></div>
4343
4444 END;
45 - foreach ($this->templates as $template) {
 45+ foreach ( $this->templates as $template ) {
4646 $text .= $template->createMarkup() . "\n";
4747 }
48 - $free_text_label = wfMsgForContent('sf_form_freetextlabel');
49 - $text .=<<<END
 48+ $free_text_label = wfMsgForContent( 'sf_form_freetextlabel' );
 49+ $text .= <<<END
5050 '''$free_text_label:'''
5151
5252 {{{standard input|free text|rows=10}}}
@@ -87,79 +87,79 @@
8888 // of an "#if" statement), so they're only recorded the first time they're
8989 // found. Also, every field gets replaced with a string of x's after
9090 // being found, so it doesn't interfere with future parsing.
91 - $template_title = Title::makeTitleSafe(NS_TEMPLATE, $this->template_name);
 91+ $template_title = Title::makeTitleSafe( NS_TEMPLATE, $this->template_name );
9292 $template_article = null;
93 - if(isset($template_title)) $template_article = new Article($template_title);
94 - if(isset($template_article)) {
 93+ if ( isset( $template_title ) ) $template_article = new Article( $template_title );
 94+ if ( isset( $template_article ) ) {
9595 $template_text = $template_article->getContent();
9696 // ignore 'noinclude' sections and 'includeonly' tags
97 - $template_text = StringUtils::delimiterReplace('<noinclude>', '</noinclude>', '', $template_text);
98 - $template_text = strtr($template_text, array('<includeonly>' => '', '</includeonly>' => ''));
 97+ $template_text = StringUtils::delimiterReplace( '<noinclude>', '</noinclude>', '', $template_text );
 98+ $template_text = strtr( $template_text, array( '<includeonly>' => '', '</includeonly>' => '' ) );
9999
100100 // first, look for "arraymap" parser function calls that map a
101101 // property onto a list
102 - if (preg_match_all('/{{#arraymap:{{{([^|}]*:?[^|}]*)[^\[]*\[\[([^:=]*:?[^:=]*)(:[:=])/mis', $template_text, $matches)) {
 102+ if ( preg_match_all( '/{{#arraymap:{{{([^|}]*:?[^|}]*)[^\[]*\[\[([^:=]*:?[^:=]*)(:[:=])/mis', $template_text, $matches ) ) {
103103 // this is a two-dimensional array; we need the last three of the four
104104 // sub-arrays; we also have to remove redundant values
105 - foreach ($matches[1] as $i => $field_name) {
 105+ foreach ( $matches[1] as $i => $field_name ) {
106106 $semantic_property = $matches[2][$i];
107107 $full_field_text = $matches[0][$i];
108 - if (! in_array($field_name, $field_names_array)) {
109 - $template_field = SFTemplateField::create($field_name, $wgContLang->ucfirst($field_name));
110 - $template_field->setSemanticProperty($semantic_property);
 108+ if ( ! in_array( $field_name, $field_names_array ) ) {
 109+ $template_field = SFTemplateField::create( $field_name, $wgContLang->ucfirst( $field_name ) );
 110+ $template_field->setSemanticProperty( $semantic_property );
111111 $template_field->is_list = true;
112 - $cur_pos = stripos($template_text, $full_field_text);
 112+ $cur_pos = stripos( $template_text, $full_field_text );
113113 $template_fields[$cur_pos] = $template_field;
114114 $field_names_array[] = $field_name;
115 - $replacement = str_repeat("x", strlen($full_field_text));
116 - $template_text = str_replace($full_field_text, $replacement, $template_text);
 115+ $replacement = str_repeat( "x", strlen( $full_field_text ) );
 116+ $template_text = str_replace( $full_field_text, $replacement, $template_text );
117117 }
118118 }
119119 }
120120
121121 // second, look for normal property calls
122 - if (preg_match_all('/\[\[([^:=]*:*?[^:=]*)(:[:=]){{{([^\]\|}]*).*?\]\]/mis', $template_text, $matches)) {
 122+ if ( preg_match_all( '/\[\[([^:=]*:*?[^:=]*)(:[:=]){{{([^\]\|}]*).*?\]\]/mis', $template_text, $matches ) ) {
123123 // this is a two-dimensional array; we need the last three of the four
124124 // sub-arrays; we also have to remove redundant values
125 - foreach ($matches[1] as $i => $semantic_property) {
 125+ foreach ( $matches[1] as $i => $semantic_property ) {
126126 $field_name = $matches[3][$i];
127127 $full_field_text = $matches[0][$i];
128 - if (! in_array($field_name, $field_names_array)) {
129 - $template_field = SFTemplateField::create($field_name, $wgContLang->ucfirst($field_name));
130 - $template_field->setSemanticProperty($semantic_property);
131 - $cur_pos = stripos($template_text, $full_field_text);
 128+ if ( ! in_array( $field_name, $field_names_array ) ) {
 129+ $template_field = SFTemplateField::create( $field_name, $wgContLang->ucfirst( $field_name ) );
 130+ $template_field->setSemanticProperty( $semantic_property );
 131+ $cur_pos = stripos( $template_text, $full_field_text );
132132 $template_fields[$cur_pos] = $template_field;
133133 $field_names_array[] = $field_name;
134 - $replacement = str_repeat("x", strlen($full_field_text));
135 - $template_text = str_replace($full_field_text, $replacement, $template_text);
 134+ $replacement = str_repeat( "x", strlen( $full_field_text ) );
 135+ $template_text = str_replace( $full_field_text, $replacement, $template_text );
136136 }
137137 }
138138 }
139139
140140 // finally, get any non-semantic fields defined
141 - if (preg_match_all('/{{{([^|}]*)/mis', $template_text, $matches)) {
142 - foreach ($matches[1] as $i => $field_name) {
 141+ if ( preg_match_all( '/{{{([^|}]*)/mis', $template_text, $matches ) ) {
 142+ foreach ( $matches[1] as $i => $field_name ) {
143143 $full_field_text = $matches[0][$i];
144 - if (($full_field_text != '') && (! in_array($field_name, $field_names_array))) {
145 - $cur_pos = stripos($template_text, $full_field_text);
146 - $template_fields[$cur_pos] = SFTemplateField::create($field_name, $wgContLang->ucfirst($field_name));
 144+ if ( ( $full_field_text != '' ) && ( ! in_array( $field_name, $field_names_array ) ) ) {
 145+ $cur_pos = stripos( $template_text, $full_field_text );
 146+ $template_fields[$cur_pos] = SFTemplateField::create( $field_name, $wgContLang->ucfirst( $field_name ) );
147147 $field_names_array[] = $field_name;
148148 }
149149 }
150150 }
151151 }
152 - ksort($template_fields);
 152+ ksort( $template_fields );
153153 return $template_fields;
154154 }
155155
156 - static function create($name, $label, $allow_multiple, $max_allowed = null) {
 156+ static function create( $name, $label, $allow_multiple, $max_allowed = null ) {
157157 $tif = new SFTemplateInForm();
158 - $tif->template_name = str_replace('_', ' ', $name);
 158+ $tif->template_name = str_replace( '_', ' ', $name );
159159 $tif->fields = array();
160160 $fields = $tif->getAllFields();
161161 $field_num = 0;
162 - foreach ($fields as $field) {
163 - $tif->fields[] = SFFormField::create($field_num++, $field);
 162+ foreach ( $fields as $field ) {
 163+ $tif->fields[] = SFFormField::create( $field_num++, $field );
164164 }
165165 $tif->label = $label;
166166 $tif->allow_multiple = $allow_multiple;
@@ -167,12 +167,12 @@
168168 return $tif;
169169 }
170170
171 - function creationHTML($template_num) {
172 - $checked_str = ($this->allow_multiple) ? "checked" : "";
173 - $template_str = wfMsg('sf_createform_template');
174 - $template_label_input = wfMsg('sf_createform_templatelabelinput');
175 - $allow_multiple_text = wfMsg('sf_createform_allowmultiple');
176 - $text =<<<END
 171+ function creationHTML( $template_num ) {
 172+ $checked_str = ( $this->allow_multiple ) ? "checked" : "";
 173+ $template_str = wfMsg( 'sf_createform_template' );
 174+ $template_label_input = wfMsg( 'sf_createform_templatelabelinput' );
 175+ $allow_multiple_text = wfMsg( 'sf_createform_allowmultiple' );
 176+ $text = <<<END
177177 <input type="hidden" name="template_$template_num" value="$this->template_name">
178178 <div class="templateForm">
179179 <h2>$template_str '$this->template_name'</h2>
@@ -181,11 +181,11 @@
182182 <hr>
183183
184184 END;
185 - foreach ($this->fields as $field) {
186 - $text .= $field->creationHTML($template_num);
 185+ foreach ( $this->fields as $field ) {
 186+ $text .= $field->creationHTML( $template_num );
187187 }
188188 $text .= ' <p><input type="submit" name="del_' . $template_num .
189 - '" value="' . wfMsg('sf_createform_removetemplate') . '"></p>' . "\n";
 189+ '" value="' . wfMsg( 'sf_createform_removetemplate' ) . '"></p>' . "\n";
190190 $text .= " </div>\n";
191191 return $text;
192192 }
@@ -193,19 +193,19 @@
194194 function createMarkup() {
195195 $text = "";
196196 $text .= "{{{for template|" . $this->template_name;
197 - if ($this->allow_multiple)
 197+ if ( $this->allow_multiple )
198198 $text .= "|multiple";
199 - if ($this->label != '')
 199+ if ( $this->label != '' )
200200 $text .= "|label=" . $this->label;
201201 $text .= "}}}\n";
202202 // for now, HTML for templates differs for multiple-instance templates;
203203 // this may change if handling of form definitions gets more sophisticated
204 - if (! $this->allow_multiple) { $text .= "{| class=\"formtable\"\n"; }
205 - foreach ($this->fields as $i => $field) {
206 - $is_last_field = ($i == count($this->fields) - 1);
207 - $text .= $field->createMarkup($this->allow_multiple, $is_last_field);
 204+ if ( ! $this->allow_multiple ) { $text .= "{| class=\"formtable\"\n"; }
 205+ foreach ( $this->fields as $i => $field ) {
 206+ $is_last_field = ( $i == count( $this->fields ) - 1 );
 207+ $text .= $field->createMarkup( $this->allow_multiple, $is_last_field );
208208 }
209 - if (! $this->allow_multiple) { $text .= "|}\n"; }
 209+ if ( ! $this->allow_multiple ) { $text .= "|}\n"; }
210210 $text .= "{{{end template}}}\n";
211211 return $text;
212212 }
Index: trunk/extensions/SemanticForms/includes/SF_FormUtils.inc
@@ -70,15 +70,15 @@
7171 static function validationJavascript() {
7272 global $sfgJSValidationCalls;
7373
74 - $form_errors_header = Xml::escapeJsString(wfMsg('sf_formerrors_header'));
75 - $blank_error_str = Xml::escapeJsString(wfMsg('sf_blank_error'));
76 - $bad_url_error_str = Xml::escapeJsString(wfMsg('sf_bad_url_error'));
77 - $bad_email_error_str = Xml::escapeJsString(wfMsg('sf_bad_email_error'));
78 - $bad_number_error_str = Xml::escapeJsString(wfMsg('sf_bad_number_error'));
79 - $bad_integer_error_str = Xml::escapeJsString(wfMsg('sf_bad_integer_error'));
80 - $bad_date_error_str = Xml::escapeJsString(wfMsg('sf_bad_date_error'));
 74+ $form_errors_header = Xml::escapeJsString( wfMsg( 'sf_formerrors_header' ) );
 75+ $blank_error_str = Xml::escapeJsString( wfMsg( 'sf_blank_error' ) );
 76+ $bad_url_error_str = Xml::escapeJsString( wfMsg( 'sf_bad_url_error' ) );
 77+ $bad_email_error_str = Xml::escapeJsString( wfMsg( 'sf_bad_email_error' ) );
 78+ $bad_number_error_str = Xml::escapeJsString( wfMsg( 'sf_bad_number_error' ) );
 79+ $bad_integer_error_str = Xml::escapeJsString( wfMsg( 'sf_bad_integer_error' ) );
 80+ $bad_date_error_str = Xml::escapeJsString( wfMsg( 'sf_bad_date_error' ) );
8181
82 - $javascript_text =<<<END
 82+ $javascript_text = <<<END
8383
8484 function validate_mandatory_field(field_id, info_id) {
8585 field = document.getElementById(field_id);
@@ -223,10 +223,10 @@
224224 var num_errors = 0;
225225
226226 END;
227 - foreach ($sfgJSValidationCalls as $function_call) {
 227+ foreach ( $sfgJSValidationCalls as $function_call ) {
228228 $javascript_text .= " if (! $function_call) num_errors += 1;\n";
229229 }
230 - $javascript_text .=<<<END
 230+ $javascript_text .= <<<END
231231 if (num_errors > 0) {
232232 // add error header, if it's not there already
233233 if (! document.getElementById("form_error_header")) {
@@ -243,9 +243,9 @@
244244 return $javascript_text;
245245 }
246246
247 - static function instancesJavascript($using_choosers) {
248 - $remove_text = wfMsg('sf_formedit_remove');
249 - $javascript_text =<<<END
 247+ static function instancesJavascript( $using_choosers ) {
 248+ $remove_text = wfMsg( 'sf_formedit_remove' );
 249+ $javascript_text = <<<END
250250
251251 var num_elements = 0;
252252
@@ -338,7 +338,7 @@
339339 static function autocompletionJavascript() {
340340 global $wgScriptPath;
341341
342 - $javascript_text =<<<END
 342+ $javascript_text = <<<END
343343 var autocompletemappings = new Array();
344344 var autocompletestrings = new Array();
345345 var autocompletedatatypes = new Array();
@@ -407,12 +407,12 @@
408408 return $javascript_text;
409409 }
410410
411 - static function hiddenFieldHTML($input_name, $cur_value) {
412 - $input = self::buttonHTML(array(
 411+ static function hiddenFieldHTML( $input_name, $cur_value ) {
 412+ $input = self::buttonHTML( array(
413413 'type' => 'hidden',
414414 'name' => $input_name,
415415 'value' => $cur_value,
416 - ));
 416+ ) );
417417 return <<<END
418418 $input
419419
@@ -423,11 +423,11 @@
424424 * Add a hidden input for each field in the template call that's
425425 * not handled by the form itself
426426 */
427 - static function unhandledFieldsHTML($template_contents) {
 427+ static function unhandledFieldsHTML( $template_contents ) {
428428 $text = "";
429 - foreach ($template_contents as $key => $value) {
430 - if ($key != '' && !is_numeric($key))
431 - $text .= self::hiddenFieldHTML("_unhandled_$key", $value);
 429+ foreach ( $template_contents as $key => $value ) {
 430+ if ( $key != '' && !is_numeric( $key ) )
 431+ $text .= self::hiddenFieldHTML( "_unhandled_$key", $value );
432432 }
433433 return $text;
434434 }
@@ -439,9 +439,9 @@
440440 static function addUnhandledFields() {
441441 global $wgRequest;
442442 $additional_template_text = "";
443 - foreach ($wgRequest->getValues() as $key => $value) {
444 - if (substr($key, 0, 11) == '_unhandled_') {
445 - $field_name = substr($key, 11);
 443+ foreach ( $wgRequest->getValues() as $key => $value ) {
 444+ if ( substr( $key, 0, 11 ) == '_unhandled_' ) {
 445+ $field_name = substr( $key, 11 );
446446 $additional_template_text .= "|$field_name=$value\n";
447447 }
448448 }
@@ -457,21 +457,21 @@
458458 return Xml::expandAttributes( $attribs );
459459 } else {
460460 $out = '';
461 - foreach( $attribs as $name => $val )
 461+ foreach ( $attribs as $name => $val )
462462 $out .= " {$name}=\"" . Sanitizer::encodeAttribute( $val ) . '"';
463463 return $out;
464464 }
465465 }
466466
467 - static function summaryInputHTML($is_disabled, $label = null, $attr = array()) {
 467+ static function summaryInputHTML( $is_disabled, $label = null, $attr = array() ) {
468468 global $sfgTabIndex;
469469
470470 $sfgTabIndex++;
471 - if ($label == null)
472 - $label = wfMsg('summary');
473 - $disabled_text = ($is_disabled) ? " disabled" : "";
474 - $attr = self::expandAttributes($attr);
475 - $text =<<<END
 471+ if ( $label == null )
 472+ $label = wfMsg( 'summary' );
 473+ $disabled_text = ( $is_disabled ) ? " disabled" : "";
 474+ $attr = self::expandAttributes( $attr );
 475+ $text = <<<END
476476 <span id='wpSummaryLabel'><label for='wpSummary'>$label</label></span>
477477 <input tabindex="$sfgTabIndex" type='text' value="" name='wpSummary' id='wpSummary' maxlength='200' size='60'$disabled_text$attr/>
478478
@@ -479,17 +479,17 @@
480480 return $text;
481481 }
482482
483 - static function minorEditInputHTML($is_disabled, $label = null, $attr = array()) {
 483+ static function minorEditInputHTML( $is_disabled, $label = null, $attr = array() ) {
484484 global $sfgTabIndex;
485485
486486 $sfgTabIndex++;
487 - $disabled_text = ($is_disabled) ? " disabled" : "";
488 - if ($label == null)
489 - $label = wfMsgExt('minoredit', array('parseinline'));
490 - $accesskey = wfMsg('accesskey-minoredit');
491 - $tooltip = wfMsg('tooltip-minoredit');
492 - $attr = self::expandAttributes($attr);
493 - $text =<<<END
 487+ $disabled_text = ( $is_disabled ) ? " disabled" : "";
 488+ if ( $label == null )
 489+ $label = wfMsgExt( 'minoredit', array( 'parseinline' ) );
 490+ $accesskey = wfMsg( 'accesskey-minoredit' );
 491+ $tooltip = wfMsg( 'tooltip-minoredit' );
 492+ $attr = self::expandAttributes( $attr );
 493+ $text = <<<END
494494 <input tabindex="$sfgTabIndex" type="checkbox" value="1" name="wpMinoredit" accesskey="$accesskey" id="wpMinoredit"$disabled_text$attr/>
495495 <label for="wpMinoredit" title="$tooltip">$label</label>
496496
@@ -497,30 +497,30 @@
498498 return $text;
499499 }
500500
501 - static function watchInputHTML($is_disabled, $label = null, $attr = array()) {
 501+ static function watchInputHTML( $is_disabled, $label = null, $attr = array() ) {
502502 global $sfgTabIndex, $wgUser, $wgTitle;
503503
504504 $sfgTabIndex++;
505505 $checked_text = "";
506 - $disabled_text = ($is_disabled) ? " disabled" : "";
 506+ $disabled_text = ( $is_disabled ) ? " disabled" : "";
507507 // figure out if the checkbox should be checked -
508508 // this code borrowed from /includes/EditPage.php
509 - if ($wgUser->getOption('watchdefault')) {
 509+ if ( $wgUser->getOption( 'watchdefault' ) ) {
510510 # Watch all edits
511511 $checked_text = " checked";
512 - } elseif ($wgUser->getOption('watchcreations') && !$wgTitle->exists() ) {
 512+ } elseif ( $wgUser->getOption( 'watchcreations' ) && !$wgTitle->exists() ) {
513513 # Watch creations
514514 $checked_text = " checked";
515 - } elseif ($wgTitle->userIsWatching()) {
 515+ } elseif ( $wgTitle->userIsWatching() ) {
516516 # Already watched
517517 $checked_text = " checked";
518518 }
519 - if ($label == null)
520 - $label = wfMsgExt('watchthis', array('parseinline'));
521 - $accesskey = htmlspecialchars(wfMsg('accesskey-watch'));
522 - $tooltip = htmlspecialchars(wfMsg('tooltip-watch'));
523 - $attr = self::expandAttributes($attr);
524 - $text =<<<END
 519+ if ( $label == null )
 520+ $label = wfMsgExt( 'watchthis', array( 'parseinline' ) );
 521+ $accesskey = htmlspecialchars( wfMsg( 'accesskey-watch' ) );
 522+ $tooltip = htmlspecialchars( wfMsg( 'tooltip-watch' ) );
 523+ $attr = self::expandAttributes( $attr );
 524+ $text = <<<END
525525 <input tabindex="$sfgTabIndex" type="checkbox" name="wpWatchthis" accesskey="$accesskey" id='wpWatchthis'$checked_text$disabled_text$attr/>
526526 <label for="wpWatchthis" title="$tooltip">$label</label>
527527
@@ -531,139 +531,139 @@
532532 /**
533533 * Helper function to display a simple button
534534 */
535 - static function buttonHTML($values) {
536 - $button_html = Xml::element('input', $values, '');
 535+ static function buttonHTML( $values ) {
 536+ $button_html = Xml::element( 'input', $values, '' );
537537 return " $button_html\n";
538538 }
539539
540 - static function saveButtonHTML($is_disabled, $label = null, $attr = array()) {
 540+ static function saveButtonHTML( $is_disabled, $label = null, $attr = array() ) {
541541 global $sfgTabIndex;
542542
543543 $sfgTabIndex++;
544 - if ($label == null)
545 - $label = wfMsg('savearticle');
 544+ if ( $label == null )
 545+ $label = wfMsg( 'savearticle' );
546546 $temp = $attr + array(
547547 'id' => 'wpSave',
548548 'name' => 'wpSave',
549549 'type' => 'submit',
550550 'tabindex' => $sfgTabIndex,
551551 'value' => $label,
552 - 'accesskey' => wfMsg('accesskey-save'),
553 - 'title' => wfMsg('tooltip-save'),
 552+ 'accesskey' => wfMsg( 'accesskey-save' ),
 553+ 'title' => wfMsg( 'tooltip-save' ),
554554 );
555555 if ( $is_disabled ) {
556556 $temp['disabled'] = '';
557557 }
558 - return self::buttonHTML($temp);
 558+ return self::buttonHTML( $temp );
559559 }
560560
561 - static function showPreviewButtonHTML($is_disabled, $label = null, $attr = array()) {
 561+ static function showPreviewButtonHTML( $is_disabled, $label = null, $attr = array() ) {
562562 global $sfgTabIndex;
563563
564564 $sfgTabIndex++;
565 - if ($label == null)
566 - $label = wfMsg('showpreview');
 565+ if ( $label == null )
 566+ $label = wfMsg( 'showpreview' );
567567 $temp = $attr + array(
568568 'id' => 'wpPreview',
569569 'name' => 'wpPreview',
570570 'type' => 'submit',
571571 'tabindex' => $sfgTabIndex,
572572 'value' => $label,
573 - 'accesskey' => wfMsg('accesskey-preview'),
574 - 'title' => wfMsg('tooltip-preview'),
 573+ 'accesskey' => wfMsg( 'accesskey-preview' ),
 574+ 'title' => wfMsg( 'tooltip-preview' ),
575575 );
576576 if ( $is_disabled ) {
577577 $temp['disabled'] = '';
578578 }
579 - return self::buttonHTML($temp);
 579+ return self::buttonHTML( $temp );
580580 }
581581
582 - static function showChangesButtonHTML($is_disabled, $label = null, $attr = array()) {
 582+ static function showChangesButtonHTML( $is_disabled, $label = null, $attr = array() ) {
583583 global $sfgTabIndex;
584584
585585 $sfgTabIndex++;
586 - if ($label == null)
587 - $label = wfMsg('showdiff');
 586+ if ( $label == null )
 587+ $label = wfMsg( 'showdiff' );
588588 $temp = $attr + array(
589589 'id' => 'wpDiff',
590590 'name' => 'wpDiff',
591591 'type' => 'submit',
592592 'tabindex' => $sfgTabIndex,
593593 'value' => $label,
594 - 'accesskey' => wfMsg('accesskey-diff'),
595 - 'title' => wfMsg('tooltip-diff'),
 594+ 'accesskey' => wfMsg( 'accesskey-diff' ),
 595+ 'title' => wfMsg( 'tooltip-diff' ),
596596 );
597597 if ( $is_disabled ) {
598598 $temp['disabled'] = '';
599599 }
600 - return self::buttonHTML($temp);
 600+ return self::buttonHTML( $temp );
601601 }
602602
603 - static function cancelLinkHTML($is_disabled, $label = null, $attr = array()) {
 603+ static function cancelLinkHTML( $is_disabled, $label = null, $attr = array() ) {
604604 global $wgUser, $wgTitle;
605605
606606 $sk = $wgUser->getSkin();
607 - if ($label == null)
608 - $label = wfMsgExt('cancel', array('parseinline'));
609 - if ($wgTitle == null)
 607+ if ( $label == null )
 608+ $label = wfMsgExt( 'cancel', array( 'parseinline' ) );
 609+ if ( $wgTitle == null )
610610 $cancel = '';
611611 // if we're on the special 'FormEdit' page, just send the user
612612 // back to the previous page they were on
613 - elseif ($wgTitle->getText() == 'FormEdit'
614 - && $wgTitle->getNamespace() == NS_SPECIAL) {
 613+ elseif ( $wgTitle->getText() == 'FormEdit'
 614+ && $wgTitle->getNamespace() == NS_SPECIAL ) {
615615 $cancel = '<a href="javascript:history.go(-1);">' . $label . '</a>';
616616 } else
617 - $cancel = $sk->makeKnownLink( $wgTitle->getPrefixedText(), $label);
 617+ $cancel = $sk->makeKnownLink( $wgTitle->getPrefixedText(), $label );
618618 $text = " <span class='editHelp'>$cancel</span>\n";
619619 return $text;
620620 }
621621
622 - static function runQueryButtonHTML($is_disabled = false, $label = null, $attr = array()) {
 622+ static function runQueryButtonHTML( $is_disabled = false, $label = null, $attr = array() ) {
623623 // is_disabled is currently ignored
624624 global $sfgTabIndex;
625625
626626 $sfgTabIndex++;
627 - if ($label == null)
628 - $label = wfMsg('runquery');
629 - return self::buttonHTML($attr + array(
 627+ if ( $label == null )
 628+ $label = wfMsg( 'runquery' );
 629+ return self::buttonHTML( $attr + array(
630630 'id' => 'wpRunQuery',
631631 'name' => 'wpRunQuery',
632632 'type' => 'submit',
633633 'tabindex' => $sfgTabIndex,
634634 'value' => $label,
635635 'title' => $label,
636 - ));
 636+ ) );
637637 }
638638
639639 // Much of this function is based on MediaWiki's EditPage::showEditForm()
640 - static function formBottom($is_disabled) {
 640+ static function formBottom( $is_disabled ) {
641641 global $wgUser;
642642
643 - $summary_text = SFFormUtils::summaryInputHTML($is_disabled);
644 - $text =<<<END
 643+ $summary_text = SFFormUtils::summaryInputHTML( $is_disabled );
 644+ $text = <<<END
645645 <br /><br />
646646 <div class='editOptions'>
647647 $summary_text <br />
648648
649649 END;
650 - if ( $wgUser->isAllowed('minoredit') ) {
651 - $text .= SFFormUtils::minorEditInputHTML($is_disabled);
 650+ if ( $wgUser->isAllowed( 'minoredit' ) ) {
 651+ $text .= SFFormUtils::minorEditInputHTML( $is_disabled );
652652 }
653653
654654 if ( $wgUser->isLoggedIn() ) {
655 - $text .= SFFormUtils::watchInputHTML($is_disabled);
 655+ $text .= SFFormUtils::watchInputHTML( $is_disabled );
656656 }
657657
658 - $text .=<<<END
 658+ $text .= <<<END
659659 <br />
660660 <div class='editButtons'>
661661
662662 END;
663 - $text .= SFFormUtils::saveButtonHTML($is_disabled);
664 - $text .= SFFormUtils::showPreviewButtonHTML($is_disabled);
665 - $text .= SFFormUtils::showChangesButtonHTML($is_disabled);
666 - $text .= SFFormUtils::cancelLinkHTML($is_disabled);
667 - $text .=<<<END
 663+ $text .= SFFormUtils::saveButtonHTML( $is_disabled );
 664+ $text .= SFFormUtils::showPreviewButtonHTML( $is_disabled );
 665+ $text .= SFFormUtils::showChangesButtonHTML( $is_disabled );
 666+ $text .= SFFormUtils::cancelLinkHTML( $is_disabled );
 667+ $text .= <<<END
668668 </div><!-- editButtons -->
669669 </div><!-- editOptions -->
670670
@@ -672,24 +672,24 @@
673673 }
674674
675675 // based on MediaWiki's EditPage::getPreloadedText()
676 - static function getPreloadedText($preload) {
 676+ static function getPreloadedText( $preload ) {
677677 if ( $preload === '' ) {
678678 return '';
679679 } else {
680680 $preloadTitle = Title::newFromText( $preload );
681681 if ( isset( $preloadTitle ) && $preloadTitle->userCanRead() ) {
682 - $rev = Revision::newFromTitle($preloadTitle);
 682+ $rev = Revision::newFromTitle( $preloadTitle );
683683 if ( is_object( $rev ) ) {
684684 $text = $rev->getText();
685685 // Remove <noinclude> sections and <includeonly> tags from text
686 - $text = StringUtils::delimiterReplace('<noinclude>', '</noinclude>', '', $text);
687 - $text = strtr($text, array('<includeonly>' => '', '</includeonly>' => ''));
 686+ $text = StringUtils::delimiterReplace( '<noinclude>', '</noinclude>', '', $text );
 687+ $text = strtr( $text, array( '<includeonly>' => '', '</includeonly>' => '' ) );
688688 return $text;
689689 }
690690 }
691691 return '';
692692 }
693 - }
 693+ }
694694
695695 /**
696696 * Used by 'RunQuery' page
@@ -700,18 +700,18 @@
701701
702702 static function getMonthNames() {
703703 return array(
704 - wfMsgForContent('january'),
705 - wfMsgForContent('february'),
706 - wfMsgForContent('march'),
707 - wfMsgForContent('april'),
708 - wfMsgForContent('may'),
709 - wfMsgForContent('june'),
710 - wfMsgForContent('july'),
711 - wfMsgForContent('august'),
712 - wfMsgForContent('september'),
713 - wfMsgForContent('october'),
714 - wfMsgForContent('november'),
715 - wfMsgForContent('december')
 704+ wfMsgForContent( 'january' ),
 705+ wfMsgForContent( 'february' ),
 706+ wfMsgForContent( 'march' ),
 707+ wfMsgForContent( 'april' ),
 708+ wfMsgForContent( 'may' ),
 709+ wfMsgForContent( 'june' ),
 710+ wfMsgForContent( 'july' ),
 711+ wfMsgForContent( 'august' ),
 712+ wfMsgForContent( 'september' ),
 713+ wfMsgForContent( 'october' ),
 714+ wfMsgForContent( 'november' ),
 715+ wfMsgForContent( 'december' )
716716 );
717717 }
718718
@@ -729,43 +729,43 @@
730730 $showFCKEditor += RTE_TOGGLE_LINK;
731731 }
732732
733 - if( (!empty($_SESSION['showMyFCKeditor'])) && ($wgUser->getOption( 'riched_toggle_remember_state' )))
 733+ if ( ( !empty( $_SESSION['showMyFCKeditor'] ) ) && ( $wgUser->getOption( 'riched_toggle_remember_state' ) ) )
734734 {
735 - //clear RTE_VISIBLE flag
 735+ // clear RTE_VISIBLE flag
736736 $showFCKEditor &= ~RTE_VISIBLE ;
737 - //get flag from session
738 - $showFCKEditor |= $_SESSION['showMyFCKeditor'] ;
 737+ // get flag from session
 738+ $showFCKEditor |= $_SESSION['showMyFCKeditor'] ;
739739 }
740740 return $showFCKEditor;
741741 }
742742
743 - static function prepareTextForFCK($text) {
 743+ static function prepareTextForFCK( $text ) {
744744 global $wgTitle;
745745
746746 $options = new FCKeditorParserOptions();
747 - $options->setTidy(true);
 747+ $options->setTidy( true );
748748 $parser = new FCKeditorParser();
749 - $parser->setOutputType(OT_HTML);
750 - $text = $parser->parse($text, $wgTitle, $options)->getText();
 749+ $parser->setOutputType( OT_HTML );
 750+ $text = $parser->parse( $text, $wgTitle, $options )->getText();
751751 return $text;
752752 }
753753
754 - static function mainFCKJavascript($showFCKEditor) {
 754+ static function mainFCKJavascript( $showFCKEditor ) {
755755 global $wgUser, $wgScriptPath, $wgFCKEditorExtDir, $wgFCKEditorDir, $wgFCKEditorToolbarSet, $wgFCKEditorHeight;
756756
757 - $newWinMsg = wfMsg('rich_editor_new_window');
 757+ $newWinMsg = wfMsg( 'rich_editor_new_window' );
758758 $javascript_text = '
759 -var showFCKEditor = '. $showFCKEditor .';
 759+var showFCKEditor = ' . $showFCKEditor . ';
760760 var popup = false; //pointer to popup document
761761 var firstLoad = true;
762 -var editorMsgOn = "'. wfMsg( 'textrichditor' ) .'";
763 -var editorMsgOff = "'. wfMsg( 'tog-riched_disable' ) .'";
764 -var editorLink = "'. (($showFCKEditor & RTE_VISIBLE)? wfMsg( 'tog-riched_disable' ): wfMsg( 'textrichditor' )) .'";
765 -var saveSetting = '. ($wgUser->getOption( 'riched_toggle_remember_state' ) ? 1 : 0) .';
766 -var RTE_VISIBLE = '.RTE_VISIBLE.';
767 -var RTE_TOGGLE_LINK = '.RTE_TOGGLE_LINK.';
768 -var RTE_POPUP = '.RTE_POPUP.';
769 -';
 762+var editorMsgOn = "' . wfMsg( 'textrichditor' ) . '";
 763+var editorMsgOff = "' . wfMsg( 'tog-riched_disable' ) . '";
 764+var editorLink = "' . ( ( $showFCKEditor & RTE_VISIBLE ) ? wfMsg( 'tog-riched_disable' ): wfMsg( 'textrichditor' ) ) . '";
 765+var saveSetting = ' . ( $wgUser->getOption( 'riched_toggle_remember_state' ) ? 1 : 0 ) . ';
 766+var RTE_VISIBLE = ' . RTE_VISIBLE . ';
 767+var RTE_TOGGLE_LINK = ' . RTE_TOGGLE_LINK . ';
 768+var RTE_POPUP = ' . RTE_POPUP . ';
 769+';
770770
771771 $javascript_text .= <<<END
772772 var oFCKeditor = new FCKeditor( "free_text" );
@@ -981,7 +981,7 @@
982982 }
983983
984984 static function FCKToggleJavascript() {
985 - //add toggle link and handler
 985+ // add toggle link and handler
986986 $javascript_text = <<<END
987987
988988 function ToggleFCKEditor(mode, objId)
Index: trunk/extensions/SemanticForms/includes/SF_FormInputs.inc
@@ -14,42 +14,42 @@
1515 * Create a comma-delimited string of values that match the specified
1616 * source name and type, for use by Javascript autocompletion.
1717 */
18 - static function createAutocompleteValuesString($source_name, $source_type) {
 18+ static function createAutocompleteValuesString( $source_name, $source_type ) {
1919 $names_array = array();
2020 // the query depends on whether this is a property, category, concept
2121 // or namespace
22 - if ($source_type == 'property' || $source_type == 'attribute' || $source_type == 'relation') {
23 - $names_array = SFUtils::getAllValuesForProperty($source_name);
24 - } elseif ($source_type == 'category') {
25 - $names_array = SFUtils::getAllPagesForCategory($source_name, 10);
26 - } elseif ($source_type == 'concept') {
27 - $names_array = SFUtils::getAllPagesForConcept($source_name);
 22+ if ( $source_type == 'property' || $source_type == 'attribute' || $source_type == 'relation' ) {
 23+ $names_array = SFUtils::getAllValuesForProperty( $source_name );
 24+ } elseif ( $source_type == 'category' ) {
 25+ $names_array = SFUtils::getAllPagesForCategory( $source_name, 10 );
 26+ } elseif ( $source_type == 'concept' ) {
 27+ $names_array = SFUtils::getAllPagesForConcept( $source_name );
2828 } else { // i.e., $source_type == 'namespace'
2929 // switch back to blank for main namespace
30 - if ($source_name == "Main")
 30+ if ( $source_name == "Main" )
3131 $source_name = "";
32 - $names_array = SFUtils::getAllPagesForNamespace($source_name);
 32+ $names_array = SFUtils::getAllPagesForNamespace( $source_name );
3333 }
3434 // escape quotes, to avoid Javascript errors
35 - $names_array = array_map('addslashes', $names_array);
36 - $autocomplete_string = "[['" . implode("'], ['", $names_array) . "']]";
 35+ $names_array = array_map( 'addslashes', $names_array );
 36+ $autocomplete_string = "[['" . implode( "'], ['", $names_array ) . "']]";
3737 // replace any newlines in the string, just to avoid breaking the Javascript
38 - $autocomplete_string = str_replace("\n", ' ', $autocomplete_string);
39 - $autocomplete_string = str_replace("\r", ' ', $autocomplete_string);
 38+ $autocomplete_string = str_replace( "\n", ' ', $autocomplete_string );
 39+ $autocomplete_string = str_replace( "\r", ' ', $autocomplete_string );
4040 return $autocomplete_string;
4141 }
4242
43 - static function uploadLinkHTML($input_id, $delimiter = null, $default_filename = null) {
44 - $upload_window_page = SpecialPage::getPage('UploadWindow');
 43+ static function uploadLinkHTML( $input_id, $delimiter = null, $default_filename = null ) {
 44+ $upload_window_page = SpecialPage::getPage( 'UploadWindow' );
4545 $query_string = "sfInputID=$input_id";
46 - if ($delimiter != null)
 46+ if ( $delimiter != null )
4747 $query_string .= "&sfDelimiter=$delimiter";
48 - if ($default_filename != null)
 48+ if ( $default_filename != null )
4949 $query_string .= "&wpDestFile=$default_filename";
50 - $upload_window_url = $upload_window_page->getTitle()->getFullURL($query_string);
51 - $upload_label = wfMsg('upload');
 50+ $upload_window_url = $upload_window_page->getTitle()->getFullURL( $query_string );
 51+ $upload_label = wfMsg( 'upload' );
5252 // window needs to be bigger for MediaWiki version 1.16+
53 - if (class_exists('HTMLForm'))
 53+ if ( class_exists( 'HTMLForm' ) )
5454 $style = "width:650 height:500";
5555 else
5656 $style = '';
@@ -57,46 +57,46 @@
5858 return $text;
5959 }
6060
61 - static function textEntryHTML($cur_value, $input_name, $is_mandatory, $is_disabled, $other_args) {
 61+ static function textEntryHTML( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args ) {
6262 // if it's an autocomplete, call the with-autocomplete function instead
63 - if (array_key_exists('autocompletion source', $other_args)) {
64 - return self::textInputWithAutocompleteHTML($cur_value, $input_name, $is_mandatory, $is_disabled, $other_args);
 63+ if ( array_key_exists( 'autocompletion source', $other_args ) ) {
 64+ return self::textInputWithAutocompleteHTML( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args );
6565 }
6666
6767 // if there are possible values specified, call the dropdown function
68 - if (array_key_exists('possible_values', $other_args) && $other_args['possible_values'] != null)
69 - return SFFormInputs::dropdownHTML($cur_value, $input_name, $is_mandatory, $is_disabled, $other_args);
 68+ if ( array_key_exists( 'possible_values', $other_args ) && $other_args['possible_values'] != null )
 69+ return SFFormInputs::dropdownHTML( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args );
7070
7171 global $sfgTabIndex, $sfgFieldNum, $sfgJSValidationCalls;
7272
73 - $className = ($is_mandatory) ? "createboxInput mandatoryField" : "createboxInput";
74 - if (array_key_exists('class', $other_args))
 73+ $className = ( $is_mandatory ) ? "createboxInput mandatoryField" : "createboxInput";
 74+ if ( array_key_exists( 'class', $other_args ) )
7575 $className .= " " . $other_args['class'];
7676 $input_id = "input_$sfgFieldNum";
7777 $info_id = "info_$sfgFieldNum";
7878 // set size based on pre-set size, or field type - if field type is set,
7979 // possibly add validation too
80 - if (array_key_exists('size', $other_args)) {
 80+ if ( array_key_exists( 'size', $other_args ) ) {
8181 $size = $other_args['size'];
82 - } elseif (array_key_exists('field_type', $other_args)) {
 82+ } elseif ( array_key_exists( 'field_type', $other_args ) ) {
8383 $validation_type_str = "";
84 - if ($other_args['field_type'] == 'integer') {
 84+ if ( $other_args['field_type'] == 'integer' ) {
8585 $size = 10;
8686 $validation_type_str = 'integer';
87 - } elseif ($other_args['field_type'] == 'number') {
 87+ } elseif ( $other_args['field_type'] == 'number' ) {
8888 $size = 10;
8989 $validation_type_str = 'number';
90 - } elseif ($other_args['field_type'] == 'URL') {
 90+ } elseif ( $other_args['field_type'] == 'URL' ) {
9191 $size = 100;
9292 $validation_type_str = 'URL';
93 - } elseif ($other_args['field_type'] == 'email') {
 93+ } elseif ( $other_args['field_type'] == 'email' ) {
9494 $size = 45;
9595 $validation_type_str = 'email';
9696 } else {
9797 $size = 35;
9898 }
99 - if ($validation_type_str != '') {
100 - if (array_key_exists('part_of_multiple', $other_args)) {
 99+ if ( $validation_type_str != '' ) {
 100+ if ( array_key_exists( 'part_of_multiple', $other_args ) ) {
101101 $sfgJSValidationCalls[] = "validate_type_of_multiple_fields($sfgFieldNum, '$validation_type_str')";
102102 } else {
103103 $sfgJSValidationCalls[] = "validate_field_type('$input_id', '$validation_type_str', '$info_id')";
@@ -105,24 +105,24 @@
106106 } else {
107107 $size = 35;
108108 }
109 - if (! is_null($cur_value) && ! is_array($cur_value))
110 - $cur_value = htmlspecialchars($cur_value);
 109+ if ( ! is_null( $cur_value ) && ! is_array( $cur_value ) )
 110+ $cur_value = htmlspecialchars( $cur_value );
111111
112 - $text =<<<END
 112+ $text = <<<END
113113 <input id="$input_id" tabindex="$sfgTabIndex" class="$className" name="$input_name" type="text" value="$cur_value" size="$size"
114114 END;
115 - if ($is_disabled)
 115+ if ( $is_disabled )
116116 $text .= " disabled";
117 - if (array_key_exists('maxlength', $other_args))
 117+ if ( array_key_exists( 'maxlength', $other_args ) )
118118 $text .= ' maxlength="' . $other_args['maxlength'] . '"';
119 - $text .=<<<END
 119+ $text .= <<<END
120120 />
121121 <span id="$info_id" class="errorMessage"></span>
122122
123123 END;
124 - if (array_key_exists('is_uploadable', $other_args) && $other_args['is_uploadable'] == true) {
125 - if (array_key_exists('is_list', $other_args) && $other_args['is_list'] == true) {
126 - if (array_key_exists('delimiter', $other_args)) {
 124+ if ( array_key_exists( 'is_uploadable', $other_args ) && $other_args['is_uploadable'] == true ) {
 125+ if ( array_key_exists( 'is_list', $other_args ) && $other_args['is_list'] == true ) {
 126+ if ( array_key_exists( 'delimiter', $other_args ) ) {
127127 $delimiter = $other_args['delimiter'];
128128 } else {
129129 $delimiter = ",";
@@ -130,109 +130,109 @@
131131 } else {
132132 $delimiter = null;
133133 }
134 - if (array_key_exists('default filename', $other_args)) {
 134+ if ( array_key_exists( 'default filename', $other_args ) ) {
135135 $default_filename = $other_args['default filename'];
136136 } else {
137137 $default_filename = "";
138138 }
139 - $text .= SFFormInputs::uploadLinkHTML($input_id, $delimiter, $default_filename);
 139+ $text .= SFFormInputs::uploadLinkHTML( $input_id, $delimiter, $default_filename );
140140 }
141 - return array($text, null);
 141+ return array( $text, null );
142142 }
143143
144 - static function dropdownHTML($cur_value, $input_name, $is_mandatory, $is_disabled, $other_args) {
 144+ static function dropdownHTML( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args ) {
145145 global $sfgTabIndex, $sfgFieldNum;
146146
147 - $className = ($is_mandatory) ? "mandatoryField" : "createboxInput";
148 - if (array_key_exists('class', $other_args))
 147+ $className = ( $is_mandatory ) ? "mandatoryField" : "createboxInput";
 148+ if ( array_key_exists( 'class', $other_args ) )
149149 $className .= " " . $other_args['class'];
150150 $input_id = "input_$sfgFieldNum";
151151 $info_id = "info_$sfgFieldNum";
152 - $disabled_text = ($is_disabled) ? "disabled" : "";
 152+ $disabled_text = ( $is_disabled ) ? "disabled" : "";
153153 $javascript_text = '';
154154 $return_js_text = '';
155 - if (array_key_exists('show on select', $other_args)) {
 155+ if ( array_key_exists( 'show on select', $other_args ) ) {
156156 $javascript_text = 'onChange="';
157 - foreach ($other_args['show on select'] as $div_id => $options) {
158 - $options_str = implode("', '", $options);
 157+ foreach ( $other_args['show on select'] as $div_id => $options ) {
 158+ $options_str = implode( "', '", $options );
159159 $this_js_text = "showIfSelected('$input_id', ['$options_str'], '$div_id'); ";
160160 $javascript_text .= $this_js_text;
161161 $return_js_text .= $this_js_text . "\n";
162162 }
163163 $javascript_text .= '"';
164164 }
165 - $text =<<<END
 165+ $text = <<<END
166166 <select id="$input_id" tabindex="$sfgTabIndex" name="$input_name" class="$className" $disabled_text $javascript_text>
167167
168168 END;
169169 // add a blank value at the beginning, unless this is a mandatory field
170170 // and there's a current value in place (either through a default value
171171 // or because we're editing an existing page)
172 - if (! $is_mandatory || $cur_value == '') {
 172+ if ( ! $is_mandatory || $cur_value == '' ) {
173173 $text .= " <option value=\"\"></option>\n";
174174 }
175 - if (($possible_values = $other_args['possible_values']) == null)
176 - $possible_values = array();
177 - foreach ($possible_values as $possible_value) {
 175+ if ( ( $possible_values = $other_args['possible_values'] ) == null )
 176+ $possible_values = array();
 177+ foreach ( $possible_values as $possible_value ) {
178178 $text .= " <option value=\"$possible_value\"";
179 - if ($possible_value == $cur_value) {$text .= " selected=\"selected\""; }
 179+ if ( $possible_value == $cur_value ) { $text .= " selected=\"selected\""; }
180180 $text .= ">";
181 - if (array_key_exists('value_labels', $other_args) && is_array($other_args['value_labels']) && array_key_exists($possible_value, $other_args['value_labels']))
182 - $text .= htmlspecialchars($other_args['value_labels'][$possible_value]);
 181+ if ( array_key_exists( 'value_labels', $other_args ) && is_array( $other_args['value_labels'] ) && array_key_exists( $possible_value, $other_args['value_labels'] ) )
 182+ $text .= htmlspecialchars( $other_args['value_labels'][$possible_value] );
183183 else
184184 $text .= $possible_value;
185185 $text .= "</option>\n";
186186 }
187 - $text .=<<<END
 187+ $text .= <<<END
188188 </select>
189189 <span id="$info_id" class="errorMessage"></span>
190190
191191 END;
192 - return array($text, $return_js_text);
 192+ return array( $text, $return_js_text );
193193 }
194194
195195 /**
196196 * Helper function to get an array of values out of what may be either
197197 * an array or a delimited string
198198 */
199 - static function getValuesArray($value, $delimiter) {
200 - if (is_array($value)) {
 199+ static function getValuesArray( $value, $delimiter ) {
 200+ if ( is_array( $value ) ) {
201201 return $value;
202202 } else {
203203 // remove extra spaces
204 - return array_map('trim', explode($delimiter, $value));
 204+ return array_map( 'trim', explode( $delimiter, $value ) );
205205 }
206206 }
207207
208 - static function listboxHTML($cur_value, $input_name, $is_mandatory, $is_disabled, $other_args) {
 208+ static function listboxHTML( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args ) {
209209 global $sfgTabIndex, $sfgFieldNum;
210210
211 - $className = ($is_mandatory) ? "mandatoryField" : "createboxInput";
212 - if (array_key_exists('class', $other_args))
 211+ $className = ( $is_mandatory ) ? "mandatoryField" : "createboxInput";
 212+ if ( array_key_exists( 'class', $other_args ) )
213213 $className .= " " . $other_args['class'];
214214 $input_id = "input_$sfgFieldNum";
215215 $info_id = "info_$sfgFieldNum";
216216 $hidden_input_name = $input_name . "[is_list]";
217217 $input_name .= "[]"; // needed so that this input will send an array
218 - if (array_key_exists('size', $other_args))
219 - $size_text = "size=". $other_args['size'];
 218+ if ( array_key_exists( 'size', $other_args ) )
 219+ $size_text = "size=" . $other_args['size'];
220220 else
221221 $size_text = "";
222 - $disabled_text = ($is_disabled) ? "disabled" : "";
 222+ $disabled_text = ( $is_disabled ) ? "disabled" : "";
223223 // get list delimiter - default is comma
224 - if (array_key_exists('delimiter', $other_args)) {
 224+ if ( array_key_exists( 'delimiter', $other_args ) ) {
225225 $delimiter = $other_args['delimiter'];
226226 } else {
227227 $delimiter = ",";
228228 }
229 - $cur_values = self::getValuesArray($cur_value, $delimiter);
 229+ $cur_values = self::getValuesArray( $cur_value, $delimiter );
230230
231231 $javascript_text = '';
232232 $return_js_text = '';
233 - if (array_key_exists('show on select', $other_args)) {
 233+ if ( array_key_exists( 'show on select', $other_args ) ) {
234234 $javascript_text = 'onChange="';
235 - foreach ($other_args['show on select'] as $div_id => $options) {
236 - $options_str = implode("', '", $options);
 235+ foreach ( $other_args['show on select'] as $div_id => $options ) {
 236+ $options_str = implode( "', '", $options );
237237 $this_js_text = "showIfSelected('$input_id', ['$options_str'], '$div_id'); ";
238238 $javascript_text .= $this_js_text;
239239 $return_js_text .= $this_js_text . "\n";
@@ -240,71 +240,71 @@
241241 $javascript_text .= '"';
242242 }
243243
244 - $text =<<<END
 244+ $text = <<<END
245245 <select id="$input_id" tabindex="$sfgTabIndex" name="$input_name" class="$className" multiple $size_text $disabled_text $javascript_text>
246246
247247 END;
248 - if (($possible_values = $other_args['possible_values']) == null)
249 - $possible_values = array();
250 - foreach ($possible_values as $possible_value) {
 248+ if ( ( $possible_values = $other_args['possible_values'] ) == null )
 249+ $possible_values = array();
 250+ foreach ( $possible_values as $possible_value ) {
251251 $text .= " <option value=\"$possible_value\"";
252 - if (in_array($possible_value, $cur_values)) {$text .= " selected"; }
 252+ if ( in_array( $possible_value, $cur_values ) ) { $text .= " selected"; }
253253 $text .= ">";
254 - if (array_key_exists('value_labels', $other_args) && is_array($other_args['value_labels']) && array_key_exists($possible_value, $other_args['value_labels']))
255 - $text .= htmlspecialchars($other_args['value_labels'][$possible_value]);
 254+ if ( array_key_exists( 'value_labels', $other_args ) && is_array( $other_args['value_labels'] ) && array_key_exists( $possible_value, $other_args['value_labels'] ) )
 255+ $text .= htmlspecialchars( $other_args['value_labels'][$possible_value] );
256256 else
257257 $text .= $possible_value;
258258 $text .= "</option>\n";
259259 }
260 - $text .=<<<END
 260+ $text .= <<<END
261261 </select>
262262 <span id="$info_id" class="errorMessage"></span>
263263 <input type="hidden" name="$hidden_input_name" value="1" />
264264
265265 END;
266 - return array($text, $return_js_text);
 266+ return array( $text, $return_js_text );
267267 }
268268
269 - static function checkboxesHTML($cur_value, $input_name, $is_mandatory, $is_disabled, $other_args) {
 269+ static function checkboxesHTML( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args ) {
270270 global $sfgTabIndex, $sfgFieldNum;
271271
272 - $checkbox_class = ($is_mandatory) ? "mandatoryField" : "createboxInput";
 272+ $checkbox_class = ( $is_mandatory ) ? "mandatoryField" : "createboxInput";
273273 $span_class = "checkboxSpan";
274 - if (array_key_exists('class', $other_args))
 274+ if ( array_key_exists( 'class', $other_args ) )
275275 $span_class .= " " . $other_args['class'];
276276 $input_id = "input_$sfgFieldNum";
277277 $info_id = "info_$sfgFieldNum";
278278 $hidden_input_name = $input_name . "[is_list]";
279 - $disabled_text = ($is_disabled) ? "disabled" : "";
 279+ $disabled_text = ( $is_disabled ) ? "disabled" : "";
280280 // get list delimiter - default is comma
281 - if (array_key_exists('delimiter', $other_args)) {
 281+ if ( array_key_exists( 'delimiter', $other_args ) ) {
282282 $delimiter = $other_args['delimiter'];
283283 } else {
284284 $delimiter = ",";
285285 }
286 - $cur_values = self::getValuesArray($cur_value, $delimiter);
 286+ $cur_values = self::getValuesArray( $cur_value, $delimiter );
287287
288 - if (($possible_values = $other_args['possible_values']) == null)
289 - $possible_values = array();
 288+ if ( ( $possible_values = $other_args['possible_values'] ) == null )
 289+ $possible_values = array();
290290 $text = "";
291291 $return_js_text = "";
292292 $enum_input_ids = array();
293293 // if it's mandatory, add a span around all the checkboxes, since
294294 // some browsers don't support formatting of checkboxes
295 - if ($is_mandatory)
 295+ if ( $is_mandatory )
296296 $text .= ' <span class="mandatoryFieldsSpan">' . "\n";
297 - foreach ($possible_values as $key => $possible_value) {
 297+ foreach ( $possible_values as $key => $possible_value ) {
298298 // create array $enum_input_ids to associate values with their input IDs,
299299 // for use in creating the 'show on select' Javascript later
300300 $enum_input_ids[$possible_value] = $input_id;
301301 $cur_input_name = $input_name . "[" . $key . "]";
302 - $checked_text = (in_array($possible_value, $cur_values)) ? 'checked="checked"' : "";
 302+ $checked_text = ( in_array( $possible_value, $cur_values ) ) ? 'checked="checked"' : "";
303303
304 - if (array_key_exists('value_labels', $other_args) && is_array($other_args['value_labels']) && array_key_exists($possible_value, $other_args['value_labels']))
305 - $label = htmlspecialchars($other_args['value_labels'][$possible_value]);
 304+ if ( array_key_exists( 'value_labels', $other_args ) && is_array( $other_args['value_labels'] ) && array_key_exists( $possible_value, $other_args['value_labels'] ) )
 305+ $label = htmlspecialchars( $other_args['value_labels'][$possible_value] );
306306 else
307307 $label = $possible_value;
308 - $text .=<<<END
 308+ $text .= <<<END
309309 <span class="$span_class"><input type="checkbox" id="$input_id" tabindex="$sfgTabIndex" name="$cur_input_name" value="$possible_value" class="$checkbox_class" $checked_text $disabled_text/> $label</span>
310310
311311 END;
@@ -313,33 +313,33 @@
314314 $input_id = "input_$sfgFieldNum";
315315 }
316316 // close span
317 - if ($is_mandatory)
 317+ if ( $is_mandatory )
318318 $text .= " </span>";
319 - $text .=<<<END
 319+ $text .= <<<END
320320 <span id="$info_id" class="errorMessage"></span>
321321 <input type="hidden" name="$hidden_input_name" value="1" />
322322
323323 END;
324324
325325 $return_js_text = '';
326 - if (array_key_exists('show on select', $other_args)) {
327 - foreach ($other_args['show on select'] as $div_id => $options) {
 326+ if ( array_key_exists( 'show on select', $other_args ) ) {
 327+ foreach ( $other_args['show on select'] as $div_id => $options ) {
328328 $cur_input_ids = array();
329 - foreach ($options as $option) {
330 - if (array_key_exists($option, $enum_input_ids)) {
 329+ foreach ( $options as $option ) {
 330+ if ( array_key_exists( $option, $enum_input_ids ) ) {
331331 $cur_input_ids[] = $enum_input_ids[$option];
332332 }
333333 }
334 - $options_str = "['" . implode("', '", $cur_input_ids) . "']";
 334+ $options_str = "['" . implode( "', '", $cur_input_ids ) . "']";
335335 $cur_js_text = "showIfChecked($options_str, '$div_id'); ";
336336 $return_js_text .= $cur_js_text . "\n";
337 - foreach ($possible_values as $key => $possible_value) {
 337+ foreach ( $possible_values as $key => $possible_value ) {
338338 $cur_input_id = $enum_input_ids[$possible_value];
339339 // we use addClickHandler(), instead of adding the Javascript via
340340 // onClick="", because MediaWiki's wikibits.js does its own handling
341341 // of checkboxes, which impacts their behavior in IE
342 - if (in_array($possible_value, $options)) {
343 - $return_js_text .=<<<END
 342+ if ( in_array( $possible_value, $options ) ) {
 343+ $return_js_text .= <<<END
344344 addClickHandler(
345345 document.getElementById('$cur_input_id'),
346346 function() { $cur_js_text }
@@ -352,44 +352,44 @@
353353 }
354354
355355 // do the replacements
356 - foreach ($enum_input_ids as $enum_val => $input_id) {
357 - $return_js_text = str_replace("<<$enum_val>>", "'$input_id'", $return_js_text);
 356+ foreach ( $enum_input_ids as $enum_val => $input_id ) {
 357+ $return_js_text = str_replace( "<<$enum_val>>", "'$input_id'", $return_js_text );
358358 }
359 - return array($text, $return_js_text);
 359+ return array( $text, $return_js_text );
360360 }
361361
362 - static function textInputWithAutocompleteHTML($cur_value, $input_name, $is_mandatory, $is_disabled, $other_args) {
 362+ static function textInputWithAutocompleteHTML( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args ) {
363363 // if 'no autocomplete' was specified, print a regular text entry instead
364 - if (array_key_exists('no autocomplete', $other_args) &&
365 - $other_args['no autocomplete'] == true) {
366 - unset($other_args['autocompletion source']);
367 - return SFFormInputs::textEntryHTML($cur_value, $input_name, $is_mandatory, $is_disabled, $other_args);
 364+ if ( array_key_exists( 'no autocomplete', $other_args ) &&
 365+ $other_args['no autocomplete'] == true ) {
 366+ unset( $other_args['autocompletion source'] );
 367+ return SFFormInputs::textEntryHTML( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args );
368368 }
369369 // if a set of values was specified, print a dropdown instead
370 - if (array_key_exists('possible_values', $other_args) && $other_args['possible_values'] != null)
371 - return SFFormInputs::dropdownHTML($cur_value, $input_name, $is_mandatory, $is_disabled, $other_args);
 370+ if ( array_key_exists( 'possible_values', $other_args ) && $other_args['possible_values'] != null )
 371+ return SFFormInputs::dropdownHTML( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args );
372372
373373 global $sfgTabIndex, $sfgFieldNum;
374374
375 - $className = ($is_mandatory) ? "autocompleteInput mandatoryField" : "autocompleteInput createboxInput";
376 - if (array_key_exists('class', $other_args))
 375+ $className = ( $is_mandatory ) ? "autocompleteInput mandatoryField" : "autocompleteInput createboxInput";
 376+ if ( array_key_exists( 'class', $other_args ) )
377377 $className .= " " . $other_args['class'];
378 - $disabled_text = ($is_disabled) ? "disabled" : "";
379 - if (array_key_exists('autocomplete field type', $other_args)) {
 378+ $disabled_text = ( $is_disabled ) ? "disabled" : "";
 379+ if ( array_key_exists( 'autocomplete field type', $other_args ) ) {
380380 $autocomplete_field_type = $other_args['autocomplete field type'];
381381 $autocompletion_source = $other_args['autocompletion source'];
382 - if ($autocomplete_field_type != 'external_url') {
 382+ if ( $autocomplete_field_type != 'external_url' ) {
383383 global $wgContLang;
384 - $autocompletion_source = $wgContLang->ucfirst($autocompletion_source);
 384+ $autocompletion_source = $wgContLang->ucfirst( $autocompletion_source );
385385 }
386386 }
387387 $input_id = "input_" . $sfgFieldNum;
388388 $info_id = "info_" . $sfgFieldNum;
389389 $div_name = "div_" . $sfgFieldNum;
390 - if (array_key_exists('input_type', $other_args) && $other_args['input_type'] == "textarea") {
 390+ if ( array_key_exists( 'input_type', $other_args ) && $other_args['input_type'] == "textarea" ) {
391391 $rows = $other_args['rows'];
392392 $cols = $other_args['cols'];
393 - if (array_key_exists('maxlength', $other_args)) {
 393+ if ( array_key_exists( 'maxlength', $other_args ) ) {
394394 $maxlength = $other_args['maxlength'];
395395 // is this an unnecessary performance load? Get the substring of the
396396 // text on every key press or release, regardless of the current length
@@ -398,29 +398,29 @@
399399 } else {
400400 $js_call = "";
401401 }
402 - $text =<<<END
 402+ $text = <<<END
403403 <textarea tabindex="$sfgTabIndex" id="$input_id" name="$input_name" rows="$rows" cols="$cols" class="$className" $disabled_text $js_call></textarea>
404404
405405 END;
406406 } else {
407 - if (array_key_exists('size', $other_args))
 407+ if ( array_key_exists( 'size', $other_args ) )
408408 $size = $other_args['size'];
409409 else
410410 $size = "35";
411411
412 - $text =<<<END
 412+ $text = <<<END
413413 <input tabindex="$sfgTabIndex" id="$input_id" name="$input_name" type="text" value="" size="$size" class="$className"
414414 END;
415 - if ($is_disabled)
 415+ if ( $is_disabled )
416416 $text .= " disabled";
417 - if (array_key_exists('maxlength', $other_args))
 417+ if ( array_key_exists( 'maxlength', $other_args ) )
418418 $text .= ' maxlength="' . $other_args['maxlength'] . '"';
419419 $text .= "/>\n";
420420 }
421421 // is_list and delimiter variables - needed later
422 - $is_list = (array_key_exists('is_list', $other_args) && $other_args['is_list'] == true);
423 - if ($is_list) {
424 - if (array_key_exists('delimiter', $other_args)) {
 422+ $is_list = ( array_key_exists( 'is_list', $other_args ) && $other_args['is_list'] == true );
 423+ if ( $is_list ) {
 424+ if ( array_key_exists( 'delimiter', $other_args ) ) {
425425 $delimiter = $other_args['delimiter'];
426426 } else {
427427 $delimiter = ",";
@@ -428,72 +428,72 @@
429429 } else {
430430 $delimiter = null;
431431 }
432 - if (array_key_exists('is_uploadable', $other_args) && $other_args['is_uploadable'] == true) {
433 - if (array_key_exists('default filename', $other_args)) {
 432+ if ( array_key_exists( 'is_uploadable', $other_args ) && $other_args['is_uploadable'] == true ) {
 433+ if ( array_key_exists( 'default filename', $other_args ) ) {
434434 $default_filename = $other_args['default filename'];
435435 } else {
436436 $default_filename = "";
437437 }
438 - $text .= SFFormInputs::uploadLinkHTML($input_id, $delimiter, $default_filename);
 438+ $text .= SFFormInputs::uploadLinkHTML( $input_id, $delimiter, $default_filename );
439439 }
440 - $text .=<<<END
 440+ $text .= <<<END
441441 <span id="$info_id" class="errorMessage"></span>
442442 <div class="page_name_auto_complete" id="$div_name"></div>
443443 <script type="text/javascript">/* <![CDATA[ */
444444
445445 END;
446 - $options_str_key = str_replace("'", "\'", $autocompletion_source);
447 - if ($is_list) {
 446+ $options_str_key = str_replace( "'", "\'", $autocompletion_source );
 447+ if ( $is_list ) {
448448 $options_str_key .= ",list";
449 - if ($delimiter != ",") {
 449+ if ( $delimiter != "," ) {
450450 $options_str_key .= "," . $delimiter;
451451 }
452452 }
453453 $javascript_text = "autocompletemappings[$sfgFieldNum] = '$options_str_key';\n";
454 - if (array_key_exists('remote autocompletion', $other_args) &&
455 - $other_args['remote autocompletion'] == true) {
 454+ if ( array_key_exists( 'remote autocompletion', $other_args ) &&
 455+ $other_args['remote autocompletion'] == true ) {
456456 $javascript_text .= "autocompletedatatypes['$options_str_key'] = '$autocomplete_field_type';\n";
457 - } elseif ($autocompletion_source != '') {
458 - $autocomplete_string = self::createAutocompleteValuesString($autocompletion_source, $autocomplete_field_type);
 457+ } elseif ( $autocompletion_source != '' ) {
 458+ $autocomplete_string = self::createAutocompleteValuesString( $autocompletion_source, $autocomplete_field_type );
459459 $javascript_text .= "autocompletestrings['$options_str_key'] = $autocomplete_string;\n";
460460 }
461 - if ($cur_value) {
 461+ if ( $cur_value ) {
462462 // replace various values to not break the Javascript
463 - $cur_value = str_replace('"', '\"', $cur_value);
464 - $cur_value = str_replace("\n", '\n', $cur_value);
465 - $cur_value = str_replace("\r", '\r', $cur_value);
 463+ $cur_value = str_replace( '"', '\"', $cur_value );
 464+ $cur_value = str_replace( "\n", '\n', $cur_value );
 465+ $cur_value = str_replace( "\r", '\r', $cur_value );
466466 $text .= "document.getElementById('$input_id').value = \"$cur_value\"\n";
467467 }
468468 $text .= "/* ]]> */</script>\n";
469 - return array($text, $javascript_text);
 469+ return array( $text, $javascript_text );
470470 }
471471
472 - static function textAreaHTML($cur_value, $input_name, $is_mandatory, $is_disabled, $other_args) {
 472+ static function textAreaHTML( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args ) {
473473 // set size values
474 - if (! array_key_exists('rows', $other_args))
 474+ if ( ! array_key_exists( 'rows', $other_args ) )
475475 $other_args['rows'] = 5;
476 - if (! array_key_exists('cols', $other_args))
 476+ if ( ! array_key_exists( 'cols', $other_args ) )
477477 $other_args['cols'] = 80;
478478
479479 // if it's an autocomplete, call the with-autocomplete function instead
480 - if (array_key_exists('autocompletion source', $other_args)) {
 480+ if ( array_key_exists( 'autocompletion source', $other_args ) ) {
481481 $other_args['input_type'] = "textarea";
482 - return SFFormInputs::textInputWithAutocompleteHTML($cur_value, $input_name, $is_mandatory, $is_disabled, $other_args);
 482+ return SFFormInputs::textInputWithAutocompleteHTML( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args );
483483 }
484484
485485 global $sfgTabIndex, $sfgFieldNum;
486486
487 - $className = ($is_mandatory) ? "mandatoryField" : "createboxInput";
488 - if (array_key_exists('class', $other_args))
 487+ $className = ( $is_mandatory ) ? "mandatoryField" : "createboxInput";
 488+ if ( array_key_exists( 'class', $other_args ) )
489489 $className .= " " . $other_args['class'];
490490 $info_id = "info_$sfgFieldNum";
491491 // use a special ID for the free text field, for FCK's needs
492492 $input_id = $input_name == "free_text" ? "free_text" : "input_$sfgFieldNum";
493 - $disabled_text = ($is_disabled) ? "disabled" : "";
 493+ $disabled_text = ( $is_disabled ) ? "disabled" : "";
494494
495495 $rows = $other_args['rows'];
496496 $cols = $other_args['cols'];
497 - if (array_key_exists('maxlength', $other_args)) {
 497+ if ( array_key_exists( 'maxlength', $other_args ) ) {
498498 $maxlength = $other_args['maxlength'];
499499 // is this an unnecessary performance load? Get the substring of the
500500 // text on every key press or release, regardless of the current length
@@ -503,60 +503,60 @@
504504 $js_call = "";
505505 }
506506
507 - $cur_value = htmlspecialchars($cur_value);
508 - $text =<<<END
 507+ $cur_value = htmlspecialchars( $cur_value );
 508+ $text = <<<END
509509 <textarea tabindex="$sfgTabIndex" id="$input_id" name="$input_name" rows="$rows" cols="$cols" class="$className" $disabled_text $js_call>$cur_value</textarea>
510510 <span id="$info_id" class="errorMessage"></span>
511511
512512 END;
513 - return array($text, null);
 513+ return array( $text, null );
514514 }
515515
516 - static function monthDropdownHTML($cur_month, $input_name, $is_disabled) {
 516+ static function monthDropdownHTML( $cur_month, $input_name, $is_disabled ) {
517517 global $sfgTabIndex, $sfgFieldNum, $wgAmericanDates;
518518
519 - $disabled_text = ($is_disabled) ? "disabled" : "";
 519+ $disabled_text = ( $is_disabled ) ? "disabled" : "";
520520 $text = ' <select tabindex="' . $sfgTabIndex . '" id="input_' . $sfgFieldNum . '_month" name="' . $input_name . "[month]\" $disabled_text>\n";
521521 $month_names = SFFormUtils::getMonthNames();
522 - foreach ($month_names as $i => $name) {
 522+ foreach ( $month_names as $i => $name ) {
523523 // pad out month to always be two digits
524 - $month_value = ($wgAmericanDates == true) ? $name : str_pad($i + 1, 2, "0", STR_PAD_LEFT);
 524+ $month_value = ( $wgAmericanDates == true ) ? $name : str_pad( $i + 1, 2, "0", STR_PAD_LEFT );
525525 $text .= " <option value=\"$month_value\"";
526 - if ($name == $cur_month || ($i + 1) == $cur_month) {$text .= " selected=\"selected\""; }
 526+ if ( $name == $cur_month || ( $i + 1 ) == $cur_month ) { $text .= " selected=\"selected\""; }
527527 $text .= ">$name</option>\n";
528528 }
529529 $text .= " </select>\n";
530530 return $text;
531531 }
532532
533 - static function dateEntryHTML($date, $input_name, $is_mandatory, $is_disabled, $other_args) {
 533+ static function dateEntryHTML( $date, $input_name, $is_mandatory, $is_disabled, $other_args ) {
534534 global $sfgTabIndex, $sfgFieldNum, $sfgJSValidationCalls, $wgAmericanDates;
535535
536536 $input_id = "input_$sfgFieldNum";
537537 $info_id = "info_$sfgFieldNum";
538538 // add to validation calls
539 - if (array_key_exists('part_of_multiple', $other_args)) {
 539+ if ( array_key_exists( 'part_of_multiple', $other_args ) ) {
540540 $sfgJSValidationCalls[] = "validate_type_of_multiple_fields($sfgFieldNum, 'date')";
541541 } else {
542542 $sfgJSValidationCalls[] = "validate_field_type('$input_id', 'date', '$info_id')";
543543 }
544544
545 - if ($date) {
 545+ if ( $date ) {
546546 // can show up here either as an array or a string, depending on
547547 // whether it came from user input or a wiki page
548 - if (is_array($date)) {
 548+ if ( is_array( $date ) ) {
549549 $year = $date['year'];
550550 $month = $date['month'];
551551 $day = $date['day'];
552552 } else {
553553 // handle 'default=now'
554 - if ($date == 'now') $date = date('Y/m/d');
555 - $actual_date = new SMWTimeValue('_dat');
556 - $actual_date->setUserValue($date);
 554+ if ( $date == 'now' ) $date = date( 'Y/m/d' );
 555+ $actual_date = new SMWTimeValue( '_dat' );
 556+ $actual_date->setUserValue( $date );
557557 $year = $actual_date->getYear();
558558 // TODO - the code to convert from negative to BC notation should
559559 // be in SMW itself
560 - if ($year < 0) {$year = ($year * -1 + 1) . " BC";}
 560+ if ( $year < 0 ) { $year = ( $year * - 1 + 1 ) . " BC"; }
561561 $month = $actual_date->getMonth();
562562 $day = $actual_date->getDay();
563563 }
@@ -567,50 +567,50 @@
568568 $day = null; // no need for day
569569 }
570570 $text = "";
571 - $disabled_text = ($is_disabled) ? "disabled" : "";
572 - if ($wgAmericanDates) {
573 - $text .= SFFormInputs::monthDropdownHTML($month, $input_name, $is_disabled);
 571+ $disabled_text = ( $is_disabled ) ? "disabled" : "";
 572+ if ( $wgAmericanDates ) {
 573+ $text .= SFFormInputs::monthDropdownHTML( $month, $input_name, $is_disabled );
574574 $text .= ' <input tabindex="' . $sfgTabIndex . '" id="' . $input_id . '_day" name="' . $input_name . '[day]" type="text" value="' . $day . '" size="2" ' . $disabled_text . '/>' . "\n";
575575 } else {
576576 $text .= ' <input tabindex="' . $sfgTabIndex . '" id="' . $input_id . '_day" name="' . $input_name . '[day]" type="text" value="' . $day . '" size="2" ' . $disabled_text . '/>' . "\n";
577 - $text .= SFFormInputs::monthDropdownHTML($month, $input_name, $is_disabled);
 577+ $text .= SFFormInputs::monthDropdownHTML( $month, $input_name, $is_disabled );
578578 }
579579 $text .= ' <input tabindex="' . $sfgTabIndex . '" id="' . $input_id . '_year" name="' . $input_name . '[year]" type="text" value="' . $year . '" size="4" ' . $disabled_text . '/>' . "\n";
580580 $text .= " <span id=\"$info_id\" class=\"errorMessage\"></span>";
581 - return array($text, null);
 581+ return array( $text, null );
582582 }
583583
584 - static function dateTimeEntryHTML($datetime, $input_name, $is_mandatory, $is_disabled, $other_args) {
 584+ static function dateTimeEntryHTML( $datetime, $input_name, $is_mandatory, $is_disabled, $other_args ) {
585585 global $sfgTabIndex, $sfg24HourTime;
586586
587587 $include_timezone = $other_args['include_timezone'];
588588
589 - if ($datetime) {
 589+ if ( $datetime ) {
590590 // can show up here either as an array or a string, depending on
591591 // whether it came from user input or a wiki page
592 - if (is_array($datetime)) {
593 - if (isset($datetime['hour'])) $hour = $datetime['hour'];
594 - if (isset($datetime['minute'])) $minute = $datetime['minute'];
595 - if (isset($datetime['second'])) $second = $datetime['second'];
596 - if (! $sfg24HourTime) {
597 - if (isset($datetime['ampm24h'])) $ampm24h = $datetime['ampm24h'];
 592+ if ( is_array( $datetime ) ) {
 593+ if ( isset( $datetime['hour'] ) ) $hour = $datetime['hour'];
 594+ if ( isset( $datetime['minute'] ) ) $minute = $datetime['minute'];
 595+ if ( isset( $datetime['second'] ) ) $second = $datetime['second'];
 596+ if ( ! $sfg24HourTime ) {
 597+ if ( isset( $datetime['ampm24h'] ) ) $ampm24h = $datetime['ampm24h'];
598598 }
599 - if (isset($datetime['timezone'])) $timezone = $datetime['timezone'];
 599+ if ( isset( $datetime['timezone'] ) ) $timezone = $datetime['timezone'];
600600 } else {
601601 // TODO - this should change to use SMW's own date-handling class,
602602 // just like dateEntryHTML() does
603 - $actual_date = strtotime($datetime);
604 - if ($sfg24HourTime) {
605 - $hour = date("G", $actual_date);
 603+ $actual_date = strtotime( $datetime );
 604+ if ( $sfg24HourTime ) {
 605+ $hour = date( "G", $actual_date );
606606 } else {
607 - $hour = date("g", $actual_date);
 607+ $hour = date( "g", $actual_date );
608608 }
609 - $minute = date("i", $actual_date);
610 - $second = date("s", $actual_date);
611 - if (! $sfg24HourTime) {
612 - $ampm24h = date("A", $actual_date);
 609+ $minute = date( "i", $actual_date );
 610+ $second = date( "s", $actual_date );
 611+ if ( ! $sfg24HourTime ) {
 612+ $ampm24h = date( "A", $actual_date );
613613 }
614 - $timezone = date("T", $actual_date);
 614+ $timezone = date( "T", $actual_date );
615615 }
616616 } else {
617617 $cur_date = getdate();
@@ -621,47 +621,47 @@
622622 $timezone = "";
623623 }
624624
625 - list($text, $javascript_text) = SFFormInputs::dateEntryHTML($datetime, $input_name, $is_mandatory, $is_disabled, $other_args);
626 - $disabled_text = ($is_disabled) ? "disabled" : "";
 625+ list( $text, $javascript_text ) = SFFormInputs::dateEntryHTML( $datetime, $input_name, $is_mandatory, $is_disabled, $other_args );
 626+ $disabled_text = ( $is_disabled ) ? "disabled" : "";
627627 $text .= ' &nbsp;<input tabindex="' . $sfgTabIndex . '" name="' . $input_name . '[hour]" type="text" value="' . $hour . '" size="2"/ ' . $disabled_text . '>';
628628 $sfgTabIndex++;
629629 $text .= ' :<input tabindex="' . $sfgTabIndex . '" name="' . $input_name . '[minute]" type="text" value="' . $minute . '" size="2"/ ' . $disabled_text . '>';
630630 $sfgTabIndex++;
631631 $text .= ':<input tabindex="' . $sfgTabIndex . '" name="' . $input_name . '[second]" type="text" value="' . $second . '" size="2"/ ' . $disabled_text . '>' . "\n";
632632
633 - if (! $sfg24HourTime) {
 633+ if ( ! $sfg24HourTime ) {
634634 $sfgTabIndex++;
635635 $text .= ' <select tabindex="' . $sfgTabIndex . '" name="' . $input_name . "[ampm24h]\" $disabled_text>\n";
636 - $ampm24h_options = array('', 'AM', 'PM');
637 - foreach ($ampm24h_options as $value) {
 636+ $ampm24h_options = array( '', 'AM', 'PM' );
 637+ foreach ( $ampm24h_options as $value ) {
638638 $text .= " <option value=\"$value\"";
639 - if ($value == $ampm24h) {$text .= " selected=\"selected\""; }
 639+ if ( $value == $ampm24h ) { $text .= " selected=\"selected\""; }
640640 $text .= ">$value</option>\n";
641641 }
642642 $text .= " </select>\n";
643643 }
644644
645 - if ($include_timezone) {
 645+ if ( $include_timezone ) {
646646 $sfgTabIndex++;
647647 $text .= ' <input tabindex="' . $sfgTabIndex . '" name="' . $input_name . '[timezone]" type="text" value="' . $timezone . '" size="2"/ ' . $disabled_text . '>' . "\n";
648648 }
649649
650 - return array($text, $javascript_text);
 650+ return array( $text, $javascript_text );
651651 }
652652
653 - static function radioButtonHTML($cur_value, $input_name, $is_mandatory, $is_disabled, $other_args) {
 653+ static function radioButtonHTML( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args ) {
654654 global $sfgTabIndex, $sfgFieldNum;
655655
656656 $input_id = "input_$sfgFieldNum";
657657 $info_id = "info_$sfgFieldNum";
658 - $disabled_text = ($is_disabled) ? "disabled" : "";
 658+ $disabled_text = ( $is_disabled ) ? "disabled" : "";
659659 $check_set = false;
660660 $javascript_text = '';
661661 $return_js_text = '';
662 - if (array_key_exists('show on select', $other_args)) {
 662+ if ( array_key_exists( 'show on select', $other_args ) ) {
663663 $javascript_text = 'onClick="';
664 - foreach($other_args['show on select'] as $div_id => $options) {
665 - $options_str = implode("', '", $options);
 664+ foreach ( $other_args['show on select'] as $div_id => $options ) {
 665+ $options_str = implode( "', '", $options );
666666 $this_js_text = "showIfSelected('$input_id', ['$options_str'], '$div_id'); ";
667667 $javascript_text .= $this_js_text;
668668 $return_js_text .= $this_js_text . "\n";
@@ -671,62 +671,62 @@
672672 $text = "";
673673 // if it's mandatory, add a span around all the radiobuttons, since
674674 // some browsers don't support formatting of radiobuttons
675 - if ($is_mandatory)
 675+ if ( $is_mandatory )
676676 $text .= ' <span class="mandatoryFieldsSpan">' . "\n";
677677
678678 // start with an initial "None" value, unless this is a mandatory field
679679 // and there's a current value in place (either through a default value
680680 // or because we're editing an existing page)
681 - if (! $is_mandatory || $cur_value == '') {
 681+ if ( ! $is_mandatory || $cur_value == '' ) {
682682 $text .= ' <input type="radio" id="' . $input_id . '" tabindex="' . $sfgTabIndex . '" name="' . $input_name . '" value=""';
683 - if (! $cur_value) {
 683+ if ( ! $cur_value ) {
684684 $text .= ' checked="checked"';
685685 $check_set = true;
686686 }
687 - $text .= " $disabled_text $javascript_text/> " . wfMsg('sf_formedit_none') . "\n";
 687+ $text .= " $disabled_text $javascript_text/> " . wfMsg( 'sf_formedit_none' ) . "\n";
688688 }
689689
690 - if (($possible_values = $other_args['possible_values']) == null)
691 - $possible_values = array();
692 - foreach ($possible_values as $i => $possible_value) {
 690+ if ( ( $possible_values = $other_args['possible_values'] ) == null )
 691+ $possible_values = array();
 692+ foreach ( $possible_values as $i => $possible_value ) {
693693 $text .= ' <input type="radio" tabindex="' . $sfgTabIndex . '" name="' . $input_name . '" value="' . $possible_value . '"';
694 - if ($cur_value == $possible_value || (! $cur_value && ! $check_set)) {
 694+ if ( $cur_value == $possible_value || ( ! $cur_value && ! $check_set ) ) {
695695 $text .= ' checked="checked"';
696696 $check_set = true;
697697 }
698 - if (array_key_exists('value_labels', $other_args) && is_array($other_args['value_labels']) && array_key_exists($possible_value, $other_args['value_labels']))
699 - $label = htmlspecialchars($other_args['value_labels'][$possible_value]);
 698+ if ( array_key_exists( 'value_labels', $other_args ) && is_array( $other_args['value_labels'] ) && array_key_exists( $possible_value, $other_args['value_labels'] ) )
 699+ $label = htmlspecialchars( $other_args['value_labels'][$possible_value] );
700700 else
701701 $label = $possible_value;
702702 $text .= " $disabled_text $javascript_text/> $label\n";
703703 }
704704 // close span
705 - if ($is_mandatory)
 705+ if ( $is_mandatory )
706706 $text .= " </span>";
707 - $text .=<<<END
 707+ $text .= <<<END
708708 <span id="$info_id" class="errorMessage"></span>
709709
710710 END;
711 - return array($text, $return_js_text);
 711+ return array( $text, $return_js_text );
712712 }
713713
714 - static function checkboxHTML($cur_value, $input_name, $is_mandatory, $is_disabled, $other_args) {
 714+ static function checkboxHTML( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args ) {
715715 global $sfgTabIndex, $sfgFieldNum;
716716
717 - $className = ($is_mandatory) ? "mandatoryField" : "createboxInput";
718 - if (array_key_exists('class', $other_args))
 717+ $className = ( $is_mandatory ) ? "mandatoryField" : "createboxInput";
 718+ if ( array_key_exists( 'class', $other_args ) )
719719 $className .= " " . $other_args['class'];
720720 $info_id = "info_$sfgFieldNum";
721721 $input_id = "input_$sfgFieldNum";
722 - $disabled_text = ($is_disabled) ? "disabled" : "";
 722+ $disabled_text = ( $is_disabled ) ? "disabled" : "";
723723 $return_js_text = '';
724 - if (array_key_exists('show on select', $other_args)) {
725 - $div_id = key($other_args['show on select']);
 724+ if ( array_key_exists( 'show on select', $other_args ) ) {
 725+ $div_id = key( $other_args['show on select'] );
726726 $this_js_text = "showIfChecked(['$input_id'], '$div_id');";
727727 // we use addClickHandler(), instead of adding the Javascript via
728728 // onClick="", because MediaWiki's wikibits.js does its own handling
729729 // of checkboxes, which impacts their behavior in IE
730 - $return_js_text =<<<END
 730+ $return_js_text = <<<END
731731 $this_js_text;
732732 addClickHandler(
733733 document.getElementById("$input_id"),
@@ -738,50 +738,50 @@
739739
740740 // can show up here either as an array or a string, depending on
741741 // whether it came from user input or a wiki page
742 - if (is_array($cur_value)) {
743 - $checked_str = (array_key_exists('value', $cur_value) && $cur_value['value'] == 'on') ? ' checked="checked"' : "";
 742+ if ( is_array( $cur_value ) ) {
 743+ $checked_str = ( array_key_exists( 'value', $cur_value ) && $cur_value['value'] == 'on' ) ? ' checked="checked"' : "";
744744 } else {
745745 // default to false - no need to check if it matches a 'false' word
746 - $vlc = strtolower(trim($cur_value));
 746+ $vlc = strtolower( trim( $cur_value ) );
747747 // manually load SMW's message values, if they weren't loaded before
748 - wfLoadExtensionMessages('SemanticMediaWiki');
749 - if (in_array($vlc, explode(',', wfMsgForContent('smw_true_words')), TRUE)) {
 748+ wfLoadExtensionMessages( 'SemanticMediaWiki' );
 749+ if ( in_array( $vlc, explode( ',', wfMsgForContent( 'smw_true_words' ) ), TRUE ) ) {
750750 $checked_str = ' checked="checked"';
751751 } else {
752752 $checked_str = "";
753753 }
754754 }
755 - $text =<<<END
 755+ $text = <<<END
756756 <input name="{$input_name}[is_checkbox]" type="hidden" value="true" />
757757 <input id="$input_id" name="{$input_name}[value]" type="checkbox" class="$className" tabindex="$sfgTabIndex" $checked_str $disabled_text/>
758758 <span id="$info_id" class="errorMessage"></span>
759759
760760 END;
761 - return array($text, $return_js_text);
 761+ return array( $text, $return_js_text );
762762 }
763763
764 - static function categoryHTML($cur_value, $input_name, $is_mandatory, $is_disabled, $other_args) {
 764+ static function categoryHTML( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args ) {
765765 // escape if CategoryTree extension isn't included
766 - if (! function_exists('efCategoryTreeParserHook'))
767 - return array(null, null);
 766+ if ( ! function_exists( 'efCategoryTreeParserHook' ) )
 767+ return array( null, null );
768768
769769 global $sfgTabIndex, $sfgFieldNum;
770770
771 - $className = ($is_mandatory) ? "mandatoryField" : "createboxInput";
772 - if (array_key_exists('class', $other_args))
 771+ $className = ( $is_mandatory ) ? "mandatoryField" : "createboxInput";
 772+ if ( array_key_exists( 'class', $other_args ) )
773773 $className .= " " . $other_args['class'];
774 - if (array_key_exists('top category', $other_args)) {
 774+ if ( array_key_exists( 'top category', $other_args ) ) {
775775 $top_category = $other_args['top category'];
776776 } else {
777777 // escape - we can't do anything
778 - return array(null, null);
 778+ return array( null, null );
779779 }
780 - if (array_key_exists('height', $other_args)) {
 780+ if ( array_key_exists( 'height', $other_args ) ) {
781781 $height = $other_args['height'];
782782 } else {
783783 $height = "100";
784784 }
785 - if (array_key_exists('width', $other_args)) {
 785+ if ( array_key_exists( 'width', $other_args ) ) {
786786 $width = $other_args['width'];
787787 } else {
788788 $width = "500";
@@ -794,69 +794,69 @@
795795 // start with an initial "None" value, unless this is a mandatory field
796796 // and there's a current value in place (either through a default value
797797 // or because we're editing an existing page)
798 - if (! $is_mandatory || $cur_value == '') {
 798+ if ( ! $is_mandatory || $cur_value == '' ) {
799799 $input_id = "input_$sfgFieldNum";
800800 $info_id = "info_$sfgFieldNum";
801801 $text .= ' <input type="radio" id="' . $input_id . '" tabindex="' . $sfgTabIndex . '" name="' . $input_name . '" value=""';
802 - if (! $cur_value) {
 802+ if ( ! $cur_value ) {
803803 $text .= ' checked="checked"';
804804 $check_set = true;
805805 }
806 - $disabled_text = ($is_disabled) ? "disabled" : "";
807 - $text .= " $disabled_text/> <em>" . wfMsg('sf_formedit_none') . "</em>\n";
 806+ $disabled_text = ( $is_disabled ) ? "disabled" : "";
 807+ $text .= " $disabled_text/> <em>" . wfMsg( 'sf_formedit_none' ) . "</em>\n";
808808 }
809809
810810 global $wgCategoryTreeMaxDepth;
811811 $wgCategoryTreeMaxDepth = 10;
812 - $tree = efCategoryTreeParserHook($top_category, array('mode' => 'categories', 'depth' => 10));
813 - $tree = preg_replace('/(<a class="CategoryTreeLabel.*>)(.*)(<\/a>)/', '<input id="' . $input_id . '" tabindex="' . $sfgTabIndex . '" name="' . $input_name . '" value="$2" type="radio"> $1$2$3', $tree);
814 - $tree = str_replace("value=\"$cur_value\"", "value=\"$cur_value\" checked=\"checked\"", $tree);
 812+ $tree = efCategoryTreeParserHook( $top_category, array( 'mode' => 'categories', 'depth' => 10 ) );
 813+ $tree = preg_replace( '/(<a class="CategoryTreeLabel.*>)(.*)(<\/a>)/', '<input id="' . $input_id . '" tabindex="' . $sfgTabIndex . '" name="' . $input_name . '" value="$2" type="radio"> $1$2$3', $tree );
 814+ $tree = str_replace( "value=\"$cur_value\"", "value=\"$cur_value\" checked=\"checked\"", $tree );
815815 // if it's disabled, set all to disabled
816 - if ($is_disabled) {
817 - $tree = str_replace('type="radio"', 'type="radio" disabled', $tree);
 816+ if ( $is_disabled ) {
 817+ $tree = str_replace( 'type="radio"', 'type="radio" disabled', $tree );
818818 }
819819 $text .= $tree . '</div>';
820820
821 - $text .=<<<END
 821+ $text .= <<<END
822822 <span id="$info_id" class="errorMessage"></span>
823823
824824 END;
825825
826 - return array($text, null);
 826+ return array( $text, null );
827827 }
828828
829 - static function categoriesHTML($cur_value, $input_name, $is_mandatory, $is_disabled, $other_args) {
 829+ static function categoriesHTML( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args ) {
830830 // escape if CategoryTree extension isn't included
831 - if (! function_exists('efCategoryTreeParserHook'))
832 - return array(null, null);
 831+ if ( ! function_exists( 'efCategoryTreeParserHook' ) )
 832+ return array( null, null );
833833
834834 global $sfgTabIndex, $sfgFieldNum;
835835
836 - $className = ($is_mandatory) ? "mandatoryField" : "createboxInput";
837 - if (array_key_exists('class', $other_args))
 836+ $className = ( $is_mandatory ) ? "mandatoryField" : "createboxInput";
 837+ if ( array_key_exists( 'class', $other_args ) )
838838 $className .= " " . $other_args['class'];
839839 $input_id = "input_$sfgFieldNum";
840840 $info_id = "info_$sfgFieldNum";
841841 $hidden_input_name = $input_name . "[is_list]";
842842 // get list delimiter - default is comma
843 - if (array_key_exists('delimiter', $other_args)) {
 843+ if ( array_key_exists( 'delimiter', $other_args ) ) {
844844 $delimiter = $other_args['delimiter'];
845845 } else {
846846 $delimiter = ",";
847847 }
848 - $cur_values = self::getValuesArray($cur_value, $delimiter);
849 - if (array_key_exists('top category', $other_args)) {
 848+ $cur_values = self::getValuesArray( $cur_value, $delimiter );
 849+ if ( array_key_exists( 'top category', $other_args ) ) {
850850 $top_category = $other_args['top category'];
851851 } else {
852852 // escape - we can't do anything
853 - return array(null, null);
 853+ return array( null, null );
854854 }
855 - if (array_key_exists('height', $other_args)) {
 855+ if ( array_key_exists( 'height', $other_args ) ) {
856856 $height = $other_args['height'];
857857 } else {
858858 $height = "100";
859859 }
860 - if (array_key_exists('width', $other_args)) {
 860+ if ( array_key_exists( 'width', $other_args ) ) {
861861 $width = $other_args['width'];
862862 } else {
863863 $width = "500";
@@ -864,32 +864,32 @@
865865
866866 global $wgCategoryTreeMaxDepth;
867867 $wgCategoryTreeMaxDepth = 10;
868 - $tree = efCategoryTreeParserHook($top_category, array('mode' => 'categories', 'depth' => 10));
 868+ $tree = efCategoryTreeParserHook( $top_category, array( 'mode' => 'categories', 'depth' => 10 ) );
869869 // some string that will hopefully never show up in a category, template
870870 // or field name
871871 $dummy_str = 'REPLACE THIS STRING!';
872 - $tree = preg_replace('/(<a class="CategoryTreeLabel.*>)(.*)(<\/a>)/', '<input id="' . $input_id . '" tabindex="' . $sfgTabIndex . '" name="' . $input_name . '[' . $dummy_str . ']" value="$2" type="checkbox"> $1$2$3', $tree);
 872+ $tree = preg_replace( '/(<a class="CategoryTreeLabel.*>)(.*)(<\/a>)/', '<input id="' . $input_id . '" tabindex="' . $sfgTabIndex . '" name="' . $input_name . '[' . $dummy_str . ']" value="$2" type="checkbox"> $1$2$3', $tree );
873873 // replace values one at a time, by an incrementing index -
874874 // inspired by http://bugs.php.net/bug.php?id=11457
875875 $i = 0;
876 - while (($a = strpos($tree, $dummy_str)) > 0) {
877 - $tree = substr($tree, 0, $a) . $i++ . substr($tree, $a + strlen($dummy_str));
 876+ while ( ( $a = strpos( $tree, $dummy_str ) ) > 0 ) {
 877+ $tree = substr( $tree, 0, $a ) . $i++ . substr( $tree, $a + strlen( $dummy_str ) );
878878 }
879879 // set all checkboxes matching $cur_values to checked
880 - foreach ($cur_values as $value) {
881 - $tree = str_replace("value=\"$value\"", "value=\"$value\" checked=\"checked\"", $tree);
 880+ foreach ( $cur_values as $value ) {
 881+ $tree = str_replace( "value=\"$value\"", "value=\"$value\" checked=\"checked\"", $tree );
882882 }
883883 // if it's disabled, set all to disabled
884 - if ($is_disabled) {
885 - $tree = str_replace('type="checkbox"', 'type="checkbox" disabled', $tree);
 884+ if ( $is_disabled ) {
 885+ $tree = str_replace( 'type="checkbox"', 'type="checkbox" disabled', $tree );
886886 }
887887 $text = '<div style="overflow: auto; padding: 5px; border: 1px #aaaaaa solid; max-height: ' . $height . 'px; width: ' . $width . 'px;">' . $tree . '</div>';
888888
889 - $text .=<<<END
 889+ $text .= <<<END
890890 <input type="hidden" name="$hidden_input_name" value="1" />
891891
892892 END;
893893
894 - return array($text, null);
 894+ return array( $text, null );
895895 }
896896 }
Index: trunk/extensions/SemanticForms/includes/SF_FormField.inc
@@ -29,7 +29,7 @@
3030 var $input_name;
3131 var $is_disabled;
3232
33 - static function create($num, $template_field) {
 33+ static function create( $num, $template_field ) {
3434 $f = new SFFormField();
3535 $f->num = $num;
3636 $f->template_field = $template_field;
@@ -42,21 +42,21 @@
4343 return $f;
4444 }
4545
46 - static function createFromDefinition($field_name, $input_name, $is_mandatory, $is_hidden, $is_uploadable, $possible_values, $is_disabled, $is_list, $input_type, $field_args, $all_fields, $strict_parsing) {
 46+ static function createFromDefinition( $field_name, $input_name, $is_mandatory, $is_hidden, $is_uploadable, $possible_values, $is_disabled, $is_list, $input_type, $field_args, $all_fields, $strict_parsing ) {
4747 // see if this field matches one of the fields defined for this
4848 // template - if it is, use all available information about
4949 // that field; if it's not, either include it in the form or
5050 // not, depending on whether the template has a 'strict'
5151 // setting in the form definition
5252 $the_field = null;
53 - foreach ($all_fields as $cur_field) {
54 - if ($field_name == $cur_field->field_name) {
 53+ foreach ( $all_fields as $cur_field ) {
 54+ if ( $field_name == $cur_field->field_name ) {
5555 $the_field = $cur_field;
5656 break;
5757 }
5858 }
59 - if ($the_field == null) {
60 - if ($strict_parsing) {
 59+ if ( $the_field == null ) {
 60+ if ( $strict_parsing ) {
6161 $dummy_ff = new SFFormField();
6262 $dummy_ff->template_field = new SFTemplateField();
6363 $dummy_ff->is_list = false;
@@ -86,14 +86,14 @@
8787 * Get the set of possible form input types for either a specific
8888 * SMW property type or a list of such types
8989 */
90 - function possibleInputTypes($semantic_type, $is_list) {
 90+ function possibleInputTypes( $semantic_type, $is_list ) {
9191 // first, get the list of field types, to determine which one this is
9292 global $smwgContLang;
9393 $datatypeLabels = $smwgContLang->getDatatypeLabels();
9494 $string_type = $datatypeLabels['_str'];
9595 $text_type = $datatypeLabels['_txt'];
9696 // type introduced in SMW 1.2
97 - $code_type = array_key_exists('_cod', $datatypeLabels) ? $datatypeLabels['_cod'] : 'code';
 97+ $code_type = array_key_exists( '_cod', $datatypeLabels ) ? $datatypeLabels['_cod'] : 'code';
9898 $url_type = $datatypeLabels['_uri'];
9999 $email_type = $datatypeLabels['_ema'];
100100 $number_type = $datatypeLabels['_num'];
@@ -105,47 +105,47 @@
106106 // then, return the array of possible input types, depending on
107107 // the field type and whether this field will contain multiple
108108 // values
109 - if ($semantic_type == $string_type ||
 109+ if ( $semantic_type == $string_type ||
110110 $semantic_type == $number_type ||
111111 $semantic_type == $url_type ||
112 - $semantic_type == $email_type) {
113 - if ($is_list) {
114 - return array('text', 'textarea', 'categories');
 112+ $semantic_type == $email_type ) {
 113+ if ( $is_list ) {
 114+ return array( 'text', 'textarea', 'categories' );
115115 } else {
116 - return array('text', 'category');
 116+ return array( 'text', 'category' );
117117 }
118 - } elseif ($semantic_type == $text_type || $semantic_type == $code_type) {
119 - return array('textarea');
120 - } elseif ($semantic_type == $bool_type) {
121 - return array('checkbox');
122 - } elseif ($semantic_type == $date_type) {
123 - return array('date', 'datetime', 'datetime with timezone', 'year');
124 - } elseif ($semantic_type == $enum_type) {
125 - if ($is_list) {
126 - return array('checkboxes', 'listbox');
 118+ } elseif ( $semantic_type == $text_type || $semantic_type == $code_type ) {
 119+ return array( 'textarea' );
 120+ } elseif ( $semantic_type == $bool_type ) {
 121+ return array( 'checkbox' );
 122+ } elseif ( $semantic_type == $date_type ) {
 123+ return array( 'date', 'datetime', 'datetime with timezone', 'year' );
 124+ } elseif ( $semantic_type == $enum_type ) {
 125+ if ( $is_list ) {
 126+ return array( 'checkboxes', 'listbox' );
127127 } else {
128 - return array('dropdown', 'radiobutton');
 128+ return array( 'dropdown', 'radiobutton' );
129129 }
130 - } elseif ($semantic_type == $page_type) {
131 - if ($is_list) {
132 - return array('text', 'textarea');
 130+ } elseif ( $semantic_type == $page_type ) {
 131+ if ( $is_list ) {
 132+ return array( 'text', 'textarea' );
133133 } else {
134 - return array('text');
 134+ return array( 'text' );
135135 }
136136 } else { // blank or an unknown type
137 - return array('text', 'textarea', 'checkbox', 'date', 'datetime', 'datetime with timezone', 'category', 'categories');
 137+ return array( 'text', 'textarea', 'checkbox', 'date', 'datetime', 'datetime with timezone', 'category', 'categories' );
138138 }
139139 }
140140
141 - function inputTypeDropdownHTML($dropdown_name, $possible_input_types, $cur_input_type) {
 141+ function inputTypeDropdownHTML( $dropdown_name, $possible_input_types, $cur_input_type ) {
142142 // create the dropdown HTML for a list of possible input types
143143 $text = " <select name=\"$dropdown_name\">\n";
144 - foreach ($possible_input_types as $i => $input_type) {
145 - if ($i == 0) {
 144+ foreach ( $possible_input_types as $i => $input_type ) {
 145+ if ( $i == 0 ) {
146146 $text .= " <option value=\"\">$input_type " .
147 - wfMsg('sf_createform_inputtypedefault') . "</option>\n";
 147+ wfMsg( 'sf_createform_inputtypedefault' ) . "</option>\n";
148148 } else {
149 - $selected_str = ($cur_input_type == $input_type) ? "selected" : "";
 149+ $selected_str = ( $cur_input_type == $input_type ) ? "selected" : "";
150150 $text .= " <option value=\"$input_type\" $selected_str>$input_type</option>\n";
151151 }
152152 }
@@ -153,45 +153,45 @@
154154 return $text;
155155 }
156156
157 - function creationHTML($template_num) {
 157+ function creationHTML( $template_num ) {
158158 $field_form_text = $template_num . "_" . $this->num;
159159 $template_field = $this->template_field;
160 - $text = '<h3>' . wfMsg('sf_createform_field') . " '" . $template_field->field_name . "'</h3>\n";
161 - $prop_link_text = SFUtils::linkText(SMW_NS_PROPERTY, $template_field->semantic_property);
 160+ $text = '<h3>' . wfMsg( 'sf_createform_field' ) . " '" . $template_field->field_name . "'</h3>\n";
 161+ $prop_link_text = SFUtils::linkText( SMW_NS_PROPERTY, $template_field->semantic_property );
162162 // TODO - remove this probably-unnecessary check?
163 - if ($template_field->semantic_property == "") {
 163+ if ( $template_field->semantic_property == "" ) {
164164 // print nothing if there's no semantic field
165 - } elseif ($template_field->field_type == "") {
166 - $text .= '<p>' . wfMsg('sf_createform_fieldpropunknowntype', $prop_link_text) . "</p>\n";
167 - } elseif ($template_field->is_list) {
168 - $text .= '<p>' . wfMsg('sf_createform_fieldproplist', $prop_link_text,
169 - SFUtils::linkText(SMW_NS_TYPE, $template_field->field_type)) . "</p>\n";
 165+ } elseif ( $template_field->field_type == "" ) {
 166+ $text .= '<p>' . wfMsg( 'sf_createform_fieldpropunknowntype', $prop_link_text ) . "</p>\n";
 167+ } elseif ( $template_field->is_list ) {
 168+ $text .= '<p>' . wfMsg( 'sf_createform_fieldproplist', $prop_link_text,
 169+ SFUtils::linkText( SMW_NS_TYPE, $template_field->field_type ) ) . "</p>\n";
170170 } else {
171 - $text .= '<p>' . wfMsg('sf_createform_fieldprop', $prop_link_text,
172 - SFUtils::linkText(SMW_NS_TYPE, $template_field->field_type)) . "</p>\n";
 171+ $text .= '<p>' . wfMsg( 'sf_createform_fieldprop', $prop_link_text,
 172+ SFUtils::linkText( SMW_NS_TYPE, $template_field->field_type ) ) . "</p>\n";
173173 }
174174 // if it's not a semantic field - don't add any text
175 - $form_label_text = wfMsg('sf_createform_formlabel');
 175+ $form_label_text = wfMsg( 'sf_createform_formlabel' );
176176 $field_label = $template_field->label;
177 - $input_type_text = wfMsg('sf_createform_inputtype');
178 - $text .=<<<END
 177+ $input_type_text = wfMsg( 'sf_createform_inputtype' );
 178+ $text .= <<<END
179179 <p>$form_label_text <input type="text" name="label_$field_form_text" size=20 value="$field_label" />
180180 &nbsp; $input_type_text
181181
182182 END;
183 - $possible_input_types = $this->possibleInputTypes($template_field->field_type, $template_field->is_list);
184 - if (count($possible_input_types) > 1) {
185 - $text .= $this->inputTypeDropdownHTML("input_type_$field_form_text", $possible_input_types, $template_field->input_type);
 183+ $possible_input_types = $this->possibleInputTypes( $template_field->field_type, $template_field->is_list );
 184+ if ( count( $possible_input_types ) > 1 ) {
 185+ $text .= $this->inputTypeDropdownHTML( "input_type_$field_form_text", $possible_input_types, $template_field->input_type );
186186 } else {
187187 $text .= $possible_input_types[0];
188188 }
189 - $mandatory_checked_str = ($this->is_mandatory) ? "checked" : "";
190 - $mandatory_text = wfMsg('sf_createform_mandatory');
191 - $hidden_checked_str = ($this->is_hidden) ? "checked" : "";
192 - $hidden_text = wfMsg('sf_createform_hidden');
193 - $restricted_checked_str = ($this->is_restricted) ? "checked" : "";
194 - $restricted_text = wfMsg('sf_createform_restricted');
195 - $text .=<<<END
 189+ $mandatory_checked_str = ( $this->is_mandatory ) ? "checked" : "";
 190+ $mandatory_text = wfMsg( 'sf_createform_mandatory' );
 191+ $hidden_checked_str = ( $this->is_hidden ) ? "checked" : "";
 192+ $hidden_text = wfMsg( 'sf_createform_hidden' );
 193+ $restricted_checked_str = ( $this->is_restricted ) ? "checked" : "";
 194+ $restricted_text = wfMsg( 'sf_createform_restricted' );
 195+ $text .= <<<END
196196 </p>
197197 <p>
198198 <input type="checkbox" name="mandatory_$field_form_text" value="mandatory" $mandatory_checked_str /> $mandatory_text
@@ -206,32 +206,32 @@
207207 // for now, HTML of an individual field depends on whether or not it's
208208 // part of multiple-instance template; this may change if handling of
209209 // such templates in form definitions gets more sophisticated
210 - function createMarkup($part_of_multiple, $is_last_field_in_template) {
 210+ function createMarkup( $part_of_multiple, $is_last_field_in_template ) {
211211 $text = "";
212 - if ($this->template_field->label != "") {
213 - if ($part_of_multiple) {
 212+ if ( $this->template_field->label != "" ) {
 213+ if ( $part_of_multiple ) {
214214 $text .= "'''" . $this->template_field->label . ":''' ";
215215 } else {
216216 $text .= "! " . $this->template_field->label . ":\n";
217217 }
218218 }
219 - if (! $part_of_multiple) { $text .= "| "; }
 219+ if ( ! $part_of_multiple ) { $text .= "| "; }
220220 $text .= "{{{field|" . $this->template_field->field_name;
221 - if (isset($this->template_field->input_type) &&
222 - $this->template_field->input_type != null) {
 221+ if ( isset( $this->template_field->input_type ) &&
 222+ $this->template_field->input_type != null ) {
223223 $text .= "|input type=" . $this->template_field->input_type;
224224 }
225 - if ($this->is_mandatory) {
 225+ if ( $this->is_mandatory ) {
226226 $text .= "|mandatory";
227 - } elseif ($this->is_hidden) {
 227+ } elseif ( $this->is_hidden ) {
228228 $text .= "|hidden";
229 - } elseif ($this->is_restricted) {
 229+ } elseif ( $this->is_restricted ) {
230230 $text .= "|restricted";
231231 }
232232 $text .= "}}}\n";
233 - if ($part_of_multiple) {
 233+ if ( $part_of_multiple ) {
234234 $text .= "\n";
235 - } elseif (! $is_last_field_in_template) {
 235+ } elseif ( ! $is_last_field_in_template ) {
236236 $text .= "|-\n";
237237 }
238238 return $text;
@@ -243,29 +243,29 @@
244244 * array - create this array, using the attributes of this form
245245 * field and the template field it corresponds to, if any
246246 */
247 - function getArgumentsForInputCall($default_args = null) {
 247+ function getArgumentsForInputCall( $default_args = null ) {
248248 // start with the arguments array already defined
249249 $other_args = $this->field_args;
250250 // a value defined for the form field should always supersede
251251 // the coresponding value for the template field
252 - if ($this->possible_values != null)
 252+ if ( $this->possible_values != null )
253253 $other_args['possible_values'] = $this->possible_values;
254254 else {
255255 $other_args['possible_values'] = $this->template_field->possible_values;
256256 $other_args['value_labels'] = $this->template_field->value_labels;
257257 }
258 - $other_args['is_list'] = ($this->is_list || $this->template_field->is_list);
259 - if ($this->template_field->semantic_property != '' && ! array_key_exists('semantic_property', $other_args))
 258+ $other_args['is_list'] = ( $this->is_list || $this->template_field->is_list );
 259+ if ( $this->template_field->semantic_property != '' && ! array_key_exists( 'semantic_property', $other_args ) )
260260 $other_args['semantic_property'] = $this->template_field->semantic_property;
261261 // if autocompletion hasn't already been hardcoded in the form,
262262 // and it's a property of type page, or a property of another
263263 // type with 'autocomplete' specified, set the necessary
264264 // parameters
265 - if (! array_key_exists('autocompletion source', $other_args)) {
266 - if ($this->template_field->propertyIsOfType('_wpg')) {
 265+ if ( ! array_key_exists( 'autocompletion source', $other_args ) ) {
 266+ if ( $this->template_field->propertyIsOfType( '_wpg' ) ) {
267267 $other_args['autocompletion source'] = $this->template_field->semantic_property;
268268 $other_args['autocomplete field type'] = 'relation';
269 - } elseif (array_key_exists('autocomplete', $other_args) || array_key_exists('remote autocompletion', $other_args)) {
 269+ } elseif ( array_key_exists( 'autocomplete', $other_args ) || array_key_exists( 'remote autocompletion', $other_args ) ) {
270270 $other_args['autocompletion source'] = $this->template_field->semantic_property;
271271 $other_args['autocomplete field type'] = 'attribute';
272272 }
@@ -273,8 +273,8 @@
274274 // now merge in the default values set by SFFormPrinter, if
275275 // there were any - put the default values first, so that if
276276 // there's a conflict they'll be overridden
277 - if ($default_args != null)
278 - $other_args = array_merge($default_args, $other_args);
 277+ if ( $default_args != null )
 278+ $other_args = array_merge( $default_args, $other_args );
279279 return $other_args;
280280 }
281281 }
Index: trunk/extensions/SemanticForms/includes/SF_FormPrinter.inc
@@ -23,12 +23,12 @@
2424 // fields of both a specific semantic "type" and a defined "input type"
2525 // in the form definition
2626 $this->mSemanticTypeHooks = array();
27 - if ($smwgContLang != null) {
 27+ if ( $smwgContLang != null ) {
2828 $datatypeLabels = $smwgContLang->getDatatypeLabels();
2929 $string_type = $datatypeLabels['_str'];
3030 $text_type = $datatypeLabels['_txt'];
3131 // type introduced in SMW 1.2
32 - if (array_key_exists('_cod', $datatypeLabels))
 32+ if ( array_key_exists( '_cod', $datatypeLabels ) )
3333 $code_type = $datatypeLabels['_cod'];
3434 else
3535 $code_type = 'code';
@@ -39,44 +39,44 @@
4040 $date_type = $datatypeLabels['_dat'];
4141 $enum_type = 'enumeration'; // not a real type
4242 $page_type = $datatypeLabels['_wpg'];
43 - $this->setSemanticTypeHook($string_type, false, array('SFFormInputs', 'textEntryHTML'), array('field_type' => 'string'));
44 - $this->setSemanticTypeHook($string_type, true, array('SFFormInputs', 'textEntryHTML'), array('field_type' => 'string', 'is_list' => 'true', 'size' => '100'));
45 - $this->setSemanticTypeHook($text_type, false, array('SFFormInputs', 'textAreaHTML'), array());
46 - $this->setSemanticTypeHook($code_type, false, array('SFFormInputs', 'textAreaHTML'), array());
47 - $this->setSemanticTypeHook($url_type, false, array('SFFormInputs', 'textEntryHTML'), array('field_type' => 'URL'));
48 - $this->setSemanticTypeHook($email_type, false, array('SFFormInputs', 'textEntryHTML'), array('field_type' => 'email'));
49 - $this->setSemanticTypeHook($number_type, false, array('SFFormInputs', 'textEntryHTML'), array('field_type' => 'number'));
50 - $this->setSemanticTypeHook($bool_type, false, array('SFFormInputs', 'checkboxHTML'), array());
51 - $this->setSemanticTypeHook($date_type, false, array('SFFormInputs', 'dateEntryHTML'), array());
52 - $this->setSemanticTypeHook($enum_type, false, array('SFFormInputs', 'dropdownHTML'), array());
53 - $this->setSemanticTypeHook($enum_type, true, array('SFFormInputs', 'checkboxesHTML'), array());
54 - $this->setSemanticTypeHook($page_type, false, array('SFFormInputs', 'textInputWithAutocompleteHTML'), array('field_type' => 'page'));
55 - $this->setSemanticTypeHook($page_type, true, array('SFFormInputs', 'textInputWithAutocompleteHTML'), array('field_type' => 'page', 'size' => '100', 'is_list' => 'true'));
 43+ $this->setSemanticTypeHook( $string_type, false, array( 'SFFormInputs', 'textEntryHTML' ), array( 'field_type' => 'string' ) );
 44+ $this->setSemanticTypeHook( $string_type, true, array( 'SFFormInputs', 'textEntryHTML' ), array( 'field_type' => 'string', 'is_list' => 'true', 'size' => '100' ) );
 45+ $this->setSemanticTypeHook( $text_type, false, array( 'SFFormInputs', 'textAreaHTML' ), array() );
 46+ $this->setSemanticTypeHook( $code_type, false, array( 'SFFormInputs', 'textAreaHTML' ), array() );
 47+ $this->setSemanticTypeHook( $url_type, false, array( 'SFFormInputs', 'textEntryHTML' ), array( 'field_type' => 'URL' ) );
 48+ $this->setSemanticTypeHook( $email_type, false, array( 'SFFormInputs', 'textEntryHTML' ), array( 'field_type' => 'email' ) );
 49+ $this->setSemanticTypeHook( $number_type, false, array( 'SFFormInputs', 'textEntryHTML' ), array( 'field_type' => 'number' ) );
 50+ $this->setSemanticTypeHook( $bool_type, false, array( 'SFFormInputs', 'checkboxHTML' ), array() );
 51+ $this->setSemanticTypeHook( $date_type, false, array( 'SFFormInputs', 'dateEntryHTML' ), array() );
 52+ $this->setSemanticTypeHook( $enum_type, false, array( 'SFFormInputs', 'dropdownHTML' ), array() );
 53+ $this->setSemanticTypeHook( $enum_type, true, array( 'SFFormInputs', 'checkboxesHTML' ), array() );
 54+ $this->setSemanticTypeHook( $page_type, false, array( 'SFFormInputs', 'textInputWithAutocompleteHTML' ), array( 'field_type' => 'page' ) );
 55+ $this->setSemanticTypeHook( $page_type, true, array( 'SFFormInputs', 'textInputWithAutocompleteHTML' ), array( 'field_type' => 'page', 'size' => '100', 'is_list' => 'true' ) );
5656 }
5757 $this->mInputTypeHooks = array();
58 - $this->setInputTypeHook('text', array('SFFormInputs', 'textEntryHTML'), array());
59 - $this->setInputTypeHook('textarea', array('SFFormInputs', 'textAreaHTML'), array());
60 - $this->setInputTypeHook('date', array('SFFormInputs', 'dateEntryHTML'), array());
61 - $this->setInputTypeHook('datetime', array('SFFormInputs', 'dateTimeEntryHTML'), array('include_timezone' => false));
62 - $this->setInputTypeHook('datetime with timezone', array('SFFormInputs', 'dateTimeEntryHTML'), array('include_timezone' => true));
63 - $this->setInputTypeHook('year', array('SFFormInputs', 'textEntryHTML'), array('size' => 4));
64 - $this->setInputTypeHook('checkbox', array('SFFormInputs', 'checkboxHTML'), array());
65 - $this->setInputTypeHook('radiobutton', array('SFFormInputs', 'radioButtonHTML'), array());
66 - $this->setInputTypeHook('checkboxes', array('SFFormInputs', 'checkboxesHTML'), array());
67 - $this->setInputTypeHook('listbox', array('SFFormInputs', 'listboxHTML'), array());
68 - $this->setInputTypeHook('category', array('SFFormInputs', 'categoryHTML'), array());
69 - $this->setInputTypeHook('categories', array('SFFormInputs', 'categoriesHTML'), array());
 58+ $this->setInputTypeHook( 'text', array( 'SFFormInputs', 'textEntryHTML' ), array() );
 59+ $this->setInputTypeHook( 'textarea', array( 'SFFormInputs', 'textAreaHTML' ), array() );
 60+ $this->setInputTypeHook( 'date', array( 'SFFormInputs', 'dateEntryHTML' ), array() );
 61+ $this->setInputTypeHook( 'datetime', array( 'SFFormInputs', 'dateTimeEntryHTML' ), array( 'include_timezone' => false ) );
 62+ $this->setInputTypeHook( 'datetime with timezone', array( 'SFFormInputs', 'dateTimeEntryHTML' ), array( 'include_timezone' => true ) );
 63+ $this->setInputTypeHook( 'year', array( 'SFFormInputs', 'textEntryHTML' ), array( 'size' => 4 ) );
 64+ $this->setInputTypeHook( 'checkbox', array( 'SFFormInputs', 'checkboxHTML' ), array() );
 65+ $this->setInputTypeHook( 'radiobutton', array( 'SFFormInputs', 'radioButtonHTML' ), array() );
 66+ $this->setInputTypeHook( 'checkboxes', array( 'SFFormInputs', 'checkboxesHTML' ), array() );
 67+ $this->setInputTypeHook( 'listbox', array( 'SFFormInputs', 'listboxHTML' ), array() );
 68+ $this->setInputTypeHook( 'category', array( 'SFFormInputs', 'categoryHTML' ), array() );
 69+ $this->setInputTypeHook( 'categories', array( 'SFFormInputs', 'categoriesHTML' ), array() );
7070
7171 // initialize other variables
7272 $this->standardInputsIncluded = false;
7373 }
7474
75 - function setSemanticTypeHook($type, $is_list, $function_name, $default_args) {
76 - $this->mSemanticTypeHooks[$type][$is_list] = array($function_name, $default_args);
 75+ function setSemanticTypeHook( $type, $is_list, $function_name, $default_args ) {
 76+ $this->mSemanticTypeHooks[$type][$is_list] = array( $function_name, $default_args );
7777 }
7878
79 - function setInputTypeHook($input_type, $function_name, $default_args) {
80 - $this->mInputTypeHooks[$input_type] = array($function_name, $default_args);
 79+ function setInputTypeHook( $input_type, $function_name, $default_args ) {
 80+ $this->mInputTypeHooks[$input_type] = array( $function_name, $default_args );
8181 }
8282
8383
@@ -88,7 +88,7 @@
8989 */
9090 function showDeletionLog( $out ) {
9191 // if MW doesn't have LogEventsList defined, exit immediately
92 - if (! class_exists('LogEventsList'))
 92+ if ( ! class_exists( 'LogEventsList' ) )
9393 return false;
9494
9595 global $wgUser;
@@ -99,7 +99,7 @@
100100 $pager->mLimit = 10;
101101 $out->addHTML( '<div class="mw-warning-with-logexcerpt">' );
102102 // the message name changed in MW 1.16
103 - if (! wfEmptyMsg( 'moveddeleted-notice', wfMsg('moveddeleted-notice') ))
 103+ if ( ! wfEmptyMsg( 'moveddeleted-notice', wfMsg( 'moveddeleted-notice' ) ) )
104104 $out->addWikiMsg( 'moveddeleted-notice' );
105105 else
106106 $out->addWikiMsg( 'recreate-deleted-warn' );
@@ -108,7 +108,7 @@
109109 $pager->getBody() .
110110 $loglist->endLogEventsList()
111111 );
112 - if($count > 10){
 112+ if ( $count > 10 ) {
113113 $out->addHTML( $wgUser->getSkin()->link(
114114 SpecialPage::getTitleFor( 'Log' ),
115115 wfMsgHtml( 'deletelog-fulllog' ),
@@ -124,7 +124,7 @@
125125 return false;
126126 }
127127
128 - function formHTML($form_def, $form_submitted, $source_is_page, $form_id = null, $existing_page_content = null, $page_name = null, $page_name_formula = null, $is_query = false, $embedded = false) {
 128+ function formHTML( $form_def, $form_submitted, $source_is_page, $form_id = null, $existing_page_content = null, $page_name = null, $page_name_formula = null, $is_query = false, $embedded = false ) {
129129 global $wgRequest, $wgUser, $wgParser;
130130 global $sfgTabIndex; // used to represent the current tab index in the form
131131 global $sfgFieldNum; // used for setting various HTML IDs
@@ -154,12 +154,12 @@
155155 // minimize the html traffic and would allow us to do a concurrent
156156 // update check. For now, we pass it through the hidden text field...
157157
158 - if (! $wgRequest->getCheck('partial')) {
 158+ if ( ! $wgRequest->getCheck( 'partial' ) ) {
159159 $original_page_content = $existing_page_content;
160160 } else {
161161 $original_page_content = null;
162 - if($wgRequest->getCheck('free_text')) {
163 - $existing_page_content= $wgRequest->getVal('free_text');
 162+ if ( $wgRequest->getCheck( 'free_text' ) ) {
 163+ $existing_page_content = $wgRequest->getVal( 'free_text' );
164164 $form_is_partial = true;
165165 }
166166 }
@@ -169,26 +169,26 @@
170170 // set in different ways
171171 // HACK - sometimes we don't know the page name in advance, but we still
172172 // need to set a title here for testing permissions
173 - if ($page_name == '')
 173+ if ( $page_name == '' )
174174 $this->mPageTitle = Title::newFromText(
175 - $wgRequest->getVal('namespace') . ":Semantic Forms permissions test");
 175+ $wgRequest->getVal( 'namespace' ) . ":Semantic Forms permissions test" );
176176 else
177 - $this->mPageTitle = Title::newFromText($page_name);
 177+ $this->mPageTitle = Title::newFromText( $page_name );
178178 global $wgOut;
179179 // show previous set of deletions for this page, if it's been deleted before
180 - if (! $form_submitted && ! $this->mPageTitle->exists()) {
181 - $this->showDeletionLog($wgOut);
 180+ if ( ! $form_submitted && ! $this->mPageTitle->exists() ) {
 181+ $this->showDeletionLog( $wgOut );
182182 }
183 - $user_can_edit_page = ($wgUser->isAllowed('edit') && $this->mPageTitle->userCan('edit'));
184 - wfRunHooks('sfUserCanEditPage', array(&$user_can_edit_page));
185 - if ($user_can_edit_page || $is_query) {
 183+ $user_can_edit_page = ( $wgUser->isAllowed( 'edit' ) && $this->mPageTitle->userCan( 'edit' ) );
 184+ wfRunHooks( 'sfUserCanEditPage', array( &$user_can_edit_page ) );
 185+ if ( $user_can_edit_page || $is_query ) {
186186 $form_is_disabled = false;
187187 $form_text = "";
188188 // show "Your IP address will be recorded" warning if user is
189189 // anonymous, and it's not a query -
190190 // wikitext for bolding has to be replaced with HTML
191 - if ($wgUser->isAnon() && ! $is_query) {
192 - $anon_edit_warning = preg_replace("/'''(.*)'''/", "<strong>$1</strong>", wfMsg('anoneditwarning'));
 191+ if ( $wgUser->isAnon() && ! $is_query ) {
 192+ $anon_edit_warning = preg_replace( "/'''(.*)'''/", "<strong>$1</strong>", wfMsg( 'anoneditwarning' ) );
193193 $form_text .= "<p>$anon_edit_warning</p>\n";
194194 }
195195 } else {
@@ -209,34 +209,34 @@
210210 $fields_javascript_text = "";
211211
212212 // Remove <noinclude> sections and <includeonly> tags from form definition
213 - $form_def = StringUtils::delimiterReplace('<noinclude>', '</noinclude>', '', $form_def);
214 - $form_def = strtr($form_def, array('<includeonly>' => '', '</includeonly>' => ''));
 213+ $form_def = StringUtils::delimiterReplace( '<noinclude>', '</noinclude>', '', $form_def );
 214+ $form_def = strtr( $form_def, array( '<includeonly>' => '', '</includeonly>' => '' ) );
215215
216216 // parse wiki-text
217217 // add '<nowiki>' tags around every triple-bracketed form definition
218218 // element, so that the wiki parser won't touch it - the parser will
219219 // remove the '<nowiki>' tags, leaving us with what we need
220 - $form_def = "__NOEDITSECTION__" . strtr($form_def, array('{{{' => '<nowiki>{{{', '}}}' => '}}}</nowiki>'));
 220+ $form_def = "__NOEDITSECTION__" . strtr( $form_def, array( '{{{' => '<nowiki>{{{', '}}}' => '}}}</nowiki>' ) );
221221 $old_strip_state = $wgParser->mStripState;
222222 $wgParser->mStripState = new StripState();
223223 $wgParser->mOptions = new ParserOptions();
224 - $wgParser->mOptions->initialiseFromUser($wgUser);
 224+ $wgParser->mOptions->initialiseFromUser( $wgUser );
225225
226226 // get the form definition from the cache, if we're using caching and it's
227227 // there
228228 $got_form_def_from_cache = false;
229229 global $sfgCacheFormDefinitions;
230 - if ($sfgCacheFormDefinitions && ! is_null($form_id)) {
 230+ if ( $sfgCacheFormDefinitions && ! is_null( $form_id ) ) {
231231 $db = wfGetDB( DB_MASTER );
232 - $res = $db->select('page_props', 'pp_value', "pp_propname = 'formdefinition' AND pp_page = '$form_id'");
233 - if ($res->numRows() > 0) {
 232+ $res = $db->select( 'page_props', 'pp_value', "pp_propname = 'formdefinition' AND pp_page = '$form_id'" );
 233+ if ( $res->numRows() > 0 ) {
234234 $form_def = $res->fetchObject()->pp_value;
235235 $got_form_def_from_cache = true;
236236 }
237237 }
238238 // otherwise, parse it
239 - if (! $got_form_def_from_cache)
240 - $form_def = $wgParser->parse($form_def, $this->mPageTitle, $wgParser->mOptions)->getText();
 239+ if ( ! $got_form_def_from_cache )
 240+ $form_def = $wgParser->parse( $form_def, $this->mPageTitle, $wgParser->mOptions )->getText();
241241 $wgParser->mStripState = $old_strip_state;
242242
243243 // turn form definition file into an array of sections, one for each
@@ -252,24 +252,24 @@
253253 // pipes - this is a hack to allow for forms to include templates
254254 // that themselves contain form elements - the escaping is needed
255255 // to make sure that those elements don't get parsed too early
256 - $form_def = str_replace(array('&#123;', '&#124;', '&#125;'), array('{', '|', '}'), $form_def);
 256+ $form_def = str_replace( array( '&#123;', '&#124;', '&#125;' ), array( '{', '|', '}' ), $form_def );
257257 // and another hack - replace the 'free text' standard input with
258258 // a field declaration to get it to be handled as a field
259 - $form_def = str_replace('standard input|free text', 'field|<freetext>', $form_def);
260 - while ($brackets_loc = strpos($form_def, "{{{", $start_position)) {
261 - $brackets_end_loc = strpos($form_def, "}}}", $brackets_loc);
262 - $bracketed_string = substr($form_def, $brackets_loc + 3, $brackets_end_loc - ($brackets_loc + 3));
263 - $tag_components = explode('|', $bracketed_string);
264 - $tag_title = trim($tag_components[0]);
265 - if ($tag_title == 'for template' || $tag_title == 'end template') {
 259+ $form_def = str_replace( 'standard input|free text', 'field|<freetext>', $form_def );
 260+ while ( $brackets_loc = strpos( $form_def, "{{{", $start_position ) ) {
 261+ $brackets_end_loc = strpos( $form_def, "}}}", $brackets_loc );
 262+ $bracketed_string = substr( $form_def, $brackets_loc + 3, $brackets_end_loc - ( $brackets_loc + 3 ) );
 263+ $tag_components = explode( '|', $bracketed_string );
 264+ $tag_title = trim( $tag_components[0] );
 265+ if ( $tag_title == 'for template' || $tag_title == 'end template' ) {
266266 // create a section for everything up to here
267 - $section = substr($form_def, $section_start, $brackets_loc - $section_start);
 267+ $section = substr( $form_def, $section_start, $brackets_loc - $section_start );
268268 $form_def_sections[] = $section;
269269 $section_start = $brackets_loc;
270270 }
271271 $start_position = $brackets_loc + 1;
272272 } // end while
273 - $form_def_sections[] = trim(substr($form_def, $section_start));
 273+ $form_def_sections[] = trim( substr( $form_def, $section_start ) );
274274
275275 // cycle through form definition file (and possibly an existing article
276276 // as well), finding template and field declarations and replacing them
@@ -283,7 +283,7 @@
284284 $strict_parsing = false;
285285 // initialize list of choosers (dropdowns with available templates)
286286 $choosers = array();
287 - for ($section_num = 0; $section_num < count($form_def_sections); $section_num++) {
 287+ for ( $section_num = 0; $section_num < count( $form_def_sections ); $section_num++ ) {
288288 $tif = new SFTemplateInForm();
289289 $start_position = 0;
290290 $template_text = "";
@@ -291,46 +291,46 @@
292292 // modified; is it necessary?
293293 $section = " " . $form_def_sections[$section_num];
294294
295 - while ($brackets_loc = strpos($section, '{{{', $start_position)) {
296 - $brackets_end_loc = strpos($section, "}}}", $brackets_loc);
297 - $bracketed_string = substr($section, $brackets_loc + 3, $brackets_end_loc - ($brackets_loc + 3));
298 - $tag_components = explode('|', $bracketed_string);
299 - $tag_title = trim($tag_components[0]);
 295+ while ( $brackets_loc = strpos( $section, '{{{', $start_position ) ) {
 296+ $brackets_end_loc = strpos( $section, "}}}", $brackets_loc );
 297+ $bracketed_string = substr( $section, $brackets_loc + 3, $brackets_end_loc - ( $brackets_loc + 3 ) );
 298+ $tag_components = explode( '|', $bracketed_string );
 299+ $tag_title = trim( $tag_components[0] );
300300 // =====================================================
301301 // for template processing
302302 // =====================================================
303 - if ($tag_title == 'for template') {
 303+ if ( $tag_title == 'for template' ) {
304304 $old_template_name = $template_name;
305 - $template_name = trim($tag_components[1]);
 305+ $template_name = trim( $tag_components[1] );
306306 $tif->template_name = $template_name;
307 - $query_template_name = str_replace(' ', '_', $template_name);
 307+ $query_template_name = str_replace( ' ', '_', $template_name );
308308 // also replace periods with underlines, since that's what
309309 // POST does to strings anyway
310 - $query_template_name = str_replace('.', '_', $query_template_name);
 310+ $query_template_name = str_replace( '.', '_', $query_template_name );
311311 $chooser_name = false;
312312 $chooser_caption = false;
313313 // cycle through the other components
314 - for ($i = 2; $i < count($tag_components); $i++) {
 314+ for ( $i = 2; $i < count( $tag_components ); $i++ ) {
315315 $component = $tag_components[$i];
316 - if ($component == 'multiple') $allow_multiple = true;
317 - if ($component == 'strict') $strict_parsing = true;
318 - $sub_components = explode('=', $component, 2);
319 - if (count($sub_components) == 2) {
320 - if ($sub_components[0] == 'label') {
 316+ if ( $component == 'multiple' ) $allow_multiple = true;
 317+ if ( $component == 'strict' ) $strict_parsing = true;
 318+ $sub_components = explode( '=', $component, 2 );
 319+ if ( count( $sub_components ) == 2 ) {
 320+ if ( $sub_components[0] == 'label' ) {
321321 $template_label = $sub_components[1];
322 - } elseif ($sub_components[0] == 'chooser') {
 322+ } elseif ( $sub_components[0] == 'chooser' ) {
323323 $allow_multiple = true;
324324 $chooser_name = $sub_components[1];
325 - } elseif ($sub_components[0] == 'chooser caption') {
 325+ } elseif ( $sub_components[0] == 'chooser caption' ) {
326326 $chooser_caption = $sub_components[1];
327327 }
328328 }
329329 }
330330 // if this is the first instance, add the label in the form
331 - if (($old_template_name != $template_name) && isset($template_label)) {
 331+ if ( ( $old_template_name != $template_name ) && isset( $template_label ) ) {
332332 // add a placeholder to the form text so the fieldset can be
333333 // hidden if chooser support demands it
334 - if ($chooser_name !== false)
 334+ if ( $chooser_name !== false )
335335 $form_text .= "<fieldset [[placeholder]] haschooser=true>\n";
336336 else
337337 $form_text .= "<fieldset>\n";
@@ -339,22 +339,22 @@
340340 $template_text .= "{{" . $tif->template_name;
341341 $all_fields = $tif->getAllFields();
342342 // remove template tag
343 - $section = substr_replace($section, '', $brackets_loc, $brackets_end_loc + 3 - $brackets_loc);
344 - $template_instance_query_values = $wgRequest->getArray($query_template_name);
 343+ $section = substr_replace( $section, '', $brackets_loc, $brackets_end_loc + 3 - $brackets_loc );
 344+ $template_instance_query_values = $wgRequest->getArray( $query_template_name );
345345 // if we are editing a page, and this template can be found more than
346346 // once in that page, and multiple values are allowed, repeat this
347347 // section
348348 $existing_template_text = null;
349 - if ($source_is_page || $form_is_partial) {
 349+ if ( $source_is_page || $form_is_partial ) {
350350 // replace underlines with spaces in template name, to allow for
351351 // searching on either
352 - $search_template_str = str_replace('_', ' ', $tif->template_name);
 352+ $search_template_str = str_replace( '_', ' ', $tif->template_name );
353353 $preg_match_template_str = str_replace(
354 - array('/', '(', ')'),
355 - array('\/', '\(', '\)'),
356 - $search_template_str);
357 - $found_instance = preg_match('/{{' . $preg_match_template_str . '\s*[\|}]/i', str_replace('_', ' ', $existing_page_content));
358 - if ($allow_multiple) {
 354+ array( '/', '(', ')' ),
 355+ array( '\/', '\(', '\)' ),
 356+ $search_template_str );
 357+ $found_instance = preg_match( '/{{' . $preg_match_template_str . '\s*[\|}]/i', str_replace( '_', ' ', $existing_page_content ) );
 358+ if ( $allow_multiple ) {
359359 // find instances of this template in the page -
360360 // if there's at least one, re-parse this section of the
361361 // definition form for the subsequent template instances in
@@ -362,7 +362,7 @@
363363 // there has to be a more efficient way to handle multiple
364364 // instances of templates, one that doesn't involve re-parsing
365365 // the same tags, but I don't know what it is.
366 - if ($found_instance) {
 366+ if ( $found_instance ) {
367367 $instance_num++;
368368 } else {
369369 $all_instances_printed = true;
@@ -370,65 +370,65 @@
371371 }
372372 // get the first instance of this template on the page being edited,
373373 // even if there are more
374 - if ($found_instance && ($start_char = stripos(str_replace('_', ' ', $existing_page_content), '{{' . $search_template_str)) !== false) {
375 - $fields_start_char = $start_char + 2 + strlen($search_template_str);
 374+ if ( $found_instance && ( $start_char = stripos( str_replace( '_', ' ', $existing_page_content ), '{{' . $search_template_str ) ) !== false ) {
 375+ $fields_start_char = $start_char + 2 + strlen( $search_template_str );
376376 // skip ahead to the first real character
377 - while (in_array($existing_page_content[$fields_start_char], array(' ', '\n', '|'))) {
 377+ while ( in_array( $existing_page_content[$fields_start_char], array( ' ', '\n', '|' ) ) ) {
378378 $fields_start_char++;
379379 }
380 - $template_contents = array('0' => '');
 380+ $template_contents = array( '0' => '' );
381381 // cycle through template call, splitting it up by pipes ('|'),
382382 // except when that pipe is part of a piped link
383383 $field = "";
384384 $uncompleted_square_brackets = 0;
385385 $uncompleted_curly_brackets = 2;
386386 $template_ended = false;
387 - for ($i = $fields_start_char; ! $template_ended && ($i < strlen($existing_page_content)); $i++) {
 387+ for ( $i = $fields_start_char; ! $template_ended && ( $i < strlen( $existing_page_content ) ); $i++ ) {
388388 $c = $existing_page_content[$i];
389 - if ($c == '[') {
 389+ if ( $c == '[' ) {
390390 $uncompleted_square_brackets++;
391 - } elseif ($c == ']' && $uncompleted_square_brackets > 0) {
 391+ } elseif ( $c == ']' && $uncompleted_square_brackets > 0 ) {
392392 $uncompleted_square_brackets--;
393 - } elseif ($c == '{') {
 393+ } elseif ( $c == '{' ) {
394394 $uncompleted_curly_brackets++;
395 - } elseif ($c == '}' && $uncompleted_curly_brackets > 0) {
 395+ } elseif ( $c == '}' && $uncompleted_curly_brackets > 0 ) {
396396 $uncompleted_curly_brackets--;
397397 }
398398 // handle an end to a field and/or template declaration
399 - $template_ended = ($uncompleted_curly_brackets == 0 && $uncompleted_square_brackets == 0);
400 - $field_ended = ($c == '|' && $uncompleted_square_brackets == 0 && $uncompleted_curly_brackets <= 2);
401 - if ($template_ended || $field_ended) {
 399+ $template_ended = ( $uncompleted_curly_brackets == 0 && $uncompleted_square_brackets == 0 );
 400+ $field_ended = ( $c == '|' && $uncompleted_square_brackets == 0 && $uncompleted_curly_brackets <= 2 );
 401+ if ( $template_ended || $field_ended ) {
402402 // if this was the last character in the template, remove
403403 // the closing curly brackets
404 - if ($template_ended) {
405 - $field = substr($field, 0, -1);
 404+ if ( $template_ended ) {
 405+ $field = substr( $field, 0, - 1 );
406406 }
407407 // either there's an equals sign near the beginning or not -
408408 // handling is similar in either way; if there's no equals
409409 // sign, the index of this field becomes the key
410 - $sub_fields = explode('=', $field, 2);
411 - if (count($sub_fields) > 1) {
412 - $template_contents[trim($sub_fields[0])] = trim($sub_fields[1]);
 410+ $sub_fields = explode( '=', $field, 2 );
 411+ if ( count( $sub_fields ) > 1 ) {
 412+ $template_contents[trim( $sub_fields[0] )] = trim( $sub_fields[1] );
413413 } else {
414 - $template_contents[] = trim($sub_fields[0]);
 414+ $template_contents[] = trim( $sub_fields[0] );
415415 }
416416 $field = '';
417417 } else {
418418 $field .= $c;
419419 }
420420 }
421 - $existing_template_text = substr($existing_page_content, $start_char, $i - $start_char);
 421+ $existing_template_text = substr( $existing_page_content, $start_char, $i - $start_char );
422422 // now remove this template from the text being edited
423423 // if this is a partial form, establish a new insertion point
424 - if ($existing_page_content && $form_is_partial && $wgRequest->getCheck('partial')) {
 424+ if ( $existing_page_content && $form_is_partial && $wgRequest->getCheck( 'partial' ) ) {
425425 // if something already exists, set the new insertion point
426426 // to its position; otherwise just let it lie
427 - if (strpos($existing_page_content, $existing_template_text) !== false) {
428 - $existing_page_content = str_replace('{{{insertionpoint}}}', '', $existing_page_content);
429 - $existing_page_content = str_replace($existing_template_text, '{{{insertionpoint}}}', $existing_page_content);
 427+ if ( strpos( $existing_page_content, $existing_template_text ) !== false ) {
 428+ $existing_page_content = str_replace( '{{{insertionpoint}}}', '', $existing_page_content );
 429+ $existing_page_content = str_replace( $existing_template_text, '{{{insertionpoint}}}', $existing_page_content );
430430 }
431431 } else {
432 - $existing_page_content = str_replace($existing_template_text, '', $existing_page_content);
 432+ $existing_page_content = str_replace( $existing_template_text, '', $existing_page_content );
433433 }
434434 // if this is not a multiple-instance template, and we've found
435435 // a match in the source page, there's a good chance that this
@@ -440,9 +440,9 @@
441441 // instance templates to validate that this is the correct
442442 // form: the problem is that some forms contain *only* mutliple-
443443 // instance templates
444 - //if (! $allow_multiple) {
 444+ // if (! $allow_multiple) {
445445 $source_page_matches_this_form = true;
446 - //}
 446+ // }
447447 }
448448 }
449449 // if the input is from the form (meaning the user has hit one
@@ -451,39 +451,39 @@
452452 // template, then delete them from the array, so we can get the
453453 // next group next time - the next() command for arrays doesn't
454454 // seem to work here
455 - if ((! $source_is_page) && $allow_multiple && $wgRequest) {
 455+ if ( ( ! $source_is_page ) && $allow_multiple && $wgRequest ) {
456456 $all_instances_printed = true;
457 - if ($old_template_name != $template_name) {
458 - $all_values_for_template = $wgRequest->getArray($query_template_name);
 457+ if ( $old_template_name != $template_name ) {
 458+ $all_values_for_template = $wgRequest->getArray( $query_template_name );
459459 }
460 - if ($all_values_for_template) {
461 - $cur_key = key($all_values_for_template);
 460+ if ( $all_values_for_template ) {
 461+ $cur_key = key( $all_values_for_template );
462462 // skip the input coming in from the "starter" div
463 - if ($cur_key == 'num') {
464 - unset($all_values_for_template[$cur_key]);
465 - $cur_key = key($all_values_for_template);
 463+ if ( $cur_key == 'num' ) {
 464+ unset( $all_values_for_template[$cur_key] );
 465+ $cur_key = key( $all_values_for_template );
466466 }
467 - if ($template_instance_query_values = current($all_values_for_template)) {
 467+ if ( $template_instance_query_values = current( $all_values_for_template ) ) {
468468 $all_instances_printed = false;
469 - unset($all_values_for_template[$cur_key]);
 469+ unset( $all_values_for_template[$cur_key] );
470470 }
471471 }
472472 }
473473 // =====================================================
474474 // end template processing
475475 // =====================================================
476 - } elseif ($tag_title == 'end template') {
477 - if ($source_is_page) {
 476+ } elseif ( $tag_title == 'end template' ) {
 477+ if ( $source_is_page ) {
478478 // add any unhandled template fields in the page as hidden variables
479 - if (isset($template_contents))
480 - $form_text .= SFFormUtils::unhandledFieldsHTML($template_contents);
 479+ if ( isset( $template_contents ) )
 480+ $form_text .= SFFormUtils::unhandledFieldsHTML( $template_contents );
481481 }
482482 // remove this tag, reset some variables, and close off form HTML tag
483 - $section = substr_replace($section, '', $brackets_loc, $brackets_end_loc + 3 - $brackets_loc);
 483+ $section = substr_replace( $section, '', $brackets_loc, $brackets_end_loc + 3 - $brackets_loc );
484484 $template_name = null;
485 - if (isset($template_label)) {
 485+ if ( isset( $template_label ) ) {
486486 $form_text .= "</fieldset>\n";
487 - unset ($template_label);
 487+ unset ( $template_label );
488488 }
489489 $allow_multiple = false;
490490 $all_instances_printed = false;
@@ -491,12 +491,12 @@
492492 // if the hiding placeholder is still around, this fieldset should
493493 // be hidden because it is empty and choosers are being used. So,
494494 // hide it.
495 - $form_text = str_replace("[[placeholder]]", "style='display:none'", $form_text);
 495+ $form_text = str_replace( "[[placeholder]]", "style='display:none'", $form_text );
496496 // =====================================================
497497 // field processing
498498 // =====================================================
499 - } elseif ($tag_title == 'field') {
500 - $field_name = trim($tag_components[1]);
 499+ } elseif ( $tag_title == 'field' ) {
 500+ $field_name = trim( $tag_components[1] );
501501 // cycle through the other components
502502 $is_mandatory = false;
503503 $is_hidden = false;
@@ -510,140 +510,140 @@
511511 $possible_values = null;
512512 $semantic_property = null;
513513 $preload_page = null;
514 - for ($i = 2; $i < count($tag_components); $i++) {
515 - $component = trim($tag_components[$i]);
516 - if ($component == 'mandatory') {
 514+ for ( $i = 2; $i < count( $tag_components ); $i++ ) {
 515+ $component = trim( $tag_components[$i] );
 516+ if ( $component == 'mandatory' ) {
517517 $is_mandatory = true;
518 - } elseif ($component == 'hidden') {
 518+ } elseif ( $component == 'hidden' ) {
519519 $is_hidden = true;
520 - } elseif ($component == 'restricted') {
 520+ } elseif ( $component == 'restricted' ) {
521521 $is_restricted = true;
522 - } elseif ($component == 'uploadable') {
 522+ } elseif ( $component == 'uploadable' ) {
523523 $field_args['is_uploadable'] = true;
524 - } elseif ($component == 'list') {
 524+ } elseif ( $component == 'list' ) {
525525 $is_list = true;
526 - } elseif ($component == 'autocomplete') {
 526+ } elseif ( $component == 'autocomplete' ) {
527527 $field_args['autocomplete'] = true;
528 - } elseif ($component == 'no autocomplete') {
 528+ } elseif ( $component == 'no autocomplete' ) {
529529 $field_args['no autocomplete'] = true;
530 - } elseif ($component == 'remote autocompletion') {
 530+ } elseif ( $component == 'remote autocompletion' ) {
531531 $field_args['remote autocompletion'] = true;
532 - } elseif ($component == 'edittools') { // free text only
 532+ } elseif ( $component == 'edittools' ) { // free text only
533533 $free_text_components[] = 'edittools';
534534 } else {
535 - $sub_components = explode('=', $component, 2);
536 - if (count($sub_components) == 1) {
 535+ $sub_components = explode( '=', $component, 2 );
 536+ if ( count( $sub_components ) == 1 ) {
537537 // add handling for single-value params, for custom input types
538538 $field_args[$sub_components[0]] = null;
539 - } elseif (count($sub_components) == 2) {
540 - if ($sub_components[0] == 'input type') {
 539+ } elseif ( count( $sub_components ) == 2 ) {
 540+ if ( $sub_components[0] == 'input type' ) {
541541 $input_type = $sub_components[1];
542 - } elseif ($sub_components[0] == 'default') {
 542+ } elseif ( $sub_components[0] == 'default' ) {
543543 $default_value = $sub_components[1];
544 - } elseif ($sub_components[0] == 'preload') {
 544+ } elseif ( $sub_components[0] == 'preload' ) {
545545 // free text field has special handling
546 - if ($field_name == 'free text' || $field_name = '<freetext>') {
 546+ if ( $field_name == 'free text' || $field_name = '<freetext>' ) {
547547 $free_text_preload_page = $sub_components[1];
548548 } else {
549549 // this variable is not used
550550 $preload_page = $sub_components[1];
551551 }
552 - } elseif ($sub_components[0] == 'show on select') {
 552+ } elseif ( $sub_components[0] == 'show on select' ) {
553553 // html_entity_decode() is needed to turn '&gt;' to '>'
554 - $vals = explode(';', html_entity_decode($sub_components[1]));
555 - foreach ($vals as $val) {
556 - $option_div_pair = explode('=>', $val, 2);
557 - if (count($option_div_pair) > 1) {
 554+ $vals = explode( ';', html_entity_decode( $sub_components[1] ) );
 555+ foreach ( $vals as $val ) {
 556+ $option_div_pair = explode( '=>', $val, 2 );
 557+ if ( count( $option_div_pair ) > 1 ) {
558558 $option = $option_div_pair[0];
559559 $div_id = $option_div_pair[1];
560 - if (array_key_exists($div_id, $show_on_select))
 560+ if ( array_key_exists( $div_id, $show_on_select ) )
561561 $show_on_select[$div_id][] = $option;
562562 else
563 - $show_on_select[$div_id] = array($option);
 563+ $show_on_select[$div_id] = array( $option );
564564 } else {
565565 $show_on_select[$val] = array();
566566 }
567567 }
568 - } elseif ($sub_components[0] == 'autocomplete on property') {
 568+ } elseif ( $sub_components[0] == 'autocomplete on property' ) {
569569 // HACK - we need to figure out if this property is a
570570 // relation or attribute, i.e. whether it points to wiki
571571 // pages or not; so construct an SFTemplateField object
572572 // with this property, and determine it that way
573573 $property_name = $sub_components[1];
574574 $dummy_field = new SFTemplateField();
575 - $dummy_field->setSemanticProperty($property_name);
576 - if ($dummy_field->propertyIsOfType('_wpg'))
 575+ $dummy_field->setSemanticProperty( $property_name );
 576+ if ( $dummy_field->propertyIsOfType( '_wpg' ) )
577577 $field_args['autocomplete field type'] = 'relation';
578578 else
579579 $field_args['autocomplete field type'] = 'attribute';
580580 $field_args['autocompletion source'] = $sub_components[1];
581 - } elseif ($sub_components[0] == 'autocomplete on') { // for backwards-compatibility
 581+ } elseif ( $sub_components[0] == 'autocomplete on' ) { // for backwards-compatibility
582582 $field_args['autocomplete field type'] = 'category';
583583 $field_args['autocompletion source'] = $sub_components[1];
584 - } elseif ($sub_components[0] == 'autocomplete on category') {
 584+ } elseif ( $sub_components[0] == 'autocomplete on category' ) {
585585 $field_args['autocomplete field type'] = 'category';
586586 $field_args['autocompletion source'] = $sub_components[1];
587 - } elseif ($sub_components[0] == 'autocomplete on concept') {
 587+ } elseif ( $sub_components[0] == 'autocomplete on concept' ) {
588588 $field_args['autocomplete field type'] = 'concept';
589589 $field_args['autocompletion source'] = $sub_components[1];
590 - } elseif ($sub_components[0] == 'autocomplete on namespace') {
 590+ } elseif ( $sub_components[0] == 'autocomplete on namespace' ) {
591591 $field_args['autocomplete field type'] = 'namespace';
592592 $autocompletion_source = $sub_components[1];
593593 // special handling for "main" (blank) namespace
594 - if ($autocompletion_source == "")
 594+ if ( $autocompletion_source == "" )
595595 $autocompletion_source = "main";
596596 $field_args['autocompletion source'] = $autocompletion_source;
597 - } elseif ($sub_components[0] == 'autocomplete from url') {
 597+ } elseif ( $sub_components[0] == 'autocomplete from url' ) {
598598 $field_args['autocomplete field type'] = 'external_url';
599599 $field_args['autocompletion source'] = $sub_components[1];
600600 // 'external' autocompletion is always done remotely, i.e. via API
601601 $field_args['remote autocompletion'] = true;
602 - } elseif ($sub_components[0] == 'values') {
 602+ } elseif ( $sub_components[0] == 'values' ) {
603603 // remove whitespaces, and un-escape characters
604 - $possible_values = array_map('trim', explode(',', $sub_components[1]));
605 - $possible_values = array_map('htmlspecialchars_decode', $possible_values);
606 - } elseif ($sub_components[0] == 'values from category') {
607 - $category_name = ucfirst($sub_components[1]);
608 - $possible_values = SFUtils::getAllPagesForCategory($category_name, 10);
609 - } elseif ($sub_components[0] == 'values from concept') {
610 - $possible_values = SFUtils::getAllPagesForConcept($sub_components[1]);
611 - } elseif ($sub_components[0] == 'property') {
 604+ $possible_values = array_map( 'trim', explode( ',', $sub_components[1] ) );
 605+ $possible_values = array_map( 'htmlspecialchars_decode', $possible_values );
 606+ } elseif ( $sub_components[0] == 'values from category' ) {
 607+ $category_name = ucfirst( $sub_components[1] );
 608+ $possible_values = SFUtils::getAllPagesForCategory( $category_name, 10 );
 609+ } elseif ( $sub_components[0] == 'values from concept' ) {
 610+ $possible_values = SFUtils::getAllPagesForConcept( $sub_components[1] );
 611+ } elseif ( $sub_components[0] == 'property' ) {
612612 $semantic_property = $sub_components[1];
613 - } elseif ($sub_components[0] == 'default filename') {
614 - $default_filename = str_replace('&lt;page name&gt;', $page_name, $sub_components[1]);
 613+ } elseif ( $sub_components[0] == 'default filename' ) {
 614+ $default_filename = str_replace( '&lt;page name&gt;', $page_name, $sub_components[1] );
615615 $field_args['default filename'] = $default_filename;
616616 } else {
617617 $field_args[$sub_components[0]] = $sub_components[1];
618618 }
619619 // for backwards compatibility
620 - if ($sub_components[0] == 'autocomplete on' && $sub_components[1] == null) {
 620+ if ( $sub_components[0] == 'autocomplete on' && $sub_components[1] == null ) {
621621 $field_args['no autocomplete'] = true;
622622 }
623623 }
624624 }
625625 } // end for
626 - if ($allow_multiple)
 626+ if ( $allow_multiple )
627627 $field_args['part_of_multiple'] = $allow_multiple;
628 - if (count($show_on_select) > 0)
 628+ if ( count( $show_on_select ) > 0 )
629629 $field_args['show on select'] = $show_on_select;
630630 // get the value from the request, if it's there, and if it's not
631631 // an array
632 - $escaped_field_name = str_replace("'", "\'", $field_name);
633 - if (isset($template_instance_query_values) &&
 632+ $escaped_field_name = str_replace( "'", "\'", $field_name );
 633+ if ( isset( $template_instance_query_values ) &&
634634 $template_instance_query_values != null &&
635 - is_array($template_instance_query_values) &&
636 - array_key_exists($escaped_field_name, $template_instance_query_values)) {
 635+ is_array( $template_instance_query_values ) &&
 636+ array_key_exists( $escaped_field_name, $template_instance_query_values ) ) {
637637 $field_query_val = $template_instance_query_values[$escaped_field_name];
638 - if ($form_submitted || ($field_query_val != '' && ! is_array($field_query_val))) {
 638+ if ( $form_submitted || ( $field_query_val != '' && ! is_array( $field_query_val ) ) ) {
639639 $cur_value = $field_query_val;
640640 }
641641 } else
642642 $cur_value = '';
643 - //if ($cur_value && ! is_array($cur_value)) {
644 - //$cur_value = htmlspecialchars($cur_value);
645 - //}
 643+ // if ($cur_value && ! is_array($cur_value)) {
 644+ // $cur_value = htmlspecialchars($cur_value);
 645+ // }
646646
647 - if ($cur_value == null) {
 647+ if ( $cur_value == null ) {
648648 // set to default value specified in the form, if it's there
649649 $cur_value = $default_value;
650650 }
@@ -651,13 +651,13 @@
652652 // if the user is editing a page, and that page contains a call to
653653 // the template being processed, get the current field's value
654654 // from the template call
655 - if ($source_is_page && (! empty($existing_template_text))) {
656 - if (isset($template_contents[$field_name])) {
 655+ if ( $source_is_page && ( ! empty( $existing_template_text ) ) ) {
 656+ if ( isset( $template_contents[$field_name] ) ) {
657657 $cur_value = $template_contents[$field_name];
658658 // now remove this value from $template_contents, so that
659659 // at the end we can have a list of all the fields that
660660 // weren't handled by the form
661 - unset($template_contents[$field_name]);
 661+ unset( $template_contents[$field_name] );
662662 } else {
663663 $cur_value = '';
664664 }
@@ -666,27 +666,27 @@
667667 // handle the free text field - if it was declared as
668668 // "field|free text" (a deprecated usage), it has to be outside
669669 // of a template
670 - if (($template_name == '' && $field_name == 'free text') ||
671 - $field_name == '<freetext>') {
 670+ if ( ( $template_name == '' && $field_name == 'free text' ) ||
 671+ $field_name == '<freetext>' ) {
672672 // add placeholders for the free text in both the form and
673673 // the page, using <free_text> tags - once all the free text
674674 // is known (at the end), it will get substituted in
675 - if ($is_hidden) {
676 - $new_text = SFFormUtils::hiddenFieldHTML('free_text', '!free_text!');
 675+ if ( $is_hidden ) {
 676+ $new_text = SFFormUtils::hiddenFieldHTML( 'free_text', '!free_text!' );
677677 } else {
678 - if (! array_key_exists('rows', $field_args))
 678+ if ( ! array_key_exists( 'rows', $field_args ) )
679679 $field_args['rows'] = 5;
680 - if (! array_key_exists('cols', $field_args))
 680+ if ( ! array_key_exists( 'cols', $field_args ) )
681681 $field_args['cols'] = 80;
682682 $sfgTabIndex++;
683683 $sfgFieldNum++;
684 - list($new_text, $new_javascript_text) = SFFormInputs::textAreaHTML('!free_text!', 'free_text', false, ($form_is_disabled || $is_restricted), $field_args);
685 - if (in_array('edittools', $free_text_components)) {
 684+ list( $new_text, $new_javascript_text ) = SFFormInputs::textAreaHTML( '!free_text!', 'free_text', false, ( $form_is_disabled || $is_restricted ), $field_args );
 685+ if ( in_array( 'edittools', $free_text_components ) ) {
686686 // borrowed from EditPage::showEditTools()
687687 $options[] = 'parse';
688688 $edittools_text = wfMsgExt( 'edittools', array( 'parse' ), array( 'content' ) );
689689
690 - $new_text .=<<<END
 690+ $new_text .= <<<END
691691 <div class="mw-editTools">
692692 $edittools_text
693693 </div>
@@ -700,22 +700,22 @@
701701 $data_text .= "!free_text!\n";
702702 }
703703
704 - if ($template_name == '' || $field_name == '<freetext>') {
705 - $section = substr_replace($section, $new_text, $brackets_loc, $brackets_end_loc + 3 - $brackets_loc);
 704+ if ( $template_name == '' || $field_name == '<freetext>' ) {
 705+ $section = substr_replace( $section, $new_text, $brackets_loc, $brackets_end_loc + 3 - $brackets_loc );
706706 } else {
707 - if (is_array($cur_value)) {
 707+ if ( is_array( $cur_value ) ) {
708708 // first, check if it's a list
709 - if (array_key_exists('is_list', $cur_value) &&
710 - $cur_value['is_list'] == true) {
 709+ if ( array_key_exists( 'is_list', $cur_value ) &&
 710+ $cur_value['is_list'] == true ) {
711711 $cur_value_in_template = "";
712 - if (array_key_exists('delimiter', $field_args)) {
 712+ if ( array_key_exists( 'delimiter', $field_args ) ) {
713713 $delimiter = $field_args['delimiter'];
714714 } else {
715715 $delimiter = ",";
716716 }
717 - foreach ($cur_value as $key => $val) {
718 - if ($key !== "is_list") {
719 - if ($cur_value_in_template != "") {
 717+ foreach ( $cur_value as $key => $val ) {
 718+ if ( $key !== "is_list" ) {
 719+ if ( $cur_value_in_template != "" ) {
720720 $cur_value_in_template .= $delimiter . " ";
721721 }
722722 $cur_value_in_template .= $val;
@@ -727,72 +727,72 @@
728728 // 3 elements, assume it's a date
729729 // - this handling will have to get more complex if other
730730 // possibilities get added
731 - if (count($cur_value) == 1) {
 731+ if ( count( $cur_value ) == 1 ) {
732732 // manually load SMW's message values here, in case they
733733 // didn't get loaded before
734 - wfLoadExtensionMessages('SemanticMediaWiki');
735 - $words_for_false = explode(',', wfMsgForContent('smw_false_words'));
 734+ wfLoadExtensionMessages( 'SemanticMediaWiki' );
 735+ $words_for_false = explode( ',', wfMsgForContent( 'smw_false_words' ) );
736736 // for each language, there's a series of words that are
737737 // equal to false - get the word in the series that matches
738738 // "no"; generally, that's the third word
739739 $index_of_no = 2;
740 - if (count($words_for_false) > $index_of_no) {
741 - $no = ucwords($words_for_false[$index_of_no]);
742 - } elseif (count($words_for_false) == 0) {
 740+ if ( count( $words_for_false ) > $index_of_no ) {
 741+ $no = ucwords( $words_for_false[$index_of_no] );
 742+ } elseif ( count( $words_for_false ) == 0 ) {
743743 $no = "0"; // some safe value if no words are found
744744 } else {
745 - $no = ucwords($words_for_false[0]);
 745+ $no = ucwords( $words_for_false[0] );
746746 }
747747 $cur_value_in_template = $no;
748 - } elseif (count($cur_value) == 2) {
749 - wfLoadExtensionMessages('SemanticMediaWiki');
750 - $words_for_true = explode(',', wfMsgForContent('smw_true_words'));
 748+ } elseif ( count( $cur_value ) == 2 ) {
 749+ wfLoadExtensionMessages( 'SemanticMediaWiki' );
 750+ $words_for_true = explode( ',', wfMsgForContent( 'smw_true_words' ) );
751751 // get the value in the 'true' series that tends to be "yes",
752752 // and go with that one - generally, that's the third word
753753 $index_of_yes = 2;
754 - if (count($words_for_true) > $index_of_yes) {
755 - $yes = ucwords($words_for_true[$index_of_yes]);
756 - } elseif (count($words_for_true) == 0) {
 754+ if ( count( $words_for_true ) > $index_of_yes ) {
 755+ $yes = ucwords( $words_for_true[$index_of_yes] );
 756+ } elseif ( count( $words_for_true ) == 0 ) {
757757 $yes = "1"; // some safe value if no words are found
758758 } else {
759 - $yes = ucwords($words_for_true[0]);
 759+ $yes = ucwords( $words_for_true[0] );
760760 }
761761 $cur_value_in_template = $yes;
762762 // if it's 3 or greater, assume it's a date or datetime
763 - } elseif (count($cur_value) >= 3) {
 763+ } elseif ( count( $cur_value ) >= 3 ) {
764764 $month = $cur_value['month'];
765765 $day = $cur_value['day'];
766 - if ($day != '') {
 766+ if ( $day != '' ) {
767767 global $wgAmericanDates;
768 - if ($wgAmericanDates == false) {
 768+ if ( $wgAmericanDates == false ) {
769769 // pad out day to always be two digits
770 - $day = str_pad($day, 2, "0", STR_PAD_LEFT);
 770+ $day = str_pad( $day, 2, "0", STR_PAD_LEFT );
771771 }
772772 }
773773 $year = $cur_value['year'];
774774 $hour = $minute = $second = $ampm24h = $timezone = null;
775 - if (isset($cur_value['hour'])) $hour = $cur_value['hour'];
776 - if (isset($cur_value['minute'])) $minute = $cur_value['minute'];
777 - if (isset($cur_value['second'])) $second = $cur_value['second'];
778 - if (isset($cur_value['ampm24h'])) $ampm24h = $cur_value['ampm24h'];
779 - if (isset($cur_value['timezone'])) $timezone = $cur_value['timezone'];
780 - if ($month != '' && $day != '' && $year != '') {
 775+ if ( isset( $cur_value['hour'] ) ) $hour = $cur_value['hour'];
 776+ if ( isset( $cur_value['minute'] ) ) $minute = $cur_value['minute'];
 777+ if ( isset( $cur_value['second'] ) ) $second = $cur_value['second'];
 778+ if ( isset( $cur_value['ampm24h'] ) ) $ampm24h = $cur_value['ampm24h'];
 779+ if ( isset( $cur_value['timezone'] ) ) $timezone = $cur_value['timezone'];
 780+ if ( $month != '' && $day != '' && $year != '' ) {
781781 // special handling for American dates - otherwise, just
782782 // the standard year/month/day (where month is a number)
783783 global $wgAmericanDates;
784 - if ($wgAmericanDates == true) {
 784+ if ( $wgAmericanDates == true ) {
785785 $cur_value_in_template = "$month $day, $year";
786786 } else {
787787 $cur_value_in_template = "$year/$month/$day";
788788 }
789789 // include whatever time information we have
790 - if (! is_null($hour))
791 - $cur_value_in_template .= " " . str_pad(intval(substr($hour,0,2)),2,'0',STR_PAD_LEFT) . ":" . str_pad(intval(substr($minute,0,2)),2,'0',STR_PAD_LEFT);
792 - if (! is_null($second))
793 - $cur_value_in_template .= ":" . str_pad(intval(substr($second,0,2)),2,'0',STR_PAD_LEFT);
794 - if (! is_null($ampm24h))
 790+ if ( ! is_null( $hour ) )
 791+ $cur_value_in_template .= " " . str_pad( intval( substr( $hour, 0, 2 ) ), 2, '0', STR_PAD_LEFT ) . ":" . str_pad( intval( substr( $minute, 0, 2 ) ), 2, '0', STR_PAD_LEFT );
 792+ if ( ! is_null( $second ) )
 793+ $cur_value_in_template .= ":" . str_pad( intval( substr( $second, 0, 2 ) ), 2, '0', STR_PAD_LEFT );
 794+ if ( ! is_null( $ampm24h ) )
795795 $cur_value_in_template .= " $ampm24h";
796 - if (! is_null($timezone))
 796+ if ( ! is_null( $timezone ) )
797797 $cur_value_in_template .= " $timezone";
798798 } else {
799799 $cur_value_in_template = "";
@@ -802,9 +802,9 @@
803803 } else { // value is not an array
804804 $cur_value_in_template = $cur_value;
805805 }
806 - if ($query_template_name == null || $query_template_name == '')
 806+ if ( $query_template_name == null || $query_template_name == '' )
807807 $input_name = $field_name;
808 - elseif ($allow_multiple)
 808+ elseif ( $allow_multiple )
809809 // 'num' will get replaced by an actual index, either in PHP
810810 // or in Javascript, later on
811811 $input_name = $query_template_name . '[num][' . $field_name . ']';
@@ -814,90 +814,90 @@
815815 // if we're creating the page name from a formula based on
816816 // form values, see if the current input is part of that formula,
817817 // and if so, substitute in the actual value
818 - if ($form_submitted && $generated_page_name != '') {
 818+ if ( $form_submitted && $generated_page_name != '' ) {
819819 // this line appears unnecessary
820 - //$generated_page_name = str_replace('.', '_', $generated_page_name);
821 - $generated_page_name = str_replace(' ', '_', $generated_page_name);
822 - $escaped_input_name = str_replace(' ', '_', $input_name);
823 - $generated_page_name = str_ireplace("<$escaped_input_name>", $cur_value_in_template, $generated_page_name);
 820+ // $generated_page_name = str_replace('.', '_', $generated_page_name);
 821+ $generated_page_name = str_replace( ' ', '_', $generated_page_name );
 822+ $escaped_input_name = str_replace( ' ', '_', $input_name );
 823+ $generated_page_name = str_ireplace( "<$escaped_input_name>", $cur_value_in_template, $generated_page_name );
824824 // once the substitution is done, replace underlines back
825825 // with spaces
826 - $generated_page_name = str_replace('_', ' ', $generated_page_name);
 826+ $generated_page_name = str_replace( '_', ' ', $generated_page_name );
827827 }
828828 // disable this field if either the whole form is disabled, or
829829 // it's a restricted field and user doesn't have sysop privileges
830 - $is_disabled = ($form_is_disabled ||
831 - ($is_restricted && (! $wgUser || ! $wgUser->isAllowed('editrestrictedfields'))));
 830+ $is_disabled = ( $form_is_disabled ||
 831+ ( $is_restricted && ( ! $wgUser || ! $wgUser->isAllowed( 'editrestrictedfields' ) ) ) );
832832 // create an SFFormField instance based on all the
833833 // parameters in the form definition, and any information from
834834 // the template definition (contained in the $all_fields parameter)
835 - $form_field = SFFormField::createFromDefinition($field_name, $input_name,
 835+ $form_field = SFFormField::createFromDefinition( $field_name, $input_name,
836836 $is_mandatory, $is_hidden, $is_uploadable, $possible_values, $is_disabled,
837 - $is_list, $input_type, $field_args, $all_fields, $strict_parsing);
 837+ $is_list, $input_type, $field_args, $all_fields, $strict_parsing );
838838 // if a property was set in the form definition, overwrite whatever
839839 // is set in the template field - this is somewhat of a hack, since
840840 // parameters set in the form definition are meant to go into the
841841 // SFFormField object, not the SFTemplateField object it contains;
842842 // it seemed like too much work, though, to create an
843843 // SFFormField::setSemanticProperty() function just for this call
844 - if ($semantic_property != null)
845 - $form_field->template_field->setSemanticProperty($semantic_property);
 844+ if ( $semantic_property != null )
 845+ $form_field->template_field->setSemanticProperty( $semantic_property );
846846
847847 // call hooks - unfortunately this has to be split into two
848848 // separate calls, because of the different variable names in
849849 // each case
850 - if ($form_submitted)
851 - wfRunHooks('sfCreateFormField', array(&$form_field, &$cur_value_in_template, true));
 850+ if ( $form_submitted )
 851+ wfRunHooks( 'sfCreateFormField', array( &$form_field, &$cur_value_in_template, true ) );
852852 else
853 - wfRunHooks('sfCreateFormField', array(&$form_field, &$cur_value, false));
 853+ wfRunHooks( 'sfCreateFormField', array( &$form_field, &$cur_value, false ) );
854854 // if this is not part of a 'multiple' template, increment the
855855 // global tab index (used for correct tabbing)
856 - if (! array_key_exists('part_of_multiple', $field_args))
 856+ if ( ! array_key_exists( 'part_of_multiple', $field_args ) )
857857 $sfgTabIndex++;
858858 // increment the global field number regardless
859859 $sfgFieldNum++;
860860 // if the field is a date field, and its default value was set
861861 // to 'now', and it has no current value, set $cur_value to be
862862 // the current date
863 - if ($default_value == 'now' &&
 863+ if ( $default_value == 'now' &&
864864 // if the date is hidden, cur_value will already be set
865865 // to the default value
866 - ($cur_value == '' || $cur_value == 'now')) {
867 - if ($input_type == 'date' || $input_type == 'datetime' ||
 866+ ( $cur_value == '' || $cur_value == 'now' ) ) {
 867+ if ( $input_type == 'date' || $input_type == 'datetime' ||
868868 $input_type == 'datetime with timezone' || $input_type == 'year' ||
869 - ($input_type == '' && $form_field->template_field->propertyIsOfType('_dat'))) {
 869+ ( $input_type == '' && $form_field->template_field->propertyIsOfType( '_dat' ) ) ) {
870870 // get current time, for the time zone specified in the wiki
871871 global $wgLocaltimezone;
872 - putenv('TZ=' . $wgLocaltimezone);
 872+ putenv( 'TZ=' . $wgLocaltimezone );
873873 $cur_time = time();
874 - $year = date("Y", $cur_time);
875 - $month = date("n", $cur_time);
876 - $day = date("j", $cur_time);
 874+ $year = date( "Y", $cur_time );
 875+ $month = date( "n", $cur_time );
 876+ $day = date( "j", $cur_time );
877877 global $wgAmericanDates, $sfg24HourTime;
878 - if ($wgAmericanDates == true) {
 878+ if ( $wgAmericanDates == true ) {
879879 $month_names = SFFormUtils::getMonthNames();
880880 $month_name = $month_names[$month - 1];
881881 $cur_value_in_template = "$month_name $day, $year";
882882 } else {
883883 $cur_value_in_template = "$year/$month/$day";
884884 }
885 - if ($input_type == 'datetime' || $input_type == 'datetime with timezone') {
886 - if ($sfg24HourTime) {
887 - $hour = str_pad(intval(substr(date("G", $cur_time),0,2)),2,'0',STR_PAD_LEFT);
 885+ if ( $input_type == 'datetime' || $input_type == 'datetime with timezone' ) {
 886+ if ( $sfg24HourTime ) {
 887+ $hour = str_pad( intval( substr( date( "G", $cur_time ), 0, 2 ) ), 2, '0', STR_PAD_LEFT );
888888 } else {
889 - $hour = str_pad(intval(substr(date("g", $cur_time),0,2)),2,'0',STR_PAD_LEFT);
 889+ $hour = str_pad( intval( substr( date( "g", $cur_time ), 0, 2 ) ), 2, '0', STR_PAD_LEFT );
890890 }
891 - $minute = str_pad(intval(substr(date("i", $cur_time),0,2)),2,'0',STR_PAD_LEFT);
892 - $second = str_pad(intval(substr(date("s", $cur_time),0,2)),2,'0',STR_PAD_LEFT);
893 - if ($sfg24HourTime) {
 891+ $minute = str_pad( intval( substr( date( "i", $cur_time ), 0, 2 ) ), 2, '0', STR_PAD_LEFT );
 892+ $second = str_pad( intval( substr( date( "s", $cur_time ), 0, 2 ) ), 2, '0', STR_PAD_LEFT );
 893+ if ( $sfg24HourTime ) {
894894 $cur_value_in_template .= " $hour:$minute:$second";
895895 } else {
896 - $ampm = date("A", $cur_time);
 896+ $ampm = date( "A", $cur_time );
897897 $cur_value_in_template .= " $hour:$minute:$second $ampm";
898898 }
899899 }
900 - if ($input_type == 'datetime with timezone') {
901 - $timezone = date("T", $cur_time);
 900+ if ( $input_type == 'datetime with timezone' ) {
 901+ $timezone = date( "T", $cur_time );
902902 $cur_value_in_template .= " $timezone";
903903 }
904904 }
@@ -905,68 +905,68 @@
906906 // if the field is a text field, and its default value was set
907907 // to 'current user', and it has no current value, set $cur_value
908908 // to be the current user
909 - if ($default_value == 'current user' &&
 909+ if ( $default_value == 'current user' &&
910910 // if the date is hidden, cur_value will already be set
911911 // to the default value
912 - ($cur_value == '' || $cur_value == 'current user')) {
913 - if ($input_type == 'text' || $input_type == '') {
 912+ ( $cur_value == '' || $cur_value == 'current user' ) ) {
 913+ if ( $input_type == 'text' || $input_type == '' ) {
914914 $cur_value_in_template = $wgUser->getName();
915915 $cur_value = $cur_value_in_template;
916916 }
917917 }
918 - list($new_text, $new_javascript_text) = $this->formFieldHTML($form_field, $cur_value);
 918+ list( $new_text, $new_javascript_text ) = $this->formFieldHTML( $form_field, $cur_value );
919919
920920 $fields_javascript_text .= $new_javascript_text;
921921
922922 // if this field is disabled, add a hidden field holding
923923 // the value of this field, because disabled inputs for some
924924 // reason don't submit their value
925 - if ($form_field->is_disabled) {
926 - if ($field_name == 'free text' || $field_name == '<freetext>') {
927 - $new_text .= SFFormUtils::hiddenFieldHTML('free_text', '!free_text!');
 925+ if ( $form_field->is_disabled ) {
 926+ if ( $field_name == 'free text' || $field_name == '<freetext>' ) {
 927+ $new_text .= SFFormUtils::hiddenFieldHTML( 'free_text', '!free_text!' );
928928 } else {
929 - $new_text .= SFFormUtils::hiddenFieldHTML($input_name, $cur_value);
 929+ $new_text .= SFFormUtils::hiddenFieldHTML( $input_name, $cur_value );
930930 }
931931 }
932932
933 - if ($new_text) {
 933+ if ( $new_text ) {
934934 // include the field name only for non-numeric field names
935 - if (is_numeric($field_name)) {
 935+ if ( is_numeric( $field_name ) ) {
936936 $template_text .= "|$cur_value_in_template";
937937 } else {
938938 // if the value is null, don't include it at all
939 - if ($cur_value_in_template != '')
 939+ if ( $cur_value_in_template != '' )
940940 $template_text .= "\n|$field_name=$cur_value_in_template";
941941 }
942 - $section = substr_replace($section, $new_text, $brackets_loc, $brackets_end_loc + 3 - $brackets_loc);
 942+ $section = substr_replace( $section, $new_text, $brackets_loc, $brackets_end_loc + 3 - $brackets_loc );
943943 // also add to Javascript validation code
944944 $input_id = "input_" . $sfgFieldNum;
945945 $info_id = "info_" . $sfgFieldNum;
946 - if ($is_mandatory) {
947 - if ($input_type == 'date' || $input_type == 'datetime' || $input_type == 'datetime with timezone' ||
948 - ($input_type == '' && $form_field->template_field->propertyIsOfType('_dat'))) {
 946+ if ( $is_mandatory ) {
 947+ if ( $input_type == 'date' || $input_type == 'datetime' || $input_type == 'datetime with timezone' ||
 948+ ( $input_type == '' && $form_field->template_field->propertyIsOfType( '_dat' ) ) ) {
949949 $sfgJSValidationCalls[] = "validate_mandatory_field ('$input_id" . "_month', '$info_id')";
950950 $sfgJSValidationCalls[] = "validate_mandatory_field ('$input_id" . "_day', '$info_id')";
951951 $sfgJSValidationCalls[] = "validate_mandatory_field ('$input_id" . "_year', '$info_id')";
952 - if ($input_type == 'datetime' || $input_type == 'datetime with timezone') {
 952+ if ( $input_type == 'datetime' || $input_type == 'datetime with timezone' ) {
953953 // TODO - validate the time fields
954 - if ($input_type == 'datetime with timezone') {
 954+ if ( $input_type == 'datetime with timezone' ) {
955955 // TODO - validate the timezone
956956 }
957957 }
958958 } else {
959 - if ($allow_multiple) {
960 - if ($all_instances_printed) {
 959+ if ( $allow_multiple ) {
 960+ if ( $all_instances_printed ) {
961961 $sfgJSValidationCalls[] = "validate_multiple_mandatory_fields($sfgFieldNum)";
962962 } else {
963963 $sfgJSValidationCalls[] = "validate_mandatory_field(\"input_$sfgFieldNum\", \"info_$sfgFieldNum\")";
964964 }
965 - } elseif ($input_type == 'radiobutton' || $input_type == 'category') {
 965+ } elseif ( $input_type == 'radiobutton' || $input_type == 'category' ) {
966966 // only add this if there's a "None" option
967 - if (empty($default_value)) {
 967+ if ( empty( $default_value ) ) {
968968 $sfgJSValidationCalls[] = "validate_mandatory_radiobutton('$input_id', '$info_id')";
969969 }
970 - } elseif (($form_field->template_field->is_list && $form_field->template_field->field_type == 'enumeration' && $input_type != 'listbox') || ($input_type == 'checkboxes')) {
 970+ } elseif ( ( $form_field->template_field->is_list && $form_field->template_field->field_type == 'enumeration' && $input_type != 'listbox' ) || ( $input_type == 'checkboxes' ) ) {
971971 $sfgJSValidationCalls[] = "validate_mandatory_checkboxes('$input_id', '$info_id')";
972972 } else {
973973 $sfgJSValidationCalls[] = "validate_mandatory_field('$input_id', '$info_id')";
@@ -980,30 +980,30 @@
981981 // =====================================================
982982 // standard input processing
983983 // =====================================================
984 - } elseif ($tag_title == 'standard input') {
 984+ } elseif ( $tag_title == 'standard input' ) {
985985 // handle all the possible values
986986 $input_name = $tag_components[1];
987987 $input_label = null;
988988 $attr = array();
989989
990990 // if it's a query, ignore all standard inputs except run query
991 - if (($is_query && $input_name != 'run query') || (!$is_query && $input_name == 'run query')) {
 991+ if ( ( $is_query && $input_name != 'run query' ) || ( !$is_query && $input_name == 'run query' ) ) {
992992 $new_text = "";
993 - $section = substr_replace($section, $new_text, $brackets_loc, $brackets_end_loc + 3 - $brackets_loc);
 993+ $section = substr_replace( $section, $new_text, $brackets_loc, $brackets_end_loc + 3 - $brackets_loc );
994994 continue;
995995 }
996996 // set a flag so that the standard 'form bottom' won't get displayed
997997 $this->standardInputsIncluded = true;
998998 // cycle through the other components
999 - for ($i = 2; $i < count($tag_components); $i++) {
 999+ for ( $i = 2; $i < count( $tag_components ); $i++ ) {
10001000 $component = $tag_components[$i];
1001 - $sub_components = explode('=', $component);
1002 - if (count($sub_components) == 1) {
1003 - if ($sub_components[0] == 'edittools') {
 1001+ $sub_components = explode( '=', $component );
 1002+ if ( count( $sub_components ) == 1 ) {
 1003+ if ( $sub_components[0] == 'edittools' ) {
10041004 $free_text_components[] = 'edittools';
10051005 }
1006 - } elseif (count($sub_components) == 2) {
1007 - switch($sub_components[0]) {
 1006+ } elseif ( count( $sub_components ) == 2 ) {
 1007+ switch( $sub_components[0] ) {
10081008 case 'label':
10091009 $input_label = $sub_components[1];
10101010 break;
@@ -1013,63 +1013,63 @@
10141014 break;
10151015 }
10161016 // free text input needs more handling than the rest
1017 - if ($input_name == 'free text' || $input_name == '<freetext>') {
1018 - if ($sub_components[0] == 'preload') {
 1017+ if ( $input_name == 'free text' || $input_name == '<freetext>' ) {
 1018+ if ( $sub_components[0] == 'preload' ) {
10191019 $free_text_preload_page = $sub_components[1];
10201020 }
10211021 }
10221022 }
10231023 }
1024 - if ($input_name == 'summary') {
1025 - $new_text = SFFormUtils::summaryInputHTML($form_is_disabled, $input_label, $attr);
1026 - } elseif ($input_name == 'minor edit') {
1027 - $new_text = SFFormUtils::minorEditInputHTML($form_is_disabled, $input_label, $attr);
1028 - } elseif ($input_name == 'watch') {
1029 - $new_text = SFFormUtils::watchInputHTML($form_is_disabled, $input_label, $attr);
1030 - } elseif ($input_name == 'save') {
1031 - $new_text = SFFormUtils::saveButtonHTML($form_is_disabled, $input_label, $attr);
1032 - } elseif ($input_name == 'preview') {
1033 - $new_text = SFFormUtils::showPreviewButtonHTML($form_is_disabled, $input_label, $attr);
1034 - } elseif ($input_name == 'changes') {
1035 - $new_text = SFFormUtils::showChangesButtonHTML($form_is_disabled, $input_label, $attr);
1036 - } elseif ($input_name == 'cancel') {
1037 - $new_text = SFFormUtils::cancelLinkHTML($form_is_disabled, $input_label, $attr);
1038 - } elseif ($input_name == 'run query') {
1039 - $new_text = SFFormUtils::runQueryButtonHTML($form_is_disabled, $input_label, $attr);
 1024+ if ( $input_name == 'summary' ) {
 1025+ $new_text = SFFormUtils::summaryInputHTML( $form_is_disabled, $input_label, $attr );
 1026+ } elseif ( $input_name == 'minor edit' ) {
 1027+ $new_text = SFFormUtils::minorEditInputHTML( $form_is_disabled, $input_label, $attr );
 1028+ } elseif ( $input_name == 'watch' ) {
 1029+ $new_text = SFFormUtils::watchInputHTML( $form_is_disabled, $input_label, $attr );
 1030+ } elseif ( $input_name == 'save' ) {
 1031+ $new_text = SFFormUtils::saveButtonHTML( $form_is_disabled, $input_label, $attr );
 1032+ } elseif ( $input_name == 'preview' ) {
 1033+ $new_text = SFFormUtils::showPreviewButtonHTML( $form_is_disabled, $input_label, $attr );
 1034+ } elseif ( $input_name == 'changes' ) {
 1035+ $new_text = SFFormUtils::showChangesButtonHTML( $form_is_disabled, $input_label, $attr );
 1036+ } elseif ( $input_name == 'cancel' ) {
 1037+ $new_text = SFFormUtils::cancelLinkHTML( $form_is_disabled, $input_label, $attr );
 1038+ } elseif ( $input_name == 'run query' ) {
 1039+ $new_text = SFFormUtils::runQueryButtonHTML( $form_is_disabled, $input_label, $attr );
10401040 }
1041 - $section = substr_replace($section, $new_text, $brackets_loc, $brackets_end_loc + 3 - $brackets_loc);
 1041+ $section = substr_replace( $section, $new_text, $brackets_loc, $brackets_end_loc + 3 - $brackets_loc );
10421042 // =====================================================
10431043 // page info processing
10441044 // =====================================================
1045 - } elseif ($tag_title == 'info') {
 1045+ } elseif ( $tag_title == 'info' ) {
10461046 // TODO: Generate an error message if this is included more than once
1047 - foreach(array_slice($tag_components, 1) as $component) {
1048 - $sub_components = explode('=', $component, 2);
 1047+ foreach ( array_slice( $tag_components, 1 ) as $component ) {
 1048+ $sub_components = explode( '=', $component, 2 );
10491049 $tag = $sub_components[0];
1050 - if ($tag == 'create title' || $tag == 'add title') {
 1050+ if ( $tag == 'create title' || $tag == 'add title' ) {
10511051 // handle this only if we're adding a page
1052 - if (! $this->mPageTitle->exists()) {
 1052+ if ( ! $this->mPageTitle->exists() ) {
10531053 $val = $sub_components[1];
10541054 $form_page_title = $val;
10551055 }
10561056 }
1057 - elseif($tag == 'edit title') {
 1057+ elseif ( $tag == 'edit title' ) {
10581058 // handle this only if we're editing a page
1059 - if ($this->mPageTitle->exists()) {
 1059+ if ( $this->mPageTitle->exists() ) {
10601060 $val = $sub_components[1];
10611061 $form_page_title = $val;
10621062 }
10631063 }
1064 - elseif($tag == 'partial form') {
 1064+ elseif ( $tag == 'partial form' ) {
10651065 $form_is_partial = true;
10661066 // replacement pages may have minimal matches...
10671067 $source_page_matches_this_form = true;
10681068 }
1069 - elseif($tag == 'includeonly free text' || $tag == 'onlyinclude free text') {
 1069+ elseif ( $tag == 'includeonly free text' || $tag == 'onlyinclude free text' ) {
10701070 $onlyinclude_free_text = true;
10711071 }
10721072 }
1073 - $section = substr_replace($section, '', $brackets_loc, $brackets_end_loc + 3 - $brackets_loc);
 1073+ $section = substr_replace( $section, '', $brackets_loc, $brackets_end_loc + 3 - $brackets_loc );
10741074 // =====================================================
10751075 // default outer level processing
10761076 // =====================================================
@@ -1079,15 +1079,15 @@
10801080 } // end if
10811081 } // end while
10821082
1083 - if (! $all_instances_printed ) {
1084 - if ($template_text != '') {
 1083+ if ( ! $all_instances_printed ) {
 1084+ if ( $template_text != '' ) {
10851085 // for mostly aesthetic purposes, if the template call ends with
10861086 // a bunch of pipes (i.e., it's an indexed template with unused
10871087 // parameters at the end), remove the pipes
1088 - $template_text = preg_replace('/\|*$/', '', $template_text);
 1088+ $template_text = preg_replace( '/\|*$/', '', $template_text );
10891089 // add another newline before the final bracket, if this template
10901090 // call is already more than one line
1091 - if (strpos($template_text, "\n"))
 1091+ if ( strpos( $template_text, "\n" ) )
10921092 $template_text .= "\n";
10931093 // if we're editing an existing page, and there were fields in
10941094 // the template call not handled by this form, preserve those
@@ -1096,30 +1096,30 @@
10971097 $data_text .= $template_text . "\n";
10981098 // if there is a placeholder in the text, we know that we are
10991099 // doing a replace
1100 - if ($existing_page_content && strpos($existing_page_content, '{{{insertionpoint}}}', 0) !== false) {
1101 - $existing_page_content = preg_replace('/\{\{\{insertionpoint\}\}\}(\r?\n?)/',
1102 - preg_replace('/\}\}/m', '}�',
1103 - preg_replace('/\{\{/m', '�{', $template_text)) .
 1100+ if ( $existing_page_content && strpos( $existing_page_content, '{{{insertionpoint}}}', 0 ) !== false ) {
 1101+ $existing_page_content = preg_replace( '/\{\{\{insertionpoint\}\}\}(\r?\n?)/',
 1102+ preg_replace( '/\}\}/m', '}�',
 1103+ preg_replace( '/\{\{/m', '�{', $template_text ) ) .
11041104 "\n{{{insertionpoint}}}",
1105 - $existing_page_content);
 1105+ $existing_page_content );
11061106 // otherwise, if it's a partial form, we have to add the new
11071107 // text somewhere
1108 - } elseif ($form_is_partial && $wgRequest->getCheck('partial') ) {
1109 - $existing_page_content = preg_replace('/\}\}/m', '}�',
1110 - preg_replace('/\{\{/m', '�{', $template_text)) .
 1108+ } elseif ( $form_is_partial && $wgRequest->getCheck( 'partial' ) ) {
 1109+ $existing_page_content = preg_replace( '/\}\}/m', '}�',
 1110+ preg_replace( '/\{\{/m', '�{', $template_text ) ) .
11111111 "\n{{{insertionpoint}}}\n" . $existing_page_content;
11121112 }
11131113 }
11141114 }
11151115
1116 - if ($allow_multiple) {
1117 - if (! $all_instances_printed) {
 1116+ if ( $allow_multiple ) {
 1117+ if ( ! $all_instances_printed ) {
11181118 // add the character "a" onto the instance number of this input
11191119 // in the form, to differentiate the inputs the form starts out
11201120 // with from any inputs added by the Javascript
1121 - $section = str_replace('[num]', "[{$instance_num}a]", $section);
1122 - $remove_text = wfMsg('sf_formedit_remove');
1123 - $form_text .=<<<END
 1121+ $section = str_replace( '[num]', "[{$instance_num}a]", $section );
 1122+ $remove_text = wfMsg( 'sf_formedit_remove' );
 1123+ $form_text .= <<<END
11241124 <div id="wrapper_$sfgFieldNum" class="multipleTemplate">
11251125 $section
11261126 <input type="button" onclick="removeInstance('wrapper_$sfgFieldNum');" value="$remove_text" tabindex="$sfgTabIndex" class="remove" />
@@ -1130,27 +1130,27 @@
11311131 $section_num--;
11321132 // because there is an instance, the fieldset will never be hidden,
11331133 // even if choosers are being used. So, do not hide the fieldset.
1134 - $form_text = str_replace("[[placeholder]]", "", $form_text);
 1134+ $form_text = str_replace( "[[placeholder]]", "", $form_text );
11351135 } else {
11361136 // this is the last instance of this template - stick an 'add'
11371137 // button in the form
1138 - $form_text .=<<<END
 1138+ $form_text .= <<<END
11391139 <div id="starter_$query_template_name" class="multipleTemplate" style="display: none;">
11401140 $section
11411141 </div>
11421142 <div id="main_$query_template_name"></div>
11431143
11441144 END;
1145 - $add_another = wfMsg('sf_formedit_addanother');
1146 - $form_text .=<<<END
 1145+ $add_another = wfMsg( 'sf_formedit_addanother' );
 1146+ $form_text .= <<<END
11471147 <p style="margin-left:10px;">
11481148 <p><input type="button" onclick="addInstance('starter_$query_template_name', 'main_$query_template_name', '$sfgFieldNum');" value="$add_another" tabindex="$sfgTabIndex" class="addAnother" /></p>
11491149
11501150 END;
11511151 // if a chooser is being used for this template, add the template
11521152 // to the chooser data array
1153 - if ($chooser_name !== false)
1154 - $choosers[$chooser_name][]= array($query_template_name, $sfgFieldNum, $chooser_caption);
 1153+ if ( $chooser_name !== false )
 1154+ $choosers[$chooser_name][] = array( $query_template_name, $sfgFieldNum, $chooser_caption );
11551155 }
11561156 } else {
11571157 $form_text .= $section;
@@ -1160,8 +1160,8 @@
11611161
11621162 // if it wasn't included in the form definition, add the
11631163 // 'free text' input as a hidden field at the bottom
1164 - if (! $free_text_was_included) {
1165 - $form_text .= SFFormUtils::hiddenFieldHTML('free_text', '!free_text!');
 1164+ if ( ! $free_text_was_included ) {
 1165+ $form_text .= SFFormUtils::hiddenFieldHTML( 'free_text', '!free_text!' );
11661166 }
11671167 // get free text, and add to page data, as well as retroactively
11681168 // inserting it into the form
@@ -1169,67 +1169,67 @@
11701170 // If $form_is_partial is true then either:
11711171 // (a) we're processing a replacement (param 'partial' == 1)
11721172 // (b) we're sending out something to be replaced (param 'partial' is missing)
1173 - if ($form_is_partial) {
1174 - if(!$wgRequest->getCheck('partial')) {
 1173+ if ( $form_is_partial ) {
 1174+ if ( !$wgRequest->getCheck( 'partial' ) ) {
11751175 $free_text = $original_page_content;
1176 - $form_text .= SFFormUtils::hiddenFieldHTML('partial', 1);
 1176+ $form_text .= SFFormUtils::hiddenFieldHTML( 'partial', 1 );
11771177 } else {
11781178 $free_text = null;
1179 - $existing_page_content = preg_replace('/�\{(.*?)\}�/s', '{{\1}}', $existing_page_content);
1180 - $existing_page_content = preg_replace('/\{\{\{insertionpoint\}\}\}/', '', $existing_page_content);
 1179+ $existing_page_content = preg_replace( '/�\{(.*?)\}�/s', '{{\1}}', $existing_page_content );
 1180+ $existing_page_content = preg_replace( '/\{\{\{insertionpoint\}\}\}/', '', $existing_page_content );
11811181 }
1182 - } elseif ($source_is_page) {
 1182+ } elseif ( $source_is_page ) {
11831183 // if the page is the source, free_text will just be whatever in the
11841184 // page hasn't already been inserted into the form
1185 - $free_text = trim($existing_page_content);
 1185+ $free_text = trim( $existing_page_content );
11861186 // or get it from a form submission
1187 - } elseif ($wgRequest->getCheck('free_text')) {
1188 - $free_text = $wgRequest->getVal('free_text');
1189 - if (! $free_text_was_included) {
 1187+ } elseif ( $wgRequest->getCheck( 'free_text' ) ) {
 1188+ $free_text = $wgRequest->getVal( 'free_text' );
 1189+ if ( ! $free_text_was_included ) {
11901190 $data_text .= "!free_text!";
11911191 }
11921192 // or get it from the form definition
1193 - } elseif ($free_text_preload_page != null) {
1194 - $free_text = SFFormUtils::getPreloadedText($free_text_preload_page);
 1193+ } elseif ( $free_text_preload_page != null ) {
 1194+ $free_text = SFFormUtils::getPreloadedText( $free_text_preload_page );
11951195 } else {
11961196 $free_text = null;
11971197 }
1198 - if ($onlyinclude_free_text) {
 1198+ if ( $onlyinclude_free_text ) {
11991199 // modify free text and data text to insert <onlyinclude> tags
1200 - $free_text = str_replace("<onlyinclude>",'', $free_text);
1201 - $free_text = str_replace("</onlyinclude>",'', $free_text);
1202 - $free_text = trim($free_text);
1203 - $data_text = str_replace('!free_text!','<onlyinclude>!free_text!</onlyinclude>', $data_text);
 1200+ $free_text = str_replace( "<onlyinclude>", '', $free_text );
 1201+ $free_text = str_replace( "</onlyinclude>", '', $free_text );
 1202+ $free_text = trim( $free_text );
 1203+ $data_text = str_replace( '!free_text!', '<onlyinclude>!free_text!</onlyinclude>', $data_text );
12041204 }
12051205 // if the FCKeditor extension is installed, use that for the free text input
12061206 global $wgFCKEditorDir;
1207 - if ($wgFCKEditorDir) {
 1207+ if ( $wgFCKEditorDir ) {
12081208 $showFCKEditor = SFFormUtils::getShowFCKEditor();
1209 - if(!$form_submitted && ($showFCKEditor & RTE_VISIBLE)) {
1210 - $free_text = SFFormUtils::prepareTextForFCK($free_text);
 1209+ if ( !$form_submitted && ( $showFCKEditor & RTE_VISIBLE ) ) {
 1210+ $free_text = SFFormUtils::prepareTextForFCK( $free_text );
12111211 }
12121212 } else {
12131213 $showFCKEditor = 0;
12141214 }
12151215 // now that we have it, substitute free text into the form and page
12161216 $escaped_free_text = Sanitizer::safeEncodeAttribute( $free_text );
1217 - $form_text = str_replace('!free_text!', $escaped_free_text, $form_text);
1218 - $data_text = str_replace('!free_text!', $free_text, $data_text);
 1217+ $form_text = str_replace( '!free_text!', $escaped_free_text, $form_text );
 1218+ $data_text = str_replace( '!free_text!', $free_text, $data_text );
12191219
12201220 // add a warning in, if we're editing an existing page and that page
12211221 // appears to not have been created with this form
1222 - if ($this->mPageTitle->exists() && ($existing_page_content != '') && ! $source_page_matches_this_form) {
1223 - $form_text = ' <div class="warningMessage">' . wfMsg('sf_formedit_formwarning', $this->mPageTitle->getFullURL()) . "</div>\n" . $form_text;
 1222+ if ( $this->mPageTitle->exists() && ( $existing_page_content != '' ) && ! $source_page_matches_this_form ) {
 1223+ $form_text = ' <div class="warningMessage">' . wfMsg( 'sf_formedit_formwarning', $this->mPageTitle->getFullURL() ) . "</div>\n" . $form_text;
12241224 }
12251225
1226 - //Substitute the choosers in here too.
 1226+ // Substitute the choosers in here too.
12271227 $chooser_count = 0;
12281228 $chooser_text = "";
12291229 $using_choosers = "false";
1230 - foreach ($choosers as $choosername => $chooser) {
1231 - if (count($chooser)!=0) {
 1230+ foreach ( $choosers as $choosername => $chooser ) {
 1231+ if ( count( $chooser ) != 0 ) {
12321232 $chooser_count++;
1233 - if ($chooser_count==1) {
 1233+ if ( $chooser_count == 1 ) {
12341234 // emit the initial javascript code
12351235 $using_choosers = "true";
12361236 $chooser_text .= <<<END
@@ -1284,53 +1284,53 @@
12851285 }
12861286
12871287 $chooser_text .= "<p>$choosername:<select id='chooserselect$chooser_count' size='1' onchange='updatechooserbutton(this,\"chooserbutton$chooser_count\")'>\n";
1288 - $chooser_text .= "<option value='invalid'>" . wfMsg('sf_createform_choosefield') . "</option>\n";
1289 - foreach ($chooser as $chooser_item) {
1290 - $chooser_value = str_replace('"','\\"',$chooser_item[0]);
 1288+ $chooser_text .= "<option value='invalid'>" . wfMsg( 'sf_createform_choosefield' ) . "</option>\n";
 1289+ foreach ( $chooser as $chooser_item ) {
 1290+ $chooser_value = str_replace( '"', '\\"', $chooser_item[0] );
12911291 $tabindex = $chooser_item[1];
12921292 $chooser_caption = $chooser_item[2];
1293 - if ($chooser_caption === false)
1294 - $chooser_caption = str_replace('_', ' ', $chooser_value);
 1293+ if ( $chooser_caption === false )
 1294+ $chooser_caption = str_replace( '_', ' ', $chooser_value );
12951295 $chooser_text .= "<option value=\"$tabindex ,$chooser_value\">$chooser_caption</option>\n";
12961296 }
12971297 $chooser_text .= "</select>\n";
12981298 }
1299 - $chooser_text .= "<input type='button' onclick=\"addInstanceFromChooser('chooserselect$chooser_count');\" value='" . wfMsg('sf_formedit_addanother') . "' disabled='true' id='chooserbutton$chooser_count'></p>";
 1299+ $chooser_text .= "<input type='button' onclick=\"addInstanceFromChooser('chooserselect$chooser_count');\" value='" . wfMsg( 'sf_formedit_addanother' ) . "' disabled='true' id='chooserbutton$chooser_count'></p>";
13001300 }
13011301
1302 - $form_text = str_replace('{{{choosers}}}', $chooser_text, $form_text);
 1302+ $form_text = str_replace( '{{{choosers}}}', $chooser_text, $form_text );
13031303
13041304 // add form bottom, if no custom "standard inputs" have been defined
13051305 if ( !$this->standardInputsIncluded ) {
1306 - if ($is_query)
1307 - $form_text .= SFFormUtils::queryFormBottom($form_is_disabled);
 1306+ if ( $is_query )
 1307+ $form_text .= SFFormUtils::queryFormBottom( $form_is_disabled );
13081308 else
1309 - $form_text .= SFFormUtils::formBottom($form_is_disabled);
 1309+ $form_text .= SFFormUtils::formBottom( $form_is_disabled );
13101310 }
13111311 $starttime = wfTimestampNow();
1312 - $page_article = new Article($this->mPageTitle);
 1312+ $page_article = new Article( $this->mPageTitle );
13131313 $edittime = $page_article->getTimestamp();
1314 - if (!$is_query)
1315 - $form_text .=<<<END
 1314+ if ( !$is_query )
 1315+ $form_text .= <<<END
13161316
13171317 <input type="hidden" value="$starttime" name="wpStarttime" />
13181318 <input type="hidden" value="$edittime" name="wpEdittime" />
13191319 END;
1320 - $form_text .=<<<END
 1320+ $form_text .= <<<END
13211321 </form>
13221322
13231323 END;
13241324
13251325 // add Javascript code for form-wide use
13261326 $javascript_text .= SFFormUtils::validationJavascript();
1327 - $javascript_text .= SFFormUtils::instancesJavascript($using_choosers);
 1327+ $javascript_text .= SFFormUtils::instancesJavascript( $using_choosers );
13281328 $javascript_text .= SFFormUtils::autocompletionJavascript();
1329 - if ($free_text_was_included && $showFCKEditor > 0) {
1330 - $javascript_text .= SFFormUtils::mainFCKJavascript($showFCKEditor);
1331 - if ($showFCKEditor & (RTE_TOGGLE_LINK | RTE_POPUP)) {
 1329+ if ( $free_text_was_included && $showFCKEditor > 0 ) {
 1330+ $javascript_text .= SFFormUtils::mainFCKJavascript( $showFCKEditor );
 1331+ if ( $showFCKEditor & ( RTE_TOGGLE_LINK | RTE_POPUP ) ) {
13321332 $javascript_text .= SFFormUTils::FCKToggleJavascript();
13331333 }
1334 - if ($showFCKEditor & RTE_POPUP) {
 1334+ if ( $showFCKEditor & RTE_POPUP ) {
13351335 $javascript_text .= SFFormUTils::FCKPopupJavascript();
13361336 }
13371337 }
@@ -1338,34 +1338,34 @@
13391339 // send the autocomplete values to the browser, along with the mappings
13401340 // of which values should apply to which fields
13411341 // if doing a replace, the data text is actually the modified original page
1342 - if($wgRequest->getCheck('partial'))
 1342+ if ( $wgRequest->getCheck( 'partial' ) )
13431343 $data_text = $existing_page_content;
13441344 $javascript_text .= $fields_javascript_text;
13451345 global $wgParser;
13461346 $new_text = "";
13471347 if ( !$embedded )
1348 - $new_text = $wgParser->preprocess(str_replace( "{{!}}", "|", $form_page_title ), $this->mPageTitle, new ParserOptions());
 1348+ $new_text = $wgParser->preprocess( str_replace( "{{!}}", "|", $form_page_title ), $this->mPageTitle, new ParserOptions() );
13491349
1350 - return array($form_text, "/*<![CDATA[*/ $javascript_text /*]]>*/",
1351 - $data_text, $new_text, $generated_page_name);
 1350+ return array( $form_text, "/*<![CDATA[*/ $javascript_text /*]]>*/",
 1351+ $data_text, $new_text, $generated_page_name );
13521352 }
13531353
13541354 /**
13551355 * Create the HTML and Javascript to display this field within a form
13561356 */
1357 - function formFieldHTML($form_field, $cur_value) {
 1357+ function formFieldHTML( $form_field, $cur_value ) {
13581358 global $smwgContLang;
13591359
13601360 // also get the actual field, with all the semantic information (type is
13611361 // SFTemplateField, instead of SFFormField)
13621362 $template_field = $form_field->template_field;
13631363
1364 - if ($form_field->is_hidden) {
1365 - $text = SFFormUtils::hiddenFieldHTML($form_field->input_name, $cur_value);
 1364+ if ( $form_field->is_hidden ) {
 1365+ $text = SFFormUtils::hiddenFieldHTML( $form_field->input_name, $cur_value );
13661366 $javascript_text = "";
1367 - } elseif ($form_field->input_type != '' &&
1368 - array_key_exists($form_field->input_type, $this->mInputTypeHooks) &&
1369 - $this->mInputTypeHooks[$form_field->input_type] != null) {
 1367+ } elseif ( $form_field->input_type != '' &&
 1368+ array_key_exists( $form_field->input_type, $this->mInputTypeHooks ) &&
 1369+ $this->mInputTypeHooks[$form_field->input_type] != null ) {
13701370 $funcArgs = array();
13711371 $funcArgs[] = $cur_value;
13721372 $funcArgs[] = $form_field->input_name;
@@ -1375,35 +1375,35 @@
13761376 // values for this input type with all other properties set in
13771377 // the form definition, plus some semantic-related arguments
13781378 $hook_values = $this->mInputTypeHooks[$form_field->input_type];
1379 - $other_args = $form_field->getArgumentsForInputCall($hook_values[1]);
 1379+ $other_args = $form_field->getArgumentsForInputCall( $hook_values[1] );
13801380 $funcArgs[] = $other_args;
1381 - list($text, $javascript_text) = call_user_func_array($hook_values[0], $funcArgs);
 1381+ list( $text, $javascript_text ) = call_user_func_array( $hook_values[0], $funcArgs );
13821382 } else { // input type not defined in form
13831383 $field_type = $template_field->field_type;
1384 - $is_list = ($form_field->is_list || $template_field->is_list);
1385 - if ($field_type != '' &&
1386 - array_key_exists($field_type, $this->mSemanticTypeHooks) &&
1387 - isset($this->mSemanticTypeHooks[$field_type][$is_list])) {
 1384+ $is_list = ( $form_field->is_list || $template_field->is_list );
 1385+ if ( $field_type != '' &&
 1386+ array_key_exists( $field_type, $this->mSemanticTypeHooks ) &&
 1387+ isset( $this->mSemanticTypeHooks[$field_type][$is_list] ) ) {
13881388 $funcArgs = array();
13891389 $funcArgs[] = $cur_value;
13901390 $funcArgs[] = $form_field->input_name;
13911391 $funcArgs[] = $form_field->is_mandatory;
13921392 $funcArgs[] = $form_field->is_disabled;
13931393 $hook_values = $this->mSemanticTypeHooks[$field_type][$is_list];
1394 - $other_args = $form_field->getArgumentsForInputCall($hook_values[1]);
 1394+ $other_args = $form_field->getArgumentsForInputCall( $hook_values[1] );
13951395 $funcArgs[] = $other_args;
1396 - list($text, $javascript_text) = call_user_func_array($hook_values[0], $funcArgs);
 1396+ list( $text, $javascript_text ) = call_user_func_array( $hook_values[0], $funcArgs );
13971397 } else { // anything else
13981398 $other_args = $form_field->getArgumentsForInputCall();
13991399 // special call to ensure that a list input is the right default size
1400 - if ($form_field->is_list) {
1401 - if (! array_key_exists('size', $other_args))
 1400+ if ( $form_field->is_list ) {
 1401+ if ( ! array_key_exists( 'size', $other_args ) )
14021402 $other_args['size'] = 100;
14031403 }
1404 - list($text, $javascript_text) = SFFormInputs::textEntryHTML($cur_value, $form_field->input_name, $form_field->is_mandatory, $form_field->is_disabled, $other_args);
 1404+ list( $text, $javascript_text ) = SFFormInputs::textEntryHTML( $cur_value, $form_field->input_name, $form_field->is_mandatory, $form_field->is_disabled, $other_args );
14051405 }
14061406 }
1407 - return array($text, $javascript_text);
 1407+ return array( $text, $javascript_text );
14081408 }
14091409
14101410 }
Index: trunk/extensions/SemanticForms/includes/SF_LinkUtils.inc
@@ -9,17 +9,17 @@
1010
1111 class SFLinkUtils {
1212
13 - static function linkText($namespace, $name, $text = NULL) {
 13+ static function linkText( $namespace, $name, $text = NULL ) {
1414 global $wgContLang;
1515
16 - $inText = $wgContLang->getNsText($namespace) . ':' . $name;
 16+ $inText = $wgContLang->getNsText( $namespace ) . ':' . $name;
1717 $title = Title::newFromText( $inText );
18 - if ($title === NULL) {
 18+ if ( $title === NULL ) {
1919 return $inText; // TODO maybe report an error here?
2020 }
2121 if ( NULL === $text ) $text = $title->getText();
2222 $l = new Linker();
23 - return $l->makeLinkObj($title, $text);
 23+ return $l->makeLinkObj( $title, $text );
2424 }
2525
2626 /**
@@ -27,16 +27,16 @@
2828 * this method is necessary because Title::getPartialURL(), for
2929 * some reason, doesn't include the namespace
3030 */
31 - static function titleURLString($title) {
 31+ static function titleURLString( $title ) {
3232 global $wgCapitalLinks;
3333
3434 $namespace = wfUrlencode( $title->getNsText() );
3535 if ( '' != $namespace ) {
3636 $namespace .= ':';
3737 }
38 - if ($wgCapitalLinks) {
 38+ if ( $wgCapitalLinks ) {
3939 global $wgContLang;
40 - return $namespace . $wgContLang->ucfirst($title->getPartialURL());
 40+ return $namespace . $wgContLang->ucfirst( $title->getPartialURL() );
4141 } else {
4242 return $namespace . $title->getPartialURL();
4343 }
@@ -46,16 +46,16 @@
4747 * A very similar function to titleURLString(), to get the
4848 * non-URL-encoded title string
4949 */
50 - static function titleString($title) {
 50+ static function titleString( $title ) {
5151 global $wgCapitalLinks;
5252
5353 $namespace = $title->getNsText();
5454 if ( '' != $namespace ) {
5555 $namespace .= ':';
5656 }
57 - if ($wgCapitalLinks) {
 57+ if ( $wgCapitalLinks ) {
5858 global $wgContLang;
59 - return $namespace . $wgContLang->ucfirst($title->getText());
 59+ return $namespace . $wgContLang->ucfirst( $title->getText() );
6060 } else {
6161 return $namespace . $title->getText();
6262 }
@@ -66,30 +66,30 @@
6767 * "alternate form", or "default form for page", for a specific page
6868 * (which should be a category, property, or namespace page)
6969 */
70 - static function getFormsThatPagePointsTo($page_name, $page_namespace, $prop_smw_id, $backup_prop_smw_id, $prop_id) {
71 - if ($page_name == NULL)
 70+ static function getFormsThatPagePointsTo( $page_name, $page_namespace, $prop_smw_id, $backup_prop_smw_id, $prop_id ) {
 71+ if ( $page_name == NULL )
7272 return array();
7373
7474 global $sfgContLang;
7575 // produce a useful error message if SMW isn't installed
76 - if (! function_exists('smwfGetStore'))
77 - die("ERROR: <a href=\"http://semantic-mediawiki.org\">Semantic MediaWiki</a> must be installed for Semantic Forms to run!");
 76+ if ( ! function_exists( 'smwfGetStore' ) )
 77+ die( "ERROR: <a href=\"http://semantic-mediawiki.org\">Semantic MediaWiki</a> must be installed for Semantic Forms to run!" );
7878 $store = smwfGetStore();
79 - $title = Title::makeTitleSafe($page_namespace, $page_name);
80 - $property = SMWPropertyValue::makeProperty($prop_smw_id);
81 - $res = $store->getPropertyValues($title, $property);
 79+ $title = Title::makeTitleSafe( $page_namespace, $page_name );
 80+ $property = SMWPropertyValue::makeProperty( $prop_smw_id );
 81+ $res = $store->getPropertyValues( $title, $property );
8282 $form_names = array();
83 - foreach ($res as $wiki_page_value) {
 83+ foreach ( $res as $wiki_page_value ) {
8484 $form_title = $wiki_page_value->getTitle();
8585 if ( ! is_null( $form_title ) ) {
8686 $form_names[] = $form_title->getText();
8787 }
8888 }
8989 // if we're using a non-English language, check for the English string as well
90 - if (! class_exists('SF_LanguageEn') || ! $sfgContLang instanceof SF_LanguageEn) {
91 - $backup_property = SMWPropertyValue::makeProperty($backup_prop_smw_id);
92 - $res = $store->getPropertyValues($title, $backup_property);
93 - foreach ($res as $wiki_page_value)
 90+ if ( ! class_exists( 'SF_LanguageEn' ) || ! $sfgContLang instanceof SF_LanguageEn ) {
 91+ $backup_property = SMWPropertyValue::makeProperty( $backup_prop_smw_id );
 92+ $res = $store->getPropertyValues( $title, $backup_property );
 93+ foreach ( $res as $wiki_page_value )
9494 $form_names[] = $wiki_page_value->getTitle()->getText();
9595 }
9696 return $form_names;
@@ -101,19 +101,19 @@
102102 * corresponding Special:FormEdit link, if any such properties are
103103 * defined
104104 */
105 - static function getFormEditLinkForPage($target_page_title, $page_name, $page_namespace) {
106 - $default_forms = self::getFormsThatPagePointsTo($page_name, $page_namespace, '_SF_DF', '_SF_DF_BACKUP', SF_SP_HAS_DEFAULT_FORM);
107 - $alt_forms = self::getFormsThatPagePointsTo($page_name, $page_namespace, '_SF_AF', '_SF_AF_BACKUP', SF_SP_HAS_ALTERNATE_FORM);
108 - if ((count($default_forms) == 0) && (count($alt_forms) == 0))
 105+ static function getFormEditLinkForPage( $target_page_title, $page_name, $page_namespace ) {
 106+ $default_forms = self::getFormsThatPagePointsTo( $page_name, $page_namespace, '_SF_DF', '_SF_DF_BACKUP', SF_SP_HAS_DEFAULT_FORM );
 107+ $alt_forms = self::getFormsThatPagePointsTo( $page_name, $page_namespace, '_SF_AF', '_SF_AF_BACKUP', SF_SP_HAS_ALTERNATE_FORM );
 108+ if ( ( count( $default_forms ) == 0 ) && ( count( $alt_forms ) == 0 ) )
109109 return null;
110 - $fe = SpecialPage::getPage('FormEdit');
 110+ $fe = SpecialPage::getPage( 'FormEdit' );
111111 $fe_url = $fe->getTitle()->getLocalURL();
112 - if (count($default_forms) > 0)
113 - $form_edit_url = $fe_url . "/" . $default_forms[0] . "/" . self::titleURLString($target_page_title);
 112+ if ( count( $default_forms ) > 0 )
 113+ $form_edit_url = $fe_url . "/" . $default_forms[0] . "/" . self::titleURLString( $target_page_title );
114114 else
115 - $form_edit_url = $fe_url . "/" . self::titleURLString($target_page_title);
116 - foreach ($alt_forms as $i => $alt_form) {
117 - $form_edit_url .= (strpos($form_edit_url, "?")) ? "&" : "?";
 115+ $form_edit_url = $fe_url . "/" . self::titleURLString( $target_page_title );
 116+ foreach ( $alt_forms as $i => $alt_form ) {
 117+ $form_edit_url .= ( strpos( $form_edit_url, "?" ) ) ? "&" : "?";
118118 $form_edit_url .= "alt_form[$i]=$alt_form";
119119 }
120120 return $form_edit_url;
@@ -123,12 +123,12 @@
124124 * Sets the URL for form-based creation of a nonexistent (broken-linked,
125125 * AKA red-linked) page, for MediaWiki 1.13
126126 */
127 - static function setBrokenLink_1_13(&$linker, $title, $query, &$u, &$style, &$prefix, &$text, &$inside, &$trail) {
128 - if (self::createLinkedPage($title)) {
 127+ static function setBrokenLink_1_13( &$linker, $title, $query, &$u, &$style, &$prefix, &$text, &$inside, &$trail ) {
 128+ if ( self::createLinkedPage( $title ) ) {
129129 return true;
130130 }
131 - $link = self::formEditLink($title);
132 - if ($link != '')
 131+ $link = self::formEditLink( $title );
 132+ if ( $link != '' )
133133 $u = $link;
134134 return true;
135135 }
@@ -137,13 +137,13 @@
138138 * Sets the URL for form-based creation of a nonexistent (broken-linked,
139139 * AKA red-linked) page
140140 */
141 - static function setBrokenLink($linker, $target, $options, $text, &$attribs, &$ret) {
142 - if (in_array('broken', $options)) {
143 - if (self::createLinkedPage($target)) {
 141+ static function setBrokenLink( $linker, $target, $options, $text, &$attribs, &$ret ) {
 142+ if ( in_array( 'broken', $options ) ) {
 143+ if ( self::createLinkedPage( $target ) ) {
144144 return true;
145145 }
146 - $link = self::formEditLink($target);
147 - if ($link != '') {
 146+ $link = self::formEditLink( $target );
 147+ if ( $link != '' ) {
148148 $attribs['href'] = $link;
149149 }
150150 }
@@ -155,39 +155,39 @@
156156 * viewed, if there's a property pointing from anywhere to that page
157157 * that's defined with the 'Creates pages with form' special property
158158 */
159 - static function createLinkedPage($title) {
 159+ static function createLinkedPage( $title ) {
160160 // if we're in a 'special' page, just exit - this is to prevent
161161 // constant additions being made from the 'Special:RecentChanges'
162162 // page, which shows pages that were previously deleted as red
163163 // links, even if they've since been recreated. The same might
164164 // hold true for other special pages.
165165 global $wgTitle;
166 - if ($wgTitle->getNamespace() == NS_SPECIAL)
 166+ if ( $wgTitle->getNamespace() == NS_SPECIAL )
167167 return false;
168168
169169 $store = smwfGetStore();
170 - $title_text = self::titleString($title);
171 - $value = SMWDataValueFactory::newTypeIDValue('_wpg', $title_text);
172 - $incoming_properties = $store->getInProperties($value);
173 - foreach ($incoming_properties as $property) {
 170+ $title_text = self::titleString( $title );
 171+ $value = SMWDataValueFactory::newTypeIDValue( '_wpg', $title_text );
 172+ $incoming_properties = $store->getInProperties( $value );
 173+ foreach ( $incoming_properties as $property ) {
174174 $property_name = $property->getWikiValue();
175 - if (empty($property_name)) continue;
176 - $property_title = Title::makeTitleSafe(SMW_NS_PROPERTY, $property_name);
177 - $auto_create_forms = self::getFormsThatPagePointsTo($property_name, SMW_NS_PROPERTY, '_SF_CP', '_SF_CP_BACKUP', SF_SP_CREATES_PAGES_WITH_FORM);
178 - if (count($auto_create_forms) > 0) {
 175+ if ( empty( $property_name ) ) continue;
 176+ $property_title = Title::makeTitleSafe( SMW_NS_PROPERTY, $property_name );
 177+ $auto_create_forms = self::getFormsThatPagePointsTo( $property_name, SMW_NS_PROPERTY, '_SF_CP', '_SF_CP_BACKUP', SF_SP_CREATES_PAGES_WITH_FORM );
 178+ if ( count( $auto_create_forms ) > 0 ) {
179179 global $sfgFormPrinter;
180180 $form_name = $auto_create_forms[0];
181 - $form_title = Title::makeTitleSafe(SF_NS_FORM, $form_name);
182 - $form_article = new Article($form_title);
 181+ $form_title = Title::makeTitleSafe( SF_NS_FORM, $form_name );
 182+ $form_article = new Article( $form_title );
183183 $form_definition = $form_article->getContent();
184 - list ($form_text, $javascript_text, $data_text, $form_page_title, $generated_page_name) =
185 - $sfgFormPrinter->formHTML($form_definition, false, false, null, null, 'Some very long page name that will hopefully never get created ABCDEF123', null);
 184+ list ( $form_text, $javascript_text, $data_text, $form_page_title, $generated_page_name ) =
 185+ $sfgFormPrinter->formHTML( $form_definition, false, false, null, null, 'Some very long page name that will hopefully never get created ABCDEF123', null );
186186 $params = array();
187187 global $wgUser;
188188 $params['user_id'] = $wgUser->getId();
189189 $params['page_text'] = $data_text;
190190 $job = new SFCreatePageJob( $title, $params );
191 - Job::batchInsert( array($job) );
 191+ Job::batchInsert( array( $job ) );
192192
193193 return true;
194194 }
@@ -201,21 +201,21 @@
202202 * given its default and alternate form(s) - we can't just point to
203203 * '&action=formedit', because that one doesn't reflect alternate forms
204204 */
205 - static function formEditLink($title) {
 205+ static function formEditLink( $title ) {
206206 // get all properties pointing to this page, and if
207207 // getFormEditLinkForPage() returns a value with any of
208208 // them, return that
209209
210210 // produce a useful error message if SMW isn't installed
211 - if (! function_exists('smwfGetStore'))
212 - die("ERROR: <a href=\"http://semantic-mediawiki.org\">Semantic MediaWiki</a> must be installed for Semantic Forms to run!");
 211+ if ( ! function_exists( 'smwfGetStore' ) )
 212+ die( "ERROR: <a href=\"http://semantic-mediawiki.org\">Semantic MediaWiki</a> must be installed for Semantic Forms to run!" );
213213 $store = smwfGetStore();
214 - $title_text = self::titleString($title);
215 - $value = SMWDataValueFactory::newTypeIDValue('_wpg', $title_text);
216 - $incoming_properties = $store->getInProperties($value);
217 - foreach ($incoming_properties as $property) {
 214+ $title_text = self::titleString( $title );
 215+ $value = SMWDataValueFactory::newTypeIDValue( '_wpg', $title_text );
 216+ $incoming_properties = $store->getInProperties( $value );
 217+ foreach ( $incoming_properties as $property ) {
218218 $property_title = $property->getWikiValue();
219 - if ($form_edit_link = self::getFormEditLinkForPage($title, $property_title, SMW_NS_PROPERTY)) {
 219+ if ( $form_edit_link = self::getFormEditLinkForPage( $title, $property_title, SMW_NS_PROPERTY ) ) {
220220 return $form_edit_link;
221221 }
222222 }
@@ -223,13 +223,13 @@
224224 // if that didn't work, check if this page's namespace
225225 // has a default form specified
226226 $namespace = $title->getNsText();
227 - if ('' === $namespace) {
 227+ if ( '' === $namespace ) {
228228 // if it's in the main (blank) namespace, check for the
229229 // file named with the word for "Main" in this language
230 - wfLoadExtensionMessages('SemanticForms');
231 - $namespace = wfMsgForContent('sf_blank_namespace');
 230+ wfLoadExtensionMessages( 'SemanticForms' );
 231+ $namespace = wfMsgForContent( 'sf_blank_namespace' );
232232 }
233 - if ($form_edit_link = self::getFormEditLinkForPage($title, $namespace, NS_PROJECT)) {
 233+ if ( $form_edit_link = self::getFormEditLinkForPage( $title, $namespace, NS_PROJECT ) ) {
234234 return $form_edit_link;
235235 }
236236 // if nothing found still, return null
@@ -242,22 +242,22 @@
243243 * - this function doubles as a function to get all categories on
244244 * the site, if no article is specified
245245 */
246 - static function getCategoriesForArticle($article = NULL) {
 246+ static function getCategoriesForArticle( $article = NULL ) {
247247 $categories = array();
248248 $db = wfGetDB( DB_SLAVE );
249249 $conditions = null;
250 - if ($article != NULL) {
 250+ if ( $article != NULL ) {
251251 $titlekey = $article->mTitle->getArticleId();
252252 $conditions = "cl_from='$titlekey'";
253253 }
254 - $res = $db->select($db->tableName('categorylinks'),
255 - 'distinct cl_to', $conditions, __METHOD__);
256 - if ($db->numRows( $res ) > 0) {
257 - while ($row = $db->fetchRow($res)) {
 254+ $res = $db->select( $db->tableName( 'categorylinks' ),
 255+ 'distinct cl_to', $conditions, __METHOD__ );
 256+ if ( $db->numRows( $res ) > 0 ) {
 257+ while ( $row = $db->fetchRow( $res ) ) {
258258 $categories[] = $row[0];
259259 }
260260 }
261 - $db->freeResult($res);
 261+ $db->freeResult( $res );
262262 return $categories;
263263 }
264264
@@ -268,37 +268,37 @@
269269 * if there is one; or
270270 * - the default form for the article's namespace, if there is one
271271 */
272 - static function getFormsForArticle($obj) {
 272+ static function getFormsForArticle( $obj ) {
273273 // see if the page itself has a default form (or forms), and
274274 // return it/them if so
275 - $default_forms = self::getFormsThatPagePointsTo($obj->mTitle->getText(), $obj->mTitle->getNamespace(), '_SF_PDF', '_SF_PDF_BACKUP', SF_SP_PAGE_HAS_DEFAULT_FORM);
276 - if (count($default_forms) > 0)
 275+ $default_forms = self::getFormsThatPagePointsTo( $obj->mTitle->getText(), $obj->mTitle->getNamespace(), '_SF_PDF', '_SF_PDF_BACKUP', SF_SP_PAGE_HAS_DEFAULT_FORM );
 276+ if ( count( $default_forms ) > 0 )
277277 return $default_forms;
278278 // if this is not a category page, look for a default form
279279 // for its parent categories
280280 $namespace = $obj->mTitle->getNamespace();
281 - if (NS_CATEGORY !== $namespace) {
 281+ if ( NS_CATEGORY !== $namespace ) {
282282 $default_forms = array();
283 - $categories = self::getCategoriesForArticle($obj);
284 - foreach ($categories as $category) {
285 - $default_forms = array_merge($default_forms, self::getFormsThatPagePointsTo($category, NS_CATEGORY, '_SF_DF', '_SF_DF_BACKUP', SF_SP_HAS_DEFAULT_FORM));
 283+ $categories = self::getCategoriesForArticle( $obj );
 284+ foreach ( $categories as $category ) {
 285+ $default_forms = array_merge( $default_forms, self::getFormsThatPagePointsTo( $category, NS_CATEGORY, '_SF_DF', '_SF_DF_BACKUP', SF_SP_HAS_DEFAULT_FORM ) );
286286 }
287 - if (count($default_forms) > 0)
 287+ if ( count( $default_forms ) > 0 )
288288 return $default_forms;
289289 }
290290 // if we're still here, just return the default form for the
291291 // namespace, which may well be null
292 - if (NS_MAIN === $namespace) {
 292+ if ( NS_MAIN === $namespace ) {
293293 // if it's in the main (blank) namespace, check for the
294294 // file named with the word for "Main" in this language
295 - wfLoadExtensionMessages('SemanticForms');
296 - $namespace_label = wfMsgForContent('sf_blank_namespace');
 295+ wfLoadExtensionMessages( 'SemanticForms' );
 296+ $namespace_label = wfMsgForContent( 'sf_blank_namespace' );
297297 } else {
298298 global $wgContLang;
299299 $namespace_labels = $wgContLang->getNamespaces();
300300 $namespace_label = $namespace_labels[$namespace];
301301 }
302 - $default_forms = self::getFormsThatPagePointsTo($namespace_label, NS_PROJECT, '_SF_DF', '_SF_DF_BACKUP', SF_SP_HAS_DEFAULT_FORM);
 302+ $default_forms = self::getFormsThatPagePointsTo( $namespace_label, NS_PROJECT, '_SF_DF', '_SF_DF_BACKUP', SF_SP_HAS_DEFAULT_FORM );
303303 return $default_forms;
304304 }
305305

Status & tagging log