r63748 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r63747‎ | r63748 | r63749 >
Date:18:01, 14 March 2010
Author:jeroendedauw
Status:deferred
Tags:
Comment:
Stylized with Stylize.php to conform with MW's spacing conventions
Modified paths:
  • /trunk/extensions/SemanticForms/includes/SF_AutocompleteAPI.php (modified) (history)
  • /trunk/extensions/SemanticForms/includes/SF_CreatePageJob.php (modified) (history)
  • /trunk/extensions/SemanticForms/includes/SF_FormEditPage.php (modified) (history)
  • /trunk/extensions/SemanticForms/includes/SF_FormEditTab.php (modified) (history)
  • /trunk/extensions/SemanticForms/includes/SF_GlobalFunctions.php (modified) (history)
  • /trunk/extensions/SemanticForms/includes/SF_ParserFunctions.php (modified) (history)
  • /trunk/extensions/SemanticForms/includes/SF_Settings.php (modified) (history)
  • /trunk/extensions/SemanticForms/languages/SF_LanguageAr.php (modified) (history)
  • /trunk/extensions/SemanticForms/languages/SF_LanguageArz.php (modified) (history)
  • /trunk/extensions/SemanticForms/languages/SF_LanguageCa.php (modified) (history)
  • /trunk/extensions/SemanticForms/languages/SF_LanguageDe.php (modified) (history)
  • /trunk/extensions/SemanticForms/languages/SF_LanguageDe_formal.php (modified) (history)
  • /trunk/extensions/SemanticForms/languages/SF_LanguageEs.php (modified) (history)
  • /trunk/extensions/SemanticForms/languages/SF_LanguageFa.php (modified) (history)
  • /trunk/extensions/SemanticForms/languages/SF_LanguageFr.php (modified) (history)
  • /trunk/extensions/SemanticForms/languages/SF_LanguageHe.php (modified) (history)
  • /trunk/extensions/SemanticForms/languages/SF_LanguageNl.php (modified) (history)
  • /trunk/extensions/SemanticForms/languages/SF_LanguagePt_br.php (modified) (history)
  • /trunk/extensions/SemanticForms/languages/SF_LanguageZh_cn.php (modified) (history)
  • /trunk/extensions/SemanticForms/languages/SF_LanguageZh_tw.php (modified) (history)
  • /trunk/extensions/SemanticForms/specials/SF_CreateCategory.php (modified) (history)
  • /trunk/extensions/SemanticForms/specials/SF_CreateClass.php (modified) (history)
  • /trunk/extensions/SemanticForms/specials/SF_CreateForm.php (modified) (history)
  • /trunk/extensions/SemanticForms/specials/SF_CreateProperty.php (modified) (history)
  • /trunk/extensions/SemanticForms/specials/SF_CreateTemplate.php (modified) (history)
  • /trunk/extensions/SemanticForms/specials/SF_FormEdit.php (modified) (history)
  • /trunk/extensions/SemanticForms/specials/SF_FormStart.php (modified) (history)
  • /trunk/extensions/SemanticForms/specials/SF_Forms.php (modified) (history)
  • /trunk/extensions/SemanticForms/specials/SF_RunQuery.php (modified) (history)
  • /trunk/extensions/SemanticForms/specials/SF_Templates.php (modified) (history)
  • /trunk/extensions/SemanticForms/specials/SF_UploadWindow.php (modified) (history)
  • /trunk/extensions/SemanticForms/specials/SF_UploadWindow2.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticForms/specials/SF_CreateCategory.php
@@ -6,7 +6,7 @@
77 * @author Yaron Koren
88 */
99
10 -if (!defined('MEDIAWIKI')) die();
 10+if ( !defined( 'MEDIAWIKI' ) ) die();
1111
1212 class SFCreateCategory extends SpecialPage {
1313
@@ -14,27 +14,27 @@
1515 * Constructor
1616 */
1717 function SFCreateCategory() {
18 - SpecialPage::SpecialPage('CreateCategory');
19 - wfLoadExtensionMessages('SemanticForms');
 18+ SpecialPage::SpecialPage( 'CreateCategory' );
 19+ wfLoadExtensionMessages( 'SemanticForms' );
2020 }
2121
22 - function execute($query) {
 22+ function execute( $query ) {
2323 $this->setHeaders();
2424 doSpecialCreateCategory();
2525 }
2626
27 - static function createCategoryText($default_form, $category_name, $parent_category) {
28 - wfLoadExtensionMessages('SemanticForms');
 27+ static function createCategoryText( $default_form, $category_name, $parent_category ) {
 28+ wfLoadExtensionMessages( 'SemanticForms' );
2929
30 - if ($default_form == '') {
31 - $text = wfMsgForContent('sf_category_desc', $category_name);
 30+ if ( $default_form == '' ) {
 31+ $text = wfMsgForContent( 'sf_category_desc', $category_name );
3232 } else {
3333 global $sfgContLang;
3434 $specprops = $sfgContLang->getPropertyLabels();
3535 $form_tag = "[[" . $specprops[SF_SP_HAS_DEFAULT_FORM] . "::$default_form]]";
36 - $text = wfMsgForContent('sf_category_hasdefaultform', $form_tag);
 36+ $text = wfMsgForContent( 'sf_category_hasdefaultform', $form_tag );
3737 }
38 - if ($parent_category != '') {
 38+ if ( $parent_category != '' ) {
3939 global $wgContLang;
4040 $namespace_labels = $wgContLang->getNamespaces();
4141 $category_namespace = $namespace_labels[NS_CATEGORY];
@@ -47,29 +47,29 @@
4848 function doSpecialCreateCategory() {
4949 global $wgOut, $wgRequest, $wgUser, $sfgScriptPath;
5050
51 - wfLoadExtensionMessages('SemanticForms');
 51+ wfLoadExtensionMessages( 'SemanticForms' );
5252
5353 # cycle through the query values, setting the appropriate local variables
54 - $category_name = $wgRequest->getVal('category_name');
55 - $default_form = $wgRequest->getVal('default_form');
56 - $parent_category = $wgRequest->getVal('parent_category');
 54+ $category_name = $wgRequest->getVal( 'category_name' );
 55+ $default_form = $wgRequest->getVal( 'default_form' );
 56+ $parent_category = $wgRequest->getVal( 'parent_category' );
5757
58 - $save_button_text = wfMsg('savearticle');
59 - $preview_button_text = wfMsg('preview');
 58+ $save_button_text = wfMsg( 'savearticle' );
 59+ $preview_button_text = wfMsg( 'preview' );
6060 $category_name_error_str = '';
61 - $save_page = $wgRequest->getCheck('wpSave');
62 - $preview_page = $wgRequest->getCheck('wpPreview');
63 - if ($save_page || $preview_page) {
 61+ $save_page = $wgRequest->getCheck( 'wpSave' );
 62+ $preview_page = $wgRequest->getCheck( 'wpPreview' );
 63+ if ( $save_page || $preview_page ) {
6464 # validate category name
65 - if ($category_name == '') {
66 - $category_name_error_str = wfMsg('sf_blank_error');
 65+ if ( $category_name == '' ) {
 66+ $category_name_error_str = wfMsg( 'sf_blank_error' );
6767 } else {
6868 # redirect to wiki interface
69 - $wgOut->setArticleBodyOnly(true);
70 - $title = Title::makeTitleSafe(NS_CATEGORY, $category_name);
71 - $full_text = SFCreateCategory::createCategoryText($default_form, $category_name, $parent_category);
72 - $text = SFUtils::printRedirectForm($title, $full_text, "", $save_page, $preview_page, false, false, false, null, null);
73 - $wgOut->addHTML($text);
 69+ $wgOut->setArticleBodyOnly( true );
 70+ $title = Title::makeTitleSafe( NS_CATEGORY, $category_name );
 71+ $full_text = SFCreateCategory::createCategoryText( $default_form, $category_name, $parent_category );
 72+ $text = SFUtils::printRedirectForm( $title, $full_text, "", $save_page, $preview_page, false, false, false, null, null );
 73+ $wgOut->addHTML( $text );
7474 return;
7575 }
7676 }
@@ -80,9 +80,9 @@
8181 global $wgContLang;
8282 $mw_namespace_labels = $wgContLang->getNamespaces();
8383 $special_namespace = $mw_namespace_labels[NS_SPECIAL];
84 - $name_label = wfMsg('sf_createcategory_name');
85 - $form_label = wfMsg('sf_createcategory_defaultform');
86 - $text =<<<END
 84+ $name_label = wfMsg( 'sf_createcategory_name' );
 85+ $form_label = wfMsg( 'sf_createcategory_defaultform' );
 86+ $text = <<<END
8787 <form action="" method="get">
8888 <input type="hidden" name="title" value="$special_namespace:CreateCategory">
8989 <p>$name_label <input size="25" name="category_name" value="">
@@ -92,27 +92,27 @@
9393 <option></option>
9494
9595 END;
96 - foreach ($all_forms as $form) {
 96+ foreach ( $all_forms as $form ) {
9797 $text .= " <option>$form</option>\n";
9898 }
9999
100 - $subcategory_label = wfMsg('sf_createcategory_makesubcategory');
 100+ $subcategory_label = wfMsg( 'sf_createcategory_makesubcategory' );
101101 $categories = SFLinkUtils::getCategoriesForArticle();
102102 $sk = $wgUser->getSkin();
103 - $cf = SpecialPage::getPage('CreateForm');
104 - $create_form_link = $sk->makeKnownLinkObj($cf->getTitle(), $cf->getDescription());
105 - $text .=<<<END
 103+ $cf = SpecialPage::getPage( 'CreateForm' );
 104+ $create_form_link = $sk->makeKnownLinkObj( $cf->getTitle(), $cf->getDescription() );
 105+ $text .= <<<END
106106 </select>
107107 <p>$subcategory_label
108108 <select id="category_dropdown" name="parent_category">
109109 <option></option>
110110
111111 END;
112 - foreach ($categories as $category) {
113 - $category = str_replace('_', ' ', $category);
114 - $text .= " " . Xml::element('option', null, $category) . "\n";
 112+ foreach ( $categories as $category ) {
 113+ $category = str_replace( '_', ' ', $category );
 114+ $text .= " " . Xml::element( 'option', null, $category ) . "\n";
115115 }
116 - $text .=<<<END
 116+ $text .= <<<END
117117 </select>
118118 <div class="editButtons">
119119 <input type="submit" id="wpSave" name="wpSave" value="$save_button_text">
@@ -122,7 +122,7 @@
123123
124124 END;
125125
126 - $text .= " " . Xml::tags('p', null, $create_form_link . '.') . "\n";
 126+ $text .= " " . Xml::tags( 'p', null, $create_form_link . '.' ) . "\n";
127127 $text .= " </form>\n";
128128
129129 $wgOut->addLink( array(
@@ -130,6 +130,6 @@
131131 'type' => 'text/css',
132132 'media' => "screen",
133133 'href' => $sfgScriptPath . "/skins/SF_main.css"
134 - ));
135 - $wgOut->addHTML($text);
 134+ ) );
 135+ $wgOut->addHTML( $text );
136136 }
Index: trunk/extensions/SemanticForms/specials/SF_FormStart.php
@@ -6,7 +6,7 @@
77 * @author Yaron Koren
88 * @author Jeffrey Stuckman
99 */
10 -if (!defined('MEDIAWIKI')) die();
 10+if ( !defined( 'MEDIAWIKI' ) ) die();
1111
1212 class SFFormStart extends SpecialPage {
1313
@@ -14,87 +14,87 @@
1515 * Constructor
1616 */
1717 function SFFormStart() {
18 - SpecialPage::SpecialPage('FormStart');
19 - wfLoadExtensionMessages('SemanticForms');
 18+ SpecialPage::SpecialPage( 'FormStart' );
 19+ wfLoadExtensionMessages( 'SemanticForms' );
2020 }
2121
22 - function execute($query) {
 22+ function execute( $query ) {
2323 global $wgOut, $wgRequest, $sfgScriptPath;
2424
2525 $this->setHeaders();
2626
27 - wfLoadExtensionMessages('SemanticForms');
28 - $form_name = $wgRequest->getVal('form');
29 - $target_namespace = $wgRequest->getVal('namespace');
30 - $super_page = $wgRequest->getVal('super_page');
31 - $params = $wgRequest->getVal('params');
 27+ wfLoadExtensionMessages( 'SemanticForms' );
 28+ $form_name = $wgRequest->getVal( 'form' );
 29+ $target_namespace = $wgRequest->getVal( 'namespace' );
 30+ $super_page = $wgRequest->getVal( 'super_page' );
 31+ $params = $wgRequest->getVal( 'params' );
3232
3333 // if query string did not contain form name, try the URL
34 - if (! $form_name) {
35 - $queryparts = explode('/', $query, 2);
36 - $form_name = isset($queryparts[0]) ? $queryparts[0] : '';
 34+ if ( ! $form_name ) {
 35+ $queryparts = explode( '/', $query, 2 );
 36+ $form_name = isset( $queryparts[0] ) ? $queryparts[0] : '';
3737 // if a target was specified, it means we should
3838 // redirect to 'FormEdit' for this target page
39 - if (isset($queryparts[1])) {
 39+ if ( isset( $queryparts[1] ) ) {
4040 $target_name = $queryparts[1];
41 - SFFormStart::doRedirect($form_name, $target_name, $params);
 41+ SFFormStart::doRedirect( $form_name, $target_name, $params );
4242 }
4343
4444 // get namespace from the URL, if it's there
45 - if ($namespace_label_loc = strpos($form_name, "/Namespace:")) {
46 - $target_namespace = substr($form_name, $namespace_label_loc + 11);
47 - $form_name = substr($form_name, 0, $namespace_label_loc);
 45+ if ( $namespace_label_loc = strpos( $form_name, "/Namespace:" ) ) {
 46+ $target_namespace = substr( $form_name, $namespace_label_loc + 11 );
 47+ $form_name = substr( $form_name, 0, $namespace_label_loc );
4848 }
4949 }
5050
5151 // remove forbidden characters from form name
52 - $forbidden_chars = array('"', "'", '<', '>', '{', '}', '(', ')', '[', ']', '=');
53 - $form_name = str_replace($forbidden_chars, "", $form_name);
 52+ $forbidden_chars = array( '"', "'", '<', '>', '{', '}', '(', ')', '[', ']', '=' );
 53+ $form_name = str_replace( $forbidden_chars, "", $form_name );
5454
5555 // get title of form
56 - $form_title = Title::makeTitleSafe(SF_NS_FORM, $form_name);
 56+ $form_title = Title::makeTitleSafe( SF_NS_FORM, $form_name );
5757
5858 // handle submission
59 - $form_submitted = $wgRequest->getCheck('page_name');
60 - if ($form_submitted) {
61 - $page_name = $wgRequest->getVal('page_name');
 59+ $form_submitted = $wgRequest->getCheck( 'page_name' );
 60+ if ( $form_submitted ) {
 61+ $page_name = $wgRequest->getVal( 'page_name' );
6262 // This form can be used to create a sub-page for an
6363 // existing page
64 - if ('' != $super_page)
 64+ if ( '' != $super_page )
6565 {
6666 $page_name = "$super_page/$page_name";
6767 }
68 - if ('' != $page_name) {
 68+ if ( '' != $page_name ) {
6969 // Append the namespace prefix to the page name,
7070 // if a namespace was not already entered.
71 - if (strpos($page_name,":") === false && $target_namespace != '')
 71+ if ( strpos( $page_name, ":" ) === false && $target_namespace != '' )
7272 $page_name = $target_namespace . ":" . $page_name;
7373 // find out whether this page already exists,
7474 // and send user to the appropriate form
75 - $page_title = Title::newFromText($page_name);
76 - if (! $page_title) {
 75+ $page_title = Title::newFromText( $page_name );
 76+ if ( ! $page_title ) {
7777 // if there was no page title, it's
7878 // probably an invalid page name,
7979 // containing forbidden characters
80 - $error_msg = wfMsg('sf_formstart_badtitle', $page_name);
81 - $wgOut->addHTML($error_msg);
 80+ $error_msg = wfMsg( 'sf_formstart_badtitle', $page_name );
 81+ $wgOut->addHTML( $error_msg );
8282 return;
8383 } else {
84 - SFFormStart::doRedirect($form_name, $page_name, $params);
 84+ SFFormStart::doRedirect( $form_name, $page_name, $params );
8585 return;
8686 }
8787 }
8888 }
8989
90 - if ((! $form_title || ! $form_title->exists()) && ($form_name != '')) {
91 - $text = '<p>' . wfMsg('sf_formstart_badform', SFUtils::linkText(SF_NS_FORM, $form_name)) . ".</p>\n";
 90+ if ( ( ! $form_title || ! $form_title->exists() ) && ( $form_name != '' ) ) {
 91+ $text = '<p>' . wfMsg( 'sf_formstart_badform', SFUtils::linkText( SF_NS_FORM, $form_name ) ) . ".</p>\n";
9292 } else {
93 - if ($form_name == '')
94 - $description = wfMsg('sf_formstart_noform_docu', $form_name);
 93+ if ( $form_name == '' )
 94+ $description = wfMsg( 'sf_formstart_noform_docu', $form_name );
9595 else
96 - $description = wfMsg('sf_formstart_docu', $form_name);
97 - $button_text = wfMsg('sf_formstart_createoredit');
98 - $text =<<<END
 96+ $description = wfMsg( 'sf_formstart_docu', $form_name );
 97+ $button_text = wfMsg( 'sf_formstart_createoredit' );
 98+ $text = <<<END
9999 <form action="" method="post">
100100 <p>$description</p>
101101 <p><input type="text" size="40" name="page_name">
@@ -102,14 +102,14 @@
103103 END;
104104 // if no form was specified, display a dropdown letting
105105 // the user choose the form
106 - if ($form_name == '')
 106+ if ( $form_name == '' )
107107 $text .= SFUtils::formDropdownHTML();
108108
109 - $hidden_target_namespace = htmlspecialchars($target_namespace);
110 - $hidden_super_page = htmlspecialchars($super_page);
111 - $hidden_params = htmlspecialchars($params);
 109+ $hidden_target_namespace = htmlspecialchars( $target_namespace );
 110+ $hidden_super_page = htmlspecialchars( $super_page );
 111+ $hidden_params = htmlspecialchars( $params );
112112
113 - $text .=<<<END
 113+ $text .= <<<END
114114 </p>
115115 <input type="hidden" name="namespace" value="$hidden_target_namespace">
116116 <input type="hidden" name="super_page" value="$hidden_super_page">
@@ -119,20 +119,20 @@
120120
121121 END;
122122 }
123 - $wgOut->addHTML($text);
 123+ $wgOut->addHTML( $text );
124124 }
125125
126 - function doRedirect($form_name, $page_name, $params) {
 126+ function doRedirect( $form_name, $page_name, $params ) {
127127 global $wgOut;
128128
129 - $page_title = Title::newFromText($page_name);
130 - if ($page_title->exists()) {
 129+ $page_title = Title::newFromText( $page_name );
 130+ if ( $page_title->exists() ) {
131131 // it exists - see if page is a redirect; if
132132 // it is, edit the target page instead
133 - $article = new Article($page_title);
 133+ $article = new Article( $page_title );
134134 $article->loadContent();
135 - $redirect_title = Title::newFromRedirect($article->fetchContent());
136 - if ($redirect_title != null) {
 135+ $redirect_title = Title::newFromRedirect( $article->fetchContent() );
 136+ if ( $redirect_title != null ) {
137137 $page_title = $redirect_title;
138138 }
139139 // HACK - if this is the default form for
@@ -142,39 +142,39 @@
143143 // Is this logic necessary? Or should we just
144144 // out-guess the user and always send to the
145145 // standard form-edit page, with the 'correct' form?
146 - $default_forms = SFLinkUtils::getFormsForArticle($article);
147 - if (count($default_forms) > 0)
 146+ $default_forms = SFLinkUtils::getFormsForArticle( $article );
 147+ if ( count( $default_forms ) > 0 )
148148 $default_form_name = $default_forms[0];
149149 else
150150 $default_form_name = null;
151 - if ($form_name == $default_form_name) {
152 - $redirect_url = $page_title->getLocalURL('action=formedit');
 151+ if ( $form_name == $default_form_name ) {
 152+ $redirect_url = $page_title->getLocalURL( 'action=formedit' );
153153 } else {
154 - $fe = SpecialPage::getPage('FormEdit');
155 - $redirect_url = $fe->getTitle()->getFullURL() . "/" . $form_name . "/" . SFLinkUtils::titleURLString($page_title);
 154+ $fe = SpecialPage::getPage( 'FormEdit' );
 155+ $redirect_url = $fe->getTitle()->getFullURL() . "/" . $form_name . "/" . SFLinkUtils::titleURLString( $page_title );
156156 }
157157 } else {
158 - $fe = SpecialPage::getPage('FormEdit');
159 - $redirect_url = $fe->getTitle()->getFullURL() . "/" . $form_name . "/" . SFLinkUtils::titleURLString($page_title);
 158+ $fe = SpecialPage::getPage( 'FormEdit' );
 159+ $redirect_url = $fe->getTitle()->getFullURL() . "/" . $form_name . "/" . SFLinkUtils::titleURLString( $page_title );
160160 // of all the request values, send on to 'FormEdit'
161161 // only 'preload' and specific form fields - we can
162162 // tell the latter because they show up as arrays
163 - foreach ($_REQUEST as $key => $val) {
164 - if (is_array($val)) {
 163+ foreach ( $_REQUEST as $key => $val ) {
 164+ if ( is_array( $val ) ) {
165165 $template_name = $key;
166 - foreach ($val as $field_name => $value) {
167 - $redirect_url .= (strpos($redirect_url, "?") > -1) ? '&' : '?';
 166+ foreach ( $val as $field_name => $value ) {
 167+ $redirect_url .= ( strpos( $redirect_url, "?" ) > - 1 ) ? '&' : '?';
168168 $redirect_url .= $template_name . '[' . $field_name . ']=' . $value;
169169 }
170 - } elseif ($key == 'preload') {
171 - $redirect_url .= (strpos($redirect_url, "?") > -1) ? '&' : '?';
 170+ } elseif ( $key == 'preload' ) {
 171+ $redirect_url .= ( strpos( $redirect_url, "?" ) > - 1 ) ? '&' : '?';
172172 $redirect_url .= "$key=$val";
173173 }
174174 }
175175 }
176176
177 - if ('' != $params) {
178 - $redirect_url .= (strpos($redirect_url, "?") > -1) ? '&' : '?';
 177+ if ( '' != $params ) {
 178+ $redirect_url .= ( strpos( $redirect_url, "?" ) > - 1 ) ? '&' : '?';
179179 $redirect_url .= $params;
180180 }
181181
@@ -182,7 +182,7 @@
183183 // show "loading" animated image while people wait for the redirect
184184 global $sfgScriptPath;
185185 $text = "<p style=\"position: absolute; left: 45%; top: 45%;\"><img src=\"$sfgScriptPath/skins/loading.gif\" /></p>\n";
186 - $text .=<<<END
 186+ $text .= <<<END
187187 <script type="text/javascript">
188188 window.onload = function() {
189189 window.location="$redirect_url";
@@ -190,7 +190,7 @@
191191 </script>
192192
193193 END;
194 - $wgOut->addHTML($text);
 194+ $wgOut->addHTML( $text );
195195 return;
196196 }
197197
Index: trunk/extensions/SemanticForms/specials/SF_Forms.php
@@ -5,7 +5,7 @@
66 * @author Yaron Koren
77 */
88
9 -if (!defined('MEDIAWIKI')) die();
 9+if ( !defined( 'MEDIAWIKI' ) ) die();
1010
1111 class SFForms extends SpecialPage {
1212
@@ -13,11 +13,11 @@
1414 * Constructor
1515 */
1616 function SFForms() {
17 - SpecialPage::SpecialPage('Forms');
18 - wfLoadExtensionMessages('SemanticForms');
 17+ SpecialPage::SpecialPage( 'Forms' );
 18+ wfLoadExtensionMessages( 'SemanticForms' );
1919 }
2020
21 - function execute($query) {
 21+ function execute( $query ) {
2222 $this->setHeaders();
2323 list( $limit, $offset ) = wfCheckLimits();
2424 $rep = new FormsPage();
@@ -37,13 +37,13 @@
3838 function getPageHeader() {
3939 global $wgUser;
4040
41 - wfLoadExtensionMessages('SemanticForms');
 41+ wfLoadExtensionMessages( 'SemanticForms' );
4242
4343 $sk = $wgUser->getSkin();
44 - $cf = SpecialPage::getPage('CreateForm');
45 - $create_form_link = $sk->makeKnownLinkObj($cf->getTitle(), $cf->getDescription());
 44+ $cf = SpecialPage::getPage( 'CreateForm' );
 45+ $create_form_link = $sk->makeKnownLinkObj( $cf->getTitle(), $cf->getDescription() );
4646 $header = "<p>" . $create_form_link . ".</p>\n";
47 - $header .= '<p>' . wfMsg('sf_forms_docu') . "</p><br />\n";
 47+ $header .= '<p>' . wfMsg( 'sf_forms_docu' ) . "</p><br />\n";
4848 return $header;
4949 }
5050
@@ -68,7 +68,7 @@
6969 return false;
7070 }
7171
72 - function formatResult($skin, $result) {
 72+ function formatResult( $skin, $result ) {
7373 $title = Title::makeTitle( SF_NS_FORM, $result->value );
7474 return $skin->makeLinkObj( $title, $title->getText() );
7575 }
Index: trunk/extensions/SemanticForms/specials/SF_CreateForm.php
@@ -6,7 +6,7 @@
77 * @author Yaron Koren
88 */
99
10 -if (!defined('MEDIAWIKI')) die();
 10+if ( !defined( 'MEDIAWIKI' ) ) die();
1111
1212 class SFCreateForm extends SpecialPage {
1313
@@ -14,11 +14,11 @@
1515 * Constructor
1616 */
1717 function SFCreateForm() {
18 - SpecialPage::SpecialPage('CreateForm');
19 - wfLoadExtensionMessages('SemanticForms');
 18+ SpecialPage::SpecialPage( 'CreateForm' );
 19+ wfLoadExtensionMessages( 'SemanticForms' );
2020 }
2121
22 - function execute($query) {
 22+ function execute( $query ) {
2323 $this->setHeaders();
2424 doSpecialCreateForm();
2525 }
@@ -28,16 +28,16 @@
2929 global $wgOut, $wgRequest, $wgUser, $sfgScriptPath, $wgContLang;
3030 $db = wfGetDB( DB_SLAVE );
3131
32 - wfLoadExtensionMessages('SemanticForms');
 32+ wfLoadExtensionMessages( 'SemanticForms' );
3333
3434 # get the names of all templates on this site
3535 $all_templates = array();
3636 $res = $db->select( 'page', 'page_title',
3737 array( 'page_namespace' => NS_TEMPLATE, 'page_is_redirect' => 0 ),
3838 array( 'ORDER BY' => 'page_title' ) );
39 - if ($db->numRows( $res ) > 0) {
40 - while ($row = $db->fetchRow($res)) {
41 - $template_name = str_replace('_', ' ', $row[0]);
 39+ if ( $db->numRows( $res ) > 0 ) {
 40+ while ( $row = $db->fetchRow( $res ) ) {
 41+ $template_name = str_replace( '_', ' ', $row[0] );
4242 $all_templates[] = $template_name;
4343 }
4444 }
@@ -47,34 +47,34 @@
4848 $deleted_template_loc = null;
4949
5050 # handle inputs
51 - $form_name = $wgRequest->getVal('form_name');
52 - foreach ($wgRequest->getValues() as $var => $val) {
 51+ $form_name = $wgRequest->getVal( 'form_name' );
 52+ foreach ( $wgRequest->getValues() as $var => $val ) {
5353 # ignore variables that are not of the right form
54 - if (strpos($var, "_") != false) {
 54+ if ( strpos( $var, "_" ) != false ) {
5555 # get the template declarations and work from there
56 - list ($action, $id) = explode("_", $var, 2);
57 - if ($action == "template") {
 56+ list ( $action, $id ) = explode( "_", $var, 2 );
 57+ if ( $action == "template" ) {
5858 # if the button was pressed to remove this
5959 # template, just don't add it to the array
60 - if ($wgRequest->getVal("del_$id") != null) {
 60+ if ( $wgRequest->getVal( "del_$id" ) != null ) {
6161 $deleted_template_loc = $id;
6262 } else {
63 - $form_template = SFTemplateInForm::create($val,
64 - $wgRequest->getVal("label_$id"),
65 - $wgRequest->getVal("allow_multiple_$id"));
 63+ $form_template = SFTemplateInForm::create( $val,
 64+ $wgRequest->getVal( "label_$id" ),
 65+ $wgRequest->getVal( "allow_multiple_$id" ) );
6666 $form_templates[] = $form_template;
6767 }
6868 }
6969 }
7070 }
71 - if ($wgRequest->getVal('add_field') != null) {
72 - $form_template = SFTemplateInForm::create($wgRequest->getVal('new_template'), "", false);
73 - $new_template_loc = $wgRequest->getVal('before_template');
74 - if ($new_template_loc === null) { $new_template_loc = 0; }
 71+ if ( $wgRequest->getVal( 'add_field' ) != null ) {
 72+ $form_template = SFTemplateInForm::create( $wgRequest->getVal( 'new_template' ), "", false );
 73+ $new_template_loc = $wgRequest->getVal( 'before_template' );
 74+ if ( $new_template_loc === null ) { $new_template_loc = 0; }
7575 # hack - array_splice() doesn't work for objects, so we have to
7676 # first insert a stub element into the array, then replace that
7777 # with the actual object
78 - array_splice($form_templates, $new_template_loc, 0, "stub");
 78+ array_splice( $form_templates, $new_template_loc, 0, "stub" );
7979 $form_templates[$new_template_loc] = $form_template;
8080 } else {
8181 $new_template_loc = null;
@@ -82,56 +82,56 @@
8383
8484 # now cycle through the templates and fields, modifying each one
8585 # per the query variables
86 - foreach ($form_templates as $i => $ft) {
87 - foreach ($ft->fields as $j => $field) {
 86+ foreach ( $form_templates as $i => $ft ) {
 87+ foreach ( $ft->fields as $j => $field ) {
8888 // handle the change in indexing if a new template was
8989 // inserted before the end, or one was deleted
9090 $old_i = $i;
91 - if ($new_template_loc != null) {
92 - if ($i > $new_template_loc) {
 91+ if ( $new_template_loc != null ) {
 92+ if ( $i > $new_template_loc ) {
9393 $old_i = $i - 1;
94 - } elseif ($i == $new_template_loc) {
 94+ } elseif ( $i == $new_template_loc ) {
9595 // it's the new template; it shouldn't
9696 // get any query string data
97 - $old_i = -1;
 97+ $old_i = - 1;
9898 }
99 - } elseif ($deleted_template_loc != null) {
100 - if ($i >= $deleted_template_loc) {
 99+ } elseif ( $deleted_template_loc != null ) {
 100+ if ( $i >= $deleted_template_loc ) {
101101 $old_i = $i + 1;
102102 }
103103 }
104 - $new_label = $wgRequest->getVal("label_" . $old_i . "_" . $j);
105 - if ($new_label)
 104+ $new_label = $wgRequest->getVal( "label_" . $old_i . "_" . $j );
 105+ if ( $new_label )
106106 $field->template_field->label = $new_label;
107 - $input_type = $wgRequest->getVal("input_type_" . $old_i . "_" . $j);
 107+ $input_type = $wgRequest->getVal( "input_type_" . $old_i . "_" . $j );
108108 $field->template_field->input_type = $input_type;
109 - if ($wgRequest->getVal("hidden_" . $old_i . "_" . $j) == "hidden") {
 109+ if ( $wgRequest->getVal( "hidden_" . $old_i . "_" . $j ) == "hidden" ) {
110110 $field->is_hidden = true;
111111 }
112 - if ($wgRequest->getVal("restricted_" . $old_i . "_" . $j) == "restricted") {
 112+ if ( $wgRequest->getVal( "restricted_" . $old_i . "_" . $j ) == "restricted" ) {
113113 $field->is_restricted = true;
114114 }
115 - if ($wgRequest->getVal("mandatory_" . $old_i . "_" . $j) == "mandatory") {
 115+ if ( $wgRequest->getVal( "mandatory_" . $old_i . "_" . $j ) == "mandatory" ) {
116116 $field->is_mandatory = true;
117117 }
118118 }
119119 }
120 - $form = SFForm::create($form_name, $form_templates);
 120+ $form = SFForm::create( $form_name, $form_templates );
121121
122122 # if submit button was pressed, create the form definitions file, then redirect
123 - $save_page = $wgRequest->getCheck('wpSave');
124 - $preview_page = $wgRequest->getCheck('wpPreview');
125 - if ($save_page || $preview_page) {
 123+ $save_page = $wgRequest->getCheck( 'wpSave' );
 124+ $preview_page = $wgRequest->getCheck( 'wpPreview' );
 125+ if ( $save_page || $preview_page ) {
126126 # validate form name
127 - if ($form->form_name == "") {
128 - $form_name_error_str = wfMsg('sf_blank_error');
 127+ if ( $form->form_name == "" ) {
 128+ $form_name_error_str = wfMsg( 'sf_blank_error' );
129129 } else {
130130 # redirect to wiki interface
131 - $wgOut->setArticleBodyOnly(true);
132 - $title = Title::makeTitleSafe(SF_NS_FORM, $form->form_name);
 131+ $wgOut->setArticleBodyOnly( true );
 132+ $title = Title::makeTitleSafe( SF_NS_FORM, $form->form_name );
133133 $full_text = $form->createMarkup();
134 - $text = SFUtils::printRedirectForm($title, $full_text, "", $save_page, $preview_page, false, false, false, null, null);
135 - $wgOut->addHTML($text);
 134+ $text = SFUtils::printRedirectForm( $title, $full_text, "", $save_page, $preview_page, false, false, false, null, null );
 135+ $wgOut->addHTML( $text );
136136 return;
137137 }
138138 }
@@ -141,45 +141,45 @@
142142 $mw_namespace_labels = $wgContLang->getNamespaces();
143143 $special_namespace = $mw_namespace_labels[NS_SPECIAL];
144144 $text .= ' <input type="hidden" name="title" value="' . $special_namespace . ':CreateForm">' . "\n";
145 - $text .= ' <p>' . wfMsg('sf_createform_nameinput') . ' ' . wfMsg('sf_createform_nameinputdesc') . ' <input size=25 name="form_name" value="' . $form_name . '">';
146 - if (! empty($form_name_error_str))
147 - $text .= ' ' . Xml::element('font', array('color' => 'red'), $form_name_error_str);
 145+ $text .= ' <p>' . wfMsg( 'sf_createform_nameinput' ) . ' ' . wfMsg( 'sf_createform_nameinputdesc' ) . ' <input size=25 name="form_name" value="' . $form_name . '">';
 146+ if ( ! empty( $form_name_error_str ) )
 147+ $text .= ' ' . Xml::element( 'font', array( 'color' => 'red' ), $form_name_error_str );
148148 $text .= "</p>\n";
149149
150150 $text .= $form->creationHTML();
151151
152 - $text .= ' <p>' . wfMsg('sf_createform_addtemplate') . "\n";
 152+ $text .= ' <p>' . wfMsg( 'sf_createform_addtemplate' ) . "\n";
153153
154154 $select_body = "";
155 - foreach ($all_templates as $template) {
156 - $select_body .= " " . Xml::element('option', array('value' => $template), $template) . "\n";
 155+ foreach ( $all_templates as $template ) {
 156+ $select_body .= " " . Xml::element( 'option', array( 'value' => $template ), $template ) . "\n";
157157 }
158 - $text .= ' ' . Xml::tags('select', array('name' => 'new_template'), $select_body) . "\n";
 158+ $text .= ' ' . Xml::tags( 'select', array( 'name' => 'new_template' ), $select_body ) . "\n";
159159 // if a template has already been added, show a dropdown letting the
160160 // user choose where in the list to add a new dropdown
161 - if (count($form_templates) > 0) {
162 - $before_template_msg = wfMsg('sf_createform_beforetemplate');
 161+ if ( count( $form_templates ) > 0 ) {
 162+ $before_template_msg = wfMsg( 'sf_createform_beforetemplate' );
163163 $text .= $before_template_msg;
164164 $select_body = "";
165 - foreach ($form_templates as $i => $ft) {
166 - $select_body .= " " . Xml::element('option', array('value' => $i), $ft->template_name) . "\n";
 165+ foreach ( $form_templates as $i => $ft ) {
 166+ $select_body .= " " . Xml::element( 'option', array( 'value' => $i ), $ft->template_name ) . "\n";
167167 }
168 - $final_index = count($form_templates);
169 - $at_end_msg = wfMsg('sf_createform_atend');
170 - $select_body .= ' ' . Xml::element('option', array('value' => $final_index, 'selected' => 'selected'), $at_end_msg);
171 - $text .= Xml::tags('select', array('name' => 'before_template'), $select_body) . "\n";
 168+ $final_index = count( $form_templates );
 169+ $at_end_msg = wfMsg( 'sf_createform_atend' );
 170+ $select_body .= ' ' . Xml::element( 'option', array( 'value' => $final_index, 'selected' => 'selected' ), $at_end_msg );
 171+ $text .= Xml::tags( 'select', array( 'name' => 'before_template' ), $select_body ) . "\n";
172172 }
173173
174174 // disable 'save' and 'preview' buttons if user has not yet added any
175175 // templates
176 - $disabled_text = (count($form_templates) == 0) ? "disabled" : "";
177 - $save_button_text = wfMsg('savearticle');
178 - $preview_button_text = wfMsg('preview');
179 - $add_button_text = wfMsg('sf_createform_add');
 176+ $disabled_text = ( count( $form_templates ) == 0 ) ? "disabled" : "";
 177+ $save_button_text = wfMsg( 'savearticle' );
 178+ $preview_button_text = wfMsg( 'preview' );
 179+ $add_button_text = wfMsg( 'sf_createform_add' );
180180 $sk = $wgUser->getSkin();
181 - $ct = SpecialPage::getPage('CreateTemplate');
182 - $create_template_link = $sk->makeKnownLinkObj($ct->getTitle(), $ct->getDescription());
183 - $text .=<<<END
 181+ $ct = SpecialPage::getPage( 'CreateTemplate' );
 182+ $create_template_link = $sk->makeKnownLinkObj( $ct->getTitle(), $ct->getDescription() );
 183+ $text .= <<<END
184184 <input type="submit" name="add_field" value="$add_button_text"></p>
185185 <br />
186186 <div class="editButtons">
@@ -192,21 +192,21 @@
193193 END;
194194 // explanatory message if buttons are disabled because no templates
195195 // have been added
196 - if (count($form_templates) == 0) {
197 - $text .= " " . Xml::element('p', null, "(" . wfMsg('sf_createtemplate_addtemplatebeforesave') . ")");
 196+ if ( count( $form_templates ) == 0 ) {
 197+ $text .= " " . Xml::element( 'p', null, "(" . wfMsg( 'sf_createtemplate_addtemplatebeforesave' ) . ")" );
198198 }
199 - $text .=<<<END
 199+ $text .= <<<END
200200 </form>
201201 <hr /><br />
202202
203203 END;
204 - $text .= " " . Xml::tags('p', null, $create_template_link . '.');
 204+ $text .= " " . Xml::tags( 'p', null, $create_template_link . '.' );
205205
206206 $wgOut->addLink( array(
207207 'rel' => 'stylesheet',
208208 'type' => 'text/css',
209209 'media' => "screen",
210210 'href' => $sfgScriptPath . "/skins/SF_main.css"
211 - ));
212 - $wgOut->addHTML($text);
 211+ ) );
 212+ $wgOut->addHTML( $text );
213213 }
Index: trunk/extensions/SemanticForms/specials/SF_CreateProperty.php
@@ -6,7 +6,7 @@
77 * @author Yaron Koren
88 */
99
10 -if (!defined('MEDIAWIKI')) die();
 10+if ( !defined( 'MEDIAWIKI' ) ) die();
1111
1212 class SFCreateProperty extends SpecialPage {
1313
@@ -14,37 +14,37 @@
1515 * Constructor
1616 */
1717 function SFCreateProperty() {
18 - SpecialPage::SpecialPage('CreateProperty');
19 - wfLoadExtensionMessages('SemanticForms');
 18+ SpecialPage::SpecialPage( 'CreateProperty' );
 19+ wfLoadExtensionMessages( 'SemanticForms' );
2020 }
2121
22 - function execute($query) {
 22+ function execute( $query ) {
2323 $this->setHeaders();
2424 doSpecialCreateProperty();
2525 }
2626
27 - function createPropertyText($property_type, $default_form, $allowed_values_str) {
 27+ function createPropertyText( $property_type, $default_form, $allowed_values_str ) {
2828 global $smwgContLang;
2929 $prop_labels = $smwgContLang->getPropertyLabels();
3030 $type_tag = "[[{$prop_labels['_TYPE']}::$property_type]]";
31 - $text = wfMsgForContent('sf_property_isproperty', $type_tag);
32 - if ($default_form != '') {
 31+ $text = wfMsgForContent( 'sf_property_isproperty', $type_tag );
 32+ if ( $default_form != '' ) {
3333 global $sfgContLang;
3434 $sf_prop_labels = $sfgContLang->getPropertyLabels();
3535 $default_form_tag = "[[{$sf_prop_labels[SF_SP_HAS_DEFAULT_FORM]}::$default_form]]";
36 - $text .= ' ' . wfMsgForContent('sf_property_linkstoform', $default_form_tag);
 36+ $text .= ' ' . wfMsgForContent( 'sf_property_linkstoform', $default_form_tag );
3737 }
38 - if ($allowed_values_str != '') {
 38+ if ( $allowed_values_str != '' ) {
3939 // replace the comma substitution character that has no chance of
4040 // being included in the values list - namely, the ASCII beep
4141 global $sfgListSeparator;
42 - $allowed_values_str = str_replace("\\$sfgListSeparator", "\a", $allowed_values_str);
43 - $allowed_values_array = explode($sfgListSeparator, $allowed_values_str);
44 - $text .= "\n\n" . wfMsgExt('sf_property_allowedvals', array( 'parsemag', 'content' ), count( $allowed_values_array ) );
45 - foreach ($allowed_values_array as $i => $value) {
 42+ $allowed_values_str = str_replace( "\\$sfgListSeparator", "\a", $allowed_values_str );
 43+ $allowed_values_array = explode( $sfgListSeparator, $allowed_values_str );
 44+ $text .= "\n\n" . wfMsgExt( 'sf_property_allowedvals', array( 'parsemag', 'content' ), count( $allowed_values_array ) );
 45+ foreach ( $allowed_values_array as $i => $value ) {
4646 // replace beep back with comma, trim
47 - $value = str_replace("\a", $sfgListSeparator, trim($value));
48 - if (method_exists($smwgContLang, 'getPropertyLabels')) {
 47+ $value = str_replace( "\a", $sfgListSeparator, trim( $value ) );
 48+ if ( method_exists( $smwgContLang, 'getPropertyLabels' ) ) {
4949 $prop_labels = $smwgContLang->getPropertyLabels();
5050 $text .= "\n* [[" . $prop_labels['_PVAL'] . "::$value]]";
5151 } else {
@@ -62,38 +62,38 @@
6363 global $wgOut, $wgRequest, $sfgScriptPath;
6464 global $smwgContLang;
6565
66 - wfLoadExtensionMessages('SemanticForms');
 66+ wfLoadExtensionMessages( 'SemanticForms' );
6767
6868 # cycle through the query values, setting the appropriate local variables
69 - $property_name = $wgRequest->getVal('property_name');
70 - $property_type = $wgRequest->getVal('property_type');
71 - $default_form = $wgRequest->getVal('default_form');
72 - $allowed_values = $wgRequest->getVal('values');
 69+ $property_name = $wgRequest->getVal( 'property_name' );
 70+ $property_type = $wgRequest->getVal( 'property_type' );
 71+ $default_form = $wgRequest->getVal( 'default_form' );
 72+ $allowed_values = $wgRequest->getVal( 'values' );
7373
74 - $save_button_text = wfMsg('savearticle');
75 - $preview_button_text = wfMsg('preview');
 74+ $save_button_text = wfMsg( 'savearticle' );
 75+ $preview_button_text = wfMsg( 'preview' );
7676
7777 $property_name_error_str = '';
78 - $save_page = $wgRequest->getCheck('wpSave');
79 - $preview_page = $wgRequest->getCheck('wpPreview');
80 - if ($save_page || $preview_page) {
 78+ $save_page = $wgRequest->getCheck( 'wpSave' );
 79+ $preview_page = $wgRequest->getCheck( 'wpPreview' );
 80+ if ( $save_page || $preview_page ) {
8181 # validate property name
82 - if ($property_name == '') {
83 - $property_name_error_str = wfMsg('sf_blank_error');
 82+ if ( $property_name == '' ) {
 83+ $property_name_error_str = wfMsg( 'sf_blank_error' );
8484 } else {
8585 # redirect to wiki interface
86 - $wgOut->setArticleBodyOnly(true);
87 - $title = Title::makeTitleSafe(SMW_NS_PROPERTY, $property_name);
88 - $full_text = SFCreateProperty::createPropertyText($property_type, $default_form, $allowed_values);
89 - $text = SFUtils::printRedirectForm($title, $full_text, "", $save_page, $preview_page, false, false, false, null, null);
90 - $wgOut->addHTML($text);
 86+ $wgOut->setArticleBodyOnly( true );
 87+ $title = Title::makeTitleSafe( SMW_NS_PROPERTY, $property_name );
 88+ $full_text = SFCreateProperty::createPropertyText( $property_type, $default_form, $allowed_values );
 89+ $text = SFUtils::printRedirectForm( $title, $full_text, "", $save_page, $preview_page, false, false, false, null, null );
 90+ $wgOut->addHTML( $text );
9191 return;
9292 }
9393 }
9494
9595 $datatype_labels = $smwgContLang->getDatatypeLabels();
9696
97 - $javascript_text =<<<END
 97+ $javascript_text = <<<END
9898 function toggleDefaultForm(property_type) {
9999 var default_form_div = document.getElementById("default_form_div");
100100 if (property_type == '{$datatype_labels['_wpg']}') {
@@ -109,9 +109,9 @@
110110 global $wgContLang;
111111 $mw_namespace_labels = $wgContLang->getNamespaces();
112112 $special_namespace = $mw_namespace_labels[NS_SPECIAL];
113 - $name_label = wfMsg('sf_createproperty_propname');
114 - $type_label = wfMsg('sf_createproperty_proptype');
115 - $text =<<<END
 113+ $name_label = wfMsg( 'sf_createproperty_propname' );
 114+ $type_label = wfMsg( 'sf_createproperty_proptype' );
 115+ $text = <<<END
116116 <form action="" method="post">
117117 <input type="hidden" name="title" value="$special_namespace:CreateProperty">
118118 <p>$name_label <input size="25" name="property_name" value="">
@@ -119,14 +119,14 @@
120120 $type_label
121121 END;
122122 $select_body = "";
123 - foreach ($datatype_labels as $label) {
124 - $select_body .= " " . Xml::element('option', null, $label) . "\n";
 123+ foreach ( $datatype_labels as $label ) {
 124+ $select_body .= " " . Xml::element( 'option', null, $label ) . "\n";
125125 }
126 - $text .= Xml::tags('select', array('id' => 'property_dropdown', 'name' => 'property_type', 'onChange' => 'toggleDefaultForm(this.value);'), $select_body) . "\n";
 126+ $text .= Xml::tags( 'select', array( 'id' => 'property_dropdown', 'name' => 'property_type', 'onChange' => 'toggleDefaultForm(this.value);' ), $select_body ) . "\n";
127127
128 - $default_form_input = wfMsg('sf_createproperty_linktoform');
129 - $values_input = wfMsg('sf_createproperty_allowedvalsinput');
130 - $text .=<<<END
 128+ $default_form_input = wfMsg( 'sf_createproperty_linktoform' );
 129+ $values_input = wfMsg( 'sf_createproperty_allowedvalsinput' );
 130+ $text .= <<<END
131131 <div id="default_form_div" style="padding: 5px 0 5px 0; margin: 7px 0 7px 0;">
132132 <p>$default_form_input
133133 <input size="20" name="default_form" value=""></p>
@@ -137,9 +137,9 @@
138138 </div>
139139
140140 END;
141 - $edit_buttons = ' ' . Xml::element('input', array('id' => 'wpSave', 'type' => 'submit', 'name' => 'wpSave', 'value' => $save_button_text));
142 - $edit_buttons .= ' ' . Xml::element('input', array('id' => 'wpPreview', 'type' => 'submit', 'name' => 'wpPreview', 'value' => $preview_button_text));
143 - $text .= ' ' . Xml::tags('div', array('class' => 'editButtons'), $edit_buttons) . "\n";
 141+ $edit_buttons = ' ' . Xml::element( 'input', array( 'id' => 'wpSave', 'type' => 'submit', 'name' => 'wpSave', 'value' => $save_button_text ) );
 142+ $edit_buttons .= ' ' . Xml::element( 'input', array( 'id' => 'wpPreview', 'type' => 'submit', 'name' => 'wpPreview', 'value' => $preview_button_text ) );
 143+ $text .= ' ' . Xml::tags( 'div', array( 'class' => 'editButtons' ), $edit_buttons ) . "\n";
144144 $text .= " </form>\n";
145145
146146 $wgOut->addLink( array(
@@ -147,7 +147,7 @@
148148 'type' => 'text/css',
149149 'media' => "screen",
150150 'href' => $sfgScriptPath . "/skins/SF_main.css"
151 - ));
152 - $wgOut->addScript('<script type="text/javascript">' . $javascript_text . '</script>');
153 - $wgOut->addHTML($text);
 151+ ) );
 152+ $wgOut->addScript( '<script type="text/javascript">' . $javascript_text . '</script>' );
 153+ $wgOut->addHTML( $text );
154154 }
Index: trunk/extensions/SemanticForms/specials/SF_CreateClass.php
@@ -6,7 +6,7 @@
77 * @author Yaron Koren
88 */
99
10 -if (!defined('MEDIAWIKI')) die();
 10+if ( !defined( 'MEDIAWIKI' ) ) die();
1111
1212 class SFCreateClass extends SpecialPage {
1313
@@ -17,7 +17,7 @@
1818 parent::__construct( 'CreateClass', 'createclass' );
1919 }
2020
21 - function execute($query) {
 21+ function execute( $query ) {
2222 global $wgOut, $wgRequest, $wgUser, $sfgScriptPath;
2323 global $wgLang, $smwgContLang;
2424
@@ -28,44 +28,44 @@
2929 }
3030
3131 $this->setHeaders();
32 - wfLoadExtensionMessages('SemanticForms');
 32+ wfLoadExtensionMessages( 'SemanticForms' );
3333
34 - $create_button_text = wfMsg('create');
 34+ $create_button_text = wfMsg( 'create' );
3535
3636 $property_name_error_str = '';
37 - $save_page = $wgRequest->getCheck('wpSave');
38 - if ($save_page) {
39 - $template_name = trim($wgRequest->getVal("template_name"));
40 - $form_name = trim($wgRequest->getVal("form_name"));
41 - $category_name = trim($wgRequest->getVal("category_name"));
42 - if ($template_name == '' | $form_name == '' || $category_name == '') {
43 - $text = Xml::element('p', null, wfMsg('sf_createclass_missingvalues'));
44 - $wgOut->addHTML($text);
 37+ $save_page = $wgRequest->getCheck( 'wpSave' );
 38+ if ( $save_page ) {
 39+ $template_name = trim( $wgRequest->getVal( "template_name" ) );
 40+ $form_name = trim( $wgRequest->getVal( "form_name" ) );
 41+ $category_name = trim( $wgRequest->getVal( "category_name" ) );
 42+ if ( $template_name == '' | $form_name == '' || $category_name == '' ) {
 43+ $text = Xml::element( 'p', null, wfMsg( 'sf_createclass_missingvalues' ) );
 44+ $wgOut->addHTML( $text );
4545 return;
4646 }
4747 $fields = array();
4848 $jobs = array();
4949 // cycle through all the rows passed in
50 - for ($i = 1; $wgRequest->getCheck("property_name_$i"); $i++) {
 50+ for ( $i = 1; $wgRequest->getCheck( "property_name_$i" ); $i++ ) {
5151 // go through the query values, setting the appropriate local variables
52 - $property_name = trim($wgRequest->getVal("property_name_$i"));
53 - if (empty($property_name)) continue;
54 - $field_name = trim($wgRequest->getVal("field_name_$i"));
55 - if ($field_name === '')
 52+ $property_name = trim( $wgRequest->getVal( "property_name_$i" ) );
 53+ if ( empty( $property_name ) ) continue;
 54+ $field_name = trim( $wgRequest->getVal( "field_name_$i" ) );
 55+ if ( $field_name === '' )
5656 $field_name = $property_name;
57 - $property_type = $wgRequest->getVal("property_type_$i");
58 - $allowed_values = $wgRequest->getVal("allowed_values_$i");
59 - $is_list = $wgRequest->getCheck("is_list_$i");
 57+ $property_type = $wgRequest->getVal( "property_type_$i" );
 58+ $allowed_values = $wgRequest->getVal( "allowed_values_$i" );
 59+ $is_list = $wgRequest->getCheck( "is_list_$i" );
6060 // create an SFTemplateField based on these
6161 // values, and add it to the $fields array
62 - $field = SFTemplateField::create($field_name, $field_name);
 62+ $field = SFTemplateField::create( $field_name, $field_name );
6363 $field->semantic_property = $property_name;
6464 $field->is_list = $is_list;
6565 $fields[] = $field;
6666
6767 // create the property, and make a job for it
68 - $full_text = SFCreateProperty::createPropertyText($property_type, '', $allowed_values);
69 - $property_title = Title::makeTitleSafe(SMW_NS_PROPERTY, $property_name);
 68+ $full_text = SFCreateProperty::createPropertyText( $property_type, '', $allowed_values );
 69+ $property_title = Title::makeTitleSafe( SMW_NS_PROPERTY, $property_name );
7070 $params = array();
7171 $params['user_id'] = $wgUser->getId();
7272 $params['page_text'] = $full_text;
@@ -73,34 +73,34 @@
7474 }
7575
7676 // create the template, and save it
77 - $full_text = SFTemplateField::createTemplateText($template_name, $fields, $category_name, '', '', '');
78 - $template_title = Title::makeTitleSafe(NS_TEMPLATE, $template_name);
79 - $template_article = new Article($template_title);
 77+ $full_text = SFTemplateField::createTemplateText( $template_name, $fields, $category_name, '', '', '' );
 78+ $template_title = Title::makeTitleSafe( NS_TEMPLATE, $template_name );
 79+ $template_article = new Article( $template_title );
8080 $edit_summary = '';
81 - $template_article->doEdit($full_text, $edit_summary);
 81+ $template_article->doEdit( $full_text, $edit_summary );
8282
8383 // create the form, and make a job for it
84 - $form_template = SFTemplateInForm::create($template_name, '', false);
85 - $form_templates = array($form_template);
86 - $form = SFForm::create($form_name, $form_templates);
 84+ $form_template = SFTemplateInForm::create( $template_name, '', false );
 85+ $form_templates = array( $form_template );
 86+ $form = SFForm::create( $form_name, $form_templates );
8787 $full_text = $form->createMarkup();
88 - $form_title = Title::makeTitleSafe(SF_NS_FORM, $form_name);
 88+ $form_title = Title::makeTitleSafe( SF_NS_FORM, $form_name );
8989 $params = array();
9090 $params['user_id'] = $wgUser->getId();
9191 $params['page_text'] = $full_text;
9292 $jobs[] = new SFCreatePageJob( $form_title, $params );
9393
9494 // create the category, and make a job for it
95 - $full_text = SFCreateCategory::createCategoryText($form_name, $category_name, '');
96 - $category_title = Title::makeTitleSafe(NS_CATEGORY, $category_name);
 95+ $full_text = SFCreateCategory::createCategoryText( $form_name, $category_name, '' );
 96+ $category_title = Title::makeTitleSafe( NS_CATEGORY, $category_name );
9797 $params = array();
9898 $params['user_id'] = $wgUser->getId();
9999 $params['page_text'] = $full_text;
100100 $jobs[] = new SFCreatePageJob( $category_title, $params );
101101 Job::batchInsert( $jobs );
102102
103 - $text = Xml::element('p', null, wfMsg('sf_createclass_success'));
104 - $wgOut->addHTML($text);
 103+ $text = Xml::element( 'p', null, wfMsg( 'sf_createclass_success' ) );
 104+ $wgOut->addHTML( $text );
105105 return;
106106 }
107107
@@ -115,25 +115,25 @@
116116 // link to them at the top of the page
117117 $sk = $wgUser->getSkin();
118118 $creation_links = array();
119 - $cp = SpecialPage::getPage('CreateProperty');
120 - $creation_links[] = $sk->makeKnownLinkObj($cp->getTitle(), $cp->getDescription());
121 - $ct = SpecialPage::getPage('CreateTemplate');
122 - $creation_links[] = $sk->makeKnownLinkObj($ct->getTitle(), $ct->getDescription());
123 - $cf = SpecialPage::getPage('CreateForm');
124 - $creation_links[] = $sk->makeKnownLinkObj($cf->getTitle(), $cf->getDescription());
125 - $cc = SpecialPage::getPage('CreateCategory');
126 - $creation_links[] = $sk->makeKnownLinkObj($cc->getTitle(), $cc->getDescription());
127 - $create_class_docu = wfMsg('sf_createclass_docu', $wgLang->listToText($creation_links));
128 - $leave_field_blank = wfMsg('sf_createclass_leavefieldblank');
129 - $form_name_label = wfMsg('sf_createform_nameinput');
130 - $template_name_label = wfMsg('sf_createtemplate_namelabel');
131 - $category_name_label = wfMsg('sf_createcategory_name');
132 - $property_name_label = wfMsg('sf_createproperty_propname');
133 - $field_name_label = wfMsg('sf_createtemplate_fieldname');
134 - $type_label = wfMsg('sf_createproperty_proptype');
135 - $allowed_values_label = wfMsg('sf_createclass_allowedvalues') . wfMsg('colon-separator');
136 - $list_of_values_label = wfMsg('sf_createclass_listofvalues') . '?';
137 - $text =<<<END
 119+ $cp = SpecialPage::getPage( 'CreateProperty' );
 120+ $creation_links[] = $sk->makeKnownLinkObj( $cp->getTitle(), $cp->getDescription() );
 121+ $ct = SpecialPage::getPage( 'CreateTemplate' );
 122+ $creation_links[] = $sk->makeKnownLinkObj( $ct->getTitle(), $ct->getDescription() );
 123+ $cf = SpecialPage::getPage( 'CreateForm' );
 124+ $creation_links[] = $sk->makeKnownLinkObj( $cf->getTitle(), $cf->getDescription() );
 125+ $cc = SpecialPage::getPage( 'CreateCategory' );
 126+ $creation_links[] = $sk->makeKnownLinkObj( $cc->getTitle(), $cc->getDescription() );
 127+ $create_class_docu = wfMsg( 'sf_createclass_docu', $wgLang->listToText( $creation_links ) );
 128+ $leave_field_blank = wfMsg( 'sf_createclass_leavefieldblank' );
 129+ $form_name_label = wfMsg( 'sf_createform_nameinput' );
 130+ $template_name_label = wfMsg( 'sf_createtemplate_namelabel' );
 131+ $category_name_label = wfMsg( 'sf_createcategory_name' );
 132+ $property_name_label = wfMsg( 'sf_createproperty_propname' );
 133+ $field_name_label = wfMsg( 'sf_createtemplate_fieldname' );
 134+ $type_label = wfMsg( 'sf_createproperty_proptype' );
 135+ $allowed_values_label = wfMsg( 'sf_createclass_allowedvalues' ) . wfMsg( 'colon-separator' );
 136+ $list_of_values_label = wfMsg( 'sf_createclass_listofvalues' ) . '?';
 137+ $text = <<<END
138138 <form action="" method="post">
139139 <p>$create_class_docu</p>
140140 <p>$leave_field_blank</p>
@@ -150,8 +150,8 @@
151151 </tr>
152152
153153 END;
154 - for ($i = 1; $i <= 25; $i++) {
155 - $text .=<<<END
 154+ for ( $i = 1; $i <= 25; $i++ ) {
 155+ $text .= <<<END
156156 <tr>
157157 <td>$i. <input type="text" size="25" name="property_name_$i" /></td>
158158 <td><input type="text" size="25" name="field_name_$i" /></td>
@@ -159,10 +159,10 @@
160160 <select id="property_dropdown_$i" name="property_type_$i">
161161
162162 END;
163 - foreach ($datatype_labels as $label) {
 163+ foreach ( $datatype_labels as $label ) {
164164 $text .= " <option>$label</option>\n";
165165 }
166 - $text .=<<<END
 166+ $text .= <<<END
167167 </select>
168168 </td>
169169 <td><input type="text" size="25" name="allowed_values_$i" /></td>
@@ -170,7 +170,7 @@
171171
172172 END;
173173 }
174 - $text .=<<<END
 174+ $text .= <<<END
175175 </tr>
176176 </table>
177177 <br />
@@ -186,7 +186,7 @@
187187 'type' => 'text/css',
188188 'media' => "screen",
189189 'href' => $sfgScriptPath . "/skins/SF_main.css"
190 - ));
191 - $wgOut->addHTML($text);
 190+ ) );
 191+ $wgOut->addHTML( $text );
192192 }
193193 }
Index: trunk/extensions/SemanticForms/specials/SF_FormEdit.php
@@ -5,7 +5,7 @@
66 *
77 * @author Yaron Koren
88 */
9 -if (!defined('MEDIAWIKI')) die();
 9+if ( !defined( 'MEDIAWIKI' ) ) die();
1010
1111 class SFFormEdit extends SpecialPage {
1212
@@ -13,45 +13,45 @@
1414 * Constructor
1515 */
1616 function SFFormEdit() {
17 - SpecialPage::SpecialPage('FormEdit');
18 - wfLoadExtensionMessages('SemanticForms');
 17+ SpecialPage::SpecialPage( 'FormEdit' );
 18+ wfLoadExtensionMessages( 'SemanticForms' );
1919 }
2020
21 - function execute($query) {
 21+ function execute( $query ) {
2222 global $wgRequest;
2323
2424 $this->setHeaders();
25 - $form_name = $wgRequest->getVal('form');
26 - $target_name = $wgRequest->getVal('target');
 25+ $form_name = $wgRequest->getVal( 'form' );
 26+ $target_name = $wgRequest->getVal( 'target' );
2727
2828 // if query string did not contain these variables, try the URL
29 - if (! $form_name && ! $target_name) {
30 - $queryparts = explode('/', $query, 2);
31 - $form_name = isset($queryparts[0]) ? $queryparts[0] : '';
32 - $target_name = isset($queryparts[1]) ? $queryparts[1] : '';
 29+ if ( ! $form_name && ! $target_name ) {
 30+ $queryparts = explode( '/', $query, 2 );
 31+ $form_name = isset( $queryparts[0] ) ? $queryparts[0] : '';
 32+ $target_name = isset( $queryparts[1] ) ? $queryparts[1] : '';
3333 }
3434
35 - $alt_forms = $wgRequest->getArray('alt_form');
 35+ $alt_forms = $wgRequest->getArray( 'alt_form' );
3636
37 - self::printForm($form_name, $target_name, $alt_forms);
 37+ self::printForm( $form_name, $target_name, $alt_forms );
3838 }
3939
40 - static function printAltFormsList($alt_forms, $target_name) {
 40+ static function printAltFormsList( $alt_forms, $target_name ) {
4141 $text = "";
42 - $fe = SpecialPage::getPage('FormEdit');
 42+ $fe = SpecialPage::getPage( 'FormEdit' );
4343 $fe_url = $fe->getTitle()->getFullURL();
4444 $i = 0;
45 - foreach ($alt_forms as $alt_form) {
46 - if ($i++ > 0) { $text .= ", "; }
47 - $text .= "<a href=\"$fe_url/$alt_form/$target_name\">" . str_replace('_', ' ', $alt_form) . "</a>";
 45+ foreach ( $alt_forms as $alt_form ) {
 46+ if ( $i++ > 0 ) { $text .= ", "; }
 47+ $text .= "<a href=\"$fe_url/$alt_form/$target_name\">" . str_replace( '_', ' ', $alt_form ) . "</a>";
4848 }
4949 return $text;
5050 }
5151
52 -static function printForm($form_name, $target_name, $alt_forms = array()) {
 52+static function printForm( $form_name, $target_name, $alt_forms = array() ) {
5353 global $wgOut, $wgRequest, $wgScriptPath, $sfgScriptPath, $sfgFormPrinter, $sfgYUIBase;
5454
55 - wfLoadExtensionMessages('SemanticForms');
 55+ wfLoadExtensionMessages( 'SemanticForms' );
5656
5757 // initialize some variables
5858 $target_title = null;
@@ -59,110 +59,110 @@
6060
6161 // get contents of form and target page - if there's only one,
6262 // it might be a target with only alternate forms
63 - if ($form_name == '') {
64 - $wgOut->addHTML( "<p class='error'>" . wfMsg('sf_formedit_badurl') . '</p>');
 63+ if ( $form_name == '' ) {
 64+ $wgOut->addHTML( "<p class='error'>" . wfMsg( 'sf_formedit_badurl' ) . '</p>' );
6565 return;
66 - } elseif ($target_name == '') {
 66+ } elseif ( $target_name == '' ) {
6767 // parse the form to see if it has a 'page name' value set
68 - $form_title = Title::makeTitleSafe(SF_NS_FORM, $form_name);
69 - $form_article = new Article($form_title);
 68+ $form_title = Title::makeTitleSafe( SF_NS_FORM, $form_name );
 69+ $form_article = new Article( $form_title );
7070 $form_definition = $form_article->getContent();
71 - $form_definition = StringUtils::delimiterReplace('<noinclude>', '</noinclude>', '', $form_definition);
 71+ $form_definition = StringUtils::delimiterReplace( '<noinclude>', '</noinclude>', '', $form_definition );
7272 $matches;
73 - if (preg_match('/{{{info.*page name=([^\|]*)/m', $form_definition, $matches)) {
74 - $page_name_formula = str_replace('_', ' ', $matches[1]);
 73+ if ( preg_match( '/{{{info.*page name=([^\|]*)/m', $form_definition, $matches ) ) {
 74+ $page_name_formula = str_replace( '_', ' ', $matches[1] );
7575 // if the tag close ('}}}') is in here, chop off that
7676 // and everything after it
77 - if ($pos = strpos($page_name_formula, '}}}')) {
78 - $page_name_formula = substr($page_name_formula, 0, $pos);
 77+ if ( $pos = strpos( $page_name_formula, '}}}' ) ) {
 78+ $page_name_formula = substr( $page_name_formula, 0, $pos );
7979 }
80 - } elseif (count($alt_forms) == 0) {
81 - $wgOut->addWikiText( "<p class='error'>" . wfMsg('sf_formedit_badurl') . '</p>');
 80+ } elseif ( count( $alt_forms ) == 0 ) {
 81+ $wgOut->addWikiText( "<p class='error'>" . wfMsg( 'sf_formedit_badurl' ) . '</p>' );
8282 return;
8383 }
8484 }
8585
86 - $form_title = Title::makeTitleSafe(SF_NS_FORM, $form_name);
 86+ $form_title = Title::makeTitleSafe( SF_NS_FORM, $form_name );
8787
88 - if ($target_name != '') {
89 - $target_title = Title::newFromText($target_name);
90 - if ($target_title->exists()) {
91 - $s = wfMsg('sf_formedit_edittitle', $form_title->getText(), $target_title->getPrefixedText());
 88+ if ( $target_name != '' ) {
 89+ $target_title = Title::newFromText( $target_name );
 90+ if ( $target_title->exists() ) {
 91+ $s = wfMsg( 'sf_formedit_edittitle', $form_title->getText(), $target_title->getPrefixedText() );
9292 } else {
93 - $s = wfMsg('sf_formedit_createtitle', $form_title->getText(), $target_title->getPrefixedText());
 93+ $s = wfMsg( 'sf_formedit_createtitle', $form_title->getText(), $target_title->getPrefixedText() );
9494 }
95 - $wgOut->setPageTitle($s);
 95+ $wgOut->setPageTitle( $s );
9696 }
9797
9898 // handling is different depending on whether page already exists
9999 // or not
100 - if ($target_title && $target_title->exists()) {
101 - if ($wgRequest->getVal('query') == 'true') {
 100+ if ( $target_title && $target_title->exists() ) {
 101+ if ( $wgRequest->getVal( 'query' ) == 'true' ) {
102102 $page_contents = null;
103103 $page_is_source = false;
104104 } else {
105 - $target_article = new Article($target_title);
 105+ $target_article = new Article( $target_title );
106106 $page_contents = $target_article->getContent();
107107 $page_is_source = true;
108108 }
109 - } elseif ($target_name != '') {
110 - $target_name = str_replace('_', ' ', $target_name);
 109+ } elseif ( $target_name != '' ) {
 110+ $target_name = str_replace( '_', ' ', $target_name );
111111 }
112112
113 - if (! $form_title || ! $form_title->exists()) {
114 - if ($form_name == '')
115 - $text = '<p class="error">' . wfMsg('sf_formedit_badurl') . "</p>\n";
 113+ if ( ! $form_title || ! $form_title->exists() ) {
 114+ if ( $form_name == '' )
 115+ $text = '<p class="error">' . wfMsg( 'sf_formedit_badurl' ) . "</p>\n";
116116 else {
117 - if (count($alt_forms) > 0) {
118 - $text .= '<div class="infoMessage">' . wfMsg('sf_formedit_altformsonly') . ' ';
119 - $text .= self::printAltFormsList($alt_forms, $form_name);
 117+ if ( count( $alt_forms ) > 0 ) {
 118+ $text .= '<div class="infoMessage">' . wfMsg( 'sf_formedit_altformsonly' ) . ' ';
 119+ $text .= self::printAltFormsList( $alt_forms, $form_name );
120120 $text .= "</div>\n";
121121 } else
122 - $text = '<p class="error">' . wfMsg('sf_formstart_badform', SFUtils::linkText(SF_NS_FORM, $form_name)) . ".</p>\n";
 122+ $text = '<p class="error">' . wfMsg( 'sf_formstart_badform', SFUtils::linkText( SF_NS_FORM, $form_name ) ) . ".</p>\n";
123123 }
124 - } elseif ($target_name == '' && $page_name_formula == '') {
125 - $text = '<p class="error">' . wfMsg('sf_formedit_badurl') . "</p>\n";
 124+ } elseif ( $target_name == '' && $page_name_formula == '' ) {
 125+ $text = '<p class="error">' . wfMsg( 'sf_formedit_badurl' ) . "</p>\n";
126126 } else {
127 - $form_article = new Article($form_title);
 127+ $form_article = new Article( $form_title );
128128 $form_definition = $form_article->getContent();
129129
130 - $save_page = $wgRequest->getCheck('wpSave');
131 - $preview_page = $wgRequest->getCheck('wpPreview');
132 - $diff_page = $wgRequest->getCheck('wpDiff');
133 - $form_submitted = ($save_page || $preview_page || $diff_page);
 130+ $save_page = $wgRequest->getCheck( 'wpSave' );
 131+ $preview_page = $wgRequest->getCheck( 'wpPreview' );
 132+ $diff_page = $wgRequest->getCheck( 'wpDiff' );
 133+ $form_submitted = ( $save_page || $preview_page || $diff_page );
134134 // get 'preload' query value, if it exists
135 - if (! $form_submitted) {
136 - if ($wgRequest->getCheck('preload')) {
 135+ if ( ! $form_submitted ) {
 136+ if ( $wgRequest->getCheck( 'preload' ) ) {
137137 $page_is_source = true;
138 - $page_contents = SFFormUtils::getPreloadedText($wgRequest->getVal('preload'));
 138+ $page_contents = SFFormUtils::getPreloadedText( $wgRequest->getVal( 'preload' ) );
139139 } else {
140140 // let other extensions preload the page, if they want
141 - wfRunHooks('sfEditFormPreloadText', array(&$page_contents, $target_title, $form_title));
142 - $page_is_source = ($page_contents != null);
 141+ wfRunHooks( 'sfEditFormPreloadText', array( &$page_contents, $target_title, $form_title ) );
 142+ $page_is_source = ( $page_contents != null );
143143 }
144144 } else {
145145 $page_is_source = false;
146146 $page_contents = null;
147147 }
148 - list ($form_text, $javascript_text, $data_text, $form_page_title, $generated_page_name) =
149 - $sfgFormPrinter->formHTML($form_definition, $form_submitted, $page_is_source, $form_article->getID(), $page_contents, $target_name, $page_name_formula);
150 - if ($form_submitted) {
151 - if ($page_name_formula != '') {
 148+ list ( $form_text, $javascript_text, $data_text, $form_page_title, $generated_page_name ) =
 149+ $sfgFormPrinter->formHTML( $form_definition, $form_submitted, $page_is_source, $form_article->getID(), $page_contents, $target_name, $page_name_formula );
 150+ if ( $form_submitted ) {
 151+ if ( $page_name_formula != '' ) {
152152 $target_name = $generated_page_name;
153153 // prepend a super-page, if one was specified
154 - if ($wgRequest->getCheck('super_page')) {
155 - $target_name = $wgRequest->getVal('super_page') . '/' . $target_name;
 154+ if ( $wgRequest->getCheck( 'super_page' ) ) {
 155+ $target_name = $wgRequest->getVal( 'super_page' ) . '/' . $target_name;
156156 }
157157 // prepend a namespace, if one was specified
158 - if ($wgRequest->getCheck('namespace')) {
159 - $target_name = $wgRequest->getVal('namespace') . ':' . $target_name;
 158+ if ( $wgRequest->getCheck( 'namespace' ) ) {
 159+ $target_name = $wgRequest->getVal( 'namespace' ) . ':' . $target_name;
160160 }
161161 // replace "unique number" tag with one that
162162 // won't get erased by the next line
163 - $target_name = preg_replace('/<unique number(.*)>/', '{num\1}', $target_name, 1);
 163+ $target_name = preg_replace( '/<unique number(.*)>/', '{num\1}', $target_name, 1 );
164164 // if any formula stuff is still in the name
165165 // after the parsing, just remove it
166 - $target_name = StringUtils::delimiterReplace('<', '>', '', $target_name);
 166+ $target_name = StringUtils::delimiterReplace( '<', '>', '', $target_name );
167167
168168 // now run the parser on it
169169 global $wgParser;
@@ -171,16 +171,16 @@
172172 // function name contains underlines -
173173 // hopefully this won't cause problems of
174174 // its own
175 - $target_name = str_replace(' ', '_', $target_name);
176 - $target_name = $wgParser->recursiveTagParse($target_name);
 175+ $target_name = str_replace( ' ', '_', $target_name );
 176+ $target_name = $wgParser->recursiveTagParse( $target_name );
177177
178 - if (strpos($target_name, '{num')) {
 178+ if ( strpos( $target_name, '{num' ) ) {
179179 // get unique number start value from
180180 // target name; if it's not there, or
181181 // it's not a positive number,
182182 // start it out as blank
183 - preg_match('/{num.*start=([^;]*).*}/', $target_name, $matches);
184 - if (count($matches) == 2 && is_numeric($matches[1]) && $matches[1] >= 0) {
 183+ preg_match( '/{num.*start=([^;]*).*}/', $target_name, $matches );
 184+ if ( count( $matches ) == 2 && is_numeric( $matches[1] ) && $matches[1] >= 0 ) {
185185 $title_number = $matches[1];
186186 } else {
187187 $title_number = "";
@@ -189,43 +189,43 @@
190190 // until we find one that gives a
191191 // nonexistent page title
192192 do {
193 - $target_title = Title::newFromText(preg_replace('/{num.*}/', $title_number, $target_name));
 193+ $target_title = Title::newFromText( preg_replace( '/{num.*}/', $title_number, $target_name ) );
194194 // if title number is blank,
195195 // change it to 2; otherwise,
196196 // increment it, and if necessary
197197 // pad it with leading 0s as well
198 - if ($title_number == "") {
 198+ if ( $title_number == "" ) {
199199 $title_number = 2;
200200 } else {
201 - $title_number = str_pad($title_number + 1, strlen($title_number), '0', STR_PAD_LEFT);
 201+ $title_number = str_pad( $title_number + 1, strlen( $title_number ), '0', STR_PAD_LEFT );
202202 }
203 - } while ($target_title->exists());
 203+ } while ( $target_title->exists() );
204204 } else {
205 - $target_title = Title::newFromText($target_name);
 205+ $target_title = Title::newFromText( $target_name );
206206 }
207207 }
208 - if (is_null($target_title)) {
209 - die (wfMsg('badtitle') . ": $target_name");
 208+ if ( is_null( $target_title ) ) {
 209+ die ( wfMsg( 'badtitle' ) . ": $target_name" );
210210 }
211211 $wgOut->setArticleBodyOnly( true );
212 - $text = SFUtils::printRedirectForm($target_title, $data_text, $wgRequest->getVal('wpSummary'), $save_page, $preview_page, $diff_page, $wgRequest->getCheck('wpMinoredit'), $wgRequest->getCheck('wpWatchthis'), $wgRequest->getVal('wpStarttime'), $wgRequest->getVal('wpEdittime'));
 212+ $text = SFUtils::printRedirectForm( $target_title, $data_text, $wgRequest->getVal( 'wpSummary' ), $save_page, $preview_page, $diff_page, $wgRequest->getCheck( 'wpMinoredit' ), $wgRequest->getCheck( 'wpWatchthis' ), $wgRequest->getVal( 'wpStarttime' ), $wgRequest->getVal( 'wpEdittime' ) );
213213 } else {
214214 // override the default title for this page if
215215 // a title was specified in the form
216 - if ($form_page_title != null) {
217 - if ($target_name == '') {
218 - $wgOut->setPageTitle($form_page_title);
 216+ if ( $form_page_title != null ) {
 217+ if ( $target_name == '' ) {
 218+ $wgOut->setPageTitle( $form_page_title );
219219 } else {
220 - $wgOut->setPageTitle("$form_page_title: {$target_title->getPrefixedText()}");
 220+ $wgOut->setPageTitle( "$form_page_title: {$target_title->getPrefixedText()}" );
221221 }
222222 }
223223 $text = "";
224 - if (count($alt_forms) > 0) {
225 - $text .= '<div class="infoMessage">' . wfMsg('sf_formedit_altforms') . ' ';
226 - $text .= self::printAltFormsList($alt_forms, $target_name);
 224+ if ( count( $alt_forms ) > 0 ) {
 225+ $text .= '<div class="infoMessage">' . wfMsg( 'sf_formedit_altforms' ) . ' ';
 226+ $text .= self::printAltFormsList( $alt_forms, $target_name );
227227 $text .= "</div>\n";
228228 }
229 - $text .=<<<END
 229+ $text .= <<<END
230230 <form name="createbox" onsubmit="return validate_all()" action="" method="post" class="createbox">
231231
232232 END;
@@ -240,11 +240,11 @@
241241 // that they can affect (i.e., hide) the relevant form fields.
242242 // if there's a less hacky way to do this, the code should switch to
243243 // that.
244 - //if (! empty($javascript_text))
 244+ // if (! empty($javascript_text))
245245 // $wgOut->addScript(' <script type="text/javascript">' . "\n" . $javascript_text . '</script>' . "\n");
246 - $wgOut->addHTML($text);
247 - if (! empty($javascript_text))
248 - $wgOut->addHTML(' <script type="text/javascript">' . "\n" . $javascript_text . '</script>' . "\n");
 246+ $wgOut->addHTML( $text );
 247+ if ( ! empty( $javascript_text ) )
 248+ $wgOut->addHTML( ' <script type="text/javascript">' . "\n" . $javascript_text . '</script>' . "\n" );
249249 }
250250
251251 }
Index: trunk/extensions/SemanticForms/specials/SF_RunQuery.php
@@ -5,7 +5,7 @@
66 * @author Yaron Koren
77 */
88
9 -if (!defined('MEDIAWIKI')) die();
 9+if ( !defined( 'MEDIAWIKI' ) ) die();
1010
1111 class SFRunQuery extends IncludableSpecialPage {
1212
@@ -13,82 +13,82 @@
1414 * Constructor
1515 */
1616 function SFRunQuery() {
17 - parent::__construct('RunQuery');
18 - wfLoadExtensionMessages('SemanticForms');
 17+ parent::__construct( 'RunQuery' );
 18+ wfLoadExtensionMessages( 'SemanticForms' );
1919 }
2020
21 - function execute($query) {
 21+ function execute( $query ) {
2222 global $wgRequest;
2323 if ( !$this->including() )
2424 $this->setHeaders();
25 - $form_name = $this->including() ? $query : $wgRequest->getVal('form', $query);
 25+ $form_name = $this->including() ? $query : $wgRequest->getVal( 'form', $query );
2626
27 - self::printQueryForm($form_name, $this->including());
 27+ self::printQueryForm( $form_name, $this->including() );
2828 }
2929
30 - static function printQueryForm($form_name, $embedded = false) {
 30+ static function printQueryForm( $form_name, $embedded = false ) {
3131 global $wgOut, $wgRequest, $wgScriptPath, $sfgScriptPath, $sfgFormPrinter, $sfgYUIBase, $wgParser;
3232
3333 // get contents of form definition file
34 - $form_title = Title::makeTitleSafe(SF_NS_FORM, $form_name);
 34+ $form_title = Title::makeTitleSafe( SF_NS_FORM, $form_name );
3535
36 - if (! $form_title || ! $form_title->exists() ) {
 36+ if ( ! $form_title || ! $form_title->exists() ) {
3737 $javascript_text = "";
38 - if ($form_name == '')
39 - $text = '<p class="error">' . wfMsg('sf_runquery_badurl') . "</p>\n";
 38+ if ( $form_name == '' )
 39+ $text = '<p class="error">' . wfMsg( 'sf_runquery_badurl' ) . "</p>\n";
4040 else
41 - $text = '<p class="error">Error: No form page was found at ' . SFUtils::linkText(SF_NS_FORM, $form_name) . ".</p>\n";
 41+ $text = '<p class="error">Error: No form page was found at ' . SFUtils::linkText( SF_NS_FORM, $form_name ) . ".</p>\n";
4242 } else {
43 - $s = wfMsg('sf_runquery_title', $form_title->getText());
 43+ $s = wfMsg( 'sf_runquery_title', $form_title->getText() );
4444 if ( !$embedded )
45 - $wgOut->setPageTitle($s);
46 - $form_article = new Article($form_title);
 45+ $wgOut->setPageTitle( $s );
 46+ $form_article = new Article( $form_title );
4747 $form_definition = $form_article->getContent();
48 - $submit_url = $form_title->getLocalURL('action=submit');
 48+ $submit_url = $form_title->getLocalURL( 'action=submit' );
4949 if ( $embedded ) {
5050 $run_query = false;
5151 $content = null;
5252 $raw = false;
5353 } else {
54 - $run_query = $wgRequest->getCheck('wpRunQuery');
55 - $content = $wgRequest->getVal('wpTextbox1');
56 - $raw = $wgRequest->getBool('raw', false);
 54+ $run_query = $wgRequest->getCheck( 'wpRunQuery' );
 55+ $content = $wgRequest->getVal( 'wpTextbox1' );
 56+ $raw = $wgRequest->getBool( 'raw', false );
5757 }
58 - $form_submitted = ($run_query);
 58+ $form_submitted = ( $run_query );
5959 if ( $raw )
6060 $wgOut->setArticleBodyOnly( true );
6161 // if user already made some action, ignore the edited
6262 // page and just get data from the query string
63 - if (!$embedded && $wgRequest->getVal('query') == 'true') {
 63+ if ( !$embedded && $wgRequest->getVal( 'query' ) == 'true' ) {
6464 $edit_content = null;
6565 $is_text_source = false;
66 - } elseif ($content != null) {
 66+ } elseif ( $content != null ) {
6767 $edit_content = $content;
6868 $is_text_source = true;
6969 } else {
7070 $edit_content = null;
7171 $is_text_source = true;
7272 }
73 - list ($form_text, $javascript_text, $data_text, $form_page_title) =
74 - $sfgFormPrinter->formHTML($form_definition, $form_submitted, $is_text_source, $form_article->getID(), $edit_content, null, null, true, $embedded);
 73+ list ( $form_text, $javascript_text, $data_text, $form_page_title ) =
 74+ $sfgFormPrinter->formHTML( $form_definition, $form_submitted, $is_text_source, $form_article->getID(), $edit_content, null, null, true, $embedded );
7575 $text = "";
7676 // override the default title for this page if
7777 // a title was specified in the form
78 - if ($form_page_title != null && !$embedded) {
79 - $wgOut->setPageTitle($form_page_title);
 78+ if ( $form_page_title != null && !$embedded ) {
 79+ $wgOut->setPageTitle( $form_page_title );
8080 }
81 - if ($form_submitted) {
 81+ if ( $form_submitted ) {
8282 global $wgUser, $wgTitle;
8383 $wgParser->mOptions = new ParserOptions();
84 - $wgParser->mOptions->initialiseFromUser($wgUser);
85 - $text = $wgParser->parse($data_text, $wgTitle, $wgParser->mOptions)->getText();
86 - $additional_query = wfMsg('sf_runquery_additionalquery');
 84+ $wgParser->mOptions->initialiseFromUser( $wgUser );
 85+ $text = $wgParser->parse( $data_text, $wgTitle, $wgParser->mOptions )->getText();
 86+ $additional_query = wfMsg( 'sf_runquery_additionalquery' );
8787 if ( !$raw )
8888 $text .= "\n<h2>$additional_query</h2>\n";
8989 }
9090 if ( !$raw ) {
91 - $action = htmlspecialchars(SpecialPage::getTitleFor("RunQuery", $form_name)->getLocalURL());
92 - $text .=<<<END
 91+ $action = htmlspecialchars( SpecialPage::getTitleFor( "RunQuery", $form_name )->getLocalURL() );
 92+ $text .= <<<END
9393 <form name="createbox" onsubmit="return validate_all()" action="$action" method="post" class="createbox">
9494 <input type="hidden" name="query" value="true" />
9595
@@ -96,14 +96,14 @@
9797 $text .= $form_text;
9898 }
9999 }
100 - SFUtils::addJavascriptAndCSS($embedded?$wgParser:null);
 100+ SFUtils::addJavascriptAndCSS( $embedded ? $wgParser:null );
101101 $script = ' <script type="text/javascript">' . "\n" . $javascript_text . '</script>' . "\n";
102102 if ( $embedded )
103 - $wgParser->getOutput()->addHeadItem($script);
 103+ $wgParser->getOutput()->addHeadItem( $script );
104104 else
105 - $wgOut->addScript($script);
 105+ $wgOut->addScript( $script );
106106 if ( $embedded )
107107 $text = "<div class='runQueryEmbedded'>$text</div>";
108 - $wgOut->addHTML($text);
 108+ $wgOut->addHTML( $text );
109109 }
110110 }
Index: trunk/extensions/SemanticForms/specials/SF_UploadWindow.php
@@ -14,7 +14,7 @@
1515 *
1616 * @author Yaron Koren
1717 */
18 -if (!defined('MEDIAWIKI')) die();
 18+if ( !defined( 'MEDIAWIKI' ) ) die();
1919
2020 class SFUploadWindow extends UnlistedSpecialPage {
2121
@@ -22,11 +22,11 @@
2323 * Constructor
2424 */
2525 function SFUploadWindow() {
26 - SpecialPage::SpecialPage('UploadWindow');
27 - wfLoadExtensionMessages('SemanticForms');
 26+ SpecialPage::SpecialPage( 'UploadWindow' );
 27+ wfLoadExtensionMessages( 'SemanticForms' );
2828 }
2929
30 - function execute($query) {
 30+ function execute( $query ) {
3131 $this->setHeaders();
3232 doSpecialUploadWindow();
3333 }
@@ -48,9 +48,9 @@
4949 $form = new UploadWindowForm( $wgRequest );
5050 $form->execute();
5151 $sk = $wgUser->getSkin();
52 - $sk->initPage($wgOut); // need to call this to set skin name correctly
 52+ $sk->initPage( $wgOut ); // need to call this to set skin name correctly
5353 // call to get user JS was changed in MW 1.14
54 - if (method_exists($sk, 'generateUserJs')) {
 54+ if ( method_exists( $sk, 'generateUserJs' ) ) {
5555 $skin_user_js = $sk->generateUserJs();
5656 } else {
5757 $skin_user_js = $sk->getUserJs();
@@ -61,7 +61,7 @@
6262 $alp = wfBoolToStr( $useAjaxLicensePreview );
6363 $autofill = wfBoolToStr( true );
6464
65 - $user_js =<<<END
 65+ $user_js = <<<END
6666 <script type="{$wgJsMimeType}">
6767 $skin_user_js;
6868 wgServer="{$wgServer}";
@@ -72,7 +72,7 @@
7373 </script>
7474
7575 END;
76 - $vars_js = Skin::makeGlobalVariablesScript(array('skinname' => $sk->getSkinName()));
 76+ $vars_js = Skin::makeGlobalVariablesScript( array( 'skinname' => $sk->getSkinName() ) );
7777 $wikibits_include = "<script type=\"{$wgJsMimeType}\" src=\"{$wgStylePath}/common/wikibits.js?$wgStyleVersion\"></script>";
7878 $ajax_include = "<script type=\"{$wgJsMimeType}\" src=\"{$wgStylePath}/common/ajax.js?$wgStyleVersion\"></script>";
7979 $ajaxwatch_include = "<script type=\"{$wgJsMimeType}\" src=\"{$wgStylePath}/common/ajaxwatch.js?$wgStyleVersion\"></script>";
@@ -80,7 +80,7 @@
8181 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
8282 <html xmlns="{$wgXhtmlDefaultNamespace}"
8383 END;
84 - foreach($wgXhtmlNamespaces as $tag => $ns) {
 84+ foreach ( $wgXhtmlNamespaces as $tag => $ns ) {
8585 $text .= "xmlns:{$tag}=\"{$ns}\" ";
8686 }
8787 $dir = $wgContLang->isRTL() ? "rtl" : "ltr";
@@ -146,7 +146,7 @@
147147 $this->mInputID = $request->getText( 'sfInputID' );
148148 $this->mDelimiter = $request->getText( 'sfDelimiter' );
149149
150 - if( !$request->wasPosted() ) {
 150+ if ( !$request->wasPosted() ) {
151151 # GET requests just give the main form; no data except destination
152152 # filename and description
153153 return;
@@ -169,8 +169,8 @@
170170 $this->mAction = $request->getVal( 'action' );
171171
172172 $this->mSessionKey = $request->getInt( 'wpSessionKey' );
173 - if( !empty( $this->mSessionKey ) &&
174 - isset( $_SESSION['wsUploadData'][$this->mSessionKey]['version'] ) &&
 173+ if ( !empty( $this->mSessionKey ) &&
 174+ isset( $_SESSION['wsUploadData'][$this->mSessionKey]['version'] ) &&
175175 $_SESSION['wsUploadData'][$this->mSessionKey]['version'] == self::SESSION_VERSION ) {
176176 /**
177177 * Confirming a temporarily stashed upload.
@@ -190,7 +190,7 @@
191191 /**
192192 *Check for a newly uploaded file.
193193 */
194 - if( $wgAllowCopyUploads && $this->mSourceType == 'web' ) {
 194+ if ( $wgAllowCopyUploads && $this->mSourceType == 'web' ) {
195195 $this->initializeFromUrl( $request );
196196 } else {
197197 $this->initializeFromUpload( $request );
@@ -241,14 +241,14 @@
242242 private function curlCopy( $url, $dest ) {
243243 global $wgUser, $wgOut;
244244
245 - if( !$wgUser->isAllowed( 'upload_by_url' ) ) {
 245+ if ( !$wgUser->isAllowed( 'upload_by_url' ) ) {
246246 $wgOut->permissionRequired( 'upload_by_url' );
247247 return true;
248248 }
249249
250250 # Maybe remove some pasting blanks :-)
251251 $url = trim( $url );
252 - if( stripos($url, 'http://') !== 0 && stripos($url, 'ftp://') !== 0 ) {
 252+ if ( stripos( $url, 'http://' ) !== 0 && stripos( $url, 'ftp://' ) !== 0 ) {
253253 # Only HTTP or FTP URLs
254254 $wgOut->errorPage( 'upload-proto-error', 'upload-proto-error-text' );
255255 return true;
@@ -256,17 +256,17 @@
257257
258258 # Open temporary file
259259 $this->mCurlDestHandle = @fopen( $this->mTempPath, "wb" );
260 - if( $this->mCurlDestHandle === false ) {
 260+ if ( $this->mCurlDestHandle === false ) {
261261 # Could not open temporary file to write in
262 - $wgOut->errorPage( 'upload-file-error', 'upload-file-error-text');
 262+ $wgOut->errorPage( 'upload-file-error', 'upload-file-error-text' );
263263 return true;
264264 }
265265
266266 $ch = curl_init();
267 - curl_setopt( $ch, CURLOPT_HTTP_VERSION, 1.0); # Probably not needed, but apparently can work around some bug
268 - curl_setopt( $ch, CURLOPT_TIMEOUT, 10); # 10 seconds timeout
269 - curl_setopt( $ch, CURLOPT_LOW_SPEED_LIMIT, 512); # 0.5KB per second minimum transfer speed
270 - curl_setopt( $ch, CURLOPT_URL, $url);
 267+ curl_setopt( $ch, CURLOPT_HTTP_VERSION, 1.0 ); # Probably not needed, but apparently can work around some bug
 268+ curl_setopt( $ch, CURLOPT_TIMEOUT, 10 ); # 10 seconds timeout
 269+ curl_setopt( $ch, CURLOPT_LOW_SPEED_LIMIT, 512 ); # 0.5KB per second minimum transfer speed
 270+ curl_setopt( $ch, CURLOPT_URL, $url );
271271 curl_setopt( $ch, CURLOPT_WRITEFUNCTION, array( $this, 'uploadCurlCallback' ) );
272272 curl_exec( $ch );
273273 $error = curl_errno( $ch ) ? true : false;
@@ -276,9 +276,9 @@
277277
278278 fclose( $this->mCurlDestHandle );
279279 unset( $this->mCurlDestHandle );
280 - if( $error ) {
 280+ if ( $error ) {
281281 unlink( $dest );
282 - if( wfEmptyMsg( "upload-curl-error$errornum", wfMsg("upload-curl-error$errornum") ) )
 282+ if ( wfEmptyMsg( "upload-curl-error$errornum", wfMsg( "upload-curl-error$errornum" ) ) )
283283 $wgOut->errorPage( 'upload-misc-error', 'upload-misc-error-text' );
284284 else
285285 $wgOut->errorPage( "upload-curl-error$errornum", "upload-curl-error$errornum-text" );
@@ -297,7 +297,7 @@
298298 global $wgMaxUploadSize;
299299 $length = strlen( $data );
300300 $this->mFileSize += $length;
301 - if( $this->mFileSize > $wgMaxUploadSize ) {
 301+ if ( $this->mFileSize > $wgMaxUploadSize ) {
302302 return 0;
303303 }
304304 fwrite( $this->mCurlDestHandle, $data );
@@ -313,14 +313,14 @@
314314 global $wgEnableUploads;
315315
316316 # Check uploading enabled
317 - if( !$wgEnableUploads ) {
 317+ if ( !$wgEnableUploads ) {
318318 $wgOut->showErrorPage( 'uploaddisabled', 'uploaddisabledtext', array( $this->mDesiredDestName ) );
319319 return;
320320 }
321321
322322 # Check permissions
323 - if( !$wgUser->isAllowed( 'upload' ) ) {
324 - if( !$wgUser->isLoggedIn() ) {
 323+ if ( !$wgUser->isAllowed( 'upload' ) ) {
 324+ if ( !$wgUser->isLoggedIn() ) {
325325 $wgOut->showErrorPage( 'uploadnologin', 'uploadnologintext' );
326326 } else {
327327 $wgOut->permissionRequired( 'upload' );
@@ -329,22 +329,22 @@
330330 }
331331
332332 # Check blocks
333 - if( $wgUser->isBlocked() ) {
 333+ if ( $wgUser->isBlocked() ) {
334334 $wgOut->blockedPage();
335335 return;
336336 }
337337
338 - if( wfReadOnly() ) {
 338+ if ( wfReadOnly() ) {
339339 $wgOut->readOnlyPage();
340340 return;
341341 }
342342
343 - if( $this->mReUpload ) {
344 - if( !$this->unsaveUploadedFile() ) {
 343+ if ( $this->mReUpload ) {
 344+ if ( !$this->unsaveUploadedFile() ) {
345345 return;
346346 }
347347 $this->mainUploadWindowForm();
348 - } else if( 'submit' == $this->mAction || $this->mUploadClicked ) {
 348+ } else if ( 'submit' == $this->mAction || $this->mUploadClicked ) {
349349 $this->processUpload();
350350 } else {
351351 $this->mainUploadWindowForm();
@@ -363,14 +363,14 @@
364364 function processUpload() {
365365 global $wgUser, $wgOut;
366366
367 - if( !wfRunHooks( 'UploadForm:BeforeProcessing', array( &$this ) ) )
 367+ if ( !wfRunHooks( 'UploadForm:BeforeProcessing', array( &$this ) ) )
368368 {
369369 wfDebug( "Hook 'UploadForm:BeforeProcessing' broke processing the file." );
370370 return false;
371371 }
372372
373373 /* Check for PHP error if any, requires php 4.2 or newer */
374 - if( $this->mCurlError == 1/*UPLOAD_ERR_INI_SIZE*/ ) {
 374+ if ( $this->mCurlError == 1/*UPLOAD_ERR_INI_SIZE*/ ) {
375375 $this->mainUploadWindowForm( wfMsgHtml( 'largefileserver' ) );
376376 return;
377377 }
@@ -378,13 +378,13 @@
379379 /**
380380 * If there was no filename or a zero size given, give up quick.
381381 */
382 - if( trim( $this->mSrcName ) == '' || empty( $this->mFileSize ) ) {
 382+ if ( trim( $this->mSrcName ) == '' || empty( $this->mFileSize ) ) {
383383 $this->mainUploadWindowForm( wfMsgHtml( 'emptyfile' ) );
384384 return;
385385 }
386386
387387 # Chop off any directories in the given filename
388 - if( $this->mDesiredDestName ) {
 388+ if ( $this->mDesiredDestName ) {
389389 $basename = $this->mDesiredDestName;
390390 } else {
391391 $basename = $this->mSrcName;
@@ -397,7 +397,7 @@
398398 */
399399 list( $partname, $ext ) = $this->splitExtensions( $filtered );
400400
401 - if( count( $ext ) ) {
 401+ if ( count( $ext ) ) {
402402 $finalExt = $ext[count( $ext ) - 1];
403403 } else {
404404 $finalExt = '';
@@ -405,12 +405,12 @@
406406
407407 # If there was more than one "extension", reassemble the base
408408 # filename to prevent bogus complaints about length
409 - if( count( $ext ) > 1 ) {
410 - for( $i = 0; $i < count( $ext ) - 1; $i++ )
 409+ if ( count( $ext ) > 1 ) {
 410+ for ( $i = 0; $i < count( $ext ) - 1; $i++ )
411411 $partname .= '.' . $ext[$i];
412412 }
413413
414 - if( strlen( $partname ) < 1 ) {
 414+ if ( strlen( $partname ) < 1 ) {
415415 $this->mainUploadWindowForm( wfMsgHtml( 'minlength1' ) );
416416 return;
417417 }
@@ -421,7 +421,7 @@
422422 */
423423 $filtered = wfStripIllegalFilenameChars ( $filtered );
424424 $nt = Title::makeTitleSafe( NS_IMAGE, $filtered );
425 - if( is_null( $nt ) ) {
 425+ if ( is_null( $nt ) ) {
426426 $this->uploadError( wfMsgWikiHtml( 'illegalfilename', htmlspecialchars( $filtered ) ) );
427427 return;
428428 }
@@ -432,7 +432,7 @@
433433 * If the image is protected, non-sysop users won't be able
434434 * to modify it by uploading a new revision.
435435 */
436 - if( !$nt->userCan( 'edit' ) ) {
 436+ if ( !$nt->userCan( 'edit' ) ) {
437437 return $this->uploadError( wfMsgWikiHtml( 'protectedpage' ) );
438438 }
439439
@@ -440,18 +440,18 @@
441441 * In some cases we may forbid overwriting of existing files.
442442 */
443443 $overwrite = $this->checkOverwrite( $this->mDestName );
444 - if( WikiError::isError( $overwrite ) ) {
 444+ if ( WikiError::isError( $overwrite ) ) {
445445 return $this->uploadError( $overwrite->toString() );
446446 }
447447
448448 /* Don't allow users to override the blacklist (check file extension) */
449449 global $wgStrictFileExtensions;
450450 global $wgFileExtensions, $wgFileBlacklist;
451 - if ($finalExt == '') {
 451+ if ( $finalExt == '' ) {
452452 return $this->uploadError( wfMsgExt( 'filetype-missing', array ( 'parseinline' ) ) );
453453 } elseif ( $this->checkFileExtensionList( $ext, $wgFileBlacklist ) ||
454 - ($wgStrictFileExtensions && !$this->checkFileExtension( $finalExt, $wgFileExtensions ) ) ) {
455 - return $this->uploadError( wfMsgExt( 'filetype-badtype', array ( 'parseinline' ),
 454+ ( $wgStrictFileExtensions && !$this->checkFileExtension( $finalExt, $wgFileExtensions ) ) ) {
 455+ return $this->uploadError( wfMsgExt( 'filetype-badtype', array ( 'parseinline' ),
456456 htmlspecialchars( $finalExt ), implode ( ', ', $wgFileExtensions ) ) );
457457 }
458458
@@ -460,12 +460,12 @@
461461 * type but it's corrupt or data of the wrong type, we should
462462 * probably not accept it.
463463 */
464 - if( !$this->mStashed ) {
 464+ if ( !$this->mStashed ) {
465465 $this->mFileProps = File::getPropsFromPath( $this->mTempPath, $finalExt );
466466 $this->checkMacBinary();
467467 $veri = $this->verify( $this->mTempPath, $finalExt );
468468
469 - if( $veri !== true ) { //it's a wiki error...
 469+ if ( $veri !== true ) { // it's a wiki error...
470470 return $this->uploadError( $veri->toString() );
471471 }
472472
@@ -473,7 +473,7 @@
474474 * Provide an opportunity for extensions to add further checks
475475 */
476476 $error = '';
477 - if( !wfRunHooks( 'UploadVerification',
 477+ if ( !wfRunHooks( 'UploadVerification',
478478 array( $this->mDestName, $this->mTempPath, &$error ) ) ) {
479479 return $this->uploadError( $error );
480480 }
@@ -487,18 +487,18 @@
488488 $warning = '';
489489
490490 global $wgCapitalLinks;
491 - if( $wgCapitalLinks ) {
 491+ if ( $wgCapitalLinks ) {
492492 $filtered = ucfirst( $filtered );
493493 }
494 - if( $basename != $filtered ) {
495 - $warning .= '<li>'.wfMsgHtml( 'badfilename', htmlspecialchars( $this->mDestName ) ).'</li>';
 494+ if ( $basename != $filtered ) {
 495+ $warning .= '<li>' . wfMsgHtml( 'badfilename', htmlspecialchars( $this->mDestName ) ) . '</li>';
496496 }
497497
498498 global $wgCheckFileExtensions;
499499 if ( $wgCheckFileExtensions ) {
500500 if ( ! $this->checkFileExtension( $finalExt, $wgFileExtensions ) ) {
501 - $warning .= '<li>'.wfMsgExt( 'filetype-badtype', array ( 'parseinline' ),
502 - htmlspecialchars( $finalExt ), implode ( ', ', $wgFileExtensions ) ).'</li>';
 501+ $warning .= '<li>' . wfMsgExt( 'filetype-badtype', array ( 'parseinline' ),
 502+ htmlspecialchars( $finalExt ), implode ( ', ', $wgFileExtensions ) ) . '</li>';
503503 }
504504 }
505505
@@ -510,13 +510,13 @@
511511 $warning .= '<li>' . wfMsgHtml( 'large-file', $wsize, $asize ) . '</li>';
512512 }
513513 if ( $this->mFileSize == 0 ) {
514 - $warning .= '<li>'.wfMsgHtml( 'emptyfile' ).'</li>';
 514+ $warning .= '<li>' . wfMsgHtml( 'emptyfile' ) . '</li>';
515515 }
516516
517517 if ( !$this->mDestWarningAck ) {
518518 $warning .= self::getExistsWarning( $this->mLocalFile );
519519 }
520 - if( $warning != '' ) {
 520+ if ( $warning != '' ) {
521521 /**
522522 * Stash the file in a temporary location; the user can choose
523523 * to let it through and we'll complete the upload then.
@@ -532,7 +532,7 @@
533533 $pageText = self::getInitialPageText( $this->mComment, $this->mLicense,
534534 $this->mCopyrightStatus, $this->mCopyrightSource );
535535
536 - $status = $this->mLocalFile->upload( $this->mTempPath, $this->mComment, $pageText,
 536+ $status = $this->mLocalFile->upload( $this->mTempPath, $this->mComment, $pageText,
537537 File::DELETE_SOURCE, $this->mFileProps );
538538 if ( !$status->isGood() ) {
539539 $this->showError( $status->getWikiText() );
@@ -543,20 +543,20 @@
544544
545545 }
546546 // Success, redirect to description page
547 - //$wgOut->redirect( $this->mLocalFile->getTitle()->getFullURL() );
 547+ // $wgOut->redirect( $this->mLocalFile->getTitle()->getFullURL() );
548548
549549 // Semantic Forms change - output Javascript to either
550550 // fill in or append to the field in original form, and
551551 // close the window
552 - $basename = str_replace('_', ' ', $basename);
 552+ $basename = str_replace( '_', ' ', $basename );
553553 $output = ' <script type="text/javascript">' . "\n";
554 - if ($this->mDelimiter == null) {
555 - $output .=<<<END
 554+ if ( $this->mDelimiter == null ) {
 555+ $output .= <<<END
556556 parent.document.getElementById("{$this->mInputID}").value = "$basename";
557557
558558 END;
559559 } else {
560 - $output .=<<<END
 560+ $output .= <<<END
561561 // if the current value is blank, set it to this file name;
562562 // if it's not blank and ends in a space or delimiter, append
563563 // the file name; if it ends with a normal character, append
@@ -576,7 +576,7 @@
577577
578578 END;
579579 }
580 - $output .=<<<END
 580+ $output .= <<<END
581581 parent.fb.end();
582582 </script>
583583
@@ -599,7 +599,7 @@
600600 // with lowercase extension exists already
601601 $warning = '';
602602
603 - if( strpos( $file->getName(), '.' ) == false ) {
 603+ if ( strpos( $file->getName(), '.' ) == false ) {
604604 $partname = $file->getName();
605605 $rawExtension = '';
606606 } else {
@@ -619,14 +619,14 @@
620620 $file_lc = false;
621621 }
622622
623 - if( $file->exists() ) {
 623+ if ( $file->exists() ) {
624624 $dlink = $sk->makeKnownLinkObj( $file->getTitle() );
625625 if ( $file->allowInlineDisplay() ) {
626 - $dlink2 = $sk->makeImageLinkObj( $file->getTitle(), wfMsgExt( 'fileexists-thumb', 'parseinline', $dlink ),
 626+ $dlink2 = $sk->makeImageLinkObj( $file->getTitle(), wfMsgExt( 'fileexists-thumb', 'parseinline', $dlink ),
627627 $file->getName(), 'right', array(), false, true );
628628 } elseif ( !$file->allowInlineDisplay() && $file->isSafeFile() ) {
629629 $icon = $file->iconThumb();
630 - $dlink2 = '<div style="float:right" id="mw-media-icon">' .
 630+ $dlink2 = '<div style="float:right" id="mw-media-icon">' .
631631 $icon->toHtml( array( 'desc-link' => true ) ) . '<br />' . $dlink . '</div>';
632632 } else {
633633 $dlink2 = '';
@@ -639,53 +639,53 @@
640640 # It's not forbidden but in 99% it makes no sense to upload the same filename with uppercase extension
641641 $dlink = $sk->makeKnownLinkObj( $nt_lc );
642642 if ( $file_lc->allowInlineDisplay() ) {
643 - $dlink2 = $sk->makeImageLinkObj( $nt_lc, wfMsgExt( 'fileexists-thumb', 'parseinline', $dlink ),
 643+ $dlink2 = $sk->makeImageLinkObj( $nt_lc, wfMsgExt( 'fileexists-thumb', 'parseinline', $dlink ),
644644 $nt_lc->getText(), 'right', array(), false, true );
645645 } elseif ( !$file_lc->allowInlineDisplay() && $file_lc->isSafeFile() ) {
646646 $icon = $file_lc->iconThumb();
647 - $dlink2 = '<div style="float:right" id="mw-media-icon">' .
 647+ $dlink2 = '<div style="float:right" id="mw-media-icon">' .
648648 $icon->toHtml( array( 'desc-link' => true ) ) . '<br />' . $dlink . '</div>';
649649 } else {
650650 $dlink2 = '';
651651 }
652652
653 - $warning .= '<li>' . wfMsgExt( 'fileexists-extension', 'parsemag', $file->getName(), $dlink ) . '</li>' . $dlink2;
 653+ $warning .= '<li>' . wfMsgExt( 'fileexists-extension', 'parsemag', $file->getName(), $dlink ) . '</li>' . $dlink2;
654654
655 - } elseif ( ( substr( $partname , 3, 3 ) == 'px-' || substr( $partname , 2, 3 ) == 'px-' )
656 - && ereg( "[0-9]{2}" , substr( $partname , 0, 2) ) )
 655+ } elseif ( ( substr( $partname , 3, 3 ) == 'px-' || substr( $partname , 2, 3 ) == 'px-' )
 656+ && ereg( "[0-9]{2}" , substr( $partname , 0, 2 ) ) )
657657 {
658658 # Check for filenames like 50px- or 180px-, these are mostly thumbnails
659 - $nt_thb = Title::newFromText( substr( $partname , strpos( $partname , '-' ) +1 ) . '.' . $rawExtension );
 659+ $nt_thb = Title::newFromText( substr( $partname , strpos( $partname , '-' ) + 1 ) . '.' . $rawExtension );
660660 $file_thb = wfLocalFile( $nt_thb );
661 - if ($file_thb->exists() ) {
 661+ if ( $file_thb->exists() ) {
662662 # Check if an image without leading '180px-' (or similiar) exists
663 - $dlink = $sk->makeKnownLinkObj( $nt_thb);
 663+ $dlink = $sk->makeKnownLinkObj( $nt_thb );
664664 if ( $file_thb->allowInlineDisplay() ) {
665 - $dlink2 = $sk->makeImageLinkObj( $nt_thb,
666 - wfMsgExt( 'fileexists-thumb', 'parseinline', $dlink ),
 665+ $dlink2 = $sk->makeImageLinkObj( $nt_thb,
 666+ wfMsgExt( 'fileexists-thumb', 'parseinline', $dlink ),
667667 $nt_thb->getText(), 'right', array(), false, true );
668668 } elseif ( !$file_thb->allowInlineDisplay() && $file_thb->isSafeFile() ) {
669669 $icon = $file_thb->iconThumb();
670 - $dlink2 = '<div style="float:right" id="mw-media-icon">' .
671 - $icon->toHtml( array( 'desc-link' => true ) ) . '<br />' .
 670+ $dlink2 = '<div style="float:right" id="mw-media-icon">' .
 671+ $icon->toHtml( array( 'desc-link' => true ) ) . '<br />' .
672672 $dlink . '</div>';
673673 } else {
674674 $dlink2 = '';
675675 }
676676
677 - $warning .= '<li>' . wfMsgExt( 'fileexists-thumbnail-yes', 'parsemag', $dlink ) .
678 - '</li>' . $dlink2;
 677+ $warning .= '<li>' . wfMsgExt( 'fileexists-thumbnail-yes', 'parsemag', $dlink ) .
 678+ '</li>' . $dlink2;
679679 } else {
680680 # Image w/o '180px-' does not exists, but we do not like these filenames
681 - $warning .= '<li>' . wfMsgExt( 'file-thumbnail-no', 'parseinline' ,
682 - substr( $partname , 0, strpos( $partname , '-' ) +1 ) ) . '</li>';
 681+ $warning .= '<li>' . wfMsgExt( 'file-thumbnail-no', 'parseinline' ,
 682+ substr( $partname , 0, strpos( $partname , '-' ) + 1 ) ) . '</li>';
683683 }
684684 }
685685 if ( $file->wasDeleted() ) {
686686 # If the file existed before and was deleted, warn the user of this
687687 # Don't bother doing so if the image exists now, however
688688 $ltitle = SpecialPage::getTitleFor( 'Log' );
689 - $llink = $sk->makeKnownLinkObj( $ltitle, wfMsgHtml( 'sf_deletionlog' ),
 689+ $llink = $sk->makeKnownLinkObj( $ltitle, wfMsgHtml( 'sf_deletionlog' ),
690690 'type=delete&page=' . $file->getTitle()->getPrefixedUrl() );
691691 $warning .= '<li>' . wfMsgWikiHtml( 'filewasdeleted', $llink ) . '</li>';
692692 }
@@ -694,7 +694,7 @@
695695
696696 static function ajaxGetExistsWarning( $filename ) {
697697 $file = wfFindFile( $filename );
698 - if( !$file ) {
 698+ if ( !$file ) {
699699 // Force local file so we have an object to do further checks against
700700 // if there isn't an exact match...
701701 $file = wfLocalFile( $filename );
@@ -764,7 +764,7 @@
765765 function stashSession() {
766766 $stash = $this->saveTempUploadedFile( $this->mDestName, $this->mTempPath );
767767
768 - if( !$stash ) {
 768+ if ( !$stash ) {
769769 # Couldn't save the file.
770770 return false;
771771 }
@@ -822,7 +822,7 @@
823823 global $wgUseCopyrightUpload;
824824
825825 $this->mSessionKey = $this->stashSession();
826 - if( !$this->mSessionKey ) {
 826+ if ( !$this->mSessionKey ) {
827827 # Couldn't save file; an error has been displayed so let's go.
828828 return;
829829 }
@@ -885,7 +885,7 @@
886886 * @param string $msg as HTML
887887 * @access private
888888 */
889 - function mainUploadWindowForm( $msg='' ) {
 889+ function mainUploadWindowForm( $msg = '' ) {
890890 global $wgOut, $wgUser, $wgContLang;
891891 global $wgUseCopyrightUpload, $wgUseAjax, $wgAjaxUploadDestCheck, $wgAjaxLicensePreview;
892892 global $wgRequest, $wgAllowCopyUploads;
@@ -904,15 +904,15 @@
905905 <script type=\"text/javascript\" src=\"{$wgStylePath}/common/upload.js?{$wgStyleVersion}\"></script>
906906 " );
907907
908 - if( !wfRunHooks( 'UploadForm:initial', array( &$this ) ) )
 908+ if ( !wfRunHooks( 'UploadForm:initial', array( &$this ) ) )
909909 {
910910 wfDebug( "Hook 'UploadForm:initial' broke output of the upload form" );
911911 return false;
912912 }
913913
914 - if( $this->mDesiredDestName && $wgUser->isAllowed( 'deletedhistory' ) ) {
 914+ if ( $this->mDesiredDestName && $wgUser->isAllowed( 'deletedhistory' ) ) {
915915 $title = Title::makeTitleSafe( NS_IMAGE, $this->mDesiredDestName );
916 - if( $title instanceof Title && ( $count = $title->isDeleted() ) > 0 ) {
 916+ if ( $title instanceof Title && ( $count = $title->isDeleted() ) > 0 ) {
917917 $link = wfMsgExt(
918918 $wgUser->isAllowed( 'delete' ) ? 'thisisdeleted' : 'viewdeleted',
919919 array( 'parse', 'replaceafter' ),
@@ -922,11 +922,11 @@
923923 )
924924 );
925925 $wgOut->addHTML( "<div id=\"contentSub2\">{$link}</div>" );
926 - }
 926+ }
927927 }
928928
929929 // ignore user's settings to get a smaller form
930 - $cols = 45; //intval($wgUser->getOption( 'cols' ));
 930+ $cols = 45; // intval($wgUser->getOption( 'cols' ));
931931 $ew = $wgUser->getOption( 'editwidth' );
932932 if ( $ew ) $ew = " style=\"width:100%\"";
933933 else $ew = '';
@@ -938,9 +938,9 @@
939939 }
940940 // the 'uploadtext' message is not displayed in this window,
941941 // because most of it is irrelevant to a form-based upload
942 - //$wgOut->addHTML( '<div id="uploadtext">' );
943 - //$wgOut->addWikiText( wfMsgNoTrans( 'uploadtext', $this->mDesiredDestName ) );
944 - //$wgOut->addHTML( '</div>' );
 942+ // $wgOut->addHTML( '<div id="uploadtext">' );
 943+ // $wgOut->addWikiText( wfMsgNoTrans( 'uploadtext', $this->mDesiredDestName ) );
 944+ // $wgOut->addHTML( '</div>' );
945945
946946 $sourcefilename = wfMsgHtml( 'sourcefilename' );
947947 $destfilename = wfMsgHtml( 'destfilename' );
@@ -976,15 +976,15 @@
977977 $warningChecked = $this->mIgnoreWarning ? 'checked' : '';
978978
979979 // Prepare form for upload or upload/copy
980 - if( $wgAllowCopyUploads && $wgUser->isAllowed( 'upload_by_url' ) ) {
 980+ if ( $wgAllowCopyUploads && $wgUser->isAllowed( 'upload_by_url' ) ) {
981981 $filename_form =
982982 "<input type='radio' id='wpSourceTypeFile' name='wpSourceType' value='file' " .
983983 "onchange='toggle_element_activation(\"wpUploadFileURL\",\"wpUploadFile\")' checked />" .
984984 "<input tabindex='1' type='file' name='wpUploadFile' id='wpUploadFile' " .
985 - "onfocus='" .
 985+ "onfocus='" .
986986 "toggle_element_activation(\"wpUploadFileURL\",\"wpUploadFile\");" .
987987 "toggle_element_check(\"wpSourceTypeFile\",\"wpSourceTypeURL\")'" .
988 - ($this->mDesiredDestName?"":"onchange='fillDestFilename(\"wpUploadFile\")' ") . "size='40' />" .
 988+ ( $this->mDesiredDestName ? "":"onchange='fillDestFilename(\"wpUploadFile\")' " ) . "size='40' />" .
989989 wfMsgHTML( 'upload_source_file' ) . "<br />" .
990990 "<input type='radio' id='wpSourceTypeURL' name='wpSourceType' value='web' " .
991991 "onchange='toggle_element_activation(\"wpUploadFile\",\"wpUploadFileURL\")' />" .
@@ -992,12 +992,12 @@
993993 "onfocus='" .
994994 "toggle_element_activation(\"wpUploadFile\",\"wpUploadFileURL\");" .
995995 "toggle_element_check(\"wpSourceTypeURL\",\"wpSourceTypeFile\")'" .
996 - ($this->mDesiredDestName?"":"onchange='fillDestFilename(\"wpUploadFileURL\")' ") . "size='40' DISABLED />" .
 996+ ( $this->mDesiredDestName ? "":"onchange='fillDestFilename(\"wpUploadFileURL\")' " ) . "size='40' DISABLED />" .
997997 wfMsgHtml( 'upload_source_url' ) ;
998998 } else {
999999 $filename_form =
10001000 "<input tabindex='1' type='file' name='wpUploadFile' id='wpUploadFile' " .
1001 - ($this->mDesiredDestName?"":"onchange='fillDestFilename(\"wpUploadFile\")' ") .
 1001+ ( $this->mDesiredDestName ? "":"onchange='fillDestFilename(\"wpUploadFile\")' " ) .
10021002 "size='40' />" .
10031003 "<input type='hidden' name='wpSourceType' value='file' />" ;
10041004 }
@@ -1055,7 +1055,7 @@
10561056 </td>
10571057 </tr>
10581058 <tr>" );
1059 - if( $useAjaxLicensePreview ) {
 1059+ if ( $useAjaxLicensePreview ) {
10601060 $wgOut->addHTML( "
10611061 <td></td>
10621062 <td id=\"mw-license-preview\"></td>
@@ -1081,7 +1081,7 @@
10821082 value=\"$uploadsource\" size='40' /></td>
10831083 </tr>
10841084 <tr>
1085 - ");
 1085+ " );
10861086 }
10871087
10881088 $wgOut->addHTML( "
@@ -1151,8 +1151,8 @@
11521152 * @return bool
11531153 */
11541154 function checkFileExtensionList( $ext, $list ) {
1155 - foreach( $ext as $e ) {
1156 - if( in_array( strtolower( $e ), $list ) ) {
 1155+ foreach ( $ext as $e ) {
 1156+ if ( in_array( strtolower( $e ), $list ) ) {
11571157 return true;
11581158 }
11591159 }
@@ -1167,42 +1167,42 @@
11681168 * @return mixed true of the file is verified, a WikiError object otherwise.
11691169 */
11701170 function verify( $tmpfile, $extension ) {
1171 - #magically determine mime type
1172 - $magic=& MimeMagic::singleton();
1173 - $mime= $magic->guessMimeType($tmpfile,false);
 1171+ # magically determine mime type
 1172+ $magic =& MimeMagic::singleton();
 1173+ $mime = $magic->guessMimeType( $tmpfile, false );
11741174
1175 - #check mime type, if desired
 1175+ # check mime type, if desired
11761176 global $wgVerifyMimeType;
1177 - if ($wgVerifyMimeType) {
 1177+ if ( $wgVerifyMimeType ) {
11781178
1179 - wfDebug ( "\n\nmime: <$mime> extension: <$extension>\n\n");
1180 - #check mime type against file extension
1181 - if( !$this->verifyExtension( $mime, $extension ) ) {
 1179+ wfDebug ( "\n\nmime: <$mime> extension: <$extension>\n\n" );
 1180+ # check mime type against file extension
 1181+ if ( !$this->verifyExtension( $mime, $extension ) ) {
11821182 return new WikiErrorMsg( 'uploadcorrupt' );
11831183 }
11841184
1185 - #check mime type blacklist
 1185+ # check mime type blacklist
11861186 global $wgMimeTypeBlacklist;
1187 - if( isset($wgMimeTypeBlacklist) && !is_null($wgMimeTypeBlacklist)
 1187+ if ( isset( $wgMimeTypeBlacklist ) && !is_null( $wgMimeTypeBlacklist )
11881188 && $this->checkFileExtension( $mime, $wgMimeTypeBlacklist ) ) {
11891189 return new WikiErrorMsg( 'filetype-badmime', htmlspecialchars( $mime ) );
11901190 }
11911191 }
11921192
1193 - #check for htmlish code and javascript
1194 - if( $this->detectScript ( $tmpfile, $mime, $extension ) ) {
 1193+ # check for htmlish code and javascript
 1194+ if ( $this->detectScript ( $tmpfile, $mime, $extension ) ) {
11951195 return new WikiErrorMsg( 'uploadscripted' );
11961196 }
11971197
11981198 /**
11991199 * Scan the uploaded file for viruses
12001200 */
1201 - $virus= $this->detectVirus($tmpfile);
 1201+ $virus = $this->detectVirus( $tmpfile );
12021202 if ( $virus ) {
1203 - return new WikiErrorMsg( 'uploadvirus', htmlspecialchars($virus) );
 1203+ return new WikiErrorMsg( 'uploadvirus', htmlspecialchars( $virus ) );
12041204 }
12051205
1206 - wfDebug( __METHOD__.": all clear; passing.\n" );
 1206+ wfDebug( __METHOD__ . ": all clear; passing.\n" );
12071207 return true;
12081208 }
12091209
@@ -1218,28 +1218,28 @@
12191219
12201220 if ( ! $mime || $mime == 'unknown' || $mime == 'unknown/unknown' )
12211221 if ( ! $magic->isRecognizableExtension( $extension ) ) {
1222 - wfDebug( __METHOD__.": passing file with unknown detected mime type; " .
 1222+ wfDebug( __METHOD__ . ": passing file with unknown detected mime type; " .
12231223 "unrecognized extension '$extension', can't verify\n" );
12241224 return true;
12251225 } else {
1226 - wfDebug( __METHOD__.": rejecting file with unknown detected mime type; ".
 1226+ wfDebug( __METHOD__ . ": rejecting file with unknown detected mime type; " .
12271227 "recognized extension '$extension', so probably invalid file\n" );
12281228 return false;
12291229 }
12301230
1231 - $match= $magic->isMatchingExtension($extension,$mime);
 1231+ $match = $magic->isMatchingExtension( $extension, $mime );
12321232
1233 - if ($match===null) {
1234 - wfDebug( __METHOD__.": no file extension known for mime type $mime, passing file\n" );
 1233+ if ( $match === null ) {
 1234+ wfDebug( __METHOD__ . ": no file extension known for mime type $mime, passing file\n" );
12351235 return true;
1236 - } elseif ($match===true) {
1237 - wfDebug( __METHOD__.": mime type $mime matches extension $extension, passing file\n" );
 1236+ } elseif ( $match === true ) {
 1237+ wfDebug( __METHOD__ . ": mime type $mime matches extension $extension, passing file\n" );
12381238
1239 - #TODO: if it's a bitmap, make sure PHP or ImageMagic resp. can handle it!
 1239+ # TODO: if it's a bitmap, make sure PHP or ImageMagic resp. can handle it!
12401240 return true;
12411241
12421242 } else {
1243 - wfDebug( __METHOD__.": mime type $mime mismatches file extension $extension, rejecting file\n" );
 1243+ wfDebug( __METHOD__ . ": mime type $mime mismatches file extension $extension, rejecting file\n" );
12441244 return false;
12451245 }
12461246 }
@@ -1254,38 +1254,38 @@
12551255 * @param string $extension The extension of the file
12561256 * @return bool true if the file contains something looking like embedded scripts
12571257 */
1258 - function detectScript($file, $mime, $extension) {
 1258+ function detectScript( $file, $mime, $extension ) {
12591259 global $wgAllowTitlesInSVG;
12601260
1261 - #ugly hack: for text files, always look at the entire file.
1262 - #For binarie field, just check the first K.
 1261+ # ugly hack: for text files, always look at the entire file.
 1262+ # For binarie field, just check the first K.
12631263
1264 - if (strpos($mime,'text/')===0) $chunk = file_get_contents( $file );
 1264+ if ( strpos( $mime, 'text/' ) === 0 ) $chunk = file_get_contents( $file );
12651265 else {
12661266 $fp = fopen( $file, 'rb' );
12671267 $chunk = fread( $fp, 1024 );
12681268 fclose( $fp );
12691269 }
12701270
1271 - $chunk= strtolower( $chunk );
 1271+ $chunk = strtolower( $chunk );
12721272
1273 - if (!$chunk) return false;
 1273+ if ( !$chunk ) return false;
12741274
1275 - #decode from UTF-16 if needed (could be used for obfuscation).
1276 - if (substr($chunk,0,2)=="\xfe\xff") $enc= "UTF-16BE";
1277 - elseif (substr($chunk,0,2)=="\xff\xfe") $enc= "UTF-16LE";
1278 - else $enc= null;
 1275+ # decode from UTF-16 if needed (could be used for obfuscation).
 1276+ if ( substr( $chunk, 0, 2 ) == "\xfe\xff" ) $enc = "UTF-16BE";
 1277+ elseif ( substr( $chunk, 0, 2 ) == "\xff\xfe" ) $enc = "UTF-16LE";
 1278+ else $enc = null;
12791279
1280 - if ($enc) $chunk= iconv($enc,"ASCII//IGNORE",$chunk);
 1280+ if ( $enc ) $chunk = iconv( $enc, "ASCII//IGNORE", $chunk );
12811281
1282 - $chunk= trim($chunk);
 1282+ $chunk = trim( $chunk );
12831283
1284 - #FIXME: convert from UTF-16 if necessarry!
 1284+ # FIXME: convert from UTF-16 if necessarry!
12851285
1286 - wfDebug("SpecialUpload::detectScript: checking for embedded scripts and HTML stuff\n");
 1286+ wfDebug( "SpecialUpload::detectScript: checking for embedded scripts and HTML stuff\n" );
12871287
1288 - #check for HTML doctype
1289 - if (eregi("<!DOCTYPE *X?HTML",$chunk)) return true;
 1288+ # check for HTML doctype
 1289+ if ( eregi( "<!DOCTYPE *X?HTML", $chunk ) ) return true;
12901290
12911291 /**
12921292 * Internet Explorer for Windows performs some really stupid file type
@@ -1306,18 +1306,18 @@
13071307 $tags = array(
13081308 '<body',
13091309 '<head',
1310 - '<html', #also in safari
 1310+ '<html', # also in safari
13111311 '<img',
13121312 '<pre',
1313 - '<script', #also in safari
 1313+ '<script', # also in safari
13141314 '<table'
13151315 );
1316 - if( ! $wgAllowTitlesInSVG && $extension !== 'svg' && $mime !== 'image/svg' ) {
 1316+ if ( ! $wgAllowTitlesInSVG && $extension !== 'svg' && $mime !== 'image/svg' ) {
13171317 $tags[] = '<title';
13181318 }
13191319
1320 - foreach( $tags as $tag ) {
1321 - if( false !== strpos( $chunk, $tag ) ) {
 1320+ foreach ( $tags as $tag ) {
 1321+ if ( false !== strpos( $chunk, $tag ) ) {
13221322 return true;
13231323 }
13241324 }
@@ -1326,19 +1326,19 @@
13271327 * look for javascript
13281328 */
13291329
1330 - #resolve entity-refs to look at attributes. may be harsh on big files... cache result?
 1330+ # resolve entity-refs to look at attributes. may be harsh on big files... cache result?
13311331 $chunk = Sanitizer::decodeCharReferences( $chunk );
13321332
1333 - #look for script-types
1334 - if (preg_match('!type\s*=\s*[\'"]?\s*(?:\w*/)?(?:ecma|java)!sim',$chunk)) return true;
 1333+ # look for script-types
 1334+ if ( preg_match( '!type\s*=\s*[\'"]?\s*(?:\w*/)?(?:ecma|java)!sim', $chunk ) ) return true;
13351335
1336 - #look for html-style script-urls
1337 - if (preg_match('!(?:href|src|data)\s*=\s*[\'"]?\s*(?:ecma|java)script:!sim',$chunk)) return true;
 1336+ # look for html-style script-urls
 1337+ if ( preg_match( '!(?:href|src|data)\s*=\s*[\'"]?\s*(?:ecma|java)script:!sim', $chunk ) ) return true;
13381338
1339 - #look for css-style script-urls
1340 - if (preg_match('!url\s*\(\s*[\'"]?\s*(?:ecma|java)script:!sim',$chunk)) return true;
 1339+ # look for css-style script-urls
 1340+ if ( preg_match( '!url\s*\(\s*[\'"]?\s*(?:ecma|java)script:!sim', $chunk ) ) return true;
13411341
1342 - wfDebug("SpecialUpload::detectScript: no scripts found\n");
 1342+ wfDebug( "SpecialUpload::detectScript: no scripts found\n" );
13431343 return false;
13441344 }
13451345
@@ -1352,18 +1352,18 @@
13531353 * or a string containing feedback from the virus scanner if a virus was found.
13541354 * If textual feedback is missing but a virus was found, this function returns true.
13551355 */
1356 - function detectVirus($file) {
 1356+ function detectVirus( $file ) {
13571357 global $wgAntivirus, $wgAntivirusSetup, $wgAntivirusRequired, $wgOut;
13581358
13591359 if ( !$wgAntivirus ) {
1360 - wfDebug( __METHOD__.": virus scanner disabled\n");
 1360+ wfDebug( __METHOD__ . ": virus scanner disabled\n" );
13611361 return null;
13621362 }
13631363
13641364 if ( !$wgAntivirusSetup[$wgAntivirus] ) {
1365 - wfDebug( __METHOD__.": unknown virus scanner: $wgAntivirus\n" );
 1365+ wfDebug( __METHOD__ . ": unknown virus scanner: $wgAntivirus\n" );
13661366 # @TODO: localise
1367 - $wgOut->addHTML( "<div class='error'>Bad configuration: unknown virus scanner: <i>$wgAntivirus</i></div>\n" );
 1367+ $wgOut->addHTML( "<div class='error'>Bad configuration: unknown virus scanner: <i>$wgAntivirus</i></div>\n" );
13681368 return "unknown antivirus: $wgAntivirus";
13691369 }
13701370
@@ -1373,20 +1373,20 @@
13741374 $msgPattern = isset( $wgAntivirusSetup[$wgAntivirus]["messagepattern"] ) ?
13751375 $wgAntivirusSetup[$wgAntivirus]["messagepattern"] : null;
13761376
1377 - if ( strpos( $command,"%f" ) === false ) {
 1377+ if ( strpos( $command, "%f" ) === false ) {
13781378 # simple pattern: append file to scan
1379 - $command .= " " . wfEscapeShellArg( $file );
 1379+ $command .= " " . wfEscapeShellArg( $file );
13801380 } else {
13811381 # complex pattern: replace "%f" with file to scan
1382 - $command = str_replace( "%f", wfEscapeShellArg( $file ), $command );
 1382+ $command = str_replace( "%f", wfEscapeShellArg( $file ), $command );
13831383 }
13841384
1385 - wfDebug( __METHOD__.": running virus scan: $command \n" );
 1385+ wfDebug( __METHOD__ . ": running virus scan: $command \n" );
13861386
13871387 # execute virus scanner
13881388 $exitCode = false;
13891389
1390 - #NOTE: there's a 50 line workaround to make stderr redirection work on windows, too.
 1390+ # NOTE: there's a 50 line workaround to make stderr redirection work on windows, too.
13911391 # that does not seem to be worth the pain.
13921392 # Ask me (Duesentrieb) about it if it's ever needed.
13931393 $output = array();
@@ -1398,7 +1398,7 @@
13991399
14001400 # map exit code to AV_xxx constants.
14011401 $mappedCode = $exitCode;
1402 - if ( $exitCodeMap ) {
 1402+ if ( $exitCodeMap ) {
14031403 if ( isset( $exitCodeMap[$exitCode] ) ) {
14041404 $mappedCode = $exitCodeMap[$exitCode];
14051405 } elseif ( isset( $exitCodeMap["*"] ) ) {
@@ -1406,29 +1406,29 @@
14071407 }
14081408 }
14091409
1410 - if ( $mappedCode === AV_SCAN_FAILED ) {
 1410+ if ( $mappedCode === AV_SCAN_FAILED ) {
14111411 # scan failed (code was mapped to false by $exitCodeMap)
1412 - wfDebug( __METHOD__.": failed to scan $file (code $exitCode).\n" );
 1412+ wfDebug( __METHOD__ . ": failed to scan $file (code $exitCode).\n" );
14131413
1414 - if ( $wgAntivirusRequired ) {
1415 - return "scan failed (code $exitCode)";
1416 - } else {
1417 - return null;
 1414+ if ( $wgAntivirusRequired ) {
 1415+ return "scan failed (code $exitCode)";
 1416+ } else {
 1417+ return null;
14181418 }
1419 - } else if ( $mappedCode === AV_SCAN_ABORTED ) {
 1419+ } else if ( $mappedCode === AV_SCAN_ABORTED ) {
14201420 # scan failed because filetype is unknown (probably imune)
1421 - wfDebug( __METHOD__.": unsupported file type $file (code $exitCode).\n" );
 1421+ wfDebug( __METHOD__ . ": unsupported file type $file (code $exitCode).\n" );
14221422 return null;
14231423 } else if ( $mappedCode === AV_NO_VIRUS ) {
14241424 # no virus found
1425 - wfDebug( __METHOD__.": file passed virus scan.\n" );
 1425+ wfDebug( __METHOD__ . ": file passed virus scan.\n" );
14261426 return false;
14271427 } else {
14281428 $output = join( "\n", $output );
14291429 $output = trim( $output );
14301430
14311431 if ( !$output ) {
1432 - $output = true; #if there's no output, return true
 1432+ $output = true; # if there's no output, return true
14331433 } elseif ( $msgPattern ) {
14341434 $groups = array();
14351435 if ( preg_match( $msgPattern, $output, $groups ) ) {
@@ -1438,7 +1438,7 @@
14391439 }
14401440 }
14411441
1442 - wfDebug( __METHOD__.": FOUND VIRUS! scanner feedback: $output" );
 1442+ wfDebug( __METHOD__ . ": FOUND VIRUS! scanner feedback: $output" );
14431443 return $output;
14441444 }
14451445 }
@@ -1453,7 +1453,7 @@
14541454 */
14551455 function checkMacBinary() {
14561456 $macbin = new MacBinary( $this->mTempPath );
1457 - if( $macbin->isValid() ) {
 1457+ if ( $macbin->isValid() ) {
14581458 $dataFile = tempnam( wfTempDir(), "WikiMacBinary" );
14591459 $dataHandle = fopen( $dataFile, 'wb' );
14601460
@@ -1492,21 +1492,21 @@
14931493 $img = wfFindFile( $name );
14941494
14951495 $error = '';
1496 - if( $img ) {
 1496+ if ( $img ) {
14971497 global $wgUser, $wgOut;
1498 - if( $img->isLocal() ) {
1499 - if( !self::userCanReUpload( $wgUser, $img->name ) ) {
 1498+ if ( $img->isLocal() ) {
 1499+ if ( !self::userCanReUpload( $wgUser, $img->name ) ) {
15001500 $error = 'fileexists-forbidden';
15011501 }
15021502 } else {
1503 - if( !$wgUser->isAllowed( 'reupload' ) ||
 1503+ if ( !$wgUser->isAllowed( 'reupload' ) ||
15041504 !$wgUser->isAllowed( 'reupload-shared' ) ) {
15051505 $error = "fileexists-shared-forbidden";
15061506 }
15071507 }
15081508 }
15091509
1510 - if( $error ) {
 1510+ if ( $error ) {
15111511 $errorText = wfMsg( $error, wfEscapeWikiText( $img->getName() ) );
15121512 return new WikiError( $wgOut->parse( $errorText ) );
15131513 }
@@ -1523,13 +1523,13 @@
15241524 * @return bool
15251525 */
15261526 public static function userCanReUpload( User $user, $img ) {
1527 - if( $user->isAllowed( 'reupload' ) )
 1527+ if ( $user->isAllowed( 'reupload' ) )
15281528 return true; // non-conditional
1529 - if( !$user->isAllowed( 'reupload-own' ) )
 1529+ if ( !$user->isAllowed( 'reupload-own' ) )
15301530 return false;
15311531
15321532 $dbr = wfGetDB( DB_SLAVE );
1533 - $row = $dbr->selectRow('image',
 1533+ $row = $dbr->selectRow( 'image',
15341534 /* SELECT */ 'img_user',
15351535 /* WHERE */ array( 'img_name' => $img )
15361536 );
Index: trunk/extensions/SemanticForms/specials/SF_Templates.php
@@ -5,7 +5,7 @@
66 * @author Yaron Koren
77 */
88
9 -if (!defined('MEDIAWIKI')) die();
 9+if ( !defined( 'MEDIAWIKI' ) ) die();
1010
1111 class SFTemplates extends SpecialPage {
1212
@@ -13,11 +13,11 @@
1414 * Constructor
1515 */
1616 function SFTemplates() {
17 - SpecialPage::SpecialPage('Templates');
18 - wfLoadExtensionMessages('SemanticForms');
 17+ SpecialPage::SpecialPage( 'Templates' );
 18+ wfLoadExtensionMessages( 'SemanticForms' );
1919 }
2020
21 - function execute($query) {
 21+ function execute( $query ) {
2222 $this->setHeaders();
2323 list( $limit, $offset ) = wfCheckLimits();
2424 $rep = new TemplatesPage();
@@ -37,13 +37,13 @@
3838 function getPageHeader() {
3939 global $wgUser;
4040
41 - wfLoadExtensionMessages('SemanticForms');
 41+ wfLoadExtensionMessages( 'SemanticForms' );
4242
4343 $sk = $wgUser->getSkin();
44 - $ct = SpecialPage::getPage('CreateTemplate');
45 - $create_template_link = $sk->makeKnownLinkObj($ct->getTitle(), $ct->getDescription());
 44+ $ct = SpecialPage::getPage( 'CreateTemplate' );
 45+ $create_template_link = $sk->makeKnownLinkObj( $ct->getTitle(), $ct->getDescription() );
4646 $header = "<p>" . $create_template_link . ".</p>\n";
47 - $header .= '<p>' . wfMsg('sf_templates_docu') . "</p><br />\n";
 47+ $header .= '<p>' . wfMsg( 'sf_templates_docu' ) . "</p><br />\n";
4848 return $header;
4949 }
5050
@@ -67,28 +67,28 @@
6868 return false;
6969 }
7070
71 - function getCategoryDefinedByTemplate($template_article) {
 71+ function getCategoryDefinedByTemplate( $template_article ) {
7272 global $wgContLang;
7373
7474 $template_text = $template_article->getContent();
75 - $cat_ns_name = $wgContLang->getNsText(14);
76 - if (preg_match_all("/\[\[(Category|$cat_ns_name):(.*)\]\]/", $template_text, $matches)) {
 75+ $cat_ns_name = $wgContLang->getNsText( 14 );
 76+ if ( preg_match_all( "/\[\[(Category|$cat_ns_name):(.*)\]\]/", $template_text, $matches ) ) {
7777 // get the last match - if there's more than one
7878 // category tag, there's a good chance that the last
7979 // one will be the relevant one - the others are
8080 // probably part of inline queries
81 - return trim(end($matches[1]));
 81+ return trim( end( $matches[1] ) );
8282 }
8383 return "";
8484 }
8585
86 - function formatResult($skin, $result) {
87 - wfLoadExtensionMessages('SemanticForms');
 86+ function formatResult( $skin, $result ) {
 87+ wfLoadExtensionMessages( 'SemanticForms' );
8888 $title = Title::makeTitle( NS_TEMPLATE, $result->value );
8989 $text = $skin->makeLinkObj( $title, $title->getText() );
90 - $category = $this->getCategoryDefinedByTemplate(new Article($title));
91 - if ($category != '')
92 - $text .= ' ' . wfMsg('sf_templates_definescat') . ' ' . SFUtils::linkText(NS_CATEGORY, $category);
 90+ $category = $this->getCategoryDefinedByTemplate( new Article( $title ) );
 91+ if ( $category != '' )
 92+ $text .= ' ' . wfMsg( 'sf_templates_definescat' ) . ' ' . SFUtils::linkText( NS_CATEGORY, $category );
9393 return $text;
9494 }
9595 }
Index: trunk/extensions/SemanticForms/specials/SF_UploadWindow2.php
@@ -64,13 +64,13 @@
6565 $this->mRequest = $request;
6666 $this->mSourceType = $request->getVal( 'wpSourceType', 'file' );
6767 $this->mUpload = UploadBase::createFromRequest( $request );
68 - $this->mUploadClicked = $request->wasPosted()
69 - && ( $request->getCheck( 'wpUpload' )
 68+ $this->mUploadClicked = $request->wasPosted()
 69+ && ( $request->getCheck( 'wpUpload' )
7070 || $request->getCheck( 'wpUploadIgnoreWarning' ) );
7171
7272 // Guess the desired name from the filename if not provided
7373 $this->mDesiredDestName = $request->getText( 'wpDestFile' );
74 - if( !$this->mDesiredDestName )
 74+ if ( !$this->mDesiredDestName )
7575 $this->mDesiredDestName = $request->getText( 'wpUploadFile' );
7676 $this->mComment = $request->getText( 'wpUploadDescription' );
7777 $this->mLicense = $request->getText( 'wpLicense' );
@@ -89,7 +89,7 @@
9090
9191 // If it was posted check for the token (no remote POST'ing with user credentials)
9292 $token = $request->getVal( 'wpEditToken' );
93 - if( $this->mSourceType == 'file' && $token == null ) {
 93+ if ( $this->mSourceType == 'file' && $token == null ) {
9494 // Skip token check for file uploads as that can't be faked via JS...
9595 // Some client-side tools don't expect to need to send wpEditToken
9696 // with their submissions, as that's new in 1.16.
@@ -127,15 +127,15 @@
128128 $this->outputHeader();
129129
130130 # Check uploading enabled
131 - if( !UploadBase::isEnabled() ) {
 131+ if ( !UploadBase::isEnabled() ) {
132132 $wgOut->showErrorPage( 'uploaddisabled', 'uploaddisabledtext' );
133133 return;
134134 }
135135
136136 # Check permissions
137137 global $wgGroupPermissions;
138 - if( !$wgUser->isAllowed( 'upload' ) ) {
139 - if( !$wgUser->isLoggedIn() && ( $wgGroupPermissions['user']['upload']
 138+ if ( !$wgUser->isAllowed( 'upload' ) ) {
 139+ if ( !$wgUser->isLoggedIn() && ( $wgGroupPermissions['user']['upload']
140140 || $wgGroupPermissions['autoconfirmed']['upload'] ) ) {
141141 // Custom message if logged-in users without any special rights can upload
142142 $wgOut->showErrorPage( 'uploadnologin', 'uploadnologintext' );
@@ -146,13 +146,13 @@
147147 }
148148
149149 # Check blocks
150 - if( $wgUser->isBlocked() ) {
 150+ if ( $wgUser->isBlocked() ) {
151151 $wgOut->blockedPage();
152152 return;
153153 }
154154
155155 # Check whether we actually want to allow changing stuff
156 - if( wfReadOnly() ) {
 156+ if ( wfReadOnly() ) {
157157 $wgOut->readOnlyPage();
158158 return;
159159 }
@@ -204,8 +204,8 @@
205205
206206 # Initialize form
207207 $form = new SFUploadForm( array(
208 - 'watch' => $this->watchCheck(),
209 - 'forreupload' => $this->mForReUpload,
 208+ 'watch' => $this->watchCheck(),
 209+ 'forreupload' => $this->mForReUpload,
210210 'sessionkey' => $sessionKey,
211211 'hideignorewarning' => $hideIgnoreWarning,
212212 'sfInputID' => $this->mInputID,
@@ -214,12 +214,12 @@
215215 $form->setTitle( $this->getTitle() );
216216
217217 # Check the token, but only if necessary
218 - if( !$this->mTokenOk && !$this->mCancelUpload
 218+ if ( !$this->mTokenOk && !$this->mCancelUpload
219219 && ( $this->mUpload && $this->mUploadClicked ) )
220220 $form->addPreText( wfMsgExt( 'session_fail_preview', 'parseinline' ) );
221221
222222 # Add text to form
223 - //$form->addPreText( '<div id="uploadtext">' . wfMsgExt( 'uploadtext', 'parse' ) . '</div>');
 223+ // $form->addPreText( '<div id="uploadtext">' . wfMsgExt( 'uploadtext', 'parse' ) . '</div>');
224224 # Add upload error message
225225 $form->addPreText( $message );
226226
@@ -230,7 +230,7 @@
231231 . $wgOut->parse( $uploadFooter ) . "</div>\n" );
232232 }
233233
234 - return $form;
 234+ return $form;
235235
236236 }
237237
@@ -242,7 +242,7 @@
243243
244244 $title = Title::makeTitleSafe( NS_FILE, $this->mDesiredDestName );
245245 // Show a subtitle link to deleted revisions (to sysops et al only)
246 - if( $title instanceof Title && ( $count = $title->isDeleted() ) > 0 && $wgUser->isAllowed( 'deletedhistory' ) ) {
 246+ if ( $title instanceof Title && ( $count = $title->isDeleted() ) > 0 && $wgUser->isAllowed( 'deletedhistory' ) ) {
247247 $link = wfMsgExt(
248248 $wgUser->isAllowed( 'delete' ) ? 'thisisdeleted' : 'viewdeleted',
249249 array( 'parse', 'replaceafter' ),
@@ -255,7 +255,7 @@
256256 }
257257
258258 // Show the relevant lines from deletion log (for still deleted files only)
259 - if( $title instanceof Title && $title->isDeletedQuick() && !$title->exists() ) {
 259+ if ( $title instanceof Title && $title->isDeletedQuick() && !$title->exists() ) {
260260 $this->showDeletionLog( $wgOut, $title->getPrefixedText() );
261261 }
262262 }
@@ -294,13 +294,13 @@
295295
296296 $warningHtml = '<h2>' . wfMsgHtml( 'uploadwarning' ) . "</h2>\n"
297297 . '<ul class="warning">';
298 - foreach( $warnings as $warning => $args ) {
 298+ foreach ( $warnings as $warning => $args ) {
299299 $msg = '';
300 - if( $warning == 'exists' ) {
 300+ if ( $warning == 'exists' ) {
301301 $msg = self::getExistsWarning( $args );
302 - } elseif( $warning == 'duplicate' ) {
 302+ } elseif ( $warning == 'duplicate' ) {
303303 $msg = self::getDupeWarning( $args );
304 - } elseif( $warning == 'duplicate-archive' ) {
 304+ } elseif ( $warning == 'duplicate-archive' ) {
305305 $msg = "\t<li>" . wfMsgExt( 'file-deleted-duplicate', 'parseinline',
306306 array( Title::makeTitle( NS_FILE, $args )->getPrefixedText() ) )
307307 . "</li>\n";
@@ -344,12 +344,12 @@
345345
346346 // Verify permissions
347347 $permErrors = $this->mUpload->verifyPermissions( $wgUser );
348 - if( $permErrors !== true )
 348+ if ( $permErrors !== true )
349349 return $wgOut->showPermissionsErrorPage( $permErrors );
350350
351351 // Fetch the file if required
352352 $status = $this->mUpload->fetchFile();
353 - if( !$status->isOK() )
 353+ if ( !$status->isOK() )
354354 return $this->showUploadForm( $this->getUploadForm( $wgOut->parse( $status->getWikiText() ) ) );
355355
356356 // Upload verification
@@ -360,14 +360,14 @@
361361 $this->mLocalFile = $this->mUpload->getLocalFile();
362362
363363 // Check warnings if necessary
364 - if( !$this->mIgnoreWarning ) {
 364+ if ( !$this->mIgnoreWarning ) {
365365 $warnings = $this->mUpload->checkWarnings();
366 - if( count( $warnings ) )
 366+ if ( count( $warnings ) )
367367 return $this->uploadWarning( $warnings );
368368 }
369369
370370 // Get the page text if this is not a reupload
371 - if( !$this->mForReUpload ) {
 371+ if ( !$this->mForReUpload ) {
372372 $pageText = self::getInitialPageText( $this->mComment, $this->mLicense,
373373 $this->mCopyrightStatus, $this->mCopyrightSource );
374374 } else {
@@ -377,26 +377,26 @@
378378 if ( !$status->isGood() )
379379 return $this->uploadError( $wgOut->parse( $status->getWikiText() ) );
380380
381 - //$wgOut->redirect( $this->mLocalFile->getTitle()->getFullURL() );
 381+ // $wgOut->redirect( $this->mLocalFile->getTitle()->getFullURL() );
382382 // Semantic Forms change - output Javascript to either
383383 // fill in or append to the field in original form, and
384384 // close the window
385385 # Chop off any directories in the given filename
386 - if( $this->mDesiredDestName ) {
 386+ if ( $this->mDesiredDestName ) {
387387 $basename = $this->mDesiredDestName;
388388 } else {
389389 $basename = $this->mSrcName;
390390 }
391391
392 - $basename = str_replace('_', ' ', $basename);
 392+ $basename = str_replace( '_', ' ', $basename );
393393 $output = ' <script type="text/javascript">' . "\n";
394 - if ($this->mDelimiter == null) {
395 - $output .=<<<END
 394+ if ( $this->mDelimiter == null ) {
 395+ $output .= <<<END
396396 parent.document.getElementById("{$this->mInputID}").value = '$basename';
397397
398398 END;
399399 } else {
400 - $output .=<<<END
 400+ $output .= <<<END
401401 // if the current value is blank, set it to this file name;
402402 // if it's not blank and ends in a space or delimiter, append
403403 // the file name; if it ends with a normal character, append
@@ -416,12 +416,12 @@
417417
418418 END;
419419 }
420 - $output .=<<<END
 420+ $output .= <<<END
421421 parent.fb.end();
422422 </script>
423423
424424 END;
425 - //$wgOut->addHTML( $output );
 425+ // $wgOut->addHTML( $output );
426426 print $output;
427427 $img = null; // @todo: added to avoid passing a ref to null - should this be defined somewhere?
428428
@@ -467,13 +467,13 @@
468468 */
469469 protected function watchCheck() {
470470 global $wgUser;
471 - if( $wgUser->getOption( 'watchdefault' ) ) {
 471+ if ( $wgUser->getOption( 'watchdefault' ) ) {
472472 // Watch all edits!
473473 return true;
474474 }
475475
476476 $local = wfLocalFile( $this->mDesiredDestName );
477 - if( $local && $local->exists() ) {
 477+ if ( $local && $local->exists() ) {
478478 // We're uploading a new version of an existing file.
479479 // No creation, so don't watch it if we're not already.
480480 return $local->getTitle()->userIsWatching();
@@ -583,10 +583,10 @@
584584
585585 $sk = $wgUser->getSkin();
586586
587 - if( $exists['warning'] == 'exists' ) {
 587+ if ( $exists['warning'] == 'exists' ) {
588588 // Exact match
589589 $warning[] = '<li>' . wfMsgExt( 'fileexists', 'parseinline', $filename ) . '</li>';
590 - } elseif( $exists['warning'] == 'page-exists' ) {
 590+ } elseif ( $exists['warning'] == 'page-exists' ) {
591591 // Page exists but file does not
592592 $warning[] = '<li>' . wfMsgExt( 'filepageexists', 'parseinline', $filename ) . '</li>';
593593 } elseif ( $exists['warning'] == 'exists-normalized' ) {
@@ -629,7 +629,7 @@
630630 */
631631 public static function ajaxGetExistsWarning( $filename ) {
632632 $file = wfFindFile( $filename );
633 - if( !$file ) {
 633+ if ( !$file ) {
634634 // Force local file so we have an object to do further checks against
635635 // if there isn't an exact match...
636636 $file = wfLocalFile( $filename );
@@ -668,10 +668,10 @@
669669 * Construct a warning and a gallery from an array of duplicate files.
670670 */
671671 public static function getDupeWarning( $dupes ) {
672 - if( $dupes ) {
 672+ if ( $dupes ) {
673673 global $wgOut;
674674 $msg = "<gallery>";
675 - foreach( $dupes as $file ) {
 675+ foreach ( $dupes as $file ) {
676676 $title = $file->getTitle();
677677 $msg .= $title->getPrefixedText() .
678678 "|" . $title->getText() . "\n";
@@ -704,7 +704,7 @@
705705
706706 $this->mWatch = !empty( $options['watch'] );
707707 $this->mForReUpload = !empty( $options['forreupload'] );
708 - $this->mSessionKey = isset( $options['sessionkey'] )
 708+ $this->mSessionKey = isset( $options['sessionkey'] )
709709 ? $options['sessionkey'] : '';
710710 $this->mHideIgnoreWarning = !empty( $options['hideignorewarning'] );
711711
@@ -729,8 +729,8 @@
730730 $this->mSourceIds[] = $field['id'];
731731 }
732732 // added for Semantic Forms
733 - $this->addHiddenField('sfInputID', $options['sfInputID']);
734 - $this->addHiddenField('sfDelimiter', $options['sfDelimiter']);
 733+ $this->addHiddenField( 'sfInputID', $options['sfInputID'] );
 734+ $this->addHiddenField( 'sfDelimiter', $options['sfDelimiter'] );
735735
736736 }
737737
@@ -817,8 +817,8 @@
818818 $wgFileExtensions, $wgFileBlacklist;
819819
820820 $allowedExtensions = '';
821 - if( $wgCheckFileExtensions ) {
822 - if( $wgStrictFileExtensions ) {
 821+ if ( $wgCheckFileExtensions ) {
 822+ if ( $wgStrictFileExtensions ) {
823823 # Everything not permitted is banned
824824 $extensionsList =
825825 '<div id="mw-upload-permitted">' .
@@ -851,7 +851,7 @@
852852 global $wgUser, $wgOut;
853853
854854 $cols = intval( $wgUser->getOption( 'cols' ) );
855 - if( $wgUser->getOption( 'editwidth' ) ) {
 855+ if ( $wgUser->getOption( 'editwidth' ) ) {
856856 $wgOut->addInlineStyle( '#mw-htmlform-description { width: 100%; }' );
857857 }
858858
@@ -953,17 +953,17 @@
954954 $wgXhtmlDefaultNamespace, $wgXhtmlNamespaces, $wgContLang;
955955 $wgOut->disable();
956956 $sk = $wgUser->getSkin();
957 - $sk->initPage($wgOut); // need to call this to set skin name correctly
958 - $wgTitle = Title::makeTitleSafe(NS_SPECIAL, 'Upload');
 957+ $sk->initPage( $wgOut ); // need to call this to set skin name correctly
 958+ $wgTitle = Title::makeTitleSafe( NS_SPECIAL, 'Upload' );
959959 $skin_user_js = $sk->generateUserJs();
960960
961 - $user_js =<<<END
 961+ $user_js = <<<END
962962 <script type="{$wgJsMimeType}">
963963 $skin_user_js;
964964 </script>
965965
966966 END;
967 - $vars_js = Skin::makeGlobalVariablesScript(array('skinname' => $sk->getSkinName()));
 967+ $vars_js = Skin::makeGlobalVariablesScript( array( 'skinname' => $sk->getSkinName() ) );
968968 $wikibits_include = "<script type=\"{$wgJsMimeType}\" src=\"{$wgStylePath}/common/wikibits.js?$wgStyleVersion\"></script>";
969969 $ajax_include = "<script type=\"{$wgJsMimeType}\" src=\"{$wgStylePath}/common/ajax.js?$wgStyleVersion\"></script>";
970970 $ajaxwatch_include = "<script type=\"{$wgJsMimeType}\" src=\"{$wgStylePath}/common/ajaxwatch.js?$wgStyleVersion\"></script>";
@@ -971,7 +971,7 @@
972972 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
973973 <html xmlns="{$wgXhtmlDefaultNamespace}"
974974 END;
975 - foreach($wgXhtmlNamespaces as $tag => $ns) {
 975+ foreach ( $wgXhtmlNamespaces as $tag => $ns ) {
976976 $text .= "xmlns:{$tag}=\"{$ns}\" ";
977977 }
978978 $dir = $wgContLang->isRTL() ? "rtl" : "ltr";
Index: trunk/extensions/SemanticForms/specials/SF_CreateTemplate.php
@@ -10,7 +10,7 @@
1111 * Protect against register_globals vulnerabilities.
1212 * This line must be present before any global variable is referenced.
1313 */
14 -if (!defined('MEDIAWIKI')) die();
 14+if ( !defined( 'MEDIAWIKI' ) ) die();
1515
1616 class SFCreateTemplate extends SpecialPage {
1717
@@ -18,11 +18,11 @@
1919 * Constructor
2020 */
2121 function SFCreateTemplate() {
22 - SpecialPage::SpecialPage('CreateTemplate');
23 - wfLoadExtensionMessages('SemanticForms');
 22+ SpecialPage::SpecialPage( 'CreateTemplate' );
 23+ wfLoadExtensionMessages( 'SemanticForms' );
2424 }
2525
26 - function execute($query) {
 26+ function execute( $query ) {
2727 $this->setHeaders();
2828 doSpecialCreateTemplate();
2929 }
@@ -34,43 +34,43 @@
3535 // getProperties() functions stop requiring a limit
3636 $options = new SMWRequestOptions();
3737 $options->limit = 10000;
38 - $used_properties = smwfGetStore()->getPropertiesSpecial($options);
39 - foreach ($used_properties as $property) {
 38+ $used_properties = smwfGetStore()->getPropertiesSpecial( $options );
 39+ foreach ( $used_properties as $property ) {
4040 $all_properties[] = $property[0]->getWikiValue();
4141 }
42 - $unused_properties = smwfGetStore()->getUnusedPropertiesSpecial($options);
43 - foreach ($unused_properties as $property) {
 42+ $unused_properties = smwfGetStore()->getUnusedPropertiesSpecial( $options );
 43+ foreach ( $unused_properties as $property ) {
4444 $all_properties[] = $property->getWikiValue();
4545 }
4646
4747 // sort properties list alphabetically
48 - sort($all_properties);
 48+ sort( $all_properties );
4949 return $all_properties;
5050 }
5151
52 - function printPropertiesDropdown($all_properties, $id, $selected_property) {
 52+ function printPropertiesDropdown( $all_properties, $id, $selected_property ) {
5353 $dropdown_str = "<select name=\"semantic_property_$id\">\n";
5454 $dropdown_str .= "<option value=\"\"></option>\n";
55 - foreach ($all_properties as $prop_name) {
56 - $selected = ($selected_property == $prop_name) ? "selected" : "";
 55+ foreach ( $all_properties as $prop_name ) {
 56+ $selected = ( $selected_property == $prop_name ) ? "selected" : "";
5757 $dropdown_str .= "<option value=\"$prop_name\" $selected>$prop_name</option>\n";
5858 }
5959 $dropdown_str .= "</select>\n";
6060 return $dropdown_str;
6161 }
6262
63 - function printFieldEntryBox($id, $f, $all_properties) {
64 - wfLoadExtensionMessages('SemanticForms');
65 - $dropdown_html = SFCreateTemplate::printPropertiesDropdown($all_properties, $id, $f->semantic_property);
 63+ function printFieldEntryBox( $id, $f, $all_properties ) {
 64+ wfLoadExtensionMessages( 'SemanticForms' );
 65+ $dropdown_html = SFCreateTemplate::printPropertiesDropdown( $all_properties, $id, $f->semantic_property );
6666 $text = ' <div class="fieldBox">' . "\n";
67 - $text .= ' <p>' . wfMsg('sf_createtemplate_fieldname') . ' <input size="15" name="name_' . $id . '" value="' . $f->field_name . '">' . "\n";
68 - $text .= ' ' . wfMsg('sf_createtemplate_displaylabel') . ' <input size="15" name="label_' . $id . '" value="' . $f->label . '">' . "\n";
69 - $text .= ' ' . wfMsg('sf_createtemplate_semanticproperty') . ' ' . $dropdown_html . "</p>\n";
70 - $checked_str = ($f->is_list) ? " checked" : "";
71 - $text .= ' <p><input type="checkbox" name="is_list_' . $id . '"' . $checked_str . '> ' . wfMsg('sf_createtemplate_fieldislist') . "\n";
 67+ $text .= ' <p>' . wfMsg( 'sf_createtemplate_fieldname' ) . ' <input size="15" name="name_' . $id . '" value="' . $f->field_name . '">' . "\n";
 68+ $text .= ' ' . wfMsg( 'sf_createtemplate_displaylabel' ) . ' <input size="15" name="label_' . $id . '" value="' . $f->label . '">' . "\n";
 69+ $text .= ' ' . wfMsg( 'sf_createtemplate_semanticproperty' ) . ' ' . $dropdown_html . "</p>\n";
 70+ $checked_str = ( $f->is_list ) ? " checked" : "";
 71+ $text .= ' <p><input type="checkbox" name="is_list_' . $id . '"' . $checked_str . '> ' . wfMsg( 'sf_createtemplate_fieldislist' ) . "\n";
7272
73 - if ($id != "new") {
74 - $text .= ' &nbsp;&nbsp;<input name="del_' . $id . '" type="submit" value="' . wfMsg('sf_createtemplate_deletefield') . '">' . "\n";
 73+ if ( $id != "new" ) {
 74+ $text .= ' &nbsp;&nbsp;<input name="del_' . $id . '" type="submit" value="' . wfMsg( 'sf_createtemplate_deletefield' ) . '">' . "\n";
7575 }
7676 $text .= <<<END
7777 </p>
@@ -84,55 +84,55 @@
8585 function doSpecialCreateTemplate() {
8686 global $wgOut, $wgRequest, $wgUser, $sfgScriptPath, $wgContLang;
8787
88 - wfLoadExtensionMessages('SemanticForms');
 88+ wfLoadExtensionMessages( 'SemanticForms' );
8989
9090 $all_properties = SFCreateTemplate::getAllPropertyNames();
9191
92 - $template_name = $wgRequest->getVal('template_name');
 92+ $template_name = $wgRequest->getVal( 'template_name' );
9393 $template_name_error_str = "";
94 - $category = $wgRequest->getVal('category');
 94+ $category = $wgRequest->getVal( 'category' );
9595 $cur_id = 1;
9696 $fields = array();
9797 # cycle through the query values, setting the appropriate local variables
98 - foreach ($wgRequest->getValues() as $var => $val) {
99 - $var_elements = explode("_", $var);
 98+ foreach ( $wgRequest->getValues() as $var => $val ) {
 99+ $var_elements = explode( "_", $var );
100100 // we only care about query variables of the form "a_b"
101 - if (count($var_elements) != 2)
 101+ if ( count( $var_elements ) != 2 )
102102 continue;
103 - list ($field_field, $old_id) = $var_elements;
104 - if ($field_field == "name") {
105 - if ($old_id != "new" || ($old_id == "new" && $val != "")) {
106 - if ($wgRequest->getVal('del_' . $old_id) != '') {
 103+ list ( $field_field, $old_id ) = $var_elements;
 104+ if ( $field_field == "name" ) {
 105+ if ( $old_id != "new" || ( $old_id == "new" && $val != "" ) ) {
 106+ if ( $wgRequest->getVal( 'del_' . $old_id ) != '' ) {
107107 # do nothing - this field won't get added to the new list
108108 } else {
109 - $field = SFTemplateField::create($val, $wgRequest->getVal('label_' . $old_id));
110 - $field->semantic_property = $wgRequest->getVal('semantic_property_' . $old_id);
111 - $field->is_list = $wgRequest->getCheck('is_list_' . $old_id);
 109+ $field = SFTemplateField::create( $val, $wgRequest->getVal( 'label_' . $old_id ) );
 110+ $field->semantic_property = $wgRequest->getVal( 'semantic_property_' . $old_id );
 111+ $field->is_list = $wgRequest->getCheck( 'is_list_' . $old_id );
112112 $fields[] = $field;
113113 }
114114 }
115115 }
116116 }
117 - $aggregating_property = $wgRequest->getVal('semantic_property_aggregation');
118 - $aggregation_label = $wgRequest->getVal('aggregation_label');
119 - $template_format = $wgRequest->getVal('template_format');
 117+ $aggregating_property = $wgRequest->getVal( 'semantic_property_aggregation' );
 118+ $aggregation_label = $wgRequest->getVal( 'aggregation_label' );
 119+ $template_format = $wgRequest->getVal( 'template_format' );
120120
121121 $text = "";
122 - $save_button_text = wfMsg('savearticle');
123 - $preview_button_text = wfMsg('preview');
124 - $save_page = $wgRequest->getCheck('wpSave');
125 - $preview_page = $wgRequest->getCheck('wpPreview');
126 - if ($save_page || $preview_page) {
 122+ $save_button_text = wfMsg( 'savearticle' );
 123+ $preview_button_text = wfMsg( 'preview' );
 124+ $save_page = $wgRequest->getCheck( 'wpSave' );
 125+ $preview_page = $wgRequest->getCheck( 'wpPreview' );
 126+ if ( $save_page || $preview_page ) {
127127 # validate template name
128 - if ($template_name == '') {
129 - $template_name_error_str = wfMsg('sf_blank_error');
 128+ if ( $template_name == '' ) {
 129+ $template_name_error_str = wfMsg( 'sf_blank_error' );
130130 } else {
131131 // redirect to wiki interface
132 - $wgOut->setArticleBodyOnly(true);
133 - $title = Title::makeTitleSafe(NS_TEMPLATE, $template_name);
134 - $full_text = SFTemplateField::createTemplateText($template_name, $fields, $category, $aggregating_property, $aggregation_label, $template_format);
135 - $text = SFUtils::printRedirectForm($title, $full_text, "", $save_page, $preview_page, false, false, false, null, null);
136 - $wgOut->addHTML($text);
 132+ $wgOut->setArticleBodyOnly( true );
 133+ $title = Title::makeTitleSafe( NS_TEMPLATE, $template_name );
 134+ $full_text = SFTemplateField::createTemplateText( $template_name, $fields, $category, $aggregating_property, $aggregation_label, $template_format );
 135+ $text = SFUtils::printRedirectForm( $title, $full_text, "", $save_page, $preview_page, false, false, false, null, null );
 136+ $wgOut->addHTML( $text );
137137 return;
138138 }
139139 }
@@ -142,30 +142,30 @@
143143 $mw_namespace_labels = $wgContLang->getNamespaces();
144144 $special_namespace = $mw_namespace_labels[NS_SPECIAL];
145145 $text .= ' <input type="hidden" name="title" value="' . $special_namespace . ':CreateTemplate">' . "\n";
146 - $text .= ' <p>' . wfMsg('sf_createtemplate_namelabel') . ' <input size="25" name="template_name" value="' . $template_name . '"> <font color="red">' . $template_name_error_str . '</font></p>' . "\n";
147 - $text .= ' <p>' . wfMsg('sf_createtemplate_categorylabel') . ' <input size="25" name="category" value="' . $category . '"></p>' . "\n";
 146+ $text .= ' <p>' . wfMsg( 'sf_createtemplate_namelabel' ) . ' <input size="25" name="template_name" value="' . $template_name . '"> <font color="red">' . $template_name_error_str . '</font></p>' . "\n";
 147+ $text .= ' <p>' . wfMsg( 'sf_createtemplate_categorylabel' ) . ' <input size="25" name="category" value="' . $category . '"></p>' . "\n";
148148 $text .= " <fieldset>\n";
149 - $text .= ' ' . Xml::element('legend', null, wfMsg('sf_createtemplate_templatefields')) . "\n";
150 - $text .= ' ' . Xml::element('p', null, wfMsg('sf_createtemplate_fieldsdesc')) . "\n";
 149+ $text .= ' ' . Xml::element( 'legend', null, wfMsg( 'sf_createtemplate_templatefields' ) ) . "\n";
 150+ $text .= ' ' . Xml::element( 'p', null, wfMsg( 'sf_createtemplate_fieldsdesc' ) ) . "\n";
151151
152 - foreach ($fields as $i => $field) {
153 - $text .= SFCreateTemplate::printFieldEntryBox($i + 1, $field, $all_properties);
 152+ foreach ( $fields as $i => $field ) {
 153+ $text .= SFCreateTemplate::printFieldEntryBox( $i + 1, $field, $all_properties );
154154 }
155155 $new_field = new SFTemplateField();
156 - $text .= SFCreateTemplate::printFieldEntryBox("new", $new_field, $all_properties);
 156+ $text .= SFCreateTemplate::printFieldEntryBox( "new", $new_field, $all_properties );
157157
158 - $text .= ' <p><input type="submit" value="' . wfMsg('sf_createtemplate_addfield') . '"></p>' . "\n";
 158+ $text .= ' <p><input type="submit" value="' . wfMsg( 'sf_createtemplate_addfield' ) . '"></p>' . "\n";
159159 $text .= " </fieldset>\n";
160160 $text .= " <fieldset>\n";
161 - $text .= ' ' . Xml::element('legend', null, wfMsg('sf_createtemplate_aggregation')) . "\n";
162 - $text .= ' ' . Xml::element('p', null, wfMsg('sf_createtemplate_aggregationdesc')) . "\n";
163 - $text .= ' <p>' . wfMsg('sf_createtemplate_semanticproperty') . " " . SFCreateTemplate::printPropertiesDropdown($all_properties, "aggregation", $aggregating_property). "</p>\n";
164 - $text .= ' <p>' . wfMsg('sf_createtemplate_aggregationlabel') . ' <input size="25" name="aggregation_label" value="' . $aggregation_label . '"></p>' . "\n";
 161+ $text .= ' ' . Xml::element( 'legend', null, wfMsg( 'sf_createtemplate_aggregation' ) ) . "\n";
 162+ $text .= ' ' . Xml::element( 'p', null, wfMsg( 'sf_createtemplate_aggregationdesc' ) ) . "\n";
 163+ $text .= ' <p>' . wfMsg( 'sf_createtemplate_semanticproperty' ) . " " . SFCreateTemplate::printPropertiesDropdown( $all_properties, "aggregation", $aggregating_property ) . "</p>\n";
 164+ $text .= ' <p>' . wfMsg( 'sf_createtemplate_aggregationlabel' ) . ' <input size="25" name="aggregation_label" value="' . $aggregation_label . '"></p>' . "\n";
165165 $text .= " </fieldset>\n";
166 - $text .= ' <p>' . wfMsg('sf_createtemplate_outputformat') . "\n";
167 - $text .= ' <input type="radio" name="template_format" checked value="standard">' . wfMsg('sf_createtemplate_standardformat') . "\n";
168 - $text .= ' <input type="radio" name="template_format" value="infobox">' . wfMsg('sf_createtemplate_infoboxformat') . "</p>\n";
169 - $text .=<<<END
 166+ $text .= ' <p>' . wfMsg( 'sf_createtemplate_outputformat' ) . "\n";
 167+ $text .= ' <input type="radio" name="template_format" checked value="standard">' . wfMsg( 'sf_createtemplate_standardformat' ) . "\n";
 168+ $text .= ' <input type="radio" name="template_format" value="infobox">' . wfMsg( 'sf_createtemplate_infoboxformat' ) . "</p>\n";
 169+ $text .= <<<END
170170 <div class="editButtons">
171171 <input type="submit" id="wpSave" name="wpSave" value="$save_button_text">
172172 <input type="submit" id="wpPreview" name="wpPreview" value="$preview_button_text">
@@ -174,16 +174,16 @@
175175
176176 END;
177177 $sk = $wgUser->getSkin();
178 - $cp = SpecialPage::getPage('CreateProperty');
179 - $create_property_link = $sk->makeKnownLinkObj($cp->getTitle(), $cp->getDescription());
 178+ $cp = SpecialPage::getPage( 'CreateProperty' );
 179+ $create_property_link = $sk->makeKnownLinkObj( $cp->getTitle(), $cp->getDescription() );
180180 $text .= " <br /><hr /><br />\n";
181 - $text .= " " . Xml::tags('p', null, $create_property_link . '.') . "\n";
 181+ $text .= " " . Xml::tags( 'p', null, $create_property_link . '.' ) . "\n";
182182
183183 $wgOut->addLink( array(
184184 'rel' => 'stylesheet',
185185 'type' => 'text/css',
186186 'media' => "screen",
187187 'href' => $sfgScriptPath . "/skins/SF_main.css"
188 - ));
189 - $wgOut->addHTML($text);
 188+ ) );
 189+ $wgOut->addHTML( $text );
190190 }
Index: trunk/extensions/SemanticForms/includes/SF_FormEditTab.php
@@ -11,50 +11,50 @@
1212 * Adds an "action" (i.e., a tab) to edit the current article with
1313 * a form
1414 */
15 - static function displayTab($obj, &$content_actions) {
 15+ static function displayTab( $obj, &$content_actions ) {
1616 // make sure that this is not a special page, and
1717 // that the user is allowed to edit it
1818 // - this function is almost never called on special pages,
1919 // but before SMW is fully initialized, it's called on
2020 // Special:SMWAdmin for some reason, which is why the
2121 // special-page check is there
22 - if (isset($obj->mTitle) &&
23 - ($obj->mTitle->getNamespace() != NS_SPECIAL)) {
24 - $form_names = SFLinkUtils::getFormsForArticle($obj);
25 - if (count($form_names) > 0) {
 22+ if ( isset( $obj->mTitle ) &&
 23+ ( $obj->mTitle->getNamespace() != NS_SPECIAL ) ) {
 24+ $form_names = SFLinkUtils::getFormsForArticle( $obj );
 25+ if ( count( $form_names ) > 0 ) {
2626 global $wgRequest, $wgUser;
2727 global $sfgRenameEditTabs, $sfgRenameMainEditTab;
2828
29 - wfLoadExtensionMessages('SemanticForms');
 29+ wfLoadExtensionMessages( 'SemanticForms' );
3030
31 - $user_can_edit = $wgUser->isAllowed('edit') && $obj->mTitle->userCan('edit');
 31+ $user_can_edit = $wgUser->isAllowed( 'edit' ) && $obj->mTitle->userCan( 'edit' );
3232 // create the form edit tab, and apply whatever
3333 // changes are specified by the edit-tab global
3434 // variables
35 - if ($sfgRenameEditTabs) {
36 - $form_edit_tab_text = $user_can_edit ? wfMsg('edit') : wfMsg('sf_viewform');
37 - if (array_key_exists('edit', $content_actions)) {
38 - $content_actions['edit']['text'] = $user_can_edit ? wfMsg('sf_editsource') : wfMsg('viewsource');
 35+ if ( $sfgRenameEditTabs ) {
 36+ $form_edit_tab_text = $user_can_edit ? wfMsg( 'edit' ) : wfMsg( 'sf_viewform' );
 37+ if ( array_key_exists( 'edit', $content_actions ) ) {
 38+ $content_actions['edit']['text'] = $user_can_edit ? wfMsg( 'sf_editsource' ) : wfMsg( 'viewsource' );
3939 }
4040 } else {
41 - if ($user_can_edit)
42 - $form_edit_tab_text = $obj->mTitle->exists() ? wfMsg('formedit') : wfMsg('sf_formcreate');
 41+ if ( $user_can_edit )
 42+ $form_edit_tab_text = $obj->mTitle->exists() ? wfMsg( 'formedit' ) : wfMsg( 'sf_formcreate' );
4343 else
44 - $form_edit_tab_text = wfMsg('sf_viewform');
 44+ $form_edit_tab_text = wfMsg( 'sf_viewform' );
4545 // check for renaming of main edit tab
4646 // only if $sfgRenameEditTabs is off
47 - if ($sfgRenameMainEditTab) {
48 - if (array_key_exists('edit', $content_actions)) {
49 - $content_actions['edit']['text'] = $user_can_edit ? wfMsg('sf_editsource') : wfMsg('viewsource');
 47+ if ( $sfgRenameMainEditTab ) {
 48+ if ( array_key_exists( 'edit', $content_actions ) ) {
 49+ $content_actions['edit']['text'] = $user_can_edit ? wfMsg( 'sf_editsource' ) : wfMsg( 'viewsource' );
5050 }
5151 }
5252 }
5353
54 - $class_name = ($wgRequest->getVal('action') == 'formedit') ? 'selected' : '';
 54+ $class_name = ( $wgRequest->getVal( 'action' ) == 'formedit' ) ? 'selected' : '';
5555 $form_edit_tab = array(
5656 'class' => $class_name,
5757 'text' => $form_edit_tab_text,
58 - 'href' => $obj->mTitle->getLocalURL('action=formedit')
 58+ 'href' => $obj->mTitle->getLocalURL( 'action=formedit' )
5959 );
6060
6161 // find the location of the 'edit' tab, and add
@@ -65,30 +65,30 @@
6666 // rebuilding the array.
6767 // based on the example at
6868 // http://us2.php.net/manual/en/function.array-splice.php#31234
69 - $tab_keys = array_keys($content_actions);
70 - $tab_values = array_values($content_actions);
71 - $edit_tab_location = array_search('edit', $tab_keys);
 69+ $tab_keys = array_keys( $content_actions );
 70+ $tab_values = array_values( $content_actions );
 71+ $edit_tab_location = array_search( 'edit', $tab_keys );
7272 // if there's no 'edit' tab, look for the
7373 // 'view source' tab instead
74 - if ($edit_tab_location == null)
75 - $edit_tab_location = array_search('viewsource', $tab_keys);
 74+ if ( $edit_tab_location == null )
 75+ $edit_tab_location = array_search( 'viewsource', $tab_keys );
7676 // this should rarely happen, but if there was
7777 // no edit *or* view source tab, set the
7878 // location index to -1, so the tab shows up
7979 // near the end
80 - if ($edit_tab_location == null)
81 - $edit_tab_location = -1;
82 - array_splice($tab_keys, $edit_tab_location, 0, 'form_edit');
83 - array_splice($tab_values, $edit_tab_location, 0, array($form_edit_tab));
 80+ if ( $edit_tab_location == null )
 81+ $edit_tab_location = - 1;
 82+ array_splice( $tab_keys, $edit_tab_location, 0, 'form_edit' );
 83+ array_splice( $tab_values, $edit_tab_location, 0, array( $form_edit_tab ) );
8484 $content_actions = array();
85 - for ($i = 0; $i < count($tab_keys); $i++)
 85+ for ( $i = 0; $i < count( $tab_keys ); $i++ )
8686 $content_actions[$tab_keys[$i]] = $tab_values[$i];
8787
8888 global $wgUser;
89 - if (! $wgUser->isAllowed('viewedittab')) {
 89+ if ( ! $wgUser->isAllowed( 'viewedittab' ) ) {
9090 // the tab can have either of those two actions
91 - unset($content_actions['edit']);
92 - unset($content_actions['viewsource']);
 91+ unset( $content_actions['edit'] );
 92+ unset( $content_actions['viewsource'] );
9393 }
9494
9595 return true;
@@ -101,11 +101,11 @@
102102 * Function currently called only for the 'Vector' skin, added in
103103 * MW 1.16 - will possibly be called for additional skins later
104104 */
105 - static function displayTab2($obj, &$links) {
 105+ static function displayTab2( $obj, &$links ) {
106106 // the old '$content_actions' array is thankfully just a
107107 // sub-array of this one
108108 $views_links = $links['views'];
109 - self::displayTab($obj, $views_links);
 109+ self::displayTab( $obj, $views_links );
110110 $links['views'] = $views_links;
111111 return true;
112112 }
@@ -114,31 +114,31 @@
115115 * The function called if we're in index.php (as opposed to one of the
116116 * special pages)
117117 */
118 - static function displayForm($action, $article) {
 118+ static function displayForm( $action, $article ) {
119119 global $sfgIP, $sfgUseFormEditPage;
120120
121121 // return "true" if the call failed (meaning, pass on handling
122122 // of the hook to others), and "false" otherwise
123 - if ($action != 'formedit') {
 123+ if ( $action != 'formedit' ) {
124124 return true;
125125 }
126126
127127 // @todo: This looks like bad code. If we can't find a form, we
128128 // should be showing an informative error page rather than
129129 // making it look like an edit form page does not exist.
130 - $form_names = SFLinkUtils::getFormsForArticle($article);
131 - if (count($form_names) == 0) {
 130+ $form_names = SFLinkUtils::getFormsForArticle( $article );
 131+ if ( count( $form_names ) == 0 ) {
132132 return true;
133133 }
134 - if (count($form_names) > 1) {
135 - wfLoadExtensionMessages('SemanticForms');
136 - $warning_text = ' <div class="warningMessage">' . wfMsg('sf_formedit_morethanoneform') . "</div>\n";
 134+ if ( count( $form_names ) > 1 ) {
 135+ wfLoadExtensionMessages( 'SemanticForms' );
 136+ $warning_text = ' <div class="warningMessage">' . wfMsg( 'sf_formedit_morethanoneform' ) . "</div>\n";
137137 global $wgOut;
138 - $wgOut->addHTML($warning_text);
 138+ $wgOut->addHTML( $warning_text );
139139 }
140140 $form_name = $form_names[0];
141141
142 - if( $sfgUseFormEditPage ) {
 142+ if ( $sfgUseFormEditPage ) {
143143 # Experimental new feature extending from the internal
144144 # EditPage class
145145 $editor = new SFFormEditPage( $article, $form_name );
@@ -147,8 +147,8 @@
148148 }
149149
150150 $target_title = $article->getTitle();
151 - $target_name = SFLinkUtils::titleString($target_title);
152 - SFFormEdit::printForm($form_name, $target_name);
 151+ $target_name = SFLinkUtils::titleString( $target_title );
 152+ SFFormEdit::printForm( $form_name, $target_name );
153153 return false;
154154 }
155155
Index: trunk/extensions/SemanticForms/includes/SF_Settings.php
@@ -2,40 +2,40 @@
33 /**
44 * Default settings for Semantic Forms
55 */
6 -if (!defined('MEDIAWIKI')) die();
 6+if ( !defined( 'MEDIAWIKI' ) ) die();
77
8 -###
 8+# ##
99 # This is the path to your installation of Semantic Forms as
1010 # seen from the web. Change it if required ($wgScriptPath is the
1111 # path to the base directory of your wiki). No final slash.
12 -##
 12+# #
1313 $sfgScriptPath = $wgScriptPath . '/extensions/SemanticForms';
14 -##
 14+# #
1515
16 -###
 16+# ##
1717 # This is the path to your installation of Semantic Forms as
1818 # seen on your local filesystem. Used against some PHP file path
1919 # issues.
20 -##
21 -$sfgIP = dirname(__FILE__) . '/..';
22 -##
 20+# #
 21+$sfgIP = dirname( __FILE__ ) . '/..';
 22+# #
2323
2424
2525 // PHP fails to find relative includes at some level of inclusion:
26 -//$pathfix = $IP . $sfgScriptPath;
 26+// $pathfix = $IP . $sfgScriptPath;
2727
2828 // load global functions
29 -require_once('SF_GlobalFunctions.php');
 29+require_once( 'SF_GlobalFunctions.php' );
3030
3131 sffInitNamespaces();
3232
33 -###
 33+# ##
3434 # The number of allowed values per autocomplete - too many might
3535 # slow down the database, and Javascript's completion
36 -###
 36+# ##
3737 $sfgMaxAutocompleteValues = 1000;
3838
39 -###
 39+# ##
4040 # Global variables for handling the two edit tabs (for traditional editing
4141 # and for editing with a form):
4242 # $sfgRenameEditTabs renames the edit-with-form tab to just "Edit", and
@@ -46,52 +46,52 @@
4747 # The wgGroupPermissions 'viewedittab' setting dictates which types of
4848 # visitors will see the "Edit" tab, for pages that are editable by form -
4949 # by default all will see it.
50 -###
 50+# ##
5151 $sfgRenameEditTabs = false;
5252 $sfgRenameMainEditTab = false;
5353 $wgGroupPermissions['*']['viewedittab'] = true;
5454 $wgAvailableRights[] = 'viewedittab';
5555
56 -###
 56+# ##
5757 # Permission to edit form fields defined as 'restricted'
58 -###
 58+# ##
5959 $wgGroupPermissions['sysop']['editrestrictedfields'] = true;
6060 $wgAvailableRights[] = 'editrestrictedfields';
6161
62 -###
 62+# ##
6363 # Permission to view, and create pages with, Special:CreateClass
64 -###
 64+# ##
6565 $wgGroupPermissions['user']['createclass'] = true;
6666 $wgAvailableRights[] = 'createclass';
6767
68 -###
 68+# ##
6969 # List separator character
70 -###
 70+# ##
7171 $sfgListSeparator = ",";
7272
73 -###
 73+# ##
7474 # The base URL for all YUI Javascript files - to store the YUI library
7575 # locally, download it (from http://developer.yahoo.com/yui/) and change this
7676 # value to the URL of the local installation's 'build' directory.
77 -###
 77+# ##
7878 $sfgYUIBase = "http://yui.yahooapis.com/2.7.0/build/";
7979
80 -###
 80+# ##
8181 # Extend the edit form from the internal EditPage class rather than using a
8282 # special page and hacking things up.
8383 #
8484 # @note This is experimental and requires updates to EditPage which I have only
8585 # added into MediaWiki 1.14a
86 -###
87 -$sfgUseFormEditPage = false;//method_exists('EditPage', 'showFooter');
 86+# ##
 87+$sfgUseFormEditPage = false;// method_exists('EditPage', 'showFooter');
8888
89 -###
 89+# ##
9090 # Use 24-hour time format in forms, e.g. 15:30 instead of 3:30 PM
91 -###
 91+# ##
9292 $sfg24HourTime = false;
9393
94 -###
 94+# ##
9595 # Cache parsed form definitions in the page_props table, to improve loading
9696 # speed
97 -###
 97+# ##
9898 $sfgCacheFormDefinitions = false;
Index: trunk/extensions/SemanticForms/includes/SF_ParserFunctions.php
@@ -106,14 +106,14 @@
107107 static $num_autocompletion_inputs = 0;
108108
109109 static function registerFunctions( &$parser ) {
110 - $parser->setFunctionHook('forminput', array('SFParserFunctions', 'renderFormInput'));
111 - $parser->setFunctionHook('formlink', array('SFParserFunctions', 'renderFormLink'));
112 - if( defined( get_class( $parser ) . '::SFH_OBJECT_ARGS' ) ) {
113 - $parser->setFunctionHook('arraymap', array('SFParserFunctions', 'renderArrayMapObj'), SFH_OBJECT_ARGS);
114 - $parser->setFunctionHook('arraymaptemplate', array('SFParserFunctions', 'renderArrayMapTemplateObj'), SFH_OBJECT_ARGS);
 110+ $parser->setFunctionHook( 'forminput', array( 'SFParserFunctions', 'renderFormInput' ) );
 111+ $parser->setFunctionHook( 'formlink', array( 'SFParserFunctions', 'renderFormLink' ) );
 112+ if ( defined( get_class( $parser ) . '::SFH_OBJECT_ARGS' ) ) {
 113+ $parser->setFunctionHook( 'arraymap', array( 'SFParserFunctions', 'renderArrayMapObj' ), SFH_OBJECT_ARGS );
 114+ $parser->setFunctionHook( 'arraymaptemplate', array( 'SFParserFunctions', 'renderArrayMapTemplateObj' ), SFH_OBJECT_ARGS );
115115 } else {
116 - $parser->setFunctionHook('arraymap', array('SFParserFunctions', 'renderArrayMap'));
117 - $parser->setFunctionHook('arraymaptemplate', array('SFParserFunctions', 'renderArrayMapTemplate'));
 116+ $parser->setFunctionHook( 'arraymap', array( 'SFParserFunctions', 'renderArrayMap' ) );
 117+ $parser->setFunctionHook( 'arraymaptemplate', array( 'SFParserFunctions', 'renderArrayMapTemplate' ) );
118118 }
119119 return true;
120120 }
@@ -130,78 +130,78 @@
131131 return true;
132132 }
133133
134 - static function renderFormLink (&$parser) {
 134+ static function renderFormLink ( &$parser ) {
135135 $params = func_get_args();
136136 array_shift( $params ); // don't need the parser
137137 // set defaults
138138 $inFormName = $inLinkStr = $inLinkType = $inQueryStr = '';
139139 // assign params - support unlabelled params, for backwards compatibility
140 - foreach ($params as $i => $param) {
141 - $elements = explode('=', $param, 2);
 140+ foreach ( $params as $i => $param ) {
 141+ $elements = explode( '=', $param, 2 );
142142 $param_name = null;
143143 $value = $param;
144 - if (count($elements) > 1) {
 144+ if ( count( $elements ) > 1 ) {
145145 $param_name = $elements[0];
146146 $value = $elements[1];
147147 }
148 - if ($param_name == 'form')
 148+ if ( $param_name == 'form' )
149149 $inFormName = $value;
150 - elseif ($param_name == 'link text')
 150+ elseif ( $param_name == 'link text' )
151151 $inLinkStr = $value;
152 - elseif ($param_name == 'link type')
 152+ elseif ( $param_name == 'link type' )
153153 $inLinkType = $value;
154 - elseif ($param_name == 'query string')
 154+ elseif ( $param_name == 'query string' )
155155 $inQueryStr = $value;
156 - elseif ($i == 0)
 156+ elseif ( $i == 0 )
157157 $inFormName = $param;
158 - elseif ($i == 1)
 158+ elseif ( $i == 1 )
159159 $inLinkStr = $param;
160 - elseif ($i == 2)
 160+ elseif ( $i == 2 )
161161 $inLinkType = $param;
162 - elseif ($i == 3)
 162+ elseif ( $i == 3 )
163163 $inQueryStr = $param;
164164 }
165165
166 - $ad = SpecialPage::getPage('FormEdit');
 166+ $ad = SpecialPage::getPage( 'FormEdit' );
167167 $link_url = $ad->getTitle()->getLocalURL() . "/$inFormName";
168 - $link_url = str_replace(' ', '_', $link_url);
169 - if ($inQueryStr != '') {
 168+ $link_url = str_replace( ' ', '_', $link_url );
 169+ if ( $inQueryStr != '' ) {
170170 // special handling for 'post button' - query string
171171 // has to be turned into hidden inputs
172 - if ($inLinkType == 'post button') {
 172+ if ( $inLinkType == 'post button' ) {
173173 $hidden_inputs = "";
174 - $query_components = explode('&', $inQueryStr);
175 - foreach ($query_components as $query_component) {
176 - $query_component = urldecode($query_component);
177 - $var_and_val = explode('=', $query_component);
178 - if (count($var_and_val) == 2) {
 174+ $query_components = explode( '&', $inQueryStr );
 175+ foreach ( $query_components as $query_component ) {
 176+ $query_component = urldecode( $query_component );
 177+ $var_and_val = explode( '=', $query_component );
 178+ if ( count( $var_and_val ) == 2 ) {
179179 $hidden_inputs .= '<input type="hidden" name="' . $var_and_val[0] . '" value="' . $var_and_val[1] . '" /> ';
180180 }
181181 }
182182 } else {
183 - $link_url .= (strstr($link_url, '?')) ? '&' : '?';
 183+ $link_url .= ( strstr( $link_url, '?' ) ) ? '&' : '?';
184184 // URL-encode any spaces or plus-signs in the query string
185 - $inQueryStr = str_replace(array(' ', '+'),
186 - array('%20', '%2B'),
187 - $inQueryStr);
 185+ $inQueryStr = str_replace( array( ' ', '+' ),
 186+ array( '%20', '%2B' ),
 187+ $inQueryStr );
188188 $link_url .= $inQueryStr;
189189 }
190190 }
191 - if ($inLinkType == 'button') {
192 - $link_url = html_entity_decode($link_url, ENT_QUOTES);
193 - $link_url = str_replace("'", "\'", $link_url);
 191+ if ( $inLinkType == 'button' ) {
 192+ $link_url = html_entity_decode( $link_url, ENT_QUOTES );
 193+ $link_url = str_replace( "'", "\'", $link_url );
194194 $str = "<form><input type=\"button\" value=\"$inLinkStr\" onclick=\"window.location.href='$link_url'\"></form>";
195 - } elseif ($inLinkType == 'post button') {
 195+ } elseif ( $inLinkType == 'post button' ) {
196196 $str = "<form action=\"$link_url\" method=\"post\"><input type=\"submit\" value=\"$inLinkStr\">$hidden_inputs</form>";
197197 } else {
198198 $str = "<a href=\"$link_url\">$inLinkStr</a>";
199199 }
200200 // hack to remove newline from beginning of output, thanks to
201201 // http://jimbojw.com/wiki/index.php?title=Raw_HTML_Output_from_a_MediaWiki_Parser_Function
202 - return $parser->insertStripItem($str, $parser->mStripState);
 202+ return $parser->insertStripItem( $str, $parser->mStripState );
203203 }
204204
205 - static function renderFormInput (&$parser) {
 205+ static function renderFormInput ( &$parser ) {
206206 $params = func_get_args();
207207 array_shift( $params ); // don't need the parser
208208 // set defaults
@@ -209,45 +209,45 @@
210210 $inAutocompletionSource = '';
211211 $inSize = 25;
212212 // assign params - support unlabelled params, for backwards compatibility
213 - foreach ($params as $i => $param) {
214 - $elements = explode('=', $param, 2);
 213+ foreach ( $params as $i => $param ) {
 214+ $elements = explode( '=', $param, 2 );
215215 $param_name = null;
216216 $value = $param;
217 - if (count($elements) > 1) {
 217+ if ( count( $elements ) > 1 ) {
218218 $param_name = $elements[0];
219219 $value = $elements[1];
220220 }
221 - if ($param_name == 'form')
 221+ if ( $param_name == 'form' )
222222 $inFormName = $value;
223 - elseif ($param_name == 'size')
 223+ elseif ( $param_name == 'size' )
224224 $inSize = $value;
225 - elseif ($param_name == 'default value')
 225+ elseif ( $param_name == 'default value' )
226226 $inValue = $value;
227 - elseif ($param_name == 'button text')
 227+ elseif ( $param_name == 'button text' )
228228 $inButtonStr = $value;
229 - elseif ($param_name == 'query string')
 229+ elseif ( $param_name == 'query string' )
230230 $inQueryStr = $value;
231 - elseif ($param_name == 'autocomplete on category') {
 231+ elseif ( $param_name == 'autocomplete on category' ) {
232232 $inAutocompletionSource = $value;
233233 $autocompletion_type = 'category';
234 - } elseif ($param_name == 'autocomplete on namespace') {
 234+ } elseif ( $param_name == 'autocomplete on namespace' ) {
235235 $inAutocompletionSource = $value;
236236 $autocompletion_type = 'namespace';
237237 }
238 - elseif ($i == 0)
 238+ elseif ( $i == 0 )
239239 $inFormName = $param;
240 - elseif ($i == 1)
 240+ elseif ( $i == 1 )
241241 $inSize = $param;
242 - elseif ($i == 2)
 242+ elseif ( $i == 2 )
243243 $inValue = $param;
244 - elseif ($i == 3)
 244+ elseif ( $i == 3 )
245245 $inButtonStr = $param;
246 - elseif ($i == 4)
 246+ elseif ( $i == 4 )
247247 $inQueryStr = $param;
248248 }
249249
250250 $input_num = 1;
251 - if (! empty($inAutocompletionSource)) {
 251+ if ( ! empty( $inAutocompletionSource ) ) {
252252 self::$num_autocompletion_inputs++;
253253 $input_num = self::$num_autocompletion_inputs;
254254 // place the necessary Javascript on the page, and
@@ -255,13 +255,13 @@
256256 // if there's more than one autocompleted #forminput
257257 // on the page, we only need to do this the first time
258258 $autocompletion_javascript = '';
259 - if ($input_num == 1) {
 259+ if ( $input_num == 1 ) {
260260 $parser->disableCache();
261261 SFUtils::addJavascriptAndCSS();
262262 $autocompletion_javascript = SFFormUtils::autocompletionJavascript();
263263 }
264 - $autocompletion_str = SFFormInputs::createAutocompleteValuesString($inAutocompletionSource, $autocompletion_type);
265 - $javascript_text =<<<END
 264+ $autocompletion_str = SFFormInputs::createAutocompleteValuesString( $inAutocompletionSource, $autocompletion_type );
 265+ $javascript_text = <<<END
266266 <script type="text/javascript">
267267 /*<![CDATA[*/
268268 $autocompletion_javascript
@@ -271,12 +271,12 @@
272272
273273 END;
274274 global $wgOut;
275 - $wgOut->addScript($javascript_text);
 275+ $wgOut->addScript( $javascript_text );
276276 }
277277
278 - $fs = SpecialPage::getPage('FormStart');
 278+ $fs = SpecialPage::getPage( 'FormStart' );
279279 $fs_url = $fs->getTitle()->getLocalURL();
280 - if (empty($inAutocompletionSource)) {
 280+ if ( empty( $inAutocompletionSource ) ) {
281281 $str = <<<END
282282 <form action="$fs_url" method="get">
283283 <p><input type="text" name="page_name" size="$inSize" value="$inValue" />
@@ -299,27 +299,27 @@
300300 // if the add page URL looks like "index.php?title=Special:AddPage"
301301 // (i.e., it's in the default URL style), add in the title as a
302302 // hidden value
303 - if (($pos = strpos($fs_url, "title=")) > -1) {
304 - $str .= ' <input type="hidden" name="title" value="' . urldecode(substr($fs_url, $pos + 6)) . '">' . "\n";
 303+ if ( ( $pos = strpos( $fs_url, "title=" ) ) > - 1 ) {
 304+ $str .= ' <input type="hidden" name="title" value="' . urldecode( substr( $fs_url, $pos + 6 ) ) . '">' . "\n";
305305 }
306 - if ($inFormName == '') {
 306+ if ( $inFormName == '' ) {
307307 $str .= SFUtils::formDropdownHTML();
308308 } else {
309309 $str .= ' <input type="hidden" name="form" value="' . $inFormName . '">' . "\n";
310310 $str .= ' <input type="hidden" name="form2" value="' . $inFormName . '">' . "\n";
311311 }
312312 // recreate the passed-in query string as a set of hidden variables
313 - $query_components = explode('&', $inQueryStr);
314 - foreach ($query_components as $component) {
315 - $subcomponents = explode('=', $component, 2);
316 - $key = (isset($subcomponents[0])) ? $subcomponents[0] : '';
317 - $val = (isset($subcomponents[1])) ? $subcomponents[1] : '';
318 - if (! empty($key))
 313+ $query_components = explode( '&', $inQueryStr );
 314+ foreach ( $query_components as $component ) {
 315+ $subcomponents = explode( '=', $component, 2 );
 316+ $key = ( isset( $subcomponents[0] ) ) ? $subcomponents[0] : '';
 317+ $val = ( isset( $subcomponents[1] ) ) ? $subcomponents[1] : '';
 318+ if ( ! empty( $key ) )
319319 $str .= ' <input type="hidden" name="' . $key . '" value="' . $val . '">' . "\n";
320320 }
321 - wfLoadExtensionMessages('SemanticForms');
322 - $button_str = ($inButtonStr != '') ? $inButtonStr : wfMsg('sf_formstart_createoredit');
323 - if (empty($inAutocompletionSource)) {
 321+ wfLoadExtensionMessages( 'SemanticForms' );
 322+ $button_str = ( $inButtonStr != '' ) ? $inButtonStr : wfMsg( 'sf_formstart_createoredit' );
 323+ if ( empty( $inAutocompletionSource ) ) {
324324 $str .= <<<END
325325 <input type="submit" value="$button_str"></p>
326326 </form>
@@ -335,7 +335,7 @@
336336
337337 // hack to remove newline from beginning of output, thanks to
338338 // http://jimbojw.com/wiki/index.php?title=Raw_HTML_Output_from_a_MediaWiki_Parser_Function
339 - return $parser->insertStripItem($str, $parser->mStripState);
 339+ return $parser->insertStripItem( $str, $parser->mStripState );
340340 }
341341
342342 /**
@@ -344,19 +344,19 @@
345345 static function renderArrayMap( &$parser, $value = '', $delimiter = ',', $var = 'x', $formula = 'x', $new_delimiter = ', ' ) {
346346 // let '\n' represent newlines - chances that anyone will
347347 // actually need the '\n' literal are small
348 - $delimiter = str_replace('\n', "\n", $delimiter);
349 - $new_delimiter = str_replace('\n', "\n", $new_delimiter);
350 - $values_array = explode($parser->mStripState->unstripNoWiki($delimiter), $value);
 348+ $delimiter = str_replace( '\n', "\n", $delimiter );
 349+ $new_delimiter = str_replace( '\n', "\n", $new_delimiter );
 350+ $values_array = explode( $parser->mStripState->unstripNoWiki( $delimiter ), $value );
351351 $results = array();
352 - foreach ($values_array as $cur_value) {
353 - $cur_value = trim($cur_value);
 352+ foreach ( $values_array as $cur_value ) {
 353+ $cur_value = trim( $cur_value );
354354 // ignore a value if it's null
355 - if ('' != $cur_value) {
 355+ if ( '' != $cur_value ) {
356356 // remove whitespaces
357 - $results[] = str_replace($var, $cur_value, $formula);
 357+ $results[] = str_replace( $var, $cur_value, $formula );
358358 }
359359 }
360 - return implode($new_delimiter, $results);
 360+ return implode( $new_delimiter, $results );
361361 }
362362
363363 /**
@@ -365,28 +365,28 @@
366366 */
367367 static function renderArrayMapObj( &$parser, $frame, $args ) {
368368 # Set variables
369 - $value = isset($args[0]) ? trim($frame->expand($args[0])) : '';
370 - $delimiter = isset($args[1]) ? trim($frame->expand($args[1])) : ',';
371 - $var = isset($args[2]) ? trim($frame->expand($args[2], PPFrame::NO_ARGS | PPFrame::NO_TEMPLATES)) : 'x';
372 - $formula = isset($args[3]) ? $args[3] : 'x';
373 - $new_delimiter = isset($args[4]) ? trim($frame->expand($args[4])) : ', ';
 369+ $value = isset( $args[0] ) ? trim( $frame->expand( $args[0] ) ) : '';
 370+ $delimiter = isset( $args[1] ) ? trim( $frame->expand( $args[1] ) ) : ',';
 371+ $var = isset( $args[2] ) ? trim( $frame->expand( $args[2], PPFrame::NO_ARGS | PPFrame::NO_TEMPLATES ) ) : 'x';
 372+ $formula = isset( $args[3] ) ? $args[3] : 'x';
 373+ $new_delimiter = isset( $args[4] ) ? trim( $frame->expand( $args[4] ) ) : ', ';
374374 # Unstrip some
375 - $delimiter = $parser->mStripState->unstripNoWiki($delimiter);
 375+ $delimiter = $parser->mStripState->unstripNoWiki( $delimiter );
376376 # let '\n' represent newlines
377 - $delimiter = str_replace('\n', "\n", $delimiter);
378 - $new_delimiter = str_replace('\n', "\n", $new_delimiter);
 377+ $delimiter = str_replace( '\n', "\n", $delimiter );
 378+ $new_delimiter = str_replace( '\n', "\n", $new_delimiter );
379379
380 - $values_array = explode($delimiter, $value);
 380+ $values_array = explode( $delimiter, $value );
381381 $results_array = array();
382 - foreach( $values_array as $old_value ) {
383 - $old_value = trim($old_value);
384 - if( $old_value == '' ) continue;
385 - $result_value = $frame->expand($formula, PPFrame::NO_ARGS | PPFrame::NO_TEMPLATES);
386 - $result_value = str_replace($var, $old_value, $result_value);
387 - $result_value = $parser->preprocessToDom($result_value, $frame->isTemplate() ? Parser::PTD_FOR_INCLUSION : 0);
388 - $results_array[] = trim($frame->expand($result_value));
 382+ foreach ( $values_array as $old_value ) {
 383+ $old_value = trim( $old_value );
 384+ if ( $old_value == '' ) continue;
 385+ $result_value = $frame->expand( $formula, PPFrame::NO_ARGS | PPFrame::NO_TEMPLATES );
 386+ $result_value = str_replace( $var, $old_value, $result_value );
 387+ $result_value = $parser->preprocessToDom( $result_value, $frame->isTemplate() ? Parser::PTD_FOR_INCLUSION : 0 );
 388+ $results_array[] = trim( $frame->expand( $result_value ) );
389389 }
390 - return implode($new_delimiter, $results_array);
 390+ return implode( $new_delimiter, $results_array );
391391 }
392392
393393 /**
@@ -394,20 +394,20 @@
395395 */
396396 static function renderArrayMapTemplate( &$parser, $value = '', $template = '', $delimiter = ',', $new_delimiter = ', ' ) {
397397 # let '\n' represent newlines
398 - $delimiter = str_replace('\n', "\n", $delimiter);
399 - $new_delimiter = str_replace('\n', "\n", $new_delimiter);
400 - $values_array = explode($parser->mStripState->unstripNoWiki($delimiter), $value);
 398+ $delimiter = str_replace( '\n', "\n", $delimiter );
 399+ $new_delimiter = str_replace( '\n', "\n", $new_delimiter );
 400+ $values_array = explode( $parser->mStripState->unstripNoWiki( $delimiter ), $value );
401401 $results = array();
402 - $template = trim($template);
403 - foreach ($values_array as $cur_value) {
404 - $cur_value = trim($cur_value);
 402+ $template = trim( $template );
 403+ foreach ( $values_array as $cur_value ) {
 404+ $cur_value = trim( $cur_value );
405405 // ignore a value if it's null
406 - if ('' != $cur_value) {
 406+ if ( '' != $cur_value ) {
407407 // remove whitespaces
408 - $results[] = '{{'.$template.'|'.$cur_value.'}}';
 408+ $results[] = '{{' . $template . '|' . $cur_value . '}}';
409409 }
410410 }
411 - return array(implode($new_delimiter, $results), 'noparse' => false, 'isHTML' => false);
 411+ return array( implode( $new_delimiter, $results ), 'noparse' => false, 'isHTML' => false );
412412 }
413413
414414 /**
@@ -416,26 +416,26 @@
417417 */
418418 static function renderArrayMapTemplateObj( &$parser, $frame, $args ) {
419419 # Set variables
420 - $value = isset($args[0]) ? trim($frame->expand($args[0])) : '';
421 - $template = isset($args[1]) ? trim($frame->expand($args[1])) : '';
422 - $delimiter = isset($args[2]) ? trim($frame->expand($args[2])) : ',';
423 - $new_delimiter = isset($args[3]) ? trim($frame->expand($args[3])) : ', ';
 420+ $value = isset( $args[0] ) ? trim( $frame->expand( $args[0] ) ) : '';
 421+ $template = isset( $args[1] ) ? trim( $frame->expand( $args[1] ) ) : '';
 422+ $delimiter = isset( $args[2] ) ? trim( $frame->expand( $args[2] ) ) : ',';
 423+ $new_delimiter = isset( $args[3] ) ? trim( $frame->expand( $args[3] ) ) : ', ';
424424 # Unstrip some
425 - $delimiter = $parser->mStripState->unstripNoWiki($delimiter);
 425+ $delimiter = $parser->mStripState->unstripNoWiki( $delimiter );
426426 # let '\n' represent newlines
427 - $delimiter = str_replace('\n', "\n", $delimiter);
428 - $new_delimiter = str_replace('\n', "\n", $new_delimiter);
 427+ $delimiter = str_replace( '\n', "\n", $delimiter );
 428+ $new_delimiter = str_replace( '\n', "\n", $new_delimiter );
429429
430 - $values_array = explode($delimiter, $value);
 430+ $values_array = explode( $delimiter, $value );
431431 $results_array = array();
432 - foreach( $values_array as $old_value ) {
433 - $old_value = trim($old_value);
434 - if( $old_value == '' ) continue;
 432+ foreach ( $values_array as $old_value ) {
 433+ $old_value = trim( $old_value );
 434+ if ( $old_value == '' ) continue;
435435 $results_array[] = $parser->replaceVariables(
436 - implode('', $frame->virtualBracketedImplode( '{{', '|', '}}',
437 - $template, '1='.$old_value )), $frame);
 436+ implode( '', $frame->virtualBracketedImplode( '{{', '|', '}}',
 437+ $template, '1=' . $old_value ) ), $frame );
438438 }
439 - return implode($new_delimiter, $results_array);
 439+ return implode( $new_delimiter, $results_array );
440440 }
441441
442442 }
Index: trunk/extensions/SemanticForms/includes/SF_FormEditPage.php
@@ -13,10 +13,10 @@
1414 function __construct( $article, $form_name = '' ) {
1515 global $wgRequest;
1616 parent::__construct( $article );
17 - wfLoadExtensionMessages('SemanticForms');
 17+ wfLoadExtensionMessages( 'SemanticForms' );
1818 $this->action = 'formedit';
19 - $form_name = $wgRequest->getText('form', $form_name);
20 - $this->form = Title::makeTitleSafe(SF_NS_FORM, $form_name);
 19+ $form_name = $wgRequest->getText( 'form', $form_name );
 20+ $this->form = Title::makeTitleSafe( SF_NS_FORM, $form_name );
2121 $this->form_name = $form_name;
2222 }
2323
@@ -27,15 +27,15 @@
2828 function setHeaders() {
2929 parent::setHeaders();
3030 global $wgOut, $wgTitle;
31 - if( !$this->isConflict ) {
 31+ if ( !$this->isConflict ) {
3232 $wgOut->setPageTitle( wfMsg( 'sf_formedit_title',
3333 $this->form->getText(), $wgTitle->getPrefixedText() ) );
3434 }
3535 }
3636
3737 protected function displayPreviewArea( $previewOutput, $isOnTop = false ) {
38 - if ($this->textbox1 != null)
39 - parent::displayPreviewArea($previewOutput);
 38+ if ( $this->textbox1 != null )
 39+ parent::displayPreviewArea( $previewOutput );
4040 }
4141
4242 protected function importContentFormData( &$request ) {
@@ -45,11 +45,11 @@
4646 protected function showContentForm() {
4747 global $sfgIP;
4848 $target_title = $this->mArticle->getTitle();
49 - $target_name = SFLinkUtils::titleString($target_title);
50 - if ($target_title->exists()) {
51 - SFEditData::printEditForm($this->form_name, $target_name, $this->textbox1);
 49+ $target_name = SFLinkUtils::titleString( $target_title );
 50+ if ( $target_title->exists() ) {
 51+ SFEditData::printEditForm( $this->form_name, $target_name, $this->textbox1 );
5252 } else {
53 - SFAddData::printAddForm($this->form_name, $target_name, array(), $this->textbox1);
 53+ SFAddData::printAddForm( $this->form_name, $target_name, array(), $this->textbox1 );
5454 }
5555 // @todo This needs a proper form builder
5656 }
Index: trunk/extensions/SemanticForms/includes/SF_GlobalFunctions.php
@@ -7,9 +7,9 @@
88
99 if ( !defined( 'MEDIAWIKI' ) ) die();
1010
11 -define('SF_VERSION','1.9');
 11+define( 'SF_VERSION', '1.9' );
1212
13 -$wgExtensionCredits['specialpage'][]= array(
 13+$wgExtensionCredits['specialpage'][] = array(
1414 'path' => __FILE__,
1515 'name' => 'Semantic Forms',
1616 'version' => SF_VERSION,
@@ -19,11 +19,11 @@
2020 );
2121
2222 // constants for special properties
23 -define('SF_SP_HAS_DEFAULT_FORM', 1);
24 -define('SF_SP_HAS_ALTERNATE_FORM', 2);
25 -define('SF_SP_CREATES_PAGES_WITH_FORM', 3);
26 -define('SF_SP_PAGE_HAS_DEFAULT_FORM', 4);
27 -define('SF_SP_HAS_FIELD_LABEL_FORMAT', 5);
 23+define( 'SF_SP_HAS_DEFAULT_FORM', 1 );
 24+define( 'SF_SP_HAS_ALTERNATE_FORM', 2 );
 25+define( 'SF_SP_CREATES_PAGES_WITH_FORM', 3 );
 26+define( 'SF_SP_PAGE_HAS_DEFAULT_FORM', 4 );
 27+define( 'SF_SP_HAS_FIELD_LABEL_FORMAT', 5 );
2828
2929 $wgExtensionFunctions[] = 'sfgSetupExtension';
3030 $wgExtensionFunctions[] = 'sfgParserFunctions';
@@ -77,7 +77,7 @@
7878 $wgAutoloadClasses['SFRunQuery'] = $sfgIP . '/specials/SF_RunQuery.php';
7979 $wgSpecialPageGroups['RunQuery'] = 'sf_group';
8080 // different upload-window class for MW 1.16+
81 -if (class_exists('HTMLTextField')) { // added in MW 1.16
 81+if ( class_exists( 'HTMLTextField' ) ) { // added in MW 1.16
8282 $wgSpecialPages['UploadWindow'] = 'SFUploadWindow2';
8383 $wgAutoloadClasses['SFUploadWindow2'] = $sfgIP . '/specials/SF_UploadWindow2.php';
8484 } else {
@@ -99,7 +99,7 @@
100100 $wgAutoloadClasses['SFAutocompleteAPI'] = $sfgIP . '/includes/SF_AutocompleteAPI.php';
101101 $wgJobClasses['createPage'] = 'SFCreatePageJob';
102102 $wgAutoloadClasses['SFCreatePageJob'] = $sfgIP . '/includes/SF_CreatePageJob.php';
103 -require_once($sfgIP . '/languages/SF_Language.php');
 103+require_once( $sfgIP . '/languages/SF_Language.php' );
104104
105105 $wgExtensionMessagesFiles['SemanticForms'] = $sfgIP . '/languages/SF_Messages.php';
106106 $wgExtensionAliasesFiles['SemanticForms'] = $sfgIP . '/languages/SF_Aliases.php';
@@ -118,7 +118,7 @@
119119
120120 function sfgParserFunctions() {
121121 global $wgHooks, $wgParser;
122 - if( defined( 'MW_SUPPORTS_PARSERFIRSTCALLINIT' ) ) {
 122+ if ( defined( 'MW_SUPPORTS_PARSERFIRSTCALLINIT' ) ) {
123123 $wgHooks['ParserFirstCallInit'][] = 'SFParserFunctions::registerFunctions';
124124 } else {
125125 if ( class_exists( 'StubObject' ) && !StubObject::isRealObject( $wgParser ) ) {
@@ -140,10 +140,10 @@
141141 function sffInitNamespaces() {
142142 global $wgExtraNamespaces, $wgNamespaceAliases, $wgNamespacesWithSubpages, $wgLanguageCode, $sfgContLang;
143143
144 - sffInitContentLanguage($wgLanguageCode);
 144+ sffInitContentLanguage( $wgLanguageCode );
145145
146146 // Register namespace identifiers
147 - if (!is_array($wgExtraNamespaces)) { $wgExtraNamespaces=array(); }
 147+ if ( !is_array( $wgExtraNamespaces ) ) { $wgExtraNamespaces = array(); }
148148 $wgExtraNamespaces = $wgExtraNamespaces + $sfgContLang->getNamespaces();
149149 $wgNamespaceAliases = $wgNamespaceAliases + $sfgContLang->getNamespaceAliases();
150150
@@ -163,19 +163,19 @@
164164 * determine labels for additional namespaces. In contrast, messages
165165 * can be initialised much later, when they are actually needed.
166166 */
167 -function sffInitContentLanguage($langcode) {
 167+function sffInitContentLanguage( $langcode ) {
168168 global $sfgIP, $sfgContLang;
169169
170 - if (!empty($sfgContLang)) { return; }
 170+ if ( !empty( $sfgContLang ) ) { return; }
171171
172172 $cont_lang_class = 'SF_Language' . str_replace( '-', '_', ucfirst( $langcode ) );
173 - if (file_exists($sfgIP . '/languages/'. $cont_lang_class . '.php')) {
174 - include_once( $sfgIP . '/languages/'. $cont_lang_class . '.php' );
 173+ if ( file_exists( $sfgIP . '/languages/' . $cont_lang_class . '.php' ) ) {
 174+ include_once( $sfgIP . '/languages/' . $cont_lang_class . '.php' );
175175 }
176176
177177 // fallback if language not supported
178 - if ( !class_exists($cont_lang_class)) {
179 - include_once($sfgIP . '/languages/SF_LanguageEn.php');
 178+ if ( !class_exists( $cont_lang_class ) ) {
 179+ include_once( $sfgIP . '/languages/SF_LanguageEn.php' );
180180 $cont_lang_class = 'SF_LanguageEn';
181181 }
182182
@@ -187,19 +187,19 @@
188188 * must happen after the content language was initialised, since
189189 * this language is used as a fallback.
190190 */
191 -function sffInitUserLanguage($langcode) {
 191+function sffInitUserLanguage( $langcode ) {
192192 global $sfgIP, $sfgLang;
193193
194 - if (!empty($sfgLang)) { return; }
 194+ if ( !empty( $sfgLang ) ) { return; }
195195
196196 $sfLangClass = 'SF_Language' . str_replace( '-', '_', ucfirst( $langcode ) );
197197
198 - if (file_exists($sfgIP . '/languages/'. $sfLangClass . '.php')) {
199 - include_once( $sfgIP . '/languages/'. $sfLangClass . '.php' );
 198+ if ( file_exists( $sfgIP . '/languages/' . $sfLangClass . '.php' ) ) {
 199+ include_once( $sfgIP . '/languages/' . $sfLangClass . '.php' );
200200 }
201201
202202 // fallback if language not supported
203 - if ( !class_exists($sfLangClass)) {
 203+ if ( !class_exists( $sfLangClass ) ) {
204204 global $sfgContLang;
205205 $sfgLang = $sfgContLang;
206206 } else {
@@ -207,24 +207,24 @@
208208 }
209209 }
210210
211 -function sffAddToAdminLinks(&$admin_links_tree) {
212 - $data_structure_label = wfMsg('smw_adminlinks_datastructure');
213 - $data_structure_section = $admin_links_tree->getSection($data_structure_label);
214 - if (is_null($data_structure_section))
 211+function sffAddToAdminLinks( &$admin_links_tree ) {
 212+ $data_structure_label = wfMsg( 'smw_adminlinks_datastructure' );
 213+ $data_structure_section = $admin_links_tree->getSection( $data_structure_label );
 214+ if ( is_null( $data_structure_section ) )
215215 return true;
216 - $smw_row = $data_structure_section->getRow('smw');
217 - $smw_row->addItem(ALItem::newFromSpecialPage('Templates'), 'Properties');
218 - $smw_row->addItem(ALItem::newFromSpecialPage('Forms'), 'SemanticStatistics');
219 - $smw_admin_row = $data_structure_section->getRow('smw_admin');
220 - $smw_admin_row->addItem(ALItem::newFromSpecialPage('CreateClass'), 'SMWAdmin');
221 - $smw_admin_row->addItem(ALItem::newFromSpecialPage('CreateProperty'), 'SMWAdmin');
222 - $smw_admin_row->addItem(ALItem::newFromSpecialPage('CreateTemplate'), 'SMWAdmin');
223 - $smw_admin_row->addItem(ALItem::newFromSpecialPage('CreateForm'), 'SMWAdmin');
224 - $smw_admin_row->addItem(ALItem::newFromSpecialPage('CreateCategory'), 'SMWAdmin');
225 - $smw_docu_row = $data_structure_section->getRow('smw_docu');
226 - $sf_name = wfMsg('specialpages-group-sf_group');
227 - $sf_docu_label = wfMsg('adminlinks_documentation', $sf_name);
228 - $smw_docu_row->addItem(ALItem::newFromExternalLink("http://www.mediawiki.org/wiki/Extension:Semantic_Forms", $sf_docu_label));
 216+ $smw_row = $data_structure_section->getRow( 'smw' );
 217+ $smw_row->addItem( ALItem::newFromSpecialPage( 'Templates' ), 'Properties' );
 218+ $smw_row->addItem( ALItem::newFromSpecialPage( 'Forms' ), 'SemanticStatistics' );
 219+ $smw_admin_row = $data_structure_section->getRow( 'smw_admin' );
 220+ $smw_admin_row->addItem( ALItem::newFromSpecialPage( 'CreateClass' ), 'SMWAdmin' );
 221+ $smw_admin_row->addItem( ALItem::newFromSpecialPage( 'CreateProperty' ), 'SMWAdmin' );
 222+ $smw_admin_row->addItem( ALItem::newFromSpecialPage( 'CreateTemplate' ), 'SMWAdmin' );
 223+ $smw_admin_row->addItem( ALItem::newFromSpecialPage( 'CreateForm' ), 'SMWAdmin' );
 224+ $smw_admin_row->addItem( ALItem::newFromSpecialPage( 'CreateCategory' ), 'SMWAdmin' );
 225+ $smw_docu_row = $data_structure_section->getRow( 'smw_docu' );
 226+ $sf_name = wfMsg( 'specialpages-group-sf_group' );
 227+ $sf_docu_label = wfMsg( 'adminlinks_documentation', $sf_name );
 228+ $smw_docu_row->addItem( ALItem::newFromExternalLink( "http://www.mediawiki.org/wiki/Extension:Semantic_Forms", $sf_docu_label ) );
229229
230230 return true;
231231 }
Index: trunk/extensions/SemanticForms/includes/SF_AutocompleteAPI.php
@@ -10,15 +10,15 @@
1111 * Protect against register_globals vulnerabilities.
1212 * This line must be present before any global variable is referenced.
1313 */
14 -if (!defined('MEDIAWIKI')) die();
 14+if ( !defined( 'MEDIAWIKI' ) ) die();
1515
1616 /**
1717 * @addtogroup API
1818 */
1919 class SFAutocompleteAPI extends ApiBase {
2020
21 - public function __construct($query, $moduleName) {
22 - parent :: __construct($query, $moduleName);
 21+ public function __construct( $query, $moduleName ) {
 22+ parent :: __construct( $query, $moduleName );
2323 }
2424
2525 public function execute() {
@@ -34,36 +34,36 @@
3535 $external_url = $params['external_url'];
3636 $limit = $params['limit'];
3737
38 - if (strlen($substr) == 0)
 38+ if ( strlen( $substr ) == 0 )
3939 {
40 - $this->dieUsage("The substring must be specified", 'param_substr');
 40+ $this->dieUsage( "The substring must be specified", 'param_substr' );
4141 }
42 - if ($attribute != '') {
43 - $data = self::getAllValuesForProperty(false, $attribute, $substr);
44 - } elseif ($relation != '') {
45 - $data = self::getAllValuesForProperty(true, $relation, $substr);
46 - } elseif ($category != '') {
47 - $data = SFUtils::getAllPagesForCategory($category, 3, $substr);
48 - } elseif ($concept != '') {
49 - $data = SFUtils::getAllPagesForConcept($concept, $substr);
50 - } elseif ($namespace != '') {
 42+ if ( $attribute != '' ) {
 43+ $data = self::getAllValuesForProperty( false, $attribute, $substr );
 44+ } elseif ( $relation != '' ) {
 45+ $data = self::getAllValuesForProperty( true, $relation, $substr );
 46+ } elseif ( $category != '' ) {
 47+ $data = SFUtils::getAllPagesForCategory( $category, 3, $substr );
 48+ } elseif ( $concept != '' ) {
 49+ $data = SFUtils::getAllPagesForConcept( $concept, $substr );
 50+ } elseif ( $namespace != '' ) {
5151 // special handling for main (blank) namespace
52 - if ($namespace == 'main')
 52+ if ( $namespace == 'main' )
5353 $namespace = '';
54 - $data = SFUtils::getAllPagesForNamespace($namespace, $substr);
55 - } elseif ($external_url != '') {
56 - $data = SFUtils::getValuesFromExternalURL($external_url, $substr);
 54+ $data = SFUtils::getAllPagesForNamespace( $namespace, $substr );
 55+ } elseif ( $external_url != '' ) {
 56+ $data = SFUtils::getValuesFromExternalURL( $external_url, $substr );
5757 } else {
5858 $data = array();
5959 }
60 - if (count($data)<=0) {
 60+ if ( count( $data ) <= 0 ) {
6161 return;
6262 }
6363
6464 // Set top-level elements
6565 $result = $this->getResult();
66 - $result->setIndexedTagName($data, 'p');
67 - $result->addValue(null, $this->getModuleName(), $data);
 66+ $result->setIndexedTagName( $data, 'p' );
 67+ $result->addValue( null, $this->getModuleName(), $data );
6868 }
6969
7070 protected function getAllowedParams() {
@@ -114,40 +114,40 @@
115115 return __CLASS__ . ': $Id$';
116116 }
117117
118 - public static function getAllValuesForProperty($is_relation, $property_name, $substring = null) {
 118+ public static function getAllValuesForProperty( $is_relation, $property_name, $substring = null ) {
119119 global $sfgMaxAutocompleteValues;
120120
121121 $values = array();
122122 $db = wfGetDB( DB_SLAVE );
123123 $sql_options = array();
124124 $sql_options['LIMIT'] = $sfgMaxAutocompleteValues;
125 - if ($is_relation) {
 125+ if ( $is_relation ) {
126126 $value_field = 'o_ids.smw_title';
127 - $from_clause = $db->tableName('smw_rels2') . " r JOIN " . $db->tableName('smw_ids') . " p_ids ON r.p_id = p_ids.smw_id JOIN " . $db->tableName('smw_ids') . " o_ids ON r.o_id = o_ids.smw_id";
 127+ $from_clause = $db->tableName( 'smw_rels2' ) . " r JOIN " . $db->tableName( 'smw_ids' ) . " p_ids ON r.p_id = p_ids.smw_id JOIN " . $db->tableName( 'smw_ids' ) . " o_ids ON r.o_id = o_ids.smw_id";
128128 } else {
129129 $value_field = 'a.value_xsd';
130 - $from_clause = $db->tableName('smw_atts2') . " a JOIN " . $db->tableName('smw_ids') . " p_ids ON a.p_id = p_ids.smw_id";
 130+ $from_clause = $db->tableName( 'smw_atts2' ) . " a JOIN " . $db->tableName( 'smw_ids' ) . " p_ids ON a.p_id = p_ids.smw_id";
131131 }
132 - $property_name = str_replace(' ', '_', $property_name);
 132+ $property_name = str_replace( ' ', '_', $property_name );
133133 $conditions = "p_ids.smw_title = '$property_name'";
134 - if ($substring != null) {
135 - $substring = str_replace("'", "\'", strtolower($substring));
 134+ if ( $substring != null ) {
 135+ $substring = str_replace( "'", "\'", strtolower( $substring ) );
136136 // utf8 conversion is needed in case MediaWiki is using
137137 // binary data storage
138138 $conditions .= " AND (REPLACE(LOWER(CONVERT($value_field USING utf8)),'_',' ') LIKE '" . $substring . "%' OR REPLACE(LOWER(CONVERT($value_field USING utf8)),'_',' ') LIKE '% " . $substring . "%')";
139139 }
140140 $sql_options['ORDER BY'] = $value_field;
141 - $res = $db->select($from_clause, "DISTINCT $value_field",
142 - $conditions, __METHOD__, $sql_options);
143 - while ($row = $db->fetchRow($res)) {
144 - if ($substring != null) {
145 - $values[] = array('title' => str_replace('_', ' ', $row[0]));
 141+ $res = $db->select( $from_clause, "DISTINCT $value_field",
 142+ $conditions, __METHOD__, $sql_options );
 143+ while ( $row = $db->fetchRow( $res ) ) {
 144+ if ( $substring != null ) {
 145+ $values[] = array( 'title' => str_replace( '_', ' ', $row[0] ) );
146146 } else {
147 - $cur_value = str_replace("'", "\'", $row[0]);
148 - $values[] = str_replace('_', ' ', $cur_value);
 147+ $cur_value = str_replace( "'", "\'", $row[0] );
 148+ $values[] = str_replace( '_', ' ', $cur_value );
149149 }
150150 }
151 - $db->freeResult($res);
 151+ $db->freeResult( $res );
152152 return $values;
153153 }
154154 }
Index: trunk/extensions/SemanticForms/includes/SF_CreatePageJob.php
@@ -23,7 +23,7 @@
2424 wfProfileOut( __METHOD__ );
2525 return false;
2626 }
27 - $article = new Article($this->title);
 27+ $article = new Article( $this->title );
2828 if ( !$article ) {
2929 $this->error = 'createPage: Article not found "' . $this->title->getPrefixedDBkey() . '"';
3030 wfProfileOut( __METHOD__ );
@@ -36,9 +36,9 @@
3737 // replacement
3838 global $wgUser;
3939 $actual_user = $wgUser;
40 - $wgUser = User::newFromId($this->params['user_id']);
41 - $edit_summary = ''; //$this->params['edit_summary'];
42 - $article->doEdit($page_text, $edit_summary);
 40+ $wgUser = User::newFromId( $this->params['user_id'] );
 41+ $edit_summary = ''; // $this->params['edit_summary'];
 42+ $article->doEdit( $page_text, $edit_summary );
4343 $wgUser = $actual_user;
4444 wfProfileOut( __METHOD__ );
4545 return true;
Index: trunk/extensions/SemanticForms/languages/SF_LanguageEs.php
@@ -7,13 +7,13 @@
88
99 /* private */ var $m_SpecialProperties = array(
1010 // always start upper-case
11 - SF_SP_HAS_DEFAULT_FORM => 'Usa el formulario por defecto', //Has default form
12 - SF_SP_HAS_ALTERNATE_FORM => 'Usa el formulario alternativo'//Has alternate form
 11+ SF_SP_HAS_DEFAULT_FORM => 'Usa el formulario por defecto', // Has default form
 12+ SF_SP_HAS_ALTERNATE_FORM => 'Usa el formulario alternativo'// Has alternate form
1313 );
1414
1515 var $m_Namespaces = array(
16 - SF_NS_FORM => 'Formulario',//Form
17 - SF_NS_FORM_TALK => 'Discusión_formulario'//Form_talk
 16+ SF_NS_FORM => 'Formulario',// Form
 17+ SF_NS_FORM_TALK => 'Discusión_formulario'// Form_talk
1818 );
1919
2020 }
Index: trunk/extensions/SemanticForms/languages/SF_LanguageFr.php
@@ -6,7 +6,7 @@
77 class SF_LanguageFr extends SF_Language {
88
99 /* private */ var $m_SpecialProperties = array(
10 - //always start upper-case
 10+ // always start upper-case
1111 SF_SP_HAS_DEFAULT_FORM => 'Utilise le formulaire',
1212 SF_SP_HAS_ALTERNATE_FORM => 'Utilise le formulaire alternatif'
1313 );
Index: trunk/extensions/SemanticForms/languages/SF_LanguageNl.php
@@ -7,7 +7,7 @@
88
99 class SF_LanguageNl extends SF_Language {
1010 /* private */ var $m_SpecialProperties = array(
11 - //always start upper-case
 11+ // always start upper-case
1212 SF_SP_HAS_DEFAULT_FORM => 'Heeft standaard formulier',
1313 SF_SP_HAS_ALTERNATE_FORM => 'Heeft formulier',
1414 );
Index: trunk/extensions/SemanticForms/languages/SF_LanguageCa.php
@@ -7,13 +7,13 @@
88
99 /* private */ var $m_SpecialProperties = array(
1010 // always start upper-case
11 - SF_SP_HAS_DEFAULT_FORM => 'Fa servir el formulari per defecte', //Has default form
12 - SF_SP_HAS_ALTERNATE_FORM => 'Fa servir el formulari alternatiu'//Has alternate form
 11+ SF_SP_HAS_DEFAULT_FORM => 'Fa servir el formulari per defecte', // Has default form
 12+ SF_SP_HAS_ALTERNATE_FORM => 'Fa servir el formulari alternatiu'// Has alternate form
1313 );
1414
1515 var $m_Namespaces = array(
16 - SF_NS_FORM => 'Formulari',//Form
17 - SF_NS_FORM_TALK => 'Discussió_formulari'//Form_talk
 16+ SF_NS_FORM => 'Formulari',// Form
 17+ SF_NS_FORM_TALK => 'Discussió_formulari'// Form_talk
1818 );
1919
2020 }
Index: trunk/extensions/SemanticForms/languages/SF_LanguageFa.php
@@ -6,14 +6,14 @@
77 class SF_LanguageFa extends SF_Language {
88
99 /* private */ var $m_SpecialProperties = array(
10 - //always start upper-case
11 - SF_SP_HAS_DEFAULT_FORM => 'فرم پیش‌فرض دارد',//Has default form
12 - SF_SP_HAS_ALTERNATE_FORM => 'فرم مشابه دارد'//Has alternate form
 10+ // always start upper-case
 11+ SF_SP_HAS_DEFAULT_FORM => 'فرم پیش‌فرض دارد',// Has default form
 12+ SF_SP_HAS_ALTERNATE_FORM => 'فرم مشابه دارد'// Has alternate form
1313 );
1414
1515 var $m_Namespaces = array(
16 - SF_NS_FORM => 'فرم',//Form
17 - SF_NS_FORM_TALK => 'بحث_فرم'//Form_talk
 16+ SF_NS_FORM => 'فرم',// Form
 17+ SF_NS_FORM_TALK => 'بحث_فرم'// Form_talk
1818 );
1919
2020 }
Index: trunk/extensions/SemanticForms/languages/SF_LanguageDe_formal.php
@@ -6,7 +6,7 @@
77 class SF_LanguageDe_formal extends SF_Language {
88
99 /* private */ var $m_SpecialProperties = array(
10 - //always start upper-case
 10+ // always start upper-case
1111 SF_SP_HAS_DEFAULT_FORM => 'Hat Standardformular',
1212 SF_SP_HAS_ALTERNATE_FORM => 'Hat Alternativformular'
1313 );
Index: trunk/extensions/SemanticForms/languages/SF_LanguageDe.php
@@ -6,7 +6,7 @@
77 class SF_LanguageDe extends SF_Language {
88
99 /* private */ var $m_SpecialProperties = array(
10 - //always start upper-case
 10+ // always start upper-case
1111 SF_SP_HAS_DEFAULT_FORM => 'Hat Standardformular',
1212 SF_SP_HAS_ALTERNATE_FORM => 'Hat Alternativformular'
1313 );
Index: trunk/extensions/SemanticForms/languages/SF_LanguageZh_tw.php
@@ -6,9 +6,9 @@
77 class SF_LanguageZh_tw extends SF_Language {
88
99 /* private */ var $m_SpecialProperties = array(
10 - //always start upper-case
11 - SF_SP_HAS_DEFAULT_FORM => '預設表單', //(Has default form)
12 - SF_SP_HAS_ALTERNATE_FORM => '代用表單' //(Has alternate form)
 10+ // always start upper-case
 11+ SF_SP_HAS_DEFAULT_FORM => '預設表單', // (Has default form)
 12+ SF_SP_HAS_ALTERNATE_FORM => '代用表單' // (Has alternate form)
1313 );
1414
1515 var $m_Namespaces = array(
@@ -18,5 +18,5 @@
1919
2020 }
2121
22 -$m_SpecialPropertyAliases ['設有表單'] = SF_SP_HAS_DEFAULT_FORM; //(Has default form) //Adding the item "Has alternate form", this item will not be suitable for translating into “設有表單”. It has changed to use “預設表單”.
 22+$m_SpecialPropertyAliases ['設有表單'] = SF_SP_HAS_DEFAULT_FORM; // (Has default form) //Adding the item "Has alternate form", this item will not be suitable for translating into “設有表單”. It has changed to use “預設表單”.
2323
Index: trunk/extensions/SemanticForms/languages/SF_LanguageArz.php
@@ -7,13 +7,13 @@
88
99 /* private */ var $m_SpecialProperties = array(
1010 // always start upper-case
11 - SF_SP_HAS_DEFAULT_FORM => 'لديه استمارة افتراضية',//Has default form
12 - SF_SP_HAS_ALTERNATE_FORM => 'لديه استمارة بديلة'//Has alternate form
 11+ SF_SP_HAS_DEFAULT_FORM => 'لديه استمارة افتراضية',// Has default form
 12+ SF_SP_HAS_ALTERNATE_FORM => 'لديه استمارة بديلة'// Has alternate form
1313 );
1414
1515 var $m_Namespaces = array(
16 - SF_NS_FORM => 'استمارة',//Form
17 - SF_NS_FORM_TALK => 'نقاش_الاستمارة'//Form_talk
 16+ SF_NS_FORM => 'استمارة',// Form
 17+ SF_NS_FORM_TALK => 'نقاش_الاستمارة'// Form_talk
1818 );
1919
2020 }
Index: trunk/extensions/SemanticForms/languages/SF_LanguageHe.php
@@ -6,7 +6,7 @@
77 class SF_LanguageHe extends SF_Language {
88
99 /* private */ var $m_SpecialProperties = array(
10 - //always start upper-case
 10+ // always start upper-case
1111 SF_SP_HAS_DEFAULT_FORM => 'משתמש בטופס',
1212 SF_SP_HAS_ALTERNATE_FORM => 'משתמש בטופס'
1313 );
Index: trunk/extensions/SemanticForms/languages/SF_LanguageZh_cn.php
@@ -6,9 +6,9 @@
77 class SF_LanguageZh_cn extends SF_Language {
88
99 /* private */ var $m_SpecialProperties = array(
10 - //always start upper-case
11 - SF_SP_HAS_DEFAULT_FORM => '预设表单', //(Has default form)
12 - SF_SP_HAS_ALTERNATE_FORM => '代用表单' //(Has alternate form)
 10+ // always start upper-case
 11+ SF_SP_HAS_DEFAULT_FORM => '预设表单', // (Has default form)
 12+ SF_SP_HAS_ALTERNATE_FORM => '代用表单' // (Has alternate form)
1313 );
1414
1515 var $m_Namespaces = array(
@@ -18,5 +18,5 @@
1919
2020 }
2121
22 -$m_SpecialPropertyAliases['设有表单'] = SF_SP_HAS_DEFAULT_FORM; //(Has default form) //Adding the item "Has alternate form", this item will not be suitable for translating into “设有表单". It has changed to use “预设表单".
 22+$m_SpecialPropertyAliases['设有表单'] = SF_SP_HAS_DEFAULT_FORM; // (Has default form) //Adding the item "Has alternate form", this item will not be suitable for translating into “设有表单". It has changed to use “预设表单".
2323
Index: trunk/extensions/SemanticForms/languages/SF_LanguageAr.php
@@ -7,13 +7,13 @@
88
99 /* private */ var $m_SpecialProperties = array(
1010 // always start upper-case
11 - SF_SP_HAS_DEFAULT_FORM => 'لديه استمارة افتراضية',//Has default form
12 - SF_SP_HAS_ALTERNATE_FORM => 'لديه استمارة بديلة'//Has alternate form
 11+ SF_SP_HAS_DEFAULT_FORM => 'لديه استمارة افتراضية',// Has default form
 12+ SF_SP_HAS_ALTERNATE_FORM => 'لديه استمارة بديلة'// Has alternate form
1313 );
1414
1515 var $m_Namespaces = array(
16 - SF_NS_FORM => 'استمارة',//Form
17 - SF_NS_FORM_TALK => 'نقاش_الاستمارة'//Form_talk
 16+ SF_NS_FORM => 'استمارة',// Form
 17+ SF_NS_FORM_TALK => 'نقاش_الاستمارة'// Form_talk
1818 );
1919
2020 }
Index: trunk/extensions/SemanticForms/languages/SF_LanguagePt_br.php
@@ -6,7 +6,7 @@
77 class SF_LanguagePt_br extends SF_Language {
88
99 /* private */ var $m_SpecialProperties = array(
10 - //always start upper-case
 10+ // always start upper-case
1111 SF_SP_HAS_DEFAULT_FORM => 'Has default form',
1212 SF_SP_HAS_ALTERNATE_FORM => 'Has alternate form'
1313 );

Status & tagging log