Index: trunk/extensions/SemanticForms/specials/SF_CreateCategory.php |
— | — | @@ -6,7 +6,7 @@ |
7 | 7 | * @author Yaron Koren |
8 | 8 | */ |
9 | 9 | |
10 | | -if (!defined('MEDIAWIKI')) die(); |
| 10 | +if ( !defined( 'MEDIAWIKI' ) ) die(); |
11 | 11 | |
12 | 12 | class SFCreateCategory extends SpecialPage { |
13 | 13 | |
— | — | @@ -14,27 +14,27 @@ |
15 | 15 | * Constructor |
16 | 16 | */ |
17 | 17 | function SFCreateCategory() { |
18 | | - SpecialPage::SpecialPage('CreateCategory'); |
19 | | - wfLoadExtensionMessages('SemanticForms'); |
| 18 | + SpecialPage::SpecialPage( 'CreateCategory' ); |
| 19 | + wfLoadExtensionMessages( 'SemanticForms' ); |
20 | 20 | } |
21 | 21 | |
22 | | - function execute($query) { |
| 22 | + function execute( $query ) { |
23 | 23 | $this->setHeaders(); |
24 | 24 | doSpecialCreateCategory(); |
25 | 25 | } |
26 | 26 | |
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' ); |
29 | 29 | |
30 | | - if ($default_form == '') { |
31 | | - $text = wfMsgForContent('sf_category_desc', $category_name); |
| 30 | + if ( $default_form == '' ) { |
| 31 | + $text = wfMsgForContent( 'sf_category_desc', $category_name ); |
32 | 32 | } else { |
33 | 33 | global $sfgContLang; |
34 | 34 | $specprops = $sfgContLang->getPropertyLabels(); |
35 | 35 | $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 ); |
37 | 37 | } |
38 | | - if ($parent_category != '') { |
| 38 | + if ( $parent_category != '' ) { |
39 | 39 | global $wgContLang; |
40 | 40 | $namespace_labels = $wgContLang->getNamespaces(); |
41 | 41 | $category_namespace = $namespace_labels[NS_CATEGORY]; |
— | — | @@ -47,29 +47,29 @@ |
48 | 48 | function doSpecialCreateCategory() { |
49 | 49 | global $wgOut, $wgRequest, $wgUser, $sfgScriptPath; |
50 | 50 | |
51 | | - wfLoadExtensionMessages('SemanticForms'); |
| 51 | + wfLoadExtensionMessages( 'SemanticForms' ); |
52 | 52 | |
53 | 53 | # 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' ); |
57 | 57 | |
58 | | - $save_button_text = wfMsg('savearticle'); |
59 | | - $preview_button_text = wfMsg('preview'); |
| 58 | + $save_button_text = wfMsg( 'savearticle' ); |
| 59 | + $preview_button_text = wfMsg( 'preview' ); |
60 | 60 | $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 ) { |
64 | 64 | # 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' ); |
67 | 67 | } else { |
68 | 68 | # 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 ); |
74 | 74 | return; |
75 | 75 | } |
76 | 76 | } |
— | — | @@ -80,9 +80,9 @@ |
81 | 81 | global $wgContLang; |
82 | 82 | $mw_namespace_labels = $wgContLang->getNamespaces(); |
83 | 83 | $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 |
87 | 87 | <form action="" method="get"> |
88 | 88 | <input type="hidden" name="title" value="$special_namespace:CreateCategory"> |
89 | 89 | <p>$name_label <input size="25" name="category_name" value=""> |
— | — | @@ -92,27 +92,27 @@ |
93 | 93 | <option></option> |
94 | 94 | |
95 | 95 | END; |
96 | | - foreach ($all_forms as $form) { |
| 96 | + foreach ( $all_forms as $form ) { |
97 | 97 | $text .= " <option>$form</option>\n"; |
98 | 98 | } |
99 | 99 | |
100 | | - $subcategory_label = wfMsg('sf_createcategory_makesubcategory'); |
| 100 | + $subcategory_label = wfMsg( 'sf_createcategory_makesubcategory' ); |
101 | 101 | $categories = SFLinkUtils::getCategoriesForArticle(); |
102 | 102 | $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 |
106 | 106 | </select> |
107 | 107 | <p>$subcategory_label |
108 | 108 | <select id="category_dropdown" name="parent_category"> |
109 | 109 | <option></option> |
110 | 110 | |
111 | 111 | 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"; |
115 | 115 | } |
116 | | - $text .=<<<END |
| 116 | + $text .= <<<END |
117 | 117 | </select> |
118 | 118 | <div class="editButtons"> |
119 | 119 | <input type="submit" id="wpSave" name="wpSave" value="$save_button_text"> |
— | — | @@ -122,7 +122,7 @@ |
123 | 123 | |
124 | 124 | END; |
125 | 125 | |
126 | | - $text .= " " . Xml::tags('p', null, $create_form_link . '.') . "\n"; |
| 126 | + $text .= " " . Xml::tags( 'p', null, $create_form_link . '.' ) . "\n"; |
127 | 127 | $text .= " </form>\n"; |
128 | 128 | |
129 | 129 | $wgOut->addLink( array( |
— | — | @@ -130,6 +130,6 @@ |
131 | 131 | 'type' => 'text/css', |
132 | 132 | 'media' => "screen", |
133 | 133 | 'href' => $sfgScriptPath . "/skins/SF_main.css" |
134 | | - )); |
135 | | - $wgOut->addHTML($text); |
| 134 | + ) ); |
| 135 | + $wgOut->addHTML( $text ); |
136 | 136 | } |
Index: trunk/extensions/SemanticForms/specials/SF_FormStart.php |
— | — | @@ -6,7 +6,7 @@ |
7 | 7 | * @author Yaron Koren |
8 | 8 | * @author Jeffrey Stuckman |
9 | 9 | */ |
10 | | -if (!defined('MEDIAWIKI')) die(); |
| 10 | +if ( !defined( 'MEDIAWIKI' ) ) die(); |
11 | 11 | |
12 | 12 | class SFFormStart extends SpecialPage { |
13 | 13 | |
— | — | @@ -14,87 +14,87 @@ |
15 | 15 | * Constructor |
16 | 16 | */ |
17 | 17 | function SFFormStart() { |
18 | | - SpecialPage::SpecialPage('FormStart'); |
19 | | - wfLoadExtensionMessages('SemanticForms'); |
| 18 | + SpecialPage::SpecialPage( 'FormStart' ); |
| 19 | + wfLoadExtensionMessages( 'SemanticForms' ); |
20 | 20 | } |
21 | 21 | |
22 | | - function execute($query) { |
| 22 | + function execute( $query ) { |
23 | 23 | global $wgOut, $wgRequest, $sfgScriptPath; |
24 | 24 | |
25 | 25 | $this->setHeaders(); |
26 | 26 | |
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' ); |
32 | 32 | |
33 | 33 | // 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] : ''; |
37 | 37 | // if a target was specified, it means we should |
38 | 38 | // redirect to 'FormEdit' for this target page |
39 | | - if (isset($queryparts[1])) { |
| 39 | + if ( isset( $queryparts[1] ) ) { |
40 | 40 | $target_name = $queryparts[1]; |
41 | | - SFFormStart::doRedirect($form_name, $target_name, $params); |
| 41 | + SFFormStart::doRedirect( $form_name, $target_name, $params ); |
42 | 42 | } |
43 | 43 | |
44 | 44 | // 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 ); |
48 | 48 | } |
49 | 49 | } |
50 | 50 | |
51 | 51 | // 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 ); |
54 | 54 | |
55 | 55 | // get title of form |
56 | | - $form_title = Title::makeTitleSafe(SF_NS_FORM, $form_name); |
| 56 | + $form_title = Title::makeTitleSafe( SF_NS_FORM, $form_name ); |
57 | 57 | |
58 | 58 | // 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' ); |
62 | 62 | // This form can be used to create a sub-page for an |
63 | 63 | // existing page |
64 | | - if ('' != $super_page) |
| 64 | + if ( '' != $super_page ) |
65 | 65 | { |
66 | 66 | $page_name = "$super_page/$page_name"; |
67 | 67 | } |
68 | | - if ('' != $page_name) { |
| 68 | + if ( '' != $page_name ) { |
69 | 69 | // Append the namespace prefix to the page name, |
70 | 70 | // if a namespace was not already entered. |
71 | | - if (strpos($page_name,":") === false && $target_namespace != '') |
| 71 | + if ( strpos( $page_name, ":" ) === false && $target_namespace != '' ) |
72 | 72 | $page_name = $target_namespace . ":" . $page_name; |
73 | 73 | // find out whether this page already exists, |
74 | 74 | // 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 ) { |
77 | 77 | // if there was no page title, it's |
78 | 78 | // probably an invalid page name, |
79 | 79 | // 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 ); |
82 | 82 | return; |
83 | 83 | } else { |
84 | | - SFFormStart::doRedirect($form_name, $page_name, $params); |
| 84 | + SFFormStart::doRedirect( $form_name, $page_name, $params ); |
85 | 85 | return; |
86 | 86 | } |
87 | 87 | } |
88 | 88 | } |
89 | 89 | |
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"; |
92 | 92 | } 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 ); |
95 | 95 | 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 |
99 | 99 | <form action="" method="post"> |
100 | 100 | <p>$description</p> |
101 | 101 | <p><input type="text" size="40" name="page_name"> |
— | — | @@ -102,14 +102,14 @@ |
103 | 103 | END; |
104 | 104 | // if no form was specified, display a dropdown letting |
105 | 105 | // the user choose the form |
106 | | - if ($form_name == '') |
| 106 | + if ( $form_name == '' ) |
107 | 107 | $text .= SFUtils::formDropdownHTML(); |
108 | 108 | |
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 ); |
112 | 112 | |
113 | | - $text .=<<<END |
| 113 | + $text .= <<<END |
114 | 114 | </p> |
115 | 115 | <input type="hidden" name="namespace" value="$hidden_target_namespace"> |
116 | 116 | <input type="hidden" name="super_page" value="$hidden_super_page"> |
— | — | @@ -119,20 +119,20 @@ |
120 | 120 | |
121 | 121 | END; |
122 | 122 | } |
123 | | - $wgOut->addHTML($text); |
| 123 | + $wgOut->addHTML( $text ); |
124 | 124 | } |
125 | 125 | |
126 | | - function doRedirect($form_name, $page_name, $params) { |
| 126 | + function doRedirect( $form_name, $page_name, $params ) { |
127 | 127 | global $wgOut; |
128 | 128 | |
129 | | - $page_title = Title::newFromText($page_name); |
130 | | - if ($page_title->exists()) { |
| 129 | + $page_title = Title::newFromText( $page_name ); |
| 130 | + if ( $page_title->exists() ) { |
131 | 131 | // it exists - see if page is a redirect; if |
132 | 132 | // it is, edit the target page instead |
133 | | - $article = new Article($page_title); |
| 133 | + $article = new Article( $page_title ); |
134 | 134 | $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 ) { |
137 | 137 | $page_title = $redirect_title; |
138 | 138 | } |
139 | 139 | // HACK - if this is the default form for |
— | — | @@ -142,39 +142,39 @@ |
143 | 143 | // Is this logic necessary? Or should we just |
144 | 144 | // out-guess the user and always send to the |
145 | 145 | // 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 ) |
148 | 148 | $default_form_name = $default_forms[0]; |
149 | 149 | else |
150 | 150 | $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' ); |
153 | 153 | } 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 ); |
156 | 156 | } |
157 | 157 | } 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 ); |
160 | 160 | // of all the request values, send on to 'FormEdit' |
161 | 161 | // only 'preload' and specific form fields - we can |
162 | 162 | // 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 ) ) { |
165 | 165 | $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 ) ? '&' : '?'; |
168 | 168 | $redirect_url .= $template_name . '[' . $field_name . ']=' . $value; |
169 | 169 | } |
170 | | - } elseif ($key == 'preload') { |
171 | | - $redirect_url .= (strpos($redirect_url, "?") > -1) ? '&' : '?'; |
| 170 | + } elseif ( $key == 'preload' ) { |
| 171 | + $redirect_url .= ( strpos( $redirect_url, "?" ) > - 1 ) ? '&' : '?'; |
172 | 172 | $redirect_url .= "$key=$val"; |
173 | 173 | } |
174 | 174 | } |
175 | 175 | } |
176 | 176 | |
177 | | - if ('' != $params) { |
178 | | - $redirect_url .= (strpos($redirect_url, "?") > -1) ? '&' : '?'; |
| 177 | + if ( '' != $params ) { |
| 178 | + $redirect_url .= ( strpos( $redirect_url, "?" ) > - 1 ) ? '&' : '?'; |
179 | 179 | $redirect_url .= $params; |
180 | 180 | } |
181 | 181 | |
— | — | @@ -182,7 +182,7 @@ |
183 | 183 | // show "loading" animated image while people wait for the redirect |
184 | 184 | global $sfgScriptPath; |
185 | 185 | $text = "<p style=\"position: absolute; left: 45%; top: 45%;\"><img src=\"$sfgScriptPath/skins/loading.gif\" /></p>\n"; |
186 | | - $text .=<<<END |
| 186 | + $text .= <<<END |
187 | 187 | <script type="text/javascript"> |
188 | 188 | window.onload = function() { |
189 | 189 | window.location="$redirect_url"; |
— | — | @@ -190,7 +190,7 @@ |
191 | 191 | </script> |
192 | 192 | |
193 | 193 | END; |
194 | | - $wgOut->addHTML($text); |
| 194 | + $wgOut->addHTML( $text ); |
195 | 195 | return; |
196 | 196 | } |
197 | 197 | |
Index: trunk/extensions/SemanticForms/specials/SF_Forms.php |
— | — | @@ -5,7 +5,7 @@ |
6 | 6 | * @author Yaron Koren |
7 | 7 | */ |
8 | 8 | |
9 | | -if (!defined('MEDIAWIKI')) die(); |
| 9 | +if ( !defined( 'MEDIAWIKI' ) ) die(); |
10 | 10 | |
11 | 11 | class SFForms extends SpecialPage { |
12 | 12 | |
— | — | @@ -13,11 +13,11 @@ |
14 | 14 | * Constructor |
15 | 15 | */ |
16 | 16 | function SFForms() { |
17 | | - SpecialPage::SpecialPage('Forms'); |
18 | | - wfLoadExtensionMessages('SemanticForms'); |
| 17 | + SpecialPage::SpecialPage( 'Forms' ); |
| 18 | + wfLoadExtensionMessages( 'SemanticForms' ); |
19 | 19 | } |
20 | 20 | |
21 | | - function execute($query) { |
| 21 | + function execute( $query ) { |
22 | 22 | $this->setHeaders(); |
23 | 23 | list( $limit, $offset ) = wfCheckLimits(); |
24 | 24 | $rep = new FormsPage(); |
— | — | @@ -37,13 +37,13 @@ |
38 | 38 | function getPageHeader() { |
39 | 39 | global $wgUser; |
40 | 40 | |
41 | | - wfLoadExtensionMessages('SemanticForms'); |
| 41 | + wfLoadExtensionMessages( 'SemanticForms' ); |
42 | 42 | |
43 | 43 | $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() ); |
46 | 46 | $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"; |
48 | 48 | return $header; |
49 | 49 | } |
50 | 50 | |
— | — | @@ -68,7 +68,7 @@ |
69 | 69 | return false; |
70 | 70 | } |
71 | 71 | |
72 | | - function formatResult($skin, $result) { |
| 72 | + function formatResult( $skin, $result ) { |
73 | 73 | $title = Title::makeTitle( SF_NS_FORM, $result->value ); |
74 | 74 | return $skin->makeLinkObj( $title, $title->getText() ); |
75 | 75 | } |
Index: trunk/extensions/SemanticForms/specials/SF_CreateForm.php |
— | — | @@ -6,7 +6,7 @@ |
7 | 7 | * @author Yaron Koren |
8 | 8 | */ |
9 | 9 | |
10 | | -if (!defined('MEDIAWIKI')) die(); |
| 10 | +if ( !defined( 'MEDIAWIKI' ) ) die(); |
11 | 11 | |
12 | 12 | class SFCreateForm extends SpecialPage { |
13 | 13 | |
— | — | @@ -14,11 +14,11 @@ |
15 | 15 | * Constructor |
16 | 16 | */ |
17 | 17 | function SFCreateForm() { |
18 | | - SpecialPage::SpecialPage('CreateForm'); |
19 | | - wfLoadExtensionMessages('SemanticForms'); |
| 18 | + SpecialPage::SpecialPage( 'CreateForm' ); |
| 19 | + wfLoadExtensionMessages( 'SemanticForms' ); |
20 | 20 | } |
21 | 21 | |
22 | | - function execute($query) { |
| 22 | + function execute( $query ) { |
23 | 23 | $this->setHeaders(); |
24 | 24 | doSpecialCreateForm(); |
25 | 25 | } |
— | — | @@ -28,16 +28,16 @@ |
29 | 29 | global $wgOut, $wgRequest, $wgUser, $sfgScriptPath, $wgContLang; |
30 | 30 | $db = wfGetDB( DB_SLAVE ); |
31 | 31 | |
32 | | - wfLoadExtensionMessages('SemanticForms'); |
| 32 | + wfLoadExtensionMessages( 'SemanticForms' ); |
33 | 33 | |
34 | 34 | # get the names of all templates on this site |
35 | 35 | $all_templates = array(); |
36 | 36 | $res = $db->select( 'page', 'page_title', |
37 | 37 | array( 'page_namespace' => NS_TEMPLATE, 'page_is_redirect' => 0 ), |
38 | 38 | 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] ); |
42 | 42 | $all_templates[] = $template_name; |
43 | 43 | } |
44 | 44 | } |
— | — | @@ -47,34 +47,34 @@ |
48 | 48 | $deleted_template_loc = null; |
49 | 49 | |
50 | 50 | # 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 ) { |
53 | 53 | # ignore variables that are not of the right form |
54 | | - if (strpos($var, "_") != false) { |
| 54 | + if ( strpos( $var, "_" ) != false ) { |
55 | 55 | # 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" ) { |
58 | 58 | # if the button was pressed to remove this |
59 | 59 | # template, just don't add it to the array |
60 | | - if ($wgRequest->getVal("del_$id") != null) { |
| 60 | + if ( $wgRequest->getVal( "del_$id" ) != null ) { |
61 | 61 | $deleted_template_loc = $id; |
62 | 62 | } 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" ) ); |
66 | 66 | $form_templates[] = $form_template; |
67 | 67 | } |
68 | 68 | } |
69 | 69 | } |
70 | 70 | } |
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; } |
75 | 75 | # hack - array_splice() doesn't work for objects, so we have to |
76 | 76 | # first insert a stub element into the array, then replace that |
77 | 77 | # with the actual object |
78 | | - array_splice($form_templates, $new_template_loc, 0, "stub"); |
| 78 | + array_splice( $form_templates, $new_template_loc, 0, "stub" ); |
79 | 79 | $form_templates[$new_template_loc] = $form_template; |
80 | 80 | } else { |
81 | 81 | $new_template_loc = null; |
— | — | @@ -82,56 +82,56 @@ |
83 | 83 | |
84 | 84 | # now cycle through the templates and fields, modifying each one |
85 | 85 | # 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 ) { |
88 | 88 | // handle the change in indexing if a new template was |
89 | 89 | // inserted before the end, or one was deleted |
90 | 90 | $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 ) { |
93 | 93 | $old_i = $i - 1; |
94 | | - } elseif ($i == $new_template_loc) { |
| 94 | + } elseif ( $i == $new_template_loc ) { |
95 | 95 | // it's the new template; it shouldn't |
96 | 96 | // get any query string data |
97 | | - $old_i = -1; |
| 97 | + $old_i = - 1; |
98 | 98 | } |
99 | | - } elseif ($deleted_template_loc != null) { |
100 | | - if ($i >= $deleted_template_loc) { |
| 99 | + } elseif ( $deleted_template_loc != null ) { |
| 100 | + if ( $i >= $deleted_template_loc ) { |
101 | 101 | $old_i = $i + 1; |
102 | 102 | } |
103 | 103 | } |
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 ) |
106 | 106 | $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 ); |
108 | 108 | $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" ) { |
110 | 110 | $field->is_hidden = true; |
111 | 111 | } |
112 | | - if ($wgRequest->getVal("restricted_" . $old_i . "_" . $j) == "restricted") { |
| 112 | + if ( $wgRequest->getVal( "restricted_" . $old_i . "_" . $j ) == "restricted" ) { |
113 | 113 | $field->is_restricted = true; |
114 | 114 | } |
115 | | - if ($wgRequest->getVal("mandatory_" . $old_i . "_" . $j) == "mandatory") { |
| 115 | + if ( $wgRequest->getVal( "mandatory_" . $old_i . "_" . $j ) == "mandatory" ) { |
116 | 116 | $field->is_mandatory = true; |
117 | 117 | } |
118 | 118 | } |
119 | 119 | } |
120 | | - $form = SFForm::create($form_name, $form_templates); |
| 120 | + $form = SFForm::create( $form_name, $form_templates ); |
121 | 121 | |
122 | 122 | # 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 ) { |
126 | 126 | # 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' ); |
129 | 129 | } else { |
130 | 130 | # 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 ); |
133 | 133 | $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 ); |
136 | 136 | return; |
137 | 137 | } |
138 | 138 | } |
— | — | @@ -141,45 +141,45 @@ |
142 | 142 | $mw_namespace_labels = $wgContLang->getNamespaces(); |
143 | 143 | $special_namespace = $mw_namespace_labels[NS_SPECIAL]; |
144 | 144 | $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 ); |
148 | 148 | $text .= "</p>\n"; |
149 | 149 | |
150 | 150 | $text .= $form->creationHTML(); |
151 | 151 | |
152 | | - $text .= ' <p>' . wfMsg('sf_createform_addtemplate') . "\n"; |
| 152 | + $text .= ' <p>' . wfMsg( 'sf_createform_addtemplate' ) . "\n"; |
153 | 153 | |
154 | 154 | $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"; |
157 | 157 | } |
158 | | - $text .= ' ' . Xml::tags('select', array('name' => 'new_template'), $select_body) . "\n"; |
| 158 | + $text .= ' ' . Xml::tags( 'select', array( 'name' => 'new_template' ), $select_body ) . "\n"; |
159 | 159 | // if a template has already been added, show a dropdown letting the |
160 | 160 | // 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' ); |
163 | 163 | $text .= $before_template_msg; |
164 | 164 | $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"; |
167 | 167 | } |
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"; |
172 | 172 | } |
173 | 173 | |
174 | 174 | // disable 'save' and 'preview' buttons if user has not yet added any |
175 | 175 | // 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' ); |
180 | 180 | $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 |
184 | 184 | <input type="submit" name="add_field" value="$add_button_text"></p> |
185 | 185 | <br /> |
186 | 186 | <div class="editButtons"> |
— | — | @@ -192,21 +192,21 @@ |
193 | 193 | END; |
194 | 194 | // explanatory message if buttons are disabled because no templates |
195 | 195 | // 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' ) . ")" ); |
198 | 198 | } |
199 | | - $text .=<<<END |
| 199 | + $text .= <<<END |
200 | 200 | </form> |
201 | 201 | <hr /><br /> |
202 | 202 | |
203 | 203 | END; |
204 | | - $text .= " " . Xml::tags('p', null, $create_template_link . '.'); |
| 204 | + $text .= " " . Xml::tags( 'p', null, $create_template_link . '.' ); |
205 | 205 | |
206 | 206 | $wgOut->addLink( array( |
207 | 207 | 'rel' => 'stylesheet', |
208 | 208 | 'type' => 'text/css', |
209 | 209 | 'media' => "screen", |
210 | 210 | 'href' => $sfgScriptPath . "/skins/SF_main.css" |
211 | | - )); |
212 | | - $wgOut->addHTML($text); |
| 211 | + ) ); |
| 212 | + $wgOut->addHTML( $text ); |
213 | 213 | } |
Index: trunk/extensions/SemanticForms/specials/SF_CreateProperty.php |
— | — | @@ -6,7 +6,7 @@ |
7 | 7 | * @author Yaron Koren |
8 | 8 | */ |
9 | 9 | |
10 | | -if (!defined('MEDIAWIKI')) die(); |
| 10 | +if ( !defined( 'MEDIAWIKI' ) ) die(); |
11 | 11 | |
12 | 12 | class SFCreateProperty extends SpecialPage { |
13 | 13 | |
— | — | @@ -14,37 +14,37 @@ |
15 | 15 | * Constructor |
16 | 16 | */ |
17 | 17 | function SFCreateProperty() { |
18 | | - SpecialPage::SpecialPage('CreateProperty'); |
19 | | - wfLoadExtensionMessages('SemanticForms'); |
| 18 | + SpecialPage::SpecialPage( 'CreateProperty' ); |
| 19 | + wfLoadExtensionMessages( 'SemanticForms' ); |
20 | 20 | } |
21 | 21 | |
22 | | - function execute($query) { |
| 22 | + function execute( $query ) { |
23 | 23 | $this->setHeaders(); |
24 | 24 | doSpecialCreateProperty(); |
25 | 25 | } |
26 | 26 | |
27 | | - function createPropertyText($property_type, $default_form, $allowed_values_str) { |
| 27 | + function createPropertyText( $property_type, $default_form, $allowed_values_str ) { |
28 | 28 | global $smwgContLang; |
29 | 29 | $prop_labels = $smwgContLang->getPropertyLabels(); |
30 | 30 | $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 != '' ) { |
33 | 33 | global $sfgContLang; |
34 | 34 | $sf_prop_labels = $sfgContLang->getPropertyLabels(); |
35 | 35 | $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 ); |
37 | 37 | } |
38 | | - if ($allowed_values_str != '') { |
| 38 | + if ( $allowed_values_str != '' ) { |
39 | 39 | // replace the comma substitution character that has no chance of |
40 | 40 | // being included in the values list - namely, the ASCII beep |
41 | 41 | 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 ) { |
46 | 46 | // 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' ) ) { |
49 | 49 | $prop_labels = $smwgContLang->getPropertyLabels(); |
50 | 50 | $text .= "\n* [[" . $prop_labels['_PVAL'] . "::$value]]"; |
51 | 51 | } else { |
— | — | @@ -62,38 +62,38 @@ |
63 | 63 | global $wgOut, $wgRequest, $sfgScriptPath; |
64 | 64 | global $smwgContLang; |
65 | 65 | |
66 | | - wfLoadExtensionMessages('SemanticForms'); |
| 66 | + wfLoadExtensionMessages( 'SemanticForms' ); |
67 | 67 | |
68 | 68 | # 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' ); |
73 | 73 | |
74 | | - $save_button_text = wfMsg('savearticle'); |
75 | | - $preview_button_text = wfMsg('preview'); |
| 74 | + $save_button_text = wfMsg( 'savearticle' ); |
| 75 | + $preview_button_text = wfMsg( 'preview' ); |
76 | 76 | |
77 | 77 | $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 ) { |
81 | 81 | # 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' ); |
84 | 84 | } else { |
85 | 85 | # 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 ); |
91 | 91 | return; |
92 | 92 | } |
93 | 93 | } |
94 | 94 | |
95 | 95 | $datatype_labels = $smwgContLang->getDatatypeLabels(); |
96 | 96 | |
97 | | - $javascript_text =<<<END |
| 97 | + $javascript_text = <<<END |
98 | 98 | function toggleDefaultForm(property_type) { |
99 | 99 | var default_form_div = document.getElementById("default_form_div"); |
100 | 100 | if (property_type == '{$datatype_labels['_wpg']}') { |
— | — | @@ -109,9 +109,9 @@ |
110 | 110 | global $wgContLang; |
111 | 111 | $mw_namespace_labels = $wgContLang->getNamespaces(); |
112 | 112 | $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 |
116 | 116 | <form action="" method="post"> |
117 | 117 | <input type="hidden" name="title" value="$special_namespace:CreateProperty"> |
118 | 118 | <p>$name_label <input size="25" name="property_name" value=""> |
— | — | @@ -119,14 +119,14 @@ |
120 | 120 | $type_label |
121 | 121 | END; |
122 | 122 | $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"; |
125 | 125 | } |
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"; |
127 | 127 | |
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 |
131 | 131 | <div id="default_form_div" style="padding: 5px 0 5px 0; margin: 7px 0 7px 0;"> |
132 | 132 | <p>$default_form_input |
133 | 133 | <input size="20" name="default_form" value=""></p> |
— | — | @@ -137,9 +137,9 @@ |
138 | 138 | </div> |
139 | 139 | |
140 | 140 | 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"; |
144 | 144 | $text .= " </form>\n"; |
145 | 145 | |
146 | 146 | $wgOut->addLink( array( |
— | — | @@ -147,7 +147,7 @@ |
148 | 148 | 'type' => 'text/css', |
149 | 149 | 'media' => "screen", |
150 | 150 | '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 ); |
154 | 154 | } |
Index: trunk/extensions/SemanticForms/specials/SF_CreateClass.php |
— | — | @@ -6,7 +6,7 @@ |
7 | 7 | * @author Yaron Koren |
8 | 8 | */ |
9 | 9 | |
10 | | -if (!defined('MEDIAWIKI')) die(); |
| 10 | +if ( !defined( 'MEDIAWIKI' ) ) die(); |
11 | 11 | |
12 | 12 | class SFCreateClass extends SpecialPage { |
13 | 13 | |
— | — | @@ -17,7 +17,7 @@ |
18 | 18 | parent::__construct( 'CreateClass', 'createclass' ); |
19 | 19 | } |
20 | 20 | |
21 | | - function execute($query) { |
| 21 | + function execute( $query ) { |
22 | 22 | global $wgOut, $wgRequest, $wgUser, $sfgScriptPath; |
23 | 23 | global $wgLang, $smwgContLang; |
24 | 24 | |
— | — | @@ -28,44 +28,44 @@ |
29 | 29 | } |
30 | 30 | |
31 | 31 | $this->setHeaders(); |
32 | | - wfLoadExtensionMessages('SemanticForms'); |
| 32 | + wfLoadExtensionMessages( 'SemanticForms' ); |
33 | 33 | |
34 | | - $create_button_text = wfMsg('create'); |
| 34 | + $create_button_text = wfMsg( 'create' ); |
35 | 35 | |
36 | 36 | $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 ); |
45 | 45 | return; |
46 | 46 | } |
47 | 47 | $fields = array(); |
48 | 48 | $jobs = array(); |
49 | 49 | // 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++ ) { |
51 | 51 | // 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 === '' ) |
56 | 56 | $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" ); |
60 | 60 | // create an SFTemplateField based on these |
61 | 61 | // values, and add it to the $fields array |
62 | | - $field = SFTemplateField::create($field_name, $field_name); |
| 62 | + $field = SFTemplateField::create( $field_name, $field_name ); |
63 | 63 | $field->semantic_property = $property_name; |
64 | 64 | $field->is_list = $is_list; |
65 | 65 | $fields[] = $field; |
66 | 66 | |
67 | 67 | // 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 ); |
70 | 70 | $params = array(); |
71 | 71 | $params['user_id'] = $wgUser->getId(); |
72 | 72 | $params['page_text'] = $full_text; |
— | — | @@ -73,34 +73,34 @@ |
74 | 74 | } |
75 | 75 | |
76 | 76 | // 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 ); |
80 | 80 | $edit_summary = ''; |
81 | | - $template_article->doEdit($full_text, $edit_summary); |
| 81 | + $template_article->doEdit( $full_text, $edit_summary ); |
82 | 82 | |
83 | 83 | // 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 ); |
87 | 87 | $full_text = $form->createMarkup(); |
88 | | - $form_title = Title::makeTitleSafe(SF_NS_FORM, $form_name); |
| 88 | + $form_title = Title::makeTitleSafe( SF_NS_FORM, $form_name ); |
89 | 89 | $params = array(); |
90 | 90 | $params['user_id'] = $wgUser->getId(); |
91 | 91 | $params['page_text'] = $full_text; |
92 | 92 | $jobs[] = new SFCreatePageJob( $form_title, $params ); |
93 | 93 | |
94 | 94 | // 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 ); |
97 | 97 | $params = array(); |
98 | 98 | $params['user_id'] = $wgUser->getId(); |
99 | 99 | $params['page_text'] = $full_text; |
100 | 100 | $jobs[] = new SFCreatePageJob( $category_title, $params ); |
101 | 101 | Job::batchInsert( $jobs ); |
102 | 102 | |
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 ); |
105 | 105 | return; |
106 | 106 | } |
107 | 107 | |
— | — | @@ -115,25 +115,25 @@ |
116 | 116 | // link to them at the top of the page |
117 | 117 | $sk = $wgUser->getSkin(); |
118 | 118 | $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 |
138 | 138 | <form action="" method="post"> |
139 | 139 | <p>$create_class_docu</p> |
140 | 140 | <p>$leave_field_blank</p> |
— | — | @@ -150,8 +150,8 @@ |
151 | 151 | </tr> |
152 | 152 | |
153 | 153 | END; |
154 | | - for ($i = 1; $i <= 25; $i++) { |
155 | | - $text .=<<<END |
| 154 | + for ( $i = 1; $i <= 25; $i++ ) { |
| 155 | + $text .= <<<END |
156 | 156 | <tr> |
157 | 157 | <td>$i. <input type="text" size="25" name="property_name_$i" /></td> |
158 | 158 | <td><input type="text" size="25" name="field_name_$i" /></td> |
— | — | @@ -159,10 +159,10 @@ |
160 | 160 | <select id="property_dropdown_$i" name="property_type_$i"> |
161 | 161 | |
162 | 162 | END; |
163 | | - foreach ($datatype_labels as $label) { |
| 163 | + foreach ( $datatype_labels as $label ) { |
164 | 164 | $text .= " <option>$label</option>\n"; |
165 | 165 | } |
166 | | - $text .=<<<END |
| 166 | + $text .= <<<END |
167 | 167 | </select> |
168 | 168 | </td> |
169 | 169 | <td><input type="text" size="25" name="allowed_values_$i" /></td> |
— | — | @@ -170,7 +170,7 @@ |
171 | 171 | |
172 | 172 | END; |
173 | 173 | } |
174 | | - $text .=<<<END |
| 174 | + $text .= <<<END |
175 | 175 | </tr> |
176 | 176 | </table> |
177 | 177 | <br /> |
— | — | @@ -186,7 +186,7 @@ |
187 | 187 | 'type' => 'text/css', |
188 | 188 | 'media' => "screen", |
189 | 189 | 'href' => $sfgScriptPath . "/skins/SF_main.css" |
190 | | - )); |
191 | | - $wgOut->addHTML($text); |
| 190 | + ) ); |
| 191 | + $wgOut->addHTML( $text ); |
192 | 192 | } |
193 | 193 | } |
Index: trunk/extensions/SemanticForms/specials/SF_FormEdit.php |
— | — | @@ -5,7 +5,7 @@ |
6 | 6 | * |
7 | 7 | * @author Yaron Koren |
8 | 8 | */ |
9 | | -if (!defined('MEDIAWIKI')) die(); |
| 9 | +if ( !defined( 'MEDIAWIKI' ) ) die(); |
10 | 10 | |
11 | 11 | class SFFormEdit extends SpecialPage { |
12 | 12 | |
— | — | @@ -13,45 +13,45 @@ |
14 | 14 | * Constructor |
15 | 15 | */ |
16 | 16 | function SFFormEdit() { |
17 | | - SpecialPage::SpecialPage('FormEdit'); |
18 | | - wfLoadExtensionMessages('SemanticForms'); |
| 17 | + SpecialPage::SpecialPage( 'FormEdit' ); |
| 18 | + wfLoadExtensionMessages( 'SemanticForms' ); |
19 | 19 | } |
20 | 20 | |
21 | | - function execute($query) { |
| 21 | + function execute( $query ) { |
22 | 22 | global $wgRequest; |
23 | 23 | |
24 | 24 | $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' ); |
27 | 27 | |
28 | 28 | // 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] : ''; |
33 | 33 | } |
34 | 34 | |
35 | | - $alt_forms = $wgRequest->getArray('alt_form'); |
| 35 | + $alt_forms = $wgRequest->getArray( 'alt_form' ); |
36 | 36 | |
37 | | - self::printForm($form_name, $target_name, $alt_forms); |
| 37 | + self::printForm( $form_name, $target_name, $alt_forms ); |
38 | 38 | } |
39 | 39 | |
40 | | - static function printAltFormsList($alt_forms, $target_name) { |
| 40 | + static function printAltFormsList( $alt_forms, $target_name ) { |
41 | 41 | $text = ""; |
42 | | - $fe = SpecialPage::getPage('FormEdit'); |
| 42 | + $fe = SpecialPage::getPage( 'FormEdit' ); |
43 | 43 | $fe_url = $fe->getTitle()->getFullURL(); |
44 | 44 | $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>"; |
48 | 48 | } |
49 | 49 | return $text; |
50 | 50 | } |
51 | 51 | |
52 | | -static function printForm($form_name, $target_name, $alt_forms = array()) { |
| 52 | +static function printForm( $form_name, $target_name, $alt_forms = array() ) { |
53 | 53 | global $wgOut, $wgRequest, $wgScriptPath, $sfgScriptPath, $sfgFormPrinter, $sfgYUIBase; |
54 | 54 | |
55 | | - wfLoadExtensionMessages('SemanticForms'); |
| 55 | + wfLoadExtensionMessages( 'SemanticForms' ); |
56 | 56 | |
57 | 57 | // initialize some variables |
58 | 58 | $target_title = null; |
— | — | @@ -59,110 +59,110 @@ |
60 | 60 | |
61 | 61 | // get contents of form and target page - if there's only one, |
62 | 62 | // 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>' ); |
65 | 65 | return; |
66 | | - } elseif ($target_name == '') { |
| 66 | + } elseif ( $target_name == '' ) { |
67 | 67 | // 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 ); |
70 | 70 | $form_definition = $form_article->getContent(); |
71 | | - $form_definition = StringUtils::delimiterReplace('<noinclude>', '</noinclude>', '', $form_definition); |
| 71 | + $form_definition = StringUtils::delimiterReplace( '<noinclude>', '</noinclude>', '', $form_definition ); |
72 | 72 | $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] ); |
75 | 75 | // if the tag close ('}}}') is in here, chop off that |
76 | 76 | // 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 ); |
79 | 79 | } |
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>' ); |
82 | 82 | return; |
83 | 83 | } |
84 | 84 | } |
85 | 85 | |
86 | | - $form_title = Title::makeTitleSafe(SF_NS_FORM, $form_name); |
| 86 | + $form_title = Title::makeTitleSafe( SF_NS_FORM, $form_name ); |
87 | 87 | |
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() ); |
92 | 92 | } 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() ); |
94 | 94 | } |
95 | | - $wgOut->setPageTitle($s); |
| 95 | + $wgOut->setPageTitle( $s ); |
96 | 96 | } |
97 | 97 | |
98 | 98 | // handling is different depending on whether page already exists |
99 | 99 | // 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' ) { |
102 | 102 | $page_contents = null; |
103 | 103 | $page_is_source = false; |
104 | 104 | } else { |
105 | | - $target_article = new Article($target_title); |
| 105 | + $target_article = new Article( $target_title ); |
106 | 106 | $page_contents = $target_article->getContent(); |
107 | 107 | $page_is_source = true; |
108 | 108 | } |
109 | | - } elseif ($target_name != '') { |
110 | | - $target_name = str_replace('_', ' ', $target_name); |
| 109 | + } elseif ( $target_name != '' ) { |
| 110 | + $target_name = str_replace( '_', ' ', $target_name ); |
111 | 111 | } |
112 | 112 | |
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"; |
116 | 116 | 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 ); |
120 | 120 | $text .= "</div>\n"; |
121 | 121 | } 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"; |
123 | 123 | } |
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"; |
126 | 126 | } else { |
127 | | - $form_article = new Article($form_title); |
| 127 | + $form_article = new Article( $form_title ); |
128 | 128 | $form_definition = $form_article->getContent(); |
129 | 129 | |
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 ); |
134 | 134 | // 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' ) ) { |
137 | 137 | $page_is_source = true; |
138 | | - $page_contents = SFFormUtils::getPreloadedText($wgRequest->getVal('preload')); |
| 138 | + $page_contents = SFFormUtils::getPreloadedText( $wgRequest->getVal( 'preload' ) ); |
139 | 139 | } else { |
140 | 140 | // 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 ); |
143 | 143 | } |
144 | 144 | } else { |
145 | 145 | $page_is_source = false; |
146 | 146 | $page_contents = null; |
147 | 147 | } |
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 != '' ) { |
152 | 152 | $target_name = $generated_page_name; |
153 | 153 | // 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; |
156 | 156 | } |
157 | 157 | // 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; |
160 | 160 | } |
161 | 161 | // replace "unique number" tag with one that |
162 | 162 | // 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 ); |
164 | 164 | // if any formula stuff is still in the name |
165 | 165 | // after the parsing, just remove it |
166 | | - $target_name = StringUtils::delimiterReplace('<', '>', '', $target_name); |
| 166 | + $target_name = StringUtils::delimiterReplace( '<', '>', '', $target_name ); |
167 | 167 | |
168 | 168 | // now run the parser on it |
169 | 169 | global $wgParser; |
— | — | @@ -171,16 +171,16 @@ |
172 | 172 | // function name contains underlines - |
173 | 173 | // hopefully this won't cause problems of |
174 | 174 | // 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 ); |
177 | 177 | |
178 | | - if (strpos($target_name, '{num')) { |
| 178 | + if ( strpos( $target_name, '{num' ) ) { |
179 | 179 | // get unique number start value from |
180 | 180 | // target name; if it's not there, or |
181 | 181 | // it's not a positive number, |
182 | 182 | // 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 ) { |
185 | 185 | $title_number = $matches[1]; |
186 | 186 | } else { |
187 | 187 | $title_number = ""; |
— | — | @@ -189,43 +189,43 @@ |
190 | 190 | // until we find one that gives a |
191 | 191 | // nonexistent page title |
192 | 192 | 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 ) ); |
194 | 194 | // if title number is blank, |
195 | 195 | // change it to 2; otherwise, |
196 | 196 | // increment it, and if necessary |
197 | 197 | // pad it with leading 0s as well |
198 | | - if ($title_number == "") { |
| 198 | + if ( $title_number == "" ) { |
199 | 199 | $title_number = 2; |
200 | 200 | } 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 ); |
202 | 202 | } |
203 | | - } while ($target_title->exists()); |
| 203 | + } while ( $target_title->exists() ); |
204 | 204 | } else { |
205 | | - $target_title = Title::newFromText($target_name); |
| 205 | + $target_title = Title::newFromText( $target_name ); |
206 | 206 | } |
207 | 207 | } |
208 | | - if (is_null($target_title)) { |
209 | | - die (wfMsg('badtitle') . ": $target_name"); |
| 208 | + if ( is_null( $target_title ) ) { |
| 209 | + die ( wfMsg( 'badtitle' ) . ": $target_name" ); |
210 | 210 | } |
211 | 211 | $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' ) ); |
213 | 213 | } else { |
214 | 214 | // override the default title for this page if |
215 | 215 | // 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 ); |
219 | 219 | } else { |
220 | | - $wgOut->setPageTitle("$form_page_title: {$target_title->getPrefixedText()}"); |
| 220 | + $wgOut->setPageTitle( "$form_page_title: {$target_title->getPrefixedText()}" ); |
221 | 221 | } |
222 | 222 | } |
223 | 223 | $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 ); |
227 | 227 | $text .= "</div>\n"; |
228 | 228 | } |
229 | | - $text .=<<<END |
| 229 | + $text .= <<<END |
230 | 230 | <form name="createbox" onsubmit="return validate_all()" action="" method="post" class="createbox"> |
231 | 231 | |
232 | 232 | END; |
— | — | @@ -240,11 +240,11 @@ |
241 | 241 | // that they can affect (i.e., hide) the relevant form fields. |
242 | 242 | // if there's a less hacky way to do this, the code should switch to |
243 | 243 | // that. |
244 | | - //if (! empty($javascript_text)) |
| 244 | + // if (! empty($javascript_text)) |
245 | 245 | // $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" ); |
249 | 249 | } |
250 | 250 | |
251 | 251 | } |
Index: trunk/extensions/SemanticForms/specials/SF_RunQuery.php |
— | — | @@ -5,7 +5,7 @@ |
6 | 6 | * @author Yaron Koren |
7 | 7 | */ |
8 | 8 | |
9 | | -if (!defined('MEDIAWIKI')) die(); |
| 9 | +if ( !defined( 'MEDIAWIKI' ) ) die(); |
10 | 10 | |
11 | 11 | class SFRunQuery extends IncludableSpecialPage { |
12 | 12 | |
— | — | @@ -13,82 +13,82 @@ |
14 | 14 | * Constructor |
15 | 15 | */ |
16 | 16 | function SFRunQuery() { |
17 | | - parent::__construct('RunQuery'); |
18 | | - wfLoadExtensionMessages('SemanticForms'); |
| 17 | + parent::__construct( 'RunQuery' ); |
| 18 | + wfLoadExtensionMessages( 'SemanticForms' ); |
19 | 19 | } |
20 | 20 | |
21 | | - function execute($query) { |
| 21 | + function execute( $query ) { |
22 | 22 | global $wgRequest; |
23 | 23 | if ( !$this->including() ) |
24 | 24 | $this->setHeaders(); |
25 | | - $form_name = $this->including() ? $query : $wgRequest->getVal('form', $query); |
| 25 | + $form_name = $this->including() ? $query : $wgRequest->getVal( 'form', $query ); |
26 | 26 | |
27 | | - self::printQueryForm($form_name, $this->including()); |
| 27 | + self::printQueryForm( $form_name, $this->including() ); |
28 | 28 | } |
29 | 29 | |
30 | | - static function printQueryForm($form_name, $embedded = false) { |
| 30 | + static function printQueryForm( $form_name, $embedded = false ) { |
31 | 31 | global $wgOut, $wgRequest, $wgScriptPath, $sfgScriptPath, $sfgFormPrinter, $sfgYUIBase, $wgParser; |
32 | 32 | |
33 | 33 | // 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 ); |
35 | 35 | |
36 | | - if (! $form_title || ! $form_title->exists() ) { |
| 36 | + if ( ! $form_title || ! $form_title->exists() ) { |
37 | 37 | $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"; |
40 | 40 | 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"; |
42 | 42 | } else { |
43 | | - $s = wfMsg('sf_runquery_title', $form_title->getText()); |
| 43 | + $s = wfMsg( 'sf_runquery_title', $form_title->getText() ); |
44 | 44 | if ( !$embedded ) |
45 | | - $wgOut->setPageTitle($s); |
46 | | - $form_article = new Article($form_title); |
| 45 | + $wgOut->setPageTitle( $s ); |
| 46 | + $form_article = new Article( $form_title ); |
47 | 47 | $form_definition = $form_article->getContent(); |
48 | | - $submit_url = $form_title->getLocalURL('action=submit'); |
| 48 | + $submit_url = $form_title->getLocalURL( 'action=submit' ); |
49 | 49 | if ( $embedded ) { |
50 | 50 | $run_query = false; |
51 | 51 | $content = null; |
52 | 52 | $raw = false; |
53 | 53 | } 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 ); |
57 | 57 | } |
58 | | - $form_submitted = ($run_query); |
| 58 | + $form_submitted = ( $run_query ); |
59 | 59 | if ( $raw ) |
60 | 60 | $wgOut->setArticleBodyOnly( true ); |
61 | 61 | // if user already made some action, ignore the edited |
62 | 62 | // page and just get data from the query string |
63 | | - if (!$embedded && $wgRequest->getVal('query') == 'true') { |
| 63 | + if ( !$embedded && $wgRequest->getVal( 'query' ) == 'true' ) { |
64 | 64 | $edit_content = null; |
65 | 65 | $is_text_source = false; |
66 | | - } elseif ($content != null) { |
| 66 | + } elseif ( $content != null ) { |
67 | 67 | $edit_content = $content; |
68 | 68 | $is_text_source = true; |
69 | 69 | } else { |
70 | 70 | $edit_content = null; |
71 | 71 | $is_text_source = true; |
72 | 72 | } |
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 ); |
75 | 75 | $text = ""; |
76 | 76 | // override the default title for this page if |
77 | 77 | // 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 ); |
80 | 80 | } |
81 | | - if ($form_submitted) { |
| 81 | + if ( $form_submitted ) { |
82 | 82 | global $wgUser, $wgTitle; |
83 | 83 | $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' ); |
87 | 87 | if ( !$raw ) |
88 | 88 | $text .= "\n<h2>$additional_query</h2>\n"; |
89 | 89 | } |
90 | 90 | 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 |
93 | 93 | <form name="createbox" onsubmit="return validate_all()" action="$action" method="post" class="createbox"> |
94 | 94 | <input type="hidden" name="query" value="true" /> |
95 | 95 | |
— | — | @@ -96,14 +96,14 @@ |
97 | 97 | $text .= $form_text; |
98 | 98 | } |
99 | 99 | } |
100 | | - SFUtils::addJavascriptAndCSS($embedded?$wgParser:null); |
| 100 | + SFUtils::addJavascriptAndCSS( $embedded ? $wgParser:null ); |
101 | 101 | $script = ' <script type="text/javascript">' . "\n" . $javascript_text . '</script>' . "\n"; |
102 | 102 | if ( $embedded ) |
103 | | - $wgParser->getOutput()->addHeadItem($script); |
| 103 | + $wgParser->getOutput()->addHeadItem( $script ); |
104 | 104 | else |
105 | | - $wgOut->addScript($script); |
| 105 | + $wgOut->addScript( $script ); |
106 | 106 | if ( $embedded ) |
107 | 107 | $text = "<div class='runQueryEmbedded'>$text</div>"; |
108 | | - $wgOut->addHTML($text); |
| 108 | + $wgOut->addHTML( $text ); |
109 | 109 | } |
110 | 110 | } |
Index: trunk/extensions/SemanticForms/specials/SF_UploadWindow.php |
— | — | @@ -14,7 +14,7 @@ |
15 | 15 | * |
16 | 16 | * @author Yaron Koren |
17 | 17 | */ |
18 | | -if (!defined('MEDIAWIKI')) die(); |
| 18 | +if ( !defined( 'MEDIAWIKI' ) ) die(); |
19 | 19 | |
20 | 20 | class SFUploadWindow extends UnlistedSpecialPage { |
21 | 21 | |
— | — | @@ -22,11 +22,11 @@ |
23 | 23 | * Constructor |
24 | 24 | */ |
25 | 25 | function SFUploadWindow() { |
26 | | - SpecialPage::SpecialPage('UploadWindow'); |
27 | | - wfLoadExtensionMessages('SemanticForms'); |
| 26 | + SpecialPage::SpecialPage( 'UploadWindow' ); |
| 27 | + wfLoadExtensionMessages( 'SemanticForms' ); |
28 | 28 | } |
29 | 29 | |
30 | | - function execute($query) { |
| 30 | + function execute( $query ) { |
31 | 31 | $this->setHeaders(); |
32 | 32 | doSpecialUploadWindow(); |
33 | 33 | } |
— | — | @@ -48,9 +48,9 @@ |
49 | 49 | $form = new UploadWindowForm( $wgRequest ); |
50 | 50 | $form->execute(); |
51 | 51 | $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 |
53 | 53 | // call to get user JS was changed in MW 1.14 |
54 | | - if (method_exists($sk, 'generateUserJs')) { |
| 54 | + if ( method_exists( $sk, 'generateUserJs' ) ) { |
55 | 55 | $skin_user_js = $sk->generateUserJs(); |
56 | 56 | } else { |
57 | 57 | $skin_user_js = $sk->getUserJs(); |
— | — | @@ -61,7 +61,7 @@ |
62 | 62 | $alp = wfBoolToStr( $useAjaxLicensePreview ); |
63 | 63 | $autofill = wfBoolToStr( true ); |
64 | 64 | |
65 | | - $user_js =<<<END |
| 65 | + $user_js = <<<END |
66 | 66 | <script type="{$wgJsMimeType}"> |
67 | 67 | $skin_user_js; |
68 | 68 | wgServer="{$wgServer}"; |
— | — | @@ -72,7 +72,7 @@ |
73 | 73 | </script> |
74 | 74 | |
75 | 75 | END; |
76 | | - $vars_js = Skin::makeGlobalVariablesScript(array('skinname' => $sk->getSkinName())); |
| 76 | + $vars_js = Skin::makeGlobalVariablesScript( array( 'skinname' => $sk->getSkinName() ) ); |
77 | 77 | $wikibits_include = "<script type=\"{$wgJsMimeType}\" src=\"{$wgStylePath}/common/wikibits.js?$wgStyleVersion\"></script>"; |
78 | 78 | $ajax_include = "<script type=\"{$wgJsMimeType}\" src=\"{$wgStylePath}/common/ajax.js?$wgStyleVersion\"></script>"; |
79 | 79 | $ajaxwatch_include = "<script type=\"{$wgJsMimeType}\" src=\"{$wgStylePath}/common/ajaxwatch.js?$wgStyleVersion\"></script>"; |
— | — | @@ -80,7 +80,7 @@ |
81 | 81 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
82 | 82 | <html xmlns="{$wgXhtmlDefaultNamespace}" |
83 | 83 | END; |
84 | | - foreach($wgXhtmlNamespaces as $tag => $ns) { |
| 84 | + foreach ( $wgXhtmlNamespaces as $tag => $ns ) { |
85 | 85 | $text .= "xmlns:{$tag}=\"{$ns}\" "; |
86 | 86 | } |
87 | 87 | $dir = $wgContLang->isRTL() ? "rtl" : "ltr"; |
— | — | @@ -146,7 +146,7 @@ |
147 | 147 | $this->mInputID = $request->getText( 'sfInputID' ); |
148 | 148 | $this->mDelimiter = $request->getText( 'sfDelimiter' ); |
149 | 149 | |
150 | | - if( !$request->wasPosted() ) { |
| 150 | + if ( !$request->wasPosted() ) { |
151 | 151 | # GET requests just give the main form; no data except destination |
152 | 152 | # filename and description |
153 | 153 | return; |
— | — | @@ -169,8 +169,8 @@ |
170 | 170 | $this->mAction = $request->getVal( 'action' ); |
171 | 171 | |
172 | 172 | $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'] ) && |
175 | 175 | $_SESSION['wsUploadData'][$this->mSessionKey]['version'] == self::SESSION_VERSION ) { |
176 | 176 | /** |
177 | 177 | * Confirming a temporarily stashed upload. |
— | — | @@ -190,7 +190,7 @@ |
191 | 191 | /** |
192 | 192 | *Check for a newly uploaded file. |
193 | 193 | */ |
194 | | - if( $wgAllowCopyUploads && $this->mSourceType == 'web' ) { |
| 194 | + if ( $wgAllowCopyUploads && $this->mSourceType == 'web' ) { |
195 | 195 | $this->initializeFromUrl( $request ); |
196 | 196 | } else { |
197 | 197 | $this->initializeFromUpload( $request ); |
— | — | @@ -241,14 +241,14 @@ |
242 | 242 | private function curlCopy( $url, $dest ) { |
243 | 243 | global $wgUser, $wgOut; |
244 | 244 | |
245 | | - if( !$wgUser->isAllowed( 'upload_by_url' ) ) { |
| 245 | + if ( !$wgUser->isAllowed( 'upload_by_url' ) ) { |
246 | 246 | $wgOut->permissionRequired( 'upload_by_url' ); |
247 | 247 | return true; |
248 | 248 | } |
249 | 249 | |
250 | 250 | # Maybe remove some pasting blanks :-) |
251 | 251 | $url = trim( $url ); |
252 | | - if( stripos($url, 'http://') !== 0 && stripos($url, 'ftp://') !== 0 ) { |
| 252 | + if ( stripos( $url, 'http://' ) !== 0 && stripos( $url, 'ftp://' ) !== 0 ) { |
253 | 253 | # Only HTTP or FTP URLs |
254 | 254 | $wgOut->errorPage( 'upload-proto-error', 'upload-proto-error-text' ); |
255 | 255 | return true; |
— | — | @@ -256,17 +256,17 @@ |
257 | 257 | |
258 | 258 | # Open temporary file |
259 | 259 | $this->mCurlDestHandle = @fopen( $this->mTempPath, "wb" ); |
260 | | - if( $this->mCurlDestHandle === false ) { |
| 260 | + if ( $this->mCurlDestHandle === false ) { |
261 | 261 | # 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' ); |
263 | 263 | return true; |
264 | 264 | } |
265 | 265 | |
266 | 266 | $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 ); |
271 | 271 | curl_setopt( $ch, CURLOPT_WRITEFUNCTION, array( $this, 'uploadCurlCallback' ) ); |
272 | 272 | curl_exec( $ch ); |
273 | 273 | $error = curl_errno( $ch ) ? true : false; |
— | — | @@ -276,9 +276,9 @@ |
277 | 277 | |
278 | 278 | fclose( $this->mCurlDestHandle ); |
279 | 279 | unset( $this->mCurlDestHandle ); |
280 | | - if( $error ) { |
| 280 | + if ( $error ) { |
281 | 281 | 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" ) ) ) |
283 | 283 | $wgOut->errorPage( 'upload-misc-error', 'upload-misc-error-text' ); |
284 | 284 | else |
285 | 285 | $wgOut->errorPage( "upload-curl-error$errornum", "upload-curl-error$errornum-text" ); |
— | — | @@ -297,7 +297,7 @@ |
298 | 298 | global $wgMaxUploadSize; |
299 | 299 | $length = strlen( $data ); |
300 | 300 | $this->mFileSize += $length; |
301 | | - if( $this->mFileSize > $wgMaxUploadSize ) { |
| 301 | + if ( $this->mFileSize > $wgMaxUploadSize ) { |
302 | 302 | return 0; |
303 | 303 | } |
304 | 304 | fwrite( $this->mCurlDestHandle, $data ); |
— | — | @@ -313,14 +313,14 @@ |
314 | 314 | global $wgEnableUploads; |
315 | 315 | |
316 | 316 | # Check uploading enabled |
317 | | - if( !$wgEnableUploads ) { |
| 317 | + if ( !$wgEnableUploads ) { |
318 | 318 | $wgOut->showErrorPage( 'uploaddisabled', 'uploaddisabledtext', array( $this->mDesiredDestName ) ); |
319 | 319 | return; |
320 | 320 | } |
321 | 321 | |
322 | 322 | # Check permissions |
323 | | - if( !$wgUser->isAllowed( 'upload' ) ) { |
324 | | - if( !$wgUser->isLoggedIn() ) { |
| 323 | + if ( !$wgUser->isAllowed( 'upload' ) ) { |
| 324 | + if ( !$wgUser->isLoggedIn() ) { |
325 | 325 | $wgOut->showErrorPage( 'uploadnologin', 'uploadnologintext' ); |
326 | 326 | } else { |
327 | 327 | $wgOut->permissionRequired( 'upload' ); |
— | — | @@ -329,22 +329,22 @@ |
330 | 330 | } |
331 | 331 | |
332 | 332 | # Check blocks |
333 | | - if( $wgUser->isBlocked() ) { |
| 333 | + if ( $wgUser->isBlocked() ) { |
334 | 334 | $wgOut->blockedPage(); |
335 | 335 | return; |
336 | 336 | } |
337 | 337 | |
338 | | - if( wfReadOnly() ) { |
| 338 | + if ( wfReadOnly() ) { |
339 | 339 | $wgOut->readOnlyPage(); |
340 | 340 | return; |
341 | 341 | } |
342 | 342 | |
343 | | - if( $this->mReUpload ) { |
344 | | - if( !$this->unsaveUploadedFile() ) { |
| 343 | + if ( $this->mReUpload ) { |
| 344 | + if ( !$this->unsaveUploadedFile() ) { |
345 | 345 | return; |
346 | 346 | } |
347 | 347 | $this->mainUploadWindowForm(); |
348 | | - } else if( 'submit' == $this->mAction || $this->mUploadClicked ) { |
| 348 | + } else if ( 'submit' == $this->mAction || $this->mUploadClicked ) { |
349 | 349 | $this->processUpload(); |
350 | 350 | } else { |
351 | 351 | $this->mainUploadWindowForm(); |
— | — | @@ -363,14 +363,14 @@ |
364 | 364 | function processUpload() { |
365 | 365 | global $wgUser, $wgOut; |
366 | 366 | |
367 | | - if( !wfRunHooks( 'UploadForm:BeforeProcessing', array( &$this ) ) ) |
| 367 | + if ( !wfRunHooks( 'UploadForm:BeforeProcessing', array( &$this ) ) ) |
368 | 368 | { |
369 | 369 | wfDebug( "Hook 'UploadForm:BeforeProcessing' broke processing the file." ); |
370 | 370 | return false; |
371 | 371 | } |
372 | 372 | |
373 | 373 | /* 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*/ ) { |
375 | 375 | $this->mainUploadWindowForm( wfMsgHtml( 'largefileserver' ) ); |
376 | 376 | return; |
377 | 377 | } |
— | — | @@ -378,13 +378,13 @@ |
379 | 379 | /** |
380 | 380 | * If there was no filename or a zero size given, give up quick. |
381 | 381 | */ |
382 | | - if( trim( $this->mSrcName ) == '' || empty( $this->mFileSize ) ) { |
| 382 | + if ( trim( $this->mSrcName ) == '' || empty( $this->mFileSize ) ) { |
383 | 383 | $this->mainUploadWindowForm( wfMsgHtml( 'emptyfile' ) ); |
384 | 384 | return; |
385 | 385 | } |
386 | 386 | |
387 | 387 | # Chop off any directories in the given filename |
388 | | - if( $this->mDesiredDestName ) { |
| 388 | + if ( $this->mDesiredDestName ) { |
389 | 389 | $basename = $this->mDesiredDestName; |
390 | 390 | } else { |
391 | 391 | $basename = $this->mSrcName; |
— | — | @@ -397,7 +397,7 @@ |
398 | 398 | */ |
399 | 399 | list( $partname, $ext ) = $this->splitExtensions( $filtered ); |
400 | 400 | |
401 | | - if( count( $ext ) ) { |
| 401 | + if ( count( $ext ) ) { |
402 | 402 | $finalExt = $ext[count( $ext ) - 1]; |
403 | 403 | } else { |
404 | 404 | $finalExt = ''; |
— | — | @@ -405,12 +405,12 @@ |
406 | 406 | |
407 | 407 | # If there was more than one "extension", reassemble the base |
408 | 408 | # 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++ ) |
411 | 411 | $partname .= '.' . $ext[$i]; |
412 | 412 | } |
413 | 413 | |
414 | | - if( strlen( $partname ) < 1 ) { |
| 414 | + if ( strlen( $partname ) < 1 ) { |
415 | 415 | $this->mainUploadWindowForm( wfMsgHtml( 'minlength1' ) ); |
416 | 416 | return; |
417 | 417 | } |
— | — | @@ -421,7 +421,7 @@ |
422 | 422 | */ |
423 | 423 | $filtered = wfStripIllegalFilenameChars ( $filtered ); |
424 | 424 | $nt = Title::makeTitleSafe( NS_IMAGE, $filtered ); |
425 | | - if( is_null( $nt ) ) { |
| 425 | + if ( is_null( $nt ) ) { |
426 | 426 | $this->uploadError( wfMsgWikiHtml( 'illegalfilename', htmlspecialchars( $filtered ) ) ); |
427 | 427 | return; |
428 | 428 | } |
— | — | @@ -432,7 +432,7 @@ |
433 | 433 | * If the image is protected, non-sysop users won't be able |
434 | 434 | * to modify it by uploading a new revision. |
435 | 435 | */ |
436 | | - if( !$nt->userCan( 'edit' ) ) { |
| 436 | + if ( !$nt->userCan( 'edit' ) ) { |
437 | 437 | return $this->uploadError( wfMsgWikiHtml( 'protectedpage' ) ); |
438 | 438 | } |
439 | 439 | |
— | — | @@ -440,18 +440,18 @@ |
441 | 441 | * In some cases we may forbid overwriting of existing files. |
442 | 442 | */ |
443 | 443 | $overwrite = $this->checkOverwrite( $this->mDestName ); |
444 | | - if( WikiError::isError( $overwrite ) ) { |
| 444 | + if ( WikiError::isError( $overwrite ) ) { |
445 | 445 | return $this->uploadError( $overwrite->toString() ); |
446 | 446 | } |
447 | 447 | |
448 | 448 | /* Don't allow users to override the blacklist (check file extension) */ |
449 | 449 | global $wgStrictFileExtensions; |
450 | 450 | global $wgFileExtensions, $wgFileBlacklist; |
451 | | - if ($finalExt == '') { |
| 451 | + if ( $finalExt == '' ) { |
452 | 452 | return $this->uploadError( wfMsgExt( 'filetype-missing', array ( 'parseinline' ) ) ); |
453 | 453 | } 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' ), |
456 | 456 | htmlspecialchars( $finalExt ), implode ( ', ', $wgFileExtensions ) ) ); |
457 | 457 | } |
458 | 458 | |
— | — | @@ -460,12 +460,12 @@ |
461 | 461 | * type but it's corrupt or data of the wrong type, we should |
462 | 462 | * probably not accept it. |
463 | 463 | */ |
464 | | - if( !$this->mStashed ) { |
| 464 | + if ( !$this->mStashed ) { |
465 | 465 | $this->mFileProps = File::getPropsFromPath( $this->mTempPath, $finalExt ); |
466 | 466 | $this->checkMacBinary(); |
467 | 467 | $veri = $this->verify( $this->mTempPath, $finalExt ); |
468 | 468 | |
469 | | - if( $veri !== true ) { //it's a wiki error... |
| 469 | + if ( $veri !== true ) { // it's a wiki error... |
470 | 470 | return $this->uploadError( $veri->toString() ); |
471 | 471 | } |
472 | 472 | |
— | — | @@ -473,7 +473,7 @@ |
474 | 474 | * Provide an opportunity for extensions to add further checks |
475 | 475 | */ |
476 | 476 | $error = ''; |
477 | | - if( !wfRunHooks( 'UploadVerification', |
| 477 | + if ( !wfRunHooks( 'UploadVerification', |
478 | 478 | array( $this->mDestName, $this->mTempPath, &$error ) ) ) { |
479 | 479 | return $this->uploadError( $error ); |
480 | 480 | } |
— | — | @@ -487,18 +487,18 @@ |
488 | 488 | $warning = ''; |
489 | 489 | |
490 | 490 | global $wgCapitalLinks; |
491 | | - if( $wgCapitalLinks ) { |
| 491 | + if ( $wgCapitalLinks ) { |
492 | 492 | $filtered = ucfirst( $filtered ); |
493 | 493 | } |
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>'; |
496 | 496 | } |
497 | 497 | |
498 | 498 | global $wgCheckFileExtensions; |
499 | 499 | if ( $wgCheckFileExtensions ) { |
500 | 500 | 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>'; |
503 | 503 | } |
504 | 504 | } |
505 | 505 | |
— | — | @@ -510,13 +510,13 @@ |
511 | 511 | $warning .= '<li>' . wfMsgHtml( 'large-file', $wsize, $asize ) . '</li>'; |
512 | 512 | } |
513 | 513 | if ( $this->mFileSize == 0 ) { |
514 | | - $warning .= '<li>'.wfMsgHtml( 'emptyfile' ).'</li>'; |
| 514 | + $warning .= '<li>' . wfMsgHtml( 'emptyfile' ) . '</li>'; |
515 | 515 | } |
516 | 516 | |
517 | 517 | if ( !$this->mDestWarningAck ) { |
518 | 518 | $warning .= self::getExistsWarning( $this->mLocalFile ); |
519 | 519 | } |
520 | | - if( $warning != '' ) { |
| 520 | + if ( $warning != '' ) { |
521 | 521 | /** |
522 | 522 | * Stash the file in a temporary location; the user can choose |
523 | 523 | * to let it through and we'll complete the upload then. |
— | — | @@ -532,7 +532,7 @@ |
533 | 533 | $pageText = self::getInitialPageText( $this->mComment, $this->mLicense, |
534 | 534 | $this->mCopyrightStatus, $this->mCopyrightSource ); |
535 | 535 | |
536 | | - $status = $this->mLocalFile->upload( $this->mTempPath, $this->mComment, $pageText, |
| 536 | + $status = $this->mLocalFile->upload( $this->mTempPath, $this->mComment, $pageText, |
537 | 537 | File::DELETE_SOURCE, $this->mFileProps ); |
538 | 538 | if ( !$status->isGood() ) { |
539 | 539 | $this->showError( $status->getWikiText() ); |
— | — | @@ -543,20 +543,20 @@ |
544 | 544 | |
545 | 545 | } |
546 | 546 | // Success, redirect to description page |
547 | | - //$wgOut->redirect( $this->mLocalFile->getTitle()->getFullURL() ); |
| 547 | + // $wgOut->redirect( $this->mLocalFile->getTitle()->getFullURL() ); |
548 | 548 | |
549 | 549 | // Semantic Forms change - output Javascript to either |
550 | 550 | // fill in or append to the field in original form, and |
551 | 551 | // close the window |
552 | | - $basename = str_replace('_', ' ', $basename); |
| 552 | + $basename = str_replace( '_', ' ', $basename ); |
553 | 553 | $output = ' <script type="text/javascript">' . "\n"; |
554 | | - if ($this->mDelimiter == null) { |
555 | | - $output .=<<<END |
| 554 | + if ( $this->mDelimiter == null ) { |
| 555 | + $output .= <<<END |
556 | 556 | parent.document.getElementById("{$this->mInputID}").value = "$basename"; |
557 | 557 | |
558 | 558 | END; |
559 | 559 | } else { |
560 | | - $output .=<<<END |
| 560 | + $output .= <<<END |
561 | 561 | // if the current value is blank, set it to this file name; |
562 | 562 | // if it's not blank and ends in a space or delimiter, append |
563 | 563 | // the file name; if it ends with a normal character, append |
— | — | @@ -576,7 +576,7 @@ |
577 | 577 | |
578 | 578 | END; |
579 | 579 | } |
580 | | - $output .=<<<END |
| 580 | + $output .= <<<END |
581 | 581 | parent.fb.end(); |
582 | 582 | </script> |
583 | 583 | |
— | — | @@ -599,7 +599,7 @@ |
600 | 600 | // with lowercase extension exists already |
601 | 601 | $warning = ''; |
602 | 602 | |
603 | | - if( strpos( $file->getName(), '.' ) == false ) { |
| 603 | + if ( strpos( $file->getName(), '.' ) == false ) { |
604 | 604 | $partname = $file->getName(); |
605 | 605 | $rawExtension = ''; |
606 | 606 | } else { |
— | — | @@ -619,14 +619,14 @@ |
620 | 620 | $file_lc = false; |
621 | 621 | } |
622 | 622 | |
623 | | - if( $file->exists() ) { |
| 623 | + if ( $file->exists() ) { |
624 | 624 | $dlink = $sk->makeKnownLinkObj( $file->getTitle() ); |
625 | 625 | 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 ), |
627 | 627 | $file->getName(), 'right', array(), false, true ); |
628 | 628 | } elseif ( !$file->allowInlineDisplay() && $file->isSafeFile() ) { |
629 | 629 | $icon = $file->iconThumb(); |
630 | | - $dlink2 = '<div style="float:right" id="mw-media-icon">' . |
| 630 | + $dlink2 = '<div style="float:right" id="mw-media-icon">' . |
631 | 631 | $icon->toHtml( array( 'desc-link' => true ) ) . '<br />' . $dlink . '</div>'; |
632 | 632 | } else { |
633 | 633 | $dlink2 = ''; |
— | — | @@ -639,53 +639,53 @@ |
640 | 640 | # It's not forbidden but in 99% it makes no sense to upload the same filename with uppercase extension |
641 | 641 | $dlink = $sk->makeKnownLinkObj( $nt_lc ); |
642 | 642 | 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 ), |
644 | 644 | $nt_lc->getText(), 'right', array(), false, true ); |
645 | 645 | } elseif ( !$file_lc->allowInlineDisplay() && $file_lc->isSafeFile() ) { |
646 | 646 | $icon = $file_lc->iconThumb(); |
647 | | - $dlink2 = '<div style="float:right" id="mw-media-icon">' . |
| 647 | + $dlink2 = '<div style="float:right" id="mw-media-icon">' . |
648 | 648 | $icon->toHtml( array( 'desc-link' => true ) ) . '<br />' . $dlink . '</div>'; |
649 | 649 | } else { |
650 | 650 | $dlink2 = ''; |
651 | 651 | } |
652 | 652 | |
653 | | - $warning .= '<li>' . wfMsgExt( 'fileexists-extension', 'parsemag', $file->getName(), $dlink ) . '</li>' . $dlink2; |
| 653 | + $warning .= '<li>' . wfMsgExt( 'fileexists-extension', 'parsemag', $file->getName(), $dlink ) . '</li>' . $dlink2; |
654 | 654 | |
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 ) ) ) |
657 | 657 | { |
658 | 658 | # 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 ); |
660 | 660 | $file_thb = wfLocalFile( $nt_thb ); |
661 | | - if ($file_thb->exists() ) { |
| 661 | + if ( $file_thb->exists() ) { |
662 | 662 | # Check if an image without leading '180px-' (or similiar) exists |
663 | | - $dlink = $sk->makeKnownLinkObj( $nt_thb); |
| 663 | + $dlink = $sk->makeKnownLinkObj( $nt_thb ); |
664 | 664 | 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 ), |
667 | 667 | $nt_thb->getText(), 'right', array(), false, true ); |
668 | 668 | } elseif ( !$file_thb->allowInlineDisplay() && $file_thb->isSafeFile() ) { |
669 | 669 | $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 />' . |
672 | 672 | $dlink . '</div>'; |
673 | 673 | } else { |
674 | 674 | $dlink2 = ''; |
675 | 675 | } |
676 | 676 | |
677 | | - $warning .= '<li>' . wfMsgExt( 'fileexists-thumbnail-yes', 'parsemag', $dlink ) . |
678 | | - '</li>' . $dlink2; |
| 677 | + $warning .= '<li>' . wfMsgExt( 'fileexists-thumbnail-yes', 'parsemag', $dlink ) . |
| 678 | + '</li>' . $dlink2; |
679 | 679 | } else { |
680 | 680 | # 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>'; |
683 | 683 | } |
684 | 684 | } |
685 | 685 | if ( $file->wasDeleted() ) { |
686 | 686 | # If the file existed before and was deleted, warn the user of this |
687 | 687 | # Don't bother doing so if the image exists now, however |
688 | 688 | $ltitle = SpecialPage::getTitleFor( 'Log' ); |
689 | | - $llink = $sk->makeKnownLinkObj( $ltitle, wfMsgHtml( 'sf_deletionlog' ), |
| 689 | + $llink = $sk->makeKnownLinkObj( $ltitle, wfMsgHtml( 'sf_deletionlog' ), |
690 | 690 | 'type=delete&page=' . $file->getTitle()->getPrefixedUrl() ); |
691 | 691 | $warning .= '<li>' . wfMsgWikiHtml( 'filewasdeleted', $llink ) . '</li>'; |
692 | 692 | } |
— | — | @@ -694,7 +694,7 @@ |
695 | 695 | |
696 | 696 | static function ajaxGetExistsWarning( $filename ) { |
697 | 697 | $file = wfFindFile( $filename ); |
698 | | - if( !$file ) { |
| 698 | + if ( !$file ) { |
699 | 699 | // Force local file so we have an object to do further checks against |
700 | 700 | // if there isn't an exact match... |
701 | 701 | $file = wfLocalFile( $filename ); |
— | — | @@ -764,7 +764,7 @@ |
765 | 765 | function stashSession() { |
766 | 766 | $stash = $this->saveTempUploadedFile( $this->mDestName, $this->mTempPath ); |
767 | 767 | |
768 | | - if( !$stash ) { |
| 768 | + if ( !$stash ) { |
769 | 769 | # Couldn't save the file. |
770 | 770 | return false; |
771 | 771 | } |
— | — | @@ -822,7 +822,7 @@ |
823 | 823 | global $wgUseCopyrightUpload; |
824 | 824 | |
825 | 825 | $this->mSessionKey = $this->stashSession(); |
826 | | - if( !$this->mSessionKey ) { |
| 826 | + if ( !$this->mSessionKey ) { |
827 | 827 | # Couldn't save file; an error has been displayed so let's go. |
828 | 828 | return; |
829 | 829 | } |
— | — | @@ -885,7 +885,7 @@ |
886 | 886 | * @param string $msg as HTML |
887 | 887 | * @access private |
888 | 888 | */ |
889 | | - function mainUploadWindowForm( $msg='' ) { |
| 889 | + function mainUploadWindowForm( $msg = '' ) { |
890 | 890 | global $wgOut, $wgUser, $wgContLang; |
891 | 891 | global $wgUseCopyrightUpload, $wgUseAjax, $wgAjaxUploadDestCheck, $wgAjaxLicensePreview; |
892 | 892 | global $wgRequest, $wgAllowCopyUploads; |
— | — | @@ -904,15 +904,15 @@ |
905 | 905 | <script type=\"text/javascript\" src=\"{$wgStylePath}/common/upload.js?{$wgStyleVersion}\"></script> |
906 | 906 | " ); |
907 | 907 | |
908 | | - if( !wfRunHooks( 'UploadForm:initial', array( &$this ) ) ) |
| 908 | + if ( !wfRunHooks( 'UploadForm:initial', array( &$this ) ) ) |
909 | 909 | { |
910 | 910 | wfDebug( "Hook 'UploadForm:initial' broke output of the upload form" ); |
911 | 911 | return false; |
912 | 912 | } |
913 | 913 | |
914 | | - if( $this->mDesiredDestName && $wgUser->isAllowed( 'deletedhistory' ) ) { |
| 914 | + if ( $this->mDesiredDestName && $wgUser->isAllowed( 'deletedhistory' ) ) { |
915 | 915 | $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 ) { |
917 | 917 | $link = wfMsgExt( |
918 | 918 | $wgUser->isAllowed( 'delete' ) ? 'thisisdeleted' : 'viewdeleted', |
919 | 919 | array( 'parse', 'replaceafter' ), |
— | — | @@ -922,11 +922,11 @@ |
923 | 923 | ) |
924 | 924 | ); |
925 | 925 | $wgOut->addHTML( "<div id=\"contentSub2\">{$link}</div>" ); |
926 | | - } |
| 926 | + } |
927 | 927 | } |
928 | 928 | |
929 | 929 | // ignore user's settings to get a smaller form |
930 | | - $cols = 45; //intval($wgUser->getOption( 'cols' )); |
| 930 | + $cols = 45; // intval($wgUser->getOption( 'cols' )); |
931 | 931 | $ew = $wgUser->getOption( 'editwidth' ); |
932 | 932 | if ( $ew ) $ew = " style=\"width:100%\""; |
933 | 933 | else $ew = ''; |
— | — | @@ -938,9 +938,9 @@ |
939 | 939 | } |
940 | 940 | // the 'uploadtext' message is not displayed in this window, |
941 | 941 | // 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>' ); |
945 | 945 | |
946 | 946 | $sourcefilename = wfMsgHtml( 'sourcefilename' ); |
947 | 947 | $destfilename = wfMsgHtml( 'destfilename' ); |
— | — | @@ -976,15 +976,15 @@ |
977 | 977 | $warningChecked = $this->mIgnoreWarning ? 'checked' : ''; |
978 | 978 | |
979 | 979 | // Prepare form for upload or upload/copy |
980 | | - if( $wgAllowCopyUploads && $wgUser->isAllowed( 'upload_by_url' ) ) { |
| 980 | + if ( $wgAllowCopyUploads && $wgUser->isAllowed( 'upload_by_url' ) ) { |
981 | 981 | $filename_form = |
982 | 982 | "<input type='radio' id='wpSourceTypeFile' name='wpSourceType' value='file' " . |
983 | 983 | "onchange='toggle_element_activation(\"wpUploadFileURL\",\"wpUploadFile\")' checked />" . |
984 | 984 | "<input tabindex='1' type='file' name='wpUploadFile' id='wpUploadFile' " . |
985 | | - "onfocus='" . |
| 985 | + "onfocus='" . |
986 | 986 | "toggle_element_activation(\"wpUploadFileURL\",\"wpUploadFile\");" . |
987 | 987 | "toggle_element_check(\"wpSourceTypeFile\",\"wpSourceTypeURL\")'" . |
988 | | - ($this->mDesiredDestName?"":"onchange='fillDestFilename(\"wpUploadFile\")' ") . "size='40' />" . |
| 988 | + ( $this->mDesiredDestName ? "":"onchange='fillDestFilename(\"wpUploadFile\")' " ) . "size='40' />" . |
989 | 989 | wfMsgHTML( 'upload_source_file' ) . "<br />" . |
990 | 990 | "<input type='radio' id='wpSourceTypeURL' name='wpSourceType' value='web' " . |
991 | 991 | "onchange='toggle_element_activation(\"wpUploadFile\",\"wpUploadFileURL\")' />" . |
— | — | @@ -992,12 +992,12 @@ |
993 | 993 | "onfocus='" . |
994 | 994 | "toggle_element_activation(\"wpUploadFile\",\"wpUploadFileURL\");" . |
995 | 995 | "toggle_element_check(\"wpSourceTypeURL\",\"wpSourceTypeFile\")'" . |
996 | | - ($this->mDesiredDestName?"":"onchange='fillDestFilename(\"wpUploadFileURL\")' ") . "size='40' DISABLED />" . |
| 996 | + ( $this->mDesiredDestName ? "":"onchange='fillDestFilename(\"wpUploadFileURL\")' " ) . "size='40' DISABLED />" . |
997 | 997 | wfMsgHtml( 'upload_source_url' ) ; |
998 | 998 | } else { |
999 | 999 | $filename_form = |
1000 | 1000 | "<input tabindex='1' type='file' name='wpUploadFile' id='wpUploadFile' " . |
1001 | | - ($this->mDesiredDestName?"":"onchange='fillDestFilename(\"wpUploadFile\")' ") . |
| 1001 | + ( $this->mDesiredDestName ? "":"onchange='fillDestFilename(\"wpUploadFile\")' " ) . |
1002 | 1002 | "size='40' />" . |
1003 | 1003 | "<input type='hidden' name='wpSourceType' value='file' />" ; |
1004 | 1004 | } |
— | — | @@ -1055,7 +1055,7 @@ |
1056 | 1056 | </td> |
1057 | 1057 | </tr> |
1058 | 1058 | <tr>" ); |
1059 | | - if( $useAjaxLicensePreview ) { |
| 1059 | + if ( $useAjaxLicensePreview ) { |
1060 | 1060 | $wgOut->addHTML( " |
1061 | 1061 | <td></td> |
1062 | 1062 | <td id=\"mw-license-preview\"></td> |
— | — | @@ -1081,7 +1081,7 @@ |
1082 | 1082 | value=\"$uploadsource\" size='40' /></td> |
1083 | 1083 | </tr> |
1084 | 1084 | <tr> |
1085 | | - "); |
| 1085 | + " ); |
1086 | 1086 | } |
1087 | 1087 | |
1088 | 1088 | $wgOut->addHTML( " |
— | — | @@ -1151,8 +1151,8 @@ |
1152 | 1152 | * @return bool |
1153 | 1153 | */ |
1154 | 1154 | 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 ) ) { |
1157 | 1157 | return true; |
1158 | 1158 | } |
1159 | 1159 | } |
— | — | @@ -1167,42 +1167,42 @@ |
1168 | 1168 | * @return mixed true of the file is verified, a WikiError object otherwise. |
1169 | 1169 | */ |
1170 | 1170 | 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 ); |
1174 | 1174 | |
1175 | | - #check mime type, if desired |
| 1175 | + # check mime type, if desired |
1176 | 1176 | global $wgVerifyMimeType; |
1177 | | - if ($wgVerifyMimeType) { |
| 1177 | + if ( $wgVerifyMimeType ) { |
1178 | 1178 | |
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 ) ) { |
1182 | 1182 | return new WikiErrorMsg( 'uploadcorrupt' ); |
1183 | 1183 | } |
1184 | 1184 | |
1185 | | - #check mime type blacklist |
| 1185 | + # check mime type blacklist |
1186 | 1186 | global $wgMimeTypeBlacklist; |
1187 | | - if( isset($wgMimeTypeBlacklist) && !is_null($wgMimeTypeBlacklist) |
| 1187 | + if ( isset( $wgMimeTypeBlacklist ) && !is_null( $wgMimeTypeBlacklist ) |
1188 | 1188 | && $this->checkFileExtension( $mime, $wgMimeTypeBlacklist ) ) { |
1189 | 1189 | return new WikiErrorMsg( 'filetype-badmime', htmlspecialchars( $mime ) ); |
1190 | 1190 | } |
1191 | 1191 | } |
1192 | 1192 | |
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 ) ) { |
1195 | 1195 | return new WikiErrorMsg( 'uploadscripted' ); |
1196 | 1196 | } |
1197 | 1197 | |
1198 | 1198 | /** |
1199 | 1199 | * Scan the uploaded file for viruses |
1200 | 1200 | */ |
1201 | | - $virus= $this->detectVirus($tmpfile); |
| 1201 | + $virus = $this->detectVirus( $tmpfile ); |
1202 | 1202 | if ( $virus ) { |
1203 | | - return new WikiErrorMsg( 'uploadvirus', htmlspecialchars($virus) ); |
| 1203 | + return new WikiErrorMsg( 'uploadvirus', htmlspecialchars( $virus ) ); |
1204 | 1204 | } |
1205 | 1205 | |
1206 | | - wfDebug( __METHOD__.": all clear; passing.\n" ); |
| 1206 | + wfDebug( __METHOD__ . ": all clear; passing.\n" ); |
1207 | 1207 | return true; |
1208 | 1208 | } |
1209 | 1209 | |
— | — | @@ -1218,28 +1218,28 @@ |
1219 | 1219 | |
1220 | 1220 | if ( ! $mime || $mime == 'unknown' || $mime == 'unknown/unknown' ) |
1221 | 1221 | if ( ! $magic->isRecognizableExtension( $extension ) ) { |
1222 | | - wfDebug( __METHOD__.": passing file with unknown detected mime type; " . |
| 1222 | + wfDebug( __METHOD__ . ": passing file with unknown detected mime type; " . |
1223 | 1223 | "unrecognized extension '$extension', can't verify\n" ); |
1224 | 1224 | return true; |
1225 | 1225 | } else { |
1226 | | - wfDebug( __METHOD__.": rejecting file with unknown detected mime type; ". |
| 1226 | + wfDebug( __METHOD__ . ": rejecting file with unknown detected mime type; " . |
1227 | 1227 | "recognized extension '$extension', so probably invalid file\n" ); |
1228 | 1228 | return false; |
1229 | 1229 | } |
1230 | 1230 | |
1231 | | - $match= $magic->isMatchingExtension($extension,$mime); |
| 1231 | + $match = $magic->isMatchingExtension( $extension, $mime ); |
1232 | 1232 | |
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" ); |
1235 | 1235 | 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" ); |
1238 | 1238 | |
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! |
1240 | 1240 | return true; |
1241 | 1241 | |
1242 | 1242 | } 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" ); |
1244 | 1244 | return false; |
1245 | 1245 | } |
1246 | 1246 | } |
— | — | @@ -1254,38 +1254,38 @@ |
1255 | 1255 | * @param string $extension The extension of the file |
1256 | 1256 | * @return bool true if the file contains something looking like embedded scripts |
1257 | 1257 | */ |
1258 | | - function detectScript($file, $mime, $extension) { |
| 1258 | + function detectScript( $file, $mime, $extension ) { |
1259 | 1259 | global $wgAllowTitlesInSVG; |
1260 | 1260 | |
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. |
1263 | 1263 | |
1264 | | - if (strpos($mime,'text/')===0) $chunk = file_get_contents( $file ); |
| 1264 | + if ( strpos( $mime, 'text/' ) === 0 ) $chunk = file_get_contents( $file ); |
1265 | 1265 | else { |
1266 | 1266 | $fp = fopen( $file, 'rb' ); |
1267 | 1267 | $chunk = fread( $fp, 1024 ); |
1268 | 1268 | fclose( $fp ); |
1269 | 1269 | } |
1270 | 1270 | |
1271 | | - $chunk= strtolower( $chunk ); |
| 1271 | + $chunk = strtolower( $chunk ); |
1272 | 1272 | |
1273 | | - if (!$chunk) return false; |
| 1273 | + if ( !$chunk ) return false; |
1274 | 1274 | |
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; |
1279 | 1279 | |
1280 | | - if ($enc) $chunk= iconv($enc,"ASCII//IGNORE",$chunk); |
| 1280 | + if ( $enc ) $chunk = iconv( $enc, "ASCII//IGNORE", $chunk ); |
1281 | 1281 | |
1282 | | - $chunk= trim($chunk); |
| 1282 | + $chunk = trim( $chunk ); |
1283 | 1283 | |
1284 | | - #FIXME: convert from UTF-16 if necessarry! |
| 1284 | + # FIXME: convert from UTF-16 if necessarry! |
1285 | 1285 | |
1286 | | - wfDebug("SpecialUpload::detectScript: checking for embedded scripts and HTML stuff\n"); |
| 1286 | + wfDebug( "SpecialUpload::detectScript: checking for embedded scripts and HTML stuff\n" ); |
1287 | 1287 | |
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; |
1290 | 1290 | |
1291 | 1291 | /** |
1292 | 1292 | * Internet Explorer for Windows performs some really stupid file type |
— | — | @@ -1306,18 +1306,18 @@ |
1307 | 1307 | $tags = array( |
1308 | 1308 | '<body', |
1309 | 1309 | '<head', |
1310 | | - '<html', #also in safari |
| 1310 | + '<html', # also in safari |
1311 | 1311 | '<img', |
1312 | 1312 | '<pre', |
1313 | | - '<script', #also in safari |
| 1313 | + '<script', # also in safari |
1314 | 1314 | '<table' |
1315 | 1315 | ); |
1316 | | - if( ! $wgAllowTitlesInSVG && $extension !== 'svg' && $mime !== 'image/svg' ) { |
| 1316 | + if ( ! $wgAllowTitlesInSVG && $extension !== 'svg' && $mime !== 'image/svg' ) { |
1317 | 1317 | $tags[] = '<title'; |
1318 | 1318 | } |
1319 | 1319 | |
1320 | | - foreach( $tags as $tag ) { |
1321 | | - if( false !== strpos( $chunk, $tag ) ) { |
| 1320 | + foreach ( $tags as $tag ) { |
| 1321 | + if ( false !== strpos( $chunk, $tag ) ) { |
1322 | 1322 | return true; |
1323 | 1323 | } |
1324 | 1324 | } |
— | — | @@ -1326,19 +1326,19 @@ |
1327 | 1327 | * look for javascript |
1328 | 1328 | */ |
1329 | 1329 | |
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? |
1331 | 1331 | $chunk = Sanitizer::decodeCharReferences( $chunk ); |
1332 | 1332 | |
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; |
1335 | 1335 | |
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; |
1338 | 1338 | |
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; |
1341 | 1341 | |
1342 | | - wfDebug("SpecialUpload::detectScript: no scripts found\n"); |
| 1342 | + wfDebug( "SpecialUpload::detectScript: no scripts found\n" ); |
1343 | 1343 | return false; |
1344 | 1344 | } |
1345 | 1345 | |
— | — | @@ -1352,18 +1352,18 @@ |
1353 | 1353 | * or a string containing feedback from the virus scanner if a virus was found. |
1354 | 1354 | * If textual feedback is missing but a virus was found, this function returns true. |
1355 | 1355 | */ |
1356 | | - function detectVirus($file) { |
| 1356 | + function detectVirus( $file ) { |
1357 | 1357 | global $wgAntivirus, $wgAntivirusSetup, $wgAntivirusRequired, $wgOut; |
1358 | 1358 | |
1359 | 1359 | if ( !$wgAntivirus ) { |
1360 | | - wfDebug( __METHOD__.": virus scanner disabled\n"); |
| 1360 | + wfDebug( __METHOD__ . ": virus scanner disabled\n" ); |
1361 | 1361 | return null; |
1362 | 1362 | } |
1363 | 1363 | |
1364 | 1364 | if ( !$wgAntivirusSetup[$wgAntivirus] ) { |
1365 | | - wfDebug( __METHOD__.": unknown virus scanner: $wgAntivirus\n" ); |
| 1365 | + wfDebug( __METHOD__ . ": unknown virus scanner: $wgAntivirus\n" ); |
1366 | 1366 | # @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" ); |
1368 | 1368 | return "unknown antivirus: $wgAntivirus"; |
1369 | 1369 | } |
1370 | 1370 | |
— | — | @@ -1373,20 +1373,20 @@ |
1374 | 1374 | $msgPattern = isset( $wgAntivirusSetup[$wgAntivirus]["messagepattern"] ) ? |
1375 | 1375 | $wgAntivirusSetup[$wgAntivirus]["messagepattern"] : null; |
1376 | 1376 | |
1377 | | - if ( strpos( $command,"%f" ) === false ) { |
| 1377 | + if ( strpos( $command, "%f" ) === false ) { |
1378 | 1378 | # simple pattern: append file to scan |
1379 | | - $command .= " " . wfEscapeShellArg( $file ); |
| 1379 | + $command .= " " . wfEscapeShellArg( $file ); |
1380 | 1380 | } else { |
1381 | 1381 | # complex pattern: replace "%f" with file to scan |
1382 | | - $command = str_replace( "%f", wfEscapeShellArg( $file ), $command ); |
| 1382 | + $command = str_replace( "%f", wfEscapeShellArg( $file ), $command ); |
1383 | 1383 | } |
1384 | 1384 | |
1385 | | - wfDebug( __METHOD__.": running virus scan: $command \n" ); |
| 1385 | + wfDebug( __METHOD__ . ": running virus scan: $command \n" ); |
1386 | 1386 | |
1387 | 1387 | # execute virus scanner |
1388 | 1388 | $exitCode = false; |
1389 | 1389 | |
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. |
1391 | 1391 | # that does not seem to be worth the pain. |
1392 | 1392 | # Ask me (Duesentrieb) about it if it's ever needed. |
1393 | 1393 | $output = array(); |
— | — | @@ -1398,7 +1398,7 @@ |
1399 | 1399 | |
1400 | 1400 | # map exit code to AV_xxx constants. |
1401 | 1401 | $mappedCode = $exitCode; |
1402 | | - if ( $exitCodeMap ) { |
| 1402 | + if ( $exitCodeMap ) { |
1403 | 1403 | if ( isset( $exitCodeMap[$exitCode] ) ) { |
1404 | 1404 | $mappedCode = $exitCodeMap[$exitCode]; |
1405 | 1405 | } elseif ( isset( $exitCodeMap["*"] ) ) { |
— | — | @@ -1406,29 +1406,29 @@ |
1407 | 1407 | } |
1408 | 1408 | } |
1409 | 1409 | |
1410 | | - if ( $mappedCode === AV_SCAN_FAILED ) { |
| 1410 | + if ( $mappedCode === AV_SCAN_FAILED ) { |
1411 | 1411 | # 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" ); |
1413 | 1413 | |
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; |
1418 | 1418 | } |
1419 | | - } else if ( $mappedCode === AV_SCAN_ABORTED ) { |
| 1419 | + } else if ( $mappedCode === AV_SCAN_ABORTED ) { |
1420 | 1420 | # 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" ); |
1422 | 1422 | return null; |
1423 | 1423 | } else if ( $mappedCode === AV_NO_VIRUS ) { |
1424 | 1424 | # no virus found |
1425 | | - wfDebug( __METHOD__.": file passed virus scan.\n" ); |
| 1425 | + wfDebug( __METHOD__ . ": file passed virus scan.\n" ); |
1426 | 1426 | return false; |
1427 | 1427 | } else { |
1428 | 1428 | $output = join( "\n", $output ); |
1429 | 1429 | $output = trim( $output ); |
1430 | 1430 | |
1431 | 1431 | if ( !$output ) { |
1432 | | - $output = true; #if there's no output, return true |
| 1432 | + $output = true; # if there's no output, return true |
1433 | 1433 | } elseif ( $msgPattern ) { |
1434 | 1434 | $groups = array(); |
1435 | 1435 | if ( preg_match( $msgPattern, $output, $groups ) ) { |
— | — | @@ -1438,7 +1438,7 @@ |
1439 | 1439 | } |
1440 | 1440 | } |
1441 | 1441 | |
1442 | | - wfDebug( __METHOD__.": FOUND VIRUS! scanner feedback: $output" ); |
| 1442 | + wfDebug( __METHOD__ . ": FOUND VIRUS! scanner feedback: $output" ); |
1443 | 1443 | return $output; |
1444 | 1444 | } |
1445 | 1445 | } |
— | — | @@ -1453,7 +1453,7 @@ |
1454 | 1454 | */ |
1455 | 1455 | function checkMacBinary() { |
1456 | 1456 | $macbin = new MacBinary( $this->mTempPath ); |
1457 | | - if( $macbin->isValid() ) { |
| 1457 | + if ( $macbin->isValid() ) { |
1458 | 1458 | $dataFile = tempnam( wfTempDir(), "WikiMacBinary" ); |
1459 | 1459 | $dataHandle = fopen( $dataFile, 'wb' ); |
1460 | 1460 | |
— | — | @@ -1492,21 +1492,21 @@ |
1493 | 1493 | $img = wfFindFile( $name ); |
1494 | 1494 | |
1495 | 1495 | $error = ''; |
1496 | | - if( $img ) { |
| 1496 | + if ( $img ) { |
1497 | 1497 | 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 ) ) { |
1500 | 1500 | $error = 'fileexists-forbidden'; |
1501 | 1501 | } |
1502 | 1502 | } else { |
1503 | | - if( !$wgUser->isAllowed( 'reupload' ) || |
| 1503 | + if ( !$wgUser->isAllowed( 'reupload' ) || |
1504 | 1504 | !$wgUser->isAllowed( 'reupload-shared' ) ) { |
1505 | 1505 | $error = "fileexists-shared-forbidden"; |
1506 | 1506 | } |
1507 | 1507 | } |
1508 | 1508 | } |
1509 | 1509 | |
1510 | | - if( $error ) { |
| 1510 | + if ( $error ) { |
1511 | 1511 | $errorText = wfMsg( $error, wfEscapeWikiText( $img->getName() ) ); |
1512 | 1512 | return new WikiError( $wgOut->parse( $errorText ) ); |
1513 | 1513 | } |
— | — | @@ -1523,13 +1523,13 @@ |
1524 | 1524 | * @return bool |
1525 | 1525 | */ |
1526 | 1526 | public static function userCanReUpload( User $user, $img ) { |
1527 | | - if( $user->isAllowed( 'reupload' ) ) |
| 1527 | + if ( $user->isAllowed( 'reupload' ) ) |
1528 | 1528 | return true; // non-conditional |
1529 | | - if( !$user->isAllowed( 'reupload-own' ) ) |
| 1529 | + if ( !$user->isAllowed( 'reupload-own' ) ) |
1530 | 1530 | return false; |
1531 | 1531 | |
1532 | 1532 | $dbr = wfGetDB( DB_SLAVE ); |
1533 | | - $row = $dbr->selectRow('image', |
| 1533 | + $row = $dbr->selectRow( 'image', |
1534 | 1534 | /* SELECT */ 'img_user', |
1535 | 1535 | /* WHERE */ array( 'img_name' => $img ) |
1536 | 1536 | ); |
Index: trunk/extensions/SemanticForms/specials/SF_Templates.php |
— | — | @@ -5,7 +5,7 @@ |
6 | 6 | * @author Yaron Koren |
7 | 7 | */ |
8 | 8 | |
9 | | -if (!defined('MEDIAWIKI')) die(); |
| 9 | +if ( !defined( 'MEDIAWIKI' ) ) die(); |
10 | 10 | |
11 | 11 | class SFTemplates extends SpecialPage { |
12 | 12 | |
— | — | @@ -13,11 +13,11 @@ |
14 | 14 | * Constructor |
15 | 15 | */ |
16 | 16 | function SFTemplates() { |
17 | | - SpecialPage::SpecialPage('Templates'); |
18 | | - wfLoadExtensionMessages('SemanticForms'); |
| 17 | + SpecialPage::SpecialPage( 'Templates' ); |
| 18 | + wfLoadExtensionMessages( 'SemanticForms' ); |
19 | 19 | } |
20 | 20 | |
21 | | - function execute($query) { |
| 21 | + function execute( $query ) { |
22 | 22 | $this->setHeaders(); |
23 | 23 | list( $limit, $offset ) = wfCheckLimits(); |
24 | 24 | $rep = new TemplatesPage(); |
— | — | @@ -37,13 +37,13 @@ |
38 | 38 | function getPageHeader() { |
39 | 39 | global $wgUser; |
40 | 40 | |
41 | | - wfLoadExtensionMessages('SemanticForms'); |
| 41 | + wfLoadExtensionMessages( 'SemanticForms' ); |
42 | 42 | |
43 | 43 | $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() ); |
46 | 46 | $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"; |
48 | 48 | return $header; |
49 | 49 | } |
50 | 50 | |
— | — | @@ -67,28 +67,28 @@ |
68 | 68 | return false; |
69 | 69 | } |
70 | 70 | |
71 | | - function getCategoryDefinedByTemplate($template_article) { |
| 71 | + function getCategoryDefinedByTemplate( $template_article ) { |
72 | 72 | global $wgContLang; |
73 | 73 | |
74 | 74 | $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 ) ) { |
77 | 77 | // get the last match - if there's more than one |
78 | 78 | // category tag, there's a good chance that the last |
79 | 79 | // one will be the relevant one - the others are |
80 | 80 | // probably part of inline queries |
81 | | - return trim(end($matches[1])); |
| 81 | + return trim( end( $matches[1] ) ); |
82 | 82 | } |
83 | 83 | return ""; |
84 | 84 | } |
85 | 85 | |
86 | | - function formatResult($skin, $result) { |
87 | | - wfLoadExtensionMessages('SemanticForms'); |
| 86 | + function formatResult( $skin, $result ) { |
| 87 | + wfLoadExtensionMessages( 'SemanticForms' ); |
88 | 88 | $title = Title::makeTitle( NS_TEMPLATE, $result->value ); |
89 | 89 | $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 ); |
93 | 93 | return $text; |
94 | 94 | } |
95 | 95 | } |
Index: trunk/extensions/SemanticForms/specials/SF_UploadWindow2.php |
— | — | @@ -64,13 +64,13 @@ |
65 | 65 | $this->mRequest = $request; |
66 | 66 | $this->mSourceType = $request->getVal( 'wpSourceType', 'file' ); |
67 | 67 | $this->mUpload = UploadBase::createFromRequest( $request ); |
68 | | - $this->mUploadClicked = $request->wasPosted() |
69 | | - && ( $request->getCheck( 'wpUpload' ) |
| 68 | + $this->mUploadClicked = $request->wasPosted() |
| 69 | + && ( $request->getCheck( 'wpUpload' ) |
70 | 70 | || $request->getCheck( 'wpUploadIgnoreWarning' ) ); |
71 | 71 | |
72 | 72 | // Guess the desired name from the filename if not provided |
73 | 73 | $this->mDesiredDestName = $request->getText( 'wpDestFile' ); |
74 | | - if( !$this->mDesiredDestName ) |
| 74 | + if ( !$this->mDesiredDestName ) |
75 | 75 | $this->mDesiredDestName = $request->getText( 'wpUploadFile' ); |
76 | 76 | $this->mComment = $request->getText( 'wpUploadDescription' ); |
77 | 77 | $this->mLicense = $request->getText( 'wpLicense' ); |
— | — | @@ -89,7 +89,7 @@ |
90 | 90 | |
91 | 91 | // If it was posted check for the token (no remote POST'ing with user credentials) |
92 | 92 | $token = $request->getVal( 'wpEditToken' ); |
93 | | - if( $this->mSourceType == 'file' && $token == null ) { |
| 93 | + if ( $this->mSourceType == 'file' && $token == null ) { |
94 | 94 | // Skip token check for file uploads as that can't be faked via JS... |
95 | 95 | // Some client-side tools don't expect to need to send wpEditToken |
96 | 96 | // with their submissions, as that's new in 1.16. |
— | — | @@ -127,15 +127,15 @@ |
128 | 128 | $this->outputHeader(); |
129 | 129 | |
130 | 130 | # Check uploading enabled |
131 | | - if( !UploadBase::isEnabled() ) { |
| 131 | + if ( !UploadBase::isEnabled() ) { |
132 | 132 | $wgOut->showErrorPage( 'uploaddisabled', 'uploaddisabledtext' ); |
133 | 133 | return; |
134 | 134 | } |
135 | 135 | |
136 | 136 | # Check permissions |
137 | 137 | 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'] |
140 | 140 | || $wgGroupPermissions['autoconfirmed']['upload'] ) ) { |
141 | 141 | // Custom message if logged-in users without any special rights can upload |
142 | 142 | $wgOut->showErrorPage( 'uploadnologin', 'uploadnologintext' ); |
— | — | @@ -146,13 +146,13 @@ |
147 | 147 | } |
148 | 148 | |
149 | 149 | # Check blocks |
150 | | - if( $wgUser->isBlocked() ) { |
| 150 | + if ( $wgUser->isBlocked() ) { |
151 | 151 | $wgOut->blockedPage(); |
152 | 152 | return; |
153 | 153 | } |
154 | 154 | |
155 | 155 | # Check whether we actually want to allow changing stuff |
156 | | - if( wfReadOnly() ) { |
| 156 | + if ( wfReadOnly() ) { |
157 | 157 | $wgOut->readOnlyPage(); |
158 | 158 | return; |
159 | 159 | } |
— | — | @@ -204,8 +204,8 @@ |
205 | 205 | |
206 | 206 | # Initialize form |
207 | 207 | $form = new SFUploadForm( array( |
208 | | - 'watch' => $this->watchCheck(), |
209 | | - 'forreupload' => $this->mForReUpload, |
| 208 | + 'watch' => $this->watchCheck(), |
| 209 | + 'forreupload' => $this->mForReUpload, |
210 | 210 | 'sessionkey' => $sessionKey, |
211 | 211 | 'hideignorewarning' => $hideIgnoreWarning, |
212 | 212 | 'sfInputID' => $this->mInputID, |
— | — | @@ -214,12 +214,12 @@ |
215 | 215 | $form->setTitle( $this->getTitle() ); |
216 | 216 | |
217 | 217 | # Check the token, but only if necessary |
218 | | - if( !$this->mTokenOk && !$this->mCancelUpload |
| 218 | + if ( !$this->mTokenOk && !$this->mCancelUpload |
219 | 219 | && ( $this->mUpload && $this->mUploadClicked ) ) |
220 | 220 | $form->addPreText( wfMsgExt( 'session_fail_preview', 'parseinline' ) ); |
221 | 221 | |
222 | 222 | # Add text to form |
223 | | - //$form->addPreText( '<div id="uploadtext">' . wfMsgExt( 'uploadtext', 'parse' ) . '</div>'); |
| 223 | + // $form->addPreText( '<div id="uploadtext">' . wfMsgExt( 'uploadtext', 'parse' ) . '</div>'); |
224 | 224 | # Add upload error message |
225 | 225 | $form->addPreText( $message ); |
226 | 226 | |
— | — | @@ -230,7 +230,7 @@ |
231 | 231 | . $wgOut->parse( $uploadFooter ) . "</div>\n" ); |
232 | 232 | } |
233 | 233 | |
234 | | - return $form; |
| 234 | + return $form; |
235 | 235 | |
236 | 236 | } |
237 | 237 | |
— | — | @@ -242,7 +242,7 @@ |
243 | 243 | |
244 | 244 | $title = Title::makeTitleSafe( NS_FILE, $this->mDesiredDestName ); |
245 | 245 | // 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' ) ) { |
247 | 247 | $link = wfMsgExt( |
248 | 248 | $wgUser->isAllowed( 'delete' ) ? 'thisisdeleted' : 'viewdeleted', |
249 | 249 | array( 'parse', 'replaceafter' ), |
— | — | @@ -255,7 +255,7 @@ |
256 | 256 | } |
257 | 257 | |
258 | 258 | // 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() ) { |
260 | 260 | $this->showDeletionLog( $wgOut, $title->getPrefixedText() ); |
261 | 261 | } |
262 | 262 | } |
— | — | @@ -294,13 +294,13 @@ |
295 | 295 | |
296 | 296 | $warningHtml = '<h2>' . wfMsgHtml( 'uploadwarning' ) . "</h2>\n" |
297 | 297 | . '<ul class="warning">'; |
298 | | - foreach( $warnings as $warning => $args ) { |
| 298 | + foreach ( $warnings as $warning => $args ) { |
299 | 299 | $msg = ''; |
300 | | - if( $warning == 'exists' ) { |
| 300 | + if ( $warning == 'exists' ) { |
301 | 301 | $msg = self::getExistsWarning( $args ); |
302 | | - } elseif( $warning == 'duplicate' ) { |
| 302 | + } elseif ( $warning == 'duplicate' ) { |
303 | 303 | $msg = self::getDupeWarning( $args ); |
304 | | - } elseif( $warning == 'duplicate-archive' ) { |
| 304 | + } elseif ( $warning == 'duplicate-archive' ) { |
305 | 305 | $msg = "\t<li>" . wfMsgExt( 'file-deleted-duplicate', 'parseinline', |
306 | 306 | array( Title::makeTitle( NS_FILE, $args )->getPrefixedText() ) ) |
307 | 307 | . "</li>\n"; |
— | — | @@ -344,12 +344,12 @@ |
345 | 345 | |
346 | 346 | // Verify permissions |
347 | 347 | $permErrors = $this->mUpload->verifyPermissions( $wgUser ); |
348 | | - if( $permErrors !== true ) |
| 348 | + if ( $permErrors !== true ) |
349 | 349 | return $wgOut->showPermissionsErrorPage( $permErrors ); |
350 | 350 | |
351 | 351 | // Fetch the file if required |
352 | 352 | $status = $this->mUpload->fetchFile(); |
353 | | - if( !$status->isOK() ) |
| 353 | + if ( !$status->isOK() ) |
354 | 354 | return $this->showUploadForm( $this->getUploadForm( $wgOut->parse( $status->getWikiText() ) ) ); |
355 | 355 | |
356 | 356 | // Upload verification |
— | — | @@ -360,14 +360,14 @@ |
361 | 361 | $this->mLocalFile = $this->mUpload->getLocalFile(); |
362 | 362 | |
363 | 363 | // Check warnings if necessary |
364 | | - if( !$this->mIgnoreWarning ) { |
| 364 | + if ( !$this->mIgnoreWarning ) { |
365 | 365 | $warnings = $this->mUpload->checkWarnings(); |
366 | | - if( count( $warnings ) ) |
| 366 | + if ( count( $warnings ) ) |
367 | 367 | return $this->uploadWarning( $warnings ); |
368 | 368 | } |
369 | 369 | |
370 | 370 | // Get the page text if this is not a reupload |
371 | | - if( !$this->mForReUpload ) { |
| 371 | + if ( !$this->mForReUpload ) { |
372 | 372 | $pageText = self::getInitialPageText( $this->mComment, $this->mLicense, |
373 | 373 | $this->mCopyrightStatus, $this->mCopyrightSource ); |
374 | 374 | } else { |
— | — | @@ -377,26 +377,26 @@ |
378 | 378 | if ( !$status->isGood() ) |
379 | 379 | return $this->uploadError( $wgOut->parse( $status->getWikiText() ) ); |
380 | 380 | |
381 | | - //$wgOut->redirect( $this->mLocalFile->getTitle()->getFullURL() ); |
| 381 | + // $wgOut->redirect( $this->mLocalFile->getTitle()->getFullURL() ); |
382 | 382 | // Semantic Forms change - output Javascript to either |
383 | 383 | // fill in or append to the field in original form, and |
384 | 384 | // close the window |
385 | 385 | # Chop off any directories in the given filename |
386 | | - if( $this->mDesiredDestName ) { |
| 386 | + if ( $this->mDesiredDestName ) { |
387 | 387 | $basename = $this->mDesiredDestName; |
388 | 388 | } else { |
389 | 389 | $basename = $this->mSrcName; |
390 | 390 | } |
391 | 391 | |
392 | | - $basename = str_replace('_', ' ', $basename); |
| 392 | + $basename = str_replace( '_', ' ', $basename ); |
393 | 393 | $output = ' <script type="text/javascript">' . "\n"; |
394 | | - if ($this->mDelimiter == null) { |
395 | | - $output .=<<<END |
| 394 | + if ( $this->mDelimiter == null ) { |
| 395 | + $output .= <<<END |
396 | 396 | parent.document.getElementById("{$this->mInputID}").value = '$basename'; |
397 | 397 | |
398 | 398 | END; |
399 | 399 | } else { |
400 | | - $output .=<<<END |
| 400 | + $output .= <<<END |
401 | 401 | // if the current value is blank, set it to this file name; |
402 | 402 | // if it's not blank and ends in a space or delimiter, append |
403 | 403 | // the file name; if it ends with a normal character, append |
— | — | @@ -416,12 +416,12 @@ |
417 | 417 | |
418 | 418 | END; |
419 | 419 | } |
420 | | - $output .=<<<END |
| 420 | + $output .= <<<END |
421 | 421 | parent.fb.end(); |
422 | 422 | </script> |
423 | 423 | |
424 | 424 | END; |
425 | | - //$wgOut->addHTML( $output ); |
| 425 | + // $wgOut->addHTML( $output ); |
426 | 426 | print $output; |
427 | 427 | $img = null; // @todo: added to avoid passing a ref to null - should this be defined somewhere? |
428 | 428 | |
— | — | @@ -467,13 +467,13 @@ |
468 | 468 | */ |
469 | 469 | protected function watchCheck() { |
470 | 470 | global $wgUser; |
471 | | - if( $wgUser->getOption( 'watchdefault' ) ) { |
| 471 | + if ( $wgUser->getOption( 'watchdefault' ) ) { |
472 | 472 | // Watch all edits! |
473 | 473 | return true; |
474 | 474 | } |
475 | 475 | |
476 | 476 | $local = wfLocalFile( $this->mDesiredDestName ); |
477 | | - if( $local && $local->exists() ) { |
| 477 | + if ( $local && $local->exists() ) { |
478 | 478 | // We're uploading a new version of an existing file. |
479 | 479 | // No creation, so don't watch it if we're not already. |
480 | 480 | return $local->getTitle()->userIsWatching(); |
— | — | @@ -583,10 +583,10 @@ |
584 | 584 | |
585 | 585 | $sk = $wgUser->getSkin(); |
586 | 586 | |
587 | | - if( $exists['warning'] == 'exists' ) { |
| 587 | + if ( $exists['warning'] == 'exists' ) { |
588 | 588 | // Exact match |
589 | 589 | $warning[] = '<li>' . wfMsgExt( 'fileexists', 'parseinline', $filename ) . '</li>'; |
590 | | - } elseif( $exists['warning'] == 'page-exists' ) { |
| 590 | + } elseif ( $exists['warning'] == 'page-exists' ) { |
591 | 591 | // Page exists but file does not |
592 | 592 | $warning[] = '<li>' . wfMsgExt( 'filepageexists', 'parseinline', $filename ) . '</li>'; |
593 | 593 | } elseif ( $exists['warning'] == 'exists-normalized' ) { |
— | — | @@ -629,7 +629,7 @@ |
630 | 630 | */ |
631 | 631 | public static function ajaxGetExistsWarning( $filename ) { |
632 | 632 | $file = wfFindFile( $filename ); |
633 | | - if( !$file ) { |
| 633 | + if ( !$file ) { |
634 | 634 | // Force local file so we have an object to do further checks against |
635 | 635 | // if there isn't an exact match... |
636 | 636 | $file = wfLocalFile( $filename ); |
— | — | @@ -668,10 +668,10 @@ |
669 | 669 | * Construct a warning and a gallery from an array of duplicate files. |
670 | 670 | */ |
671 | 671 | public static function getDupeWarning( $dupes ) { |
672 | | - if( $dupes ) { |
| 672 | + if ( $dupes ) { |
673 | 673 | global $wgOut; |
674 | 674 | $msg = "<gallery>"; |
675 | | - foreach( $dupes as $file ) { |
| 675 | + foreach ( $dupes as $file ) { |
676 | 676 | $title = $file->getTitle(); |
677 | 677 | $msg .= $title->getPrefixedText() . |
678 | 678 | "|" . $title->getText() . "\n"; |
— | — | @@ -704,7 +704,7 @@ |
705 | 705 | |
706 | 706 | $this->mWatch = !empty( $options['watch'] ); |
707 | 707 | $this->mForReUpload = !empty( $options['forreupload'] ); |
708 | | - $this->mSessionKey = isset( $options['sessionkey'] ) |
| 708 | + $this->mSessionKey = isset( $options['sessionkey'] ) |
709 | 709 | ? $options['sessionkey'] : ''; |
710 | 710 | $this->mHideIgnoreWarning = !empty( $options['hideignorewarning'] ); |
711 | 711 | |
— | — | @@ -729,8 +729,8 @@ |
730 | 730 | $this->mSourceIds[] = $field['id']; |
731 | 731 | } |
732 | 732 | // 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'] ); |
735 | 735 | |
736 | 736 | } |
737 | 737 | |
— | — | @@ -817,8 +817,8 @@ |
818 | 818 | $wgFileExtensions, $wgFileBlacklist; |
819 | 819 | |
820 | 820 | $allowedExtensions = ''; |
821 | | - if( $wgCheckFileExtensions ) { |
822 | | - if( $wgStrictFileExtensions ) { |
| 821 | + if ( $wgCheckFileExtensions ) { |
| 822 | + if ( $wgStrictFileExtensions ) { |
823 | 823 | # Everything not permitted is banned |
824 | 824 | $extensionsList = |
825 | 825 | '<div id="mw-upload-permitted">' . |
— | — | @@ -851,7 +851,7 @@ |
852 | 852 | global $wgUser, $wgOut; |
853 | 853 | |
854 | 854 | $cols = intval( $wgUser->getOption( 'cols' ) ); |
855 | | - if( $wgUser->getOption( 'editwidth' ) ) { |
| 855 | + if ( $wgUser->getOption( 'editwidth' ) ) { |
856 | 856 | $wgOut->addInlineStyle( '#mw-htmlform-description { width: 100%; }' ); |
857 | 857 | } |
858 | 858 | |
— | — | @@ -953,17 +953,17 @@ |
954 | 954 | $wgXhtmlDefaultNamespace, $wgXhtmlNamespaces, $wgContLang; |
955 | 955 | $wgOut->disable(); |
956 | 956 | $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' ); |
959 | 959 | $skin_user_js = $sk->generateUserJs(); |
960 | 960 | |
961 | | - $user_js =<<<END |
| 961 | + $user_js = <<<END |
962 | 962 | <script type="{$wgJsMimeType}"> |
963 | 963 | $skin_user_js; |
964 | 964 | </script> |
965 | 965 | |
966 | 966 | END; |
967 | | - $vars_js = Skin::makeGlobalVariablesScript(array('skinname' => $sk->getSkinName())); |
| 967 | + $vars_js = Skin::makeGlobalVariablesScript( array( 'skinname' => $sk->getSkinName() ) ); |
968 | 968 | $wikibits_include = "<script type=\"{$wgJsMimeType}\" src=\"{$wgStylePath}/common/wikibits.js?$wgStyleVersion\"></script>"; |
969 | 969 | $ajax_include = "<script type=\"{$wgJsMimeType}\" src=\"{$wgStylePath}/common/ajax.js?$wgStyleVersion\"></script>"; |
970 | 970 | $ajaxwatch_include = "<script type=\"{$wgJsMimeType}\" src=\"{$wgStylePath}/common/ajaxwatch.js?$wgStyleVersion\"></script>"; |
— | — | @@ -971,7 +971,7 @@ |
972 | 972 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
973 | 973 | <html xmlns="{$wgXhtmlDefaultNamespace}" |
974 | 974 | END; |
975 | | - foreach($wgXhtmlNamespaces as $tag => $ns) { |
| 975 | + foreach ( $wgXhtmlNamespaces as $tag => $ns ) { |
976 | 976 | $text .= "xmlns:{$tag}=\"{$ns}\" "; |
977 | 977 | } |
978 | 978 | $dir = $wgContLang->isRTL() ? "rtl" : "ltr"; |
Index: trunk/extensions/SemanticForms/specials/SF_CreateTemplate.php |
— | — | @@ -10,7 +10,7 @@ |
11 | 11 | * Protect against register_globals vulnerabilities. |
12 | 12 | * This line must be present before any global variable is referenced. |
13 | 13 | */ |
14 | | -if (!defined('MEDIAWIKI')) die(); |
| 14 | +if ( !defined( 'MEDIAWIKI' ) ) die(); |
15 | 15 | |
16 | 16 | class SFCreateTemplate extends SpecialPage { |
17 | 17 | |
— | — | @@ -18,11 +18,11 @@ |
19 | 19 | * Constructor |
20 | 20 | */ |
21 | 21 | function SFCreateTemplate() { |
22 | | - SpecialPage::SpecialPage('CreateTemplate'); |
23 | | - wfLoadExtensionMessages('SemanticForms'); |
| 22 | + SpecialPage::SpecialPage( 'CreateTemplate' ); |
| 23 | + wfLoadExtensionMessages( 'SemanticForms' ); |
24 | 24 | } |
25 | 25 | |
26 | | - function execute($query) { |
| 26 | + function execute( $query ) { |
27 | 27 | $this->setHeaders(); |
28 | 28 | doSpecialCreateTemplate(); |
29 | 29 | } |
— | — | @@ -34,43 +34,43 @@ |
35 | 35 | // getProperties() functions stop requiring a limit |
36 | 36 | $options = new SMWRequestOptions(); |
37 | 37 | $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 ) { |
40 | 40 | $all_properties[] = $property[0]->getWikiValue(); |
41 | 41 | } |
42 | | - $unused_properties = smwfGetStore()->getUnusedPropertiesSpecial($options); |
43 | | - foreach ($unused_properties as $property) { |
| 42 | + $unused_properties = smwfGetStore()->getUnusedPropertiesSpecial( $options ); |
| 43 | + foreach ( $unused_properties as $property ) { |
44 | 44 | $all_properties[] = $property->getWikiValue(); |
45 | 45 | } |
46 | 46 | |
47 | 47 | // sort properties list alphabetically |
48 | | - sort($all_properties); |
| 48 | + sort( $all_properties ); |
49 | 49 | return $all_properties; |
50 | 50 | } |
51 | 51 | |
52 | | - function printPropertiesDropdown($all_properties, $id, $selected_property) { |
| 52 | + function printPropertiesDropdown( $all_properties, $id, $selected_property ) { |
53 | 53 | $dropdown_str = "<select name=\"semantic_property_$id\">\n"; |
54 | 54 | $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" : ""; |
57 | 57 | $dropdown_str .= "<option value=\"$prop_name\" $selected>$prop_name</option>\n"; |
58 | 58 | } |
59 | 59 | $dropdown_str .= "</select>\n"; |
60 | 60 | return $dropdown_str; |
61 | 61 | } |
62 | 62 | |
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 ); |
66 | 66 | $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"; |
72 | 72 | |
73 | | - if ($id != "new") { |
74 | | - $text .= ' <input name="del_' . $id . '" type="submit" value="' . wfMsg('sf_createtemplate_deletefield') . '">' . "\n"; |
| 73 | + if ( $id != "new" ) { |
| 74 | + $text .= ' <input name="del_' . $id . '" type="submit" value="' . wfMsg( 'sf_createtemplate_deletefield' ) . '">' . "\n"; |
75 | 75 | } |
76 | 76 | $text .= <<<END |
77 | 77 | </p> |
— | — | @@ -84,55 +84,55 @@ |
85 | 85 | function doSpecialCreateTemplate() { |
86 | 86 | global $wgOut, $wgRequest, $wgUser, $sfgScriptPath, $wgContLang; |
87 | 87 | |
88 | | - wfLoadExtensionMessages('SemanticForms'); |
| 88 | + wfLoadExtensionMessages( 'SemanticForms' ); |
89 | 89 | |
90 | 90 | $all_properties = SFCreateTemplate::getAllPropertyNames(); |
91 | 91 | |
92 | | - $template_name = $wgRequest->getVal('template_name'); |
| 92 | + $template_name = $wgRequest->getVal( 'template_name' ); |
93 | 93 | $template_name_error_str = ""; |
94 | | - $category = $wgRequest->getVal('category'); |
| 94 | + $category = $wgRequest->getVal( 'category' ); |
95 | 95 | $cur_id = 1; |
96 | 96 | $fields = array(); |
97 | 97 | # 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 ); |
100 | 100 | // we only care about query variables of the form "a_b" |
101 | | - if (count($var_elements) != 2) |
| 101 | + if ( count( $var_elements ) != 2 ) |
102 | 102 | 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 ) != '' ) { |
107 | 107 | # do nothing - this field won't get added to the new list |
108 | 108 | } 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 ); |
112 | 112 | $fields[] = $field; |
113 | 113 | } |
114 | 114 | } |
115 | 115 | } |
116 | 116 | } |
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' ); |
120 | 120 | |
121 | 121 | $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 ) { |
127 | 127 | # 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' ); |
130 | 130 | } else { |
131 | 131 | // 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 ); |
137 | 137 | return; |
138 | 138 | } |
139 | 139 | } |
— | — | @@ -142,30 +142,30 @@ |
143 | 143 | $mw_namespace_labels = $wgContLang->getNamespaces(); |
144 | 144 | $special_namespace = $mw_namespace_labels[NS_SPECIAL]; |
145 | 145 | $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"; |
148 | 148 | $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"; |
151 | 151 | |
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 ); |
154 | 154 | } |
155 | 155 | $new_field = new SFTemplateField(); |
156 | | - $text .= SFCreateTemplate::printFieldEntryBox("new", $new_field, $all_properties); |
| 156 | + $text .= SFCreateTemplate::printFieldEntryBox( "new", $new_field, $all_properties ); |
157 | 157 | |
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"; |
159 | 159 | $text .= " </fieldset>\n"; |
160 | 160 | $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"; |
165 | 165 | $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 |
170 | 170 | <div class="editButtons"> |
171 | 171 | <input type="submit" id="wpSave" name="wpSave" value="$save_button_text"> |
172 | 172 | <input type="submit" id="wpPreview" name="wpPreview" value="$preview_button_text"> |
— | — | @@ -174,16 +174,16 @@ |
175 | 175 | |
176 | 176 | END; |
177 | 177 | $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() ); |
180 | 180 | $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"; |
182 | 182 | |
183 | 183 | $wgOut->addLink( array( |
184 | 184 | 'rel' => 'stylesheet', |
185 | 185 | 'type' => 'text/css', |
186 | 186 | 'media' => "screen", |
187 | 187 | 'href' => $sfgScriptPath . "/skins/SF_main.css" |
188 | | - )); |
189 | | - $wgOut->addHTML($text); |
| 188 | + ) ); |
| 189 | + $wgOut->addHTML( $text ); |
190 | 190 | } |
Index: trunk/extensions/SemanticForms/includes/SF_FormEditTab.php |
— | — | @@ -11,50 +11,50 @@ |
12 | 12 | * Adds an "action" (i.e., a tab) to edit the current article with |
13 | 13 | * a form |
14 | 14 | */ |
15 | | - static function displayTab($obj, &$content_actions) { |
| 15 | + static function displayTab( $obj, &$content_actions ) { |
16 | 16 | // make sure that this is not a special page, and |
17 | 17 | // that the user is allowed to edit it |
18 | 18 | // - this function is almost never called on special pages, |
19 | 19 | // but before SMW is fully initialized, it's called on |
20 | 20 | // Special:SMWAdmin for some reason, which is why the |
21 | 21 | // 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 ) { |
26 | 26 | global $wgRequest, $wgUser; |
27 | 27 | global $sfgRenameEditTabs, $sfgRenameMainEditTab; |
28 | 28 | |
29 | | - wfLoadExtensionMessages('SemanticForms'); |
| 29 | + wfLoadExtensionMessages( 'SemanticForms' ); |
30 | 30 | |
31 | | - $user_can_edit = $wgUser->isAllowed('edit') && $obj->mTitle->userCan('edit'); |
| 31 | + $user_can_edit = $wgUser->isAllowed( 'edit' ) && $obj->mTitle->userCan( 'edit' ); |
32 | 32 | // create the form edit tab, and apply whatever |
33 | 33 | // changes are specified by the edit-tab global |
34 | 34 | // 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' ); |
39 | 39 | } |
40 | 40 | } 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' ); |
43 | 43 | else |
44 | | - $form_edit_tab_text = wfMsg('sf_viewform'); |
| 44 | + $form_edit_tab_text = wfMsg( 'sf_viewform' ); |
45 | 45 | // check for renaming of main edit tab |
46 | 46 | // 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' ); |
50 | 50 | } |
51 | 51 | } |
52 | 52 | } |
53 | 53 | |
54 | | - $class_name = ($wgRequest->getVal('action') == 'formedit') ? 'selected' : ''; |
| 54 | + $class_name = ( $wgRequest->getVal( 'action' ) == 'formedit' ) ? 'selected' : ''; |
55 | 55 | $form_edit_tab = array( |
56 | 56 | 'class' => $class_name, |
57 | 57 | 'text' => $form_edit_tab_text, |
58 | | - 'href' => $obj->mTitle->getLocalURL('action=formedit') |
| 58 | + 'href' => $obj->mTitle->getLocalURL( 'action=formedit' ) |
59 | 59 | ); |
60 | 60 | |
61 | 61 | // find the location of the 'edit' tab, and add |
— | — | @@ -65,30 +65,30 @@ |
66 | 66 | // rebuilding the array. |
67 | 67 | // based on the example at |
68 | 68 | // 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 ); |
72 | 72 | // if there's no 'edit' tab, look for the |
73 | 73 | // '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 ); |
76 | 76 | // this should rarely happen, but if there was |
77 | 77 | // no edit *or* view source tab, set the |
78 | 78 | // location index to -1, so the tab shows up |
79 | 79 | // 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 ) ); |
84 | 84 | $content_actions = array(); |
85 | | - for ($i = 0; $i < count($tab_keys); $i++) |
| 85 | + for ( $i = 0; $i < count( $tab_keys ); $i++ ) |
86 | 86 | $content_actions[$tab_keys[$i]] = $tab_values[$i]; |
87 | 87 | |
88 | 88 | global $wgUser; |
89 | | - if (! $wgUser->isAllowed('viewedittab')) { |
| 89 | + if ( ! $wgUser->isAllowed( 'viewedittab' ) ) { |
90 | 90 | // 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'] ); |
93 | 93 | } |
94 | 94 | |
95 | 95 | return true; |
— | — | @@ -101,11 +101,11 @@ |
102 | 102 | * Function currently called only for the 'Vector' skin, added in |
103 | 103 | * MW 1.16 - will possibly be called for additional skins later |
104 | 104 | */ |
105 | | - static function displayTab2($obj, &$links) { |
| 105 | + static function displayTab2( $obj, &$links ) { |
106 | 106 | // the old '$content_actions' array is thankfully just a |
107 | 107 | // sub-array of this one |
108 | 108 | $views_links = $links['views']; |
109 | | - self::displayTab($obj, $views_links); |
| 109 | + self::displayTab( $obj, $views_links ); |
110 | 110 | $links['views'] = $views_links; |
111 | 111 | return true; |
112 | 112 | } |
— | — | @@ -114,31 +114,31 @@ |
115 | 115 | * The function called if we're in index.php (as opposed to one of the |
116 | 116 | * special pages) |
117 | 117 | */ |
118 | | - static function displayForm($action, $article) { |
| 118 | + static function displayForm( $action, $article ) { |
119 | 119 | global $sfgIP, $sfgUseFormEditPage; |
120 | 120 | |
121 | 121 | // return "true" if the call failed (meaning, pass on handling |
122 | 122 | // of the hook to others), and "false" otherwise |
123 | | - if ($action != 'formedit') { |
| 123 | + if ( $action != 'formedit' ) { |
124 | 124 | return true; |
125 | 125 | } |
126 | 126 | |
127 | 127 | // @todo: This looks like bad code. If we can't find a form, we |
128 | 128 | // should be showing an informative error page rather than |
129 | 129 | // 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 ) { |
132 | 132 | return true; |
133 | 133 | } |
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"; |
137 | 137 | global $wgOut; |
138 | | - $wgOut->addHTML($warning_text); |
| 138 | + $wgOut->addHTML( $warning_text ); |
139 | 139 | } |
140 | 140 | $form_name = $form_names[0]; |
141 | 141 | |
142 | | - if( $sfgUseFormEditPage ) { |
| 142 | + if ( $sfgUseFormEditPage ) { |
143 | 143 | # Experimental new feature extending from the internal |
144 | 144 | # EditPage class |
145 | 145 | $editor = new SFFormEditPage( $article, $form_name ); |
— | — | @@ -147,8 +147,8 @@ |
148 | 148 | } |
149 | 149 | |
150 | 150 | $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 ); |
153 | 153 | return false; |
154 | 154 | } |
155 | 155 | |
Index: trunk/extensions/SemanticForms/includes/SF_Settings.php |
— | — | @@ -2,40 +2,40 @@ |
3 | 3 | /** |
4 | 4 | * Default settings for Semantic Forms |
5 | 5 | */ |
6 | | -if (!defined('MEDIAWIKI')) die(); |
| 6 | +if ( !defined( 'MEDIAWIKI' ) ) die(); |
7 | 7 | |
8 | | -### |
| 8 | +# ## |
9 | 9 | # This is the path to your installation of Semantic Forms as |
10 | 10 | # seen from the web. Change it if required ($wgScriptPath is the |
11 | 11 | # path to the base directory of your wiki). No final slash. |
12 | | -## |
| 12 | +# # |
13 | 13 | $sfgScriptPath = $wgScriptPath . '/extensions/SemanticForms'; |
14 | | -## |
| 14 | +# # |
15 | 15 | |
16 | | -### |
| 16 | +# ## |
17 | 17 | # This is the path to your installation of Semantic Forms as |
18 | 18 | # seen on your local filesystem. Used against some PHP file path |
19 | 19 | # issues. |
20 | | -## |
21 | | -$sfgIP = dirname(__FILE__) . '/..'; |
22 | | -## |
| 20 | +# # |
| 21 | +$sfgIP = dirname( __FILE__ ) . '/..'; |
| 22 | +# # |
23 | 23 | |
24 | 24 | |
25 | 25 | // PHP fails to find relative includes at some level of inclusion: |
26 | | -//$pathfix = $IP . $sfgScriptPath; |
| 26 | +// $pathfix = $IP . $sfgScriptPath; |
27 | 27 | |
28 | 28 | // load global functions |
29 | | -require_once('SF_GlobalFunctions.php'); |
| 29 | +require_once( 'SF_GlobalFunctions.php' ); |
30 | 30 | |
31 | 31 | sffInitNamespaces(); |
32 | 32 | |
33 | | -### |
| 33 | +# ## |
34 | 34 | # The number of allowed values per autocomplete - too many might |
35 | 35 | # slow down the database, and Javascript's completion |
36 | | -### |
| 36 | +# ## |
37 | 37 | $sfgMaxAutocompleteValues = 1000; |
38 | 38 | |
39 | | -### |
| 39 | +# ## |
40 | 40 | # Global variables for handling the two edit tabs (for traditional editing |
41 | 41 | # and for editing with a form): |
42 | 42 | # $sfgRenameEditTabs renames the edit-with-form tab to just "Edit", and |
— | — | @@ -46,52 +46,52 @@ |
47 | 47 | # The wgGroupPermissions 'viewedittab' setting dictates which types of |
48 | 48 | # visitors will see the "Edit" tab, for pages that are editable by form - |
49 | 49 | # by default all will see it. |
50 | | -### |
| 50 | +# ## |
51 | 51 | $sfgRenameEditTabs = false; |
52 | 52 | $sfgRenameMainEditTab = false; |
53 | 53 | $wgGroupPermissions['*']['viewedittab'] = true; |
54 | 54 | $wgAvailableRights[] = 'viewedittab'; |
55 | 55 | |
56 | | -### |
| 56 | +# ## |
57 | 57 | # Permission to edit form fields defined as 'restricted' |
58 | | -### |
| 58 | +# ## |
59 | 59 | $wgGroupPermissions['sysop']['editrestrictedfields'] = true; |
60 | 60 | $wgAvailableRights[] = 'editrestrictedfields'; |
61 | 61 | |
62 | | -### |
| 62 | +# ## |
63 | 63 | # Permission to view, and create pages with, Special:CreateClass |
64 | | -### |
| 64 | +# ## |
65 | 65 | $wgGroupPermissions['user']['createclass'] = true; |
66 | 66 | $wgAvailableRights[] = 'createclass'; |
67 | 67 | |
68 | | -### |
| 68 | +# ## |
69 | 69 | # List separator character |
70 | | -### |
| 70 | +# ## |
71 | 71 | $sfgListSeparator = ","; |
72 | 72 | |
73 | | -### |
| 73 | +# ## |
74 | 74 | # The base URL for all YUI Javascript files - to store the YUI library |
75 | 75 | # locally, download it (from http://developer.yahoo.com/yui/) and change this |
76 | 76 | # value to the URL of the local installation's 'build' directory. |
77 | | -### |
| 77 | +# ## |
78 | 78 | $sfgYUIBase = "http://yui.yahooapis.com/2.7.0/build/"; |
79 | 79 | |
80 | | -### |
| 80 | +# ## |
81 | 81 | # Extend the edit form from the internal EditPage class rather than using a |
82 | 82 | # special page and hacking things up. |
83 | 83 | # |
84 | 84 | # @note This is experimental and requires updates to EditPage which I have only |
85 | 85 | # added into MediaWiki 1.14a |
86 | | -### |
87 | | -$sfgUseFormEditPage = false;//method_exists('EditPage', 'showFooter'); |
| 86 | +# ## |
| 87 | +$sfgUseFormEditPage = false;// method_exists('EditPage', 'showFooter'); |
88 | 88 | |
89 | | -### |
| 89 | +# ## |
90 | 90 | # Use 24-hour time format in forms, e.g. 15:30 instead of 3:30 PM |
91 | | -### |
| 91 | +# ## |
92 | 92 | $sfg24HourTime = false; |
93 | 93 | |
94 | | -### |
| 94 | +# ## |
95 | 95 | # Cache parsed form definitions in the page_props table, to improve loading |
96 | 96 | # speed |
97 | | -### |
| 97 | +# ## |
98 | 98 | $sfgCacheFormDefinitions = false; |
Index: trunk/extensions/SemanticForms/includes/SF_ParserFunctions.php |
— | — | @@ -106,14 +106,14 @@ |
107 | 107 | static $num_autocompletion_inputs = 0; |
108 | 108 | |
109 | 109 | 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 ); |
115 | 115 | } 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' ) ); |
118 | 118 | } |
119 | 119 | return true; |
120 | 120 | } |
— | — | @@ -130,78 +130,78 @@ |
131 | 131 | return true; |
132 | 132 | } |
133 | 133 | |
134 | | - static function renderFormLink (&$parser) { |
| 134 | + static function renderFormLink ( &$parser ) { |
135 | 135 | $params = func_get_args(); |
136 | 136 | array_shift( $params ); // don't need the parser |
137 | 137 | // set defaults |
138 | 138 | $inFormName = $inLinkStr = $inLinkType = $inQueryStr = ''; |
139 | 139 | // 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 ); |
142 | 142 | $param_name = null; |
143 | 143 | $value = $param; |
144 | | - if (count($elements) > 1) { |
| 144 | + if ( count( $elements ) > 1 ) { |
145 | 145 | $param_name = $elements[0]; |
146 | 146 | $value = $elements[1]; |
147 | 147 | } |
148 | | - if ($param_name == 'form') |
| 148 | + if ( $param_name == 'form' ) |
149 | 149 | $inFormName = $value; |
150 | | - elseif ($param_name == 'link text') |
| 150 | + elseif ( $param_name == 'link text' ) |
151 | 151 | $inLinkStr = $value; |
152 | | - elseif ($param_name == 'link type') |
| 152 | + elseif ( $param_name == 'link type' ) |
153 | 153 | $inLinkType = $value; |
154 | | - elseif ($param_name == 'query string') |
| 154 | + elseif ( $param_name == 'query string' ) |
155 | 155 | $inQueryStr = $value; |
156 | | - elseif ($i == 0) |
| 156 | + elseif ( $i == 0 ) |
157 | 157 | $inFormName = $param; |
158 | | - elseif ($i == 1) |
| 158 | + elseif ( $i == 1 ) |
159 | 159 | $inLinkStr = $param; |
160 | | - elseif ($i == 2) |
| 160 | + elseif ( $i == 2 ) |
161 | 161 | $inLinkType = $param; |
162 | | - elseif ($i == 3) |
| 162 | + elseif ( $i == 3 ) |
163 | 163 | $inQueryStr = $param; |
164 | 164 | } |
165 | 165 | |
166 | | - $ad = SpecialPage::getPage('FormEdit'); |
| 166 | + $ad = SpecialPage::getPage( 'FormEdit' ); |
167 | 167 | $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 != '' ) { |
170 | 170 | // special handling for 'post button' - query string |
171 | 171 | // has to be turned into hidden inputs |
172 | | - if ($inLinkType == 'post button') { |
| 172 | + if ( $inLinkType == 'post button' ) { |
173 | 173 | $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 ) { |
179 | 179 | $hidden_inputs .= '<input type="hidden" name="' . $var_and_val[0] . '" value="' . $var_and_val[1] . '" /> '; |
180 | 180 | } |
181 | 181 | } |
182 | 182 | } else { |
183 | | - $link_url .= (strstr($link_url, '?')) ? '&' : '?'; |
| 183 | + $link_url .= ( strstr( $link_url, '?' ) ) ? '&' : '?'; |
184 | 184 | // 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 ); |
188 | 188 | $link_url .= $inQueryStr; |
189 | 189 | } |
190 | 190 | } |
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 ); |
194 | 194 | $str = "<form><input type=\"button\" value=\"$inLinkStr\" onclick=\"window.location.href='$link_url'\"></form>"; |
195 | | - } elseif ($inLinkType == 'post button') { |
| 195 | + } elseif ( $inLinkType == 'post button' ) { |
196 | 196 | $str = "<form action=\"$link_url\" method=\"post\"><input type=\"submit\" value=\"$inLinkStr\">$hidden_inputs</form>"; |
197 | 197 | } else { |
198 | 198 | $str = "<a href=\"$link_url\">$inLinkStr</a>"; |
199 | 199 | } |
200 | 200 | // hack to remove newline from beginning of output, thanks to |
201 | 201 | // 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 ); |
203 | 203 | } |
204 | 204 | |
205 | | - static function renderFormInput (&$parser) { |
| 205 | + static function renderFormInput ( &$parser ) { |
206 | 206 | $params = func_get_args(); |
207 | 207 | array_shift( $params ); // don't need the parser |
208 | 208 | // set defaults |
— | — | @@ -209,45 +209,45 @@ |
210 | 210 | $inAutocompletionSource = ''; |
211 | 211 | $inSize = 25; |
212 | 212 | // 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 ); |
215 | 215 | $param_name = null; |
216 | 216 | $value = $param; |
217 | | - if (count($elements) > 1) { |
| 217 | + if ( count( $elements ) > 1 ) { |
218 | 218 | $param_name = $elements[0]; |
219 | 219 | $value = $elements[1]; |
220 | 220 | } |
221 | | - if ($param_name == 'form') |
| 221 | + if ( $param_name == 'form' ) |
222 | 222 | $inFormName = $value; |
223 | | - elseif ($param_name == 'size') |
| 223 | + elseif ( $param_name == 'size' ) |
224 | 224 | $inSize = $value; |
225 | | - elseif ($param_name == 'default value') |
| 225 | + elseif ( $param_name == 'default value' ) |
226 | 226 | $inValue = $value; |
227 | | - elseif ($param_name == 'button text') |
| 227 | + elseif ( $param_name == 'button text' ) |
228 | 228 | $inButtonStr = $value; |
229 | | - elseif ($param_name == 'query string') |
| 229 | + elseif ( $param_name == 'query string' ) |
230 | 230 | $inQueryStr = $value; |
231 | | - elseif ($param_name == 'autocomplete on category') { |
| 231 | + elseif ( $param_name == 'autocomplete on category' ) { |
232 | 232 | $inAutocompletionSource = $value; |
233 | 233 | $autocompletion_type = 'category'; |
234 | | - } elseif ($param_name == 'autocomplete on namespace') { |
| 234 | + } elseif ( $param_name == 'autocomplete on namespace' ) { |
235 | 235 | $inAutocompletionSource = $value; |
236 | 236 | $autocompletion_type = 'namespace'; |
237 | 237 | } |
238 | | - elseif ($i == 0) |
| 238 | + elseif ( $i == 0 ) |
239 | 239 | $inFormName = $param; |
240 | | - elseif ($i == 1) |
| 240 | + elseif ( $i == 1 ) |
241 | 241 | $inSize = $param; |
242 | | - elseif ($i == 2) |
| 242 | + elseif ( $i == 2 ) |
243 | 243 | $inValue = $param; |
244 | | - elseif ($i == 3) |
| 244 | + elseif ( $i == 3 ) |
245 | 245 | $inButtonStr = $param; |
246 | | - elseif ($i == 4) |
| 246 | + elseif ( $i == 4 ) |
247 | 247 | $inQueryStr = $param; |
248 | 248 | } |
249 | 249 | |
250 | 250 | $input_num = 1; |
251 | | - if (! empty($inAutocompletionSource)) { |
| 251 | + if ( ! empty( $inAutocompletionSource ) ) { |
252 | 252 | self::$num_autocompletion_inputs++; |
253 | 253 | $input_num = self::$num_autocompletion_inputs; |
254 | 254 | // place the necessary Javascript on the page, and |
— | — | @@ -255,13 +255,13 @@ |
256 | 256 | // if there's more than one autocompleted #forminput |
257 | 257 | // on the page, we only need to do this the first time |
258 | 258 | $autocompletion_javascript = ''; |
259 | | - if ($input_num == 1) { |
| 259 | + if ( $input_num == 1 ) { |
260 | 260 | $parser->disableCache(); |
261 | 261 | SFUtils::addJavascriptAndCSS(); |
262 | 262 | $autocompletion_javascript = SFFormUtils::autocompletionJavascript(); |
263 | 263 | } |
264 | | - $autocompletion_str = SFFormInputs::createAutocompleteValuesString($inAutocompletionSource, $autocompletion_type); |
265 | | - $javascript_text =<<<END |
| 264 | + $autocompletion_str = SFFormInputs::createAutocompleteValuesString( $inAutocompletionSource, $autocompletion_type ); |
| 265 | + $javascript_text = <<<END |
266 | 266 | <script type="text/javascript"> |
267 | 267 | /*<![CDATA[*/ |
268 | 268 | $autocompletion_javascript |
— | — | @@ -271,12 +271,12 @@ |
272 | 272 | |
273 | 273 | END; |
274 | 274 | global $wgOut; |
275 | | - $wgOut->addScript($javascript_text); |
| 275 | + $wgOut->addScript( $javascript_text ); |
276 | 276 | } |
277 | 277 | |
278 | | - $fs = SpecialPage::getPage('FormStart'); |
| 278 | + $fs = SpecialPage::getPage( 'FormStart' ); |
279 | 279 | $fs_url = $fs->getTitle()->getLocalURL(); |
280 | | - if (empty($inAutocompletionSource)) { |
| 280 | + if ( empty( $inAutocompletionSource ) ) { |
281 | 281 | $str = <<<END |
282 | 282 | <form action="$fs_url" method="get"> |
283 | 283 | <p><input type="text" name="page_name" size="$inSize" value="$inValue" /> |
— | — | @@ -299,27 +299,27 @@ |
300 | 300 | // if the add page URL looks like "index.php?title=Special:AddPage" |
301 | 301 | // (i.e., it's in the default URL style), add in the title as a |
302 | 302 | // 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"; |
305 | 305 | } |
306 | | - if ($inFormName == '') { |
| 306 | + if ( $inFormName == '' ) { |
307 | 307 | $str .= SFUtils::formDropdownHTML(); |
308 | 308 | } else { |
309 | 309 | $str .= ' <input type="hidden" name="form" value="' . $inFormName . '">' . "\n"; |
310 | 310 | $str .= ' <input type="hidden" name="form2" value="' . $inFormName . '">' . "\n"; |
311 | 311 | } |
312 | 312 | // 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 ) ) |
319 | 319 | $str .= ' <input type="hidden" name="' . $key . '" value="' . $val . '">' . "\n"; |
320 | 320 | } |
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 ) ) { |
324 | 324 | $str .= <<<END |
325 | 325 | <input type="submit" value="$button_str"></p> |
326 | 326 | </form> |
— | — | @@ -335,7 +335,7 @@ |
336 | 336 | |
337 | 337 | // hack to remove newline from beginning of output, thanks to |
338 | 338 | // 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 ); |
340 | 340 | } |
341 | 341 | |
342 | 342 | /** |
— | — | @@ -344,19 +344,19 @@ |
345 | 345 | static function renderArrayMap( &$parser, $value = '', $delimiter = ',', $var = 'x', $formula = 'x', $new_delimiter = ', ' ) { |
346 | 346 | // let '\n' represent newlines - chances that anyone will |
347 | 347 | // 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 ); |
351 | 351 | $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 ); |
354 | 354 | // ignore a value if it's null |
355 | | - if ('' != $cur_value) { |
| 355 | + if ( '' != $cur_value ) { |
356 | 356 | // remove whitespaces |
357 | | - $results[] = str_replace($var, $cur_value, $formula); |
| 357 | + $results[] = str_replace( $var, $cur_value, $formula ); |
358 | 358 | } |
359 | 359 | } |
360 | | - return implode($new_delimiter, $results); |
| 360 | + return implode( $new_delimiter, $results ); |
361 | 361 | } |
362 | 362 | |
363 | 363 | /** |
— | — | @@ -365,28 +365,28 @@ |
366 | 366 | */ |
367 | 367 | static function renderArrayMapObj( &$parser, $frame, $args ) { |
368 | 368 | # 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] ) ) : ', '; |
374 | 374 | # Unstrip some |
375 | | - $delimiter = $parser->mStripState->unstripNoWiki($delimiter); |
| 375 | + $delimiter = $parser->mStripState->unstripNoWiki( $delimiter ); |
376 | 376 | # 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 ); |
379 | 379 | |
380 | | - $values_array = explode($delimiter, $value); |
| 380 | + $values_array = explode( $delimiter, $value ); |
381 | 381 | $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 ) ); |
389 | 389 | } |
390 | | - return implode($new_delimiter, $results_array); |
| 390 | + return implode( $new_delimiter, $results_array ); |
391 | 391 | } |
392 | 392 | |
393 | 393 | /** |
— | — | @@ -394,20 +394,20 @@ |
395 | 395 | */ |
396 | 396 | static function renderArrayMapTemplate( &$parser, $value = '', $template = '', $delimiter = ',', $new_delimiter = ', ' ) { |
397 | 397 | # 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 ); |
401 | 401 | $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 ); |
405 | 405 | // ignore a value if it's null |
406 | | - if ('' != $cur_value) { |
| 406 | + if ( '' != $cur_value ) { |
407 | 407 | // remove whitespaces |
408 | | - $results[] = '{{'.$template.'|'.$cur_value.'}}'; |
| 408 | + $results[] = '{{' . $template . '|' . $cur_value . '}}'; |
409 | 409 | } |
410 | 410 | } |
411 | | - return array(implode($new_delimiter, $results), 'noparse' => false, 'isHTML' => false); |
| 411 | + return array( implode( $new_delimiter, $results ), 'noparse' => false, 'isHTML' => false ); |
412 | 412 | } |
413 | 413 | |
414 | 414 | /** |
— | — | @@ -416,26 +416,26 @@ |
417 | 417 | */ |
418 | 418 | static function renderArrayMapTemplateObj( &$parser, $frame, $args ) { |
419 | 419 | # 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] ) ) : ', '; |
424 | 424 | # Unstrip some |
425 | | - $delimiter = $parser->mStripState->unstripNoWiki($delimiter); |
| 425 | + $delimiter = $parser->mStripState->unstripNoWiki( $delimiter ); |
426 | 426 | # 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 ); |
429 | 429 | |
430 | | - $values_array = explode($delimiter, $value); |
| 430 | + $values_array = explode( $delimiter, $value ); |
431 | 431 | $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; |
435 | 435 | $results_array[] = $parser->replaceVariables( |
436 | | - implode('', $frame->virtualBracketedImplode( '{{', '|', '}}', |
437 | | - $template, '1='.$old_value )), $frame); |
| 436 | + implode( '', $frame->virtualBracketedImplode( '{{', '|', '}}', |
| 437 | + $template, '1=' . $old_value ) ), $frame ); |
438 | 438 | } |
439 | | - return implode($new_delimiter, $results_array); |
| 439 | + return implode( $new_delimiter, $results_array ); |
440 | 440 | } |
441 | 441 | |
442 | 442 | } |
Index: trunk/extensions/SemanticForms/includes/SF_FormEditPage.php |
— | — | @@ -13,10 +13,10 @@ |
14 | 14 | function __construct( $article, $form_name = '' ) { |
15 | 15 | global $wgRequest; |
16 | 16 | parent::__construct( $article ); |
17 | | - wfLoadExtensionMessages('SemanticForms'); |
| 17 | + wfLoadExtensionMessages( 'SemanticForms' ); |
18 | 18 | $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 ); |
21 | 21 | $this->form_name = $form_name; |
22 | 22 | } |
23 | 23 | |
— | — | @@ -27,15 +27,15 @@ |
28 | 28 | function setHeaders() { |
29 | 29 | parent::setHeaders(); |
30 | 30 | global $wgOut, $wgTitle; |
31 | | - if( !$this->isConflict ) { |
| 31 | + if ( !$this->isConflict ) { |
32 | 32 | $wgOut->setPageTitle( wfMsg( 'sf_formedit_title', |
33 | 33 | $this->form->getText(), $wgTitle->getPrefixedText() ) ); |
34 | 34 | } |
35 | 35 | } |
36 | 36 | |
37 | 37 | protected function displayPreviewArea( $previewOutput, $isOnTop = false ) { |
38 | | - if ($this->textbox1 != null) |
39 | | - parent::displayPreviewArea($previewOutput); |
| 38 | + if ( $this->textbox1 != null ) |
| 39 | + parent::displayPreviewArea( $previewOutput ); |
40 | 40 | } |
41 | 41 | |
42 | 42 | protected function importContentFormData( &$request ) { |
— | — | @@ -45,11 +45,11 @@ |
46 | 46 | protected function showContentForm() { |
47 | 47 | global $sfgIP; |
48 | 48 | $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 ); |
52 | 52 | } else { |
53 | | - SFAddData::printAddForm($this->form_name, $target_name, array(), $this->textbox1); |
| 53 | + SFAddData::printAddForm( $this->form_name, $target_name, array(), $this->textbox1 ); |
54 | 54 | } |
55 | 55 | // @todo This needs a proper form builder |
56 | 56 | } |
Index: trunk/extensions/SemanticForms/includes/SF_GlobalFunctions.php |
— | — | @@ -7,9 +7,9 @@ |
8 | 8 | |
9 | 9 | if ( !defined( 'MEDIAWIKI' ) ) die(); |
10 | 10 | |
11 | | -define('SF_VERSION','1.9'); |
| 11 | +define( 'SF_VERSION', '1.9' ); |
12 | 12 | |
13 | | -$wgExtensionCredits['specialpage'][]= array( |
| 13 | +$wgExtensionCredits['specialpage'][] = array( |
14 | 14 | 'path' => __FILE__, |
15 | 15 | 'name' => 'Semantic Forms', |
16 | 16 | 'version' => SF_VERSION, |
— | — | @@ -19,11 +19,11 @@ |
20 | 20 | ); |
21 | 21 | |
22 | 22 | // 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 ); |
28 | 28 | |
29 | 29 | $wgExtensionFunctions[] = 'sfgSetupExtension'; |
30 | 30 | $wgExtensionFunctions[] = 'sfgParserFunctions'; |
— | — | @@ -77,7 +77,7 @@ |
78 | 78 | $wgAutoloadClasses['SFRunQuery'] = $sfgIP . '/specials/SF_RunQuery.php'; |
79 | 79 | $wgSpecialPageGroups['RunQuery'] = 'sf_group'; |
80 | 80 | // 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 |
82 | 82 | $wgSpecialPages['UploadWindow'] = 'SFUploadWindow2'; |
83 | 83 | $wgAutoloadClasses['SFUploadWindow2'] = $sfgIP . '/specials/SF_UploadWindow2.php'; |
84 | 84 | } else { |
— | — | @@ -99,7 +99,7 @@ |
100 | 100 | $wgAutoloadClasses['SFAutocompleteAPI'] = $sfgIP . '/includes/SF_AutocompleteAPI.php'; |
101 | 101 | $wgJobClasses['createPage'] = 'SFCreatePageJob'; |
102 | 102 | $wgAutoloadClasses['SFCreatePageJob'] = $sfgIP . '/includes/SF_CreatePageJob.php'; |
103 | | -require_once($sfgIP . '/languages/SF_Language.php'); |
| 103 | +require_once( $sfgIP . '/languages/SF_Language.php' ); |
104 | 104 | |
105 | 105 | $wgExtensionMessagesFiles['SemanticForms'] = $sfgIP . '/languages/SF_Messages.php'; |
106 | 106 | $wgExtensionAliasesFiles['SemanticForms'] = $sfgIP . '/languages/SF_Aliases.php'; |
— | — | @@ -118,7 +118,7 @@ |
119 | 119 | |
120 | 120 | function sfgParserFunctions() { |
121 | 121 | global $wgHooks, $wgParser; |
122 | | - if( defined( 'MW_SUPPORTS_PARSERFIRSTCALLINIT' ) ) { |
| 122 | + if ( defined( 'MW_SUPPORTS_PARSERFIRSTCALLINIT' ) ) { |
123 | 123 | $wgHooks['ParserFirstCallInit'][] = 'SFParserFunctions::registerFunctions'; |
124 | 124 | } else { |
125 | 125 | if ( class_exists( 'StubObject' ) && !StubObject::isRealObject( $wgParser ) ) { |
— | — | @@ -140,10 +140,10 @@ |
141 | 141 | function sffInitNamespaces() { |
142 | 142 | global $wgExtraNamespaces, $wgNamespaceAliases, $wgNamespacesWithSubpages, $wgLanguageCode, $sfgContLang; |
143 | 143 | |
144 | | - sffInitContentLanguage($wgLanguageCode); |
| 144 | + sffInitContentLanguage( $wgLanguageCode ); |
145 | 145 | |
146 | 146 | // Register namespace identifiers |
147 | | - if (!is_array($wgExtraNamespaces)) { $wgExtraNamespaces=array(); } |
| 147 | + if ( !is_array( $wgExtraNamespaces ) ) { $wgExtraNamespaces = array(); } |
148 | 148 | $wgExtraNamespaces = $wgExtraNamespaces + $sfgContLang->getNamespaces(); |
149 | 149 | $wgNamespaceAliases = $wgNamespaceAliases + $sfgContLang->getNamespaceAliases(); |
150 | 150 | |
— | — | @@ -163,19 +163,19 @@ |
164 | 164 | * determine labels for additional namespaces. In contrast, messages |
165 | 165 | * can be initialised much later, when they are actually needed. |
166 | 166 | */ |
167 | | -function sffInitContentLanguage($langcode) { |
| 167 | +function sffInitContentLanguage( $langcode ) { |
168 | 168 | global $sfgIP, $sfgContLang; |
169 | 169 | |
170 | | - if (!empty($sfgContLang)) { return; } |
| 170 | + if ( !empty( $sfgContLang ) ) { return; } |
171 | 171 | |
172 | 172 | $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' ); |
175 | 175 | } |
176 | 176 | |
177 | 177 | // 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' ); |
180 | 180 | $cont_lang_class = 'SF_LanguageEn'; |
181 | 181 | } |
182 | 182 | |
— | — | @@ -187,19 +187,19 @@ |
188 | 188 | * must happen after the content language was initialised, since |
189 | 189 | * this language is used as a fallback. |
190 | 190 | */ |
191 | | -function sffInitUserLanguage($langcode) { |
| 191 | +function sffInitUserLanguage( $langcode ) { |
192 | 192 | global $sfgIP, $sfgLang; |
193 | 193 | |
194 | | - if (!empty($sfgLang)) { return; } |
| 194 | + if ( !empty( $sfgLang ) ) { return; } |
195 | 195 | |
196 | 196 | $sfLangClass = 'SF_Language' . str_replace( '-', '_', ucfirst( $langcode ) ); |
197 | 197 | |
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' ); |
200 | 200 | } |
201 | 201 | |
202 | 202 | // fallback if language not supported |
203 | | - if ( !class_exists($sfLangClass)) { |
| 203 | + if ( !class_exists( $sfLangClass ) ) { |
204 | 204 | global $sfgContLang; |
205 | 205 | $sfgLang = $sfgContLang; |
206 | 206 | } else { |
— | — | @@ -207,24 +207,24 @@ |
208 | 208 | } |
209 | 209 | } |
210 | 210 | |
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 ) ) |
215 | 215 | 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 ) ); |
229 | 229 | |
230 | 230 | return true; |
231 | 231 | } |
Index: trunk/extensions/SemanticForms/includes/SF_AutocompleteAPI.php |
— | — | @@ -10,15 +10,15 @@ |
11 | 11 | * Protect against register_globals vulnerabilities. |
12 | 12 | * This line must be present before any global variable is referenced. |
13 | 13 | */ |
14 | | -if (!defined('MEDIAWIKI')) die(); |
| 14 | +if ( !defined( 'MEDIAWIKI' ) ) die(); |
15 | 15 | |
16 | 16 | /** |
17 | 17 | * @addtogroup API |
18 | 18 | */ |
19 | 19 | class SFAutocompleteAPI extends ApiBase { |
20 | 20 | |
21 | | - public function __construct($query, $moduleName) { |
22 | | - parent :: __construct($query, $moduleName); |
| 21 | + public function __construct( $query, $moduleName ) { |
| 22 | + parent :: __construct( $query, $moduleName ); |
23 | 23 | } |
24 | 24 | |
25 | 25 | public function execute() { |
— | — | @@ -34,36 +34,36 @@ |
35 | 35 | $external_url = $params['external_url']; |
36 | 36 | $limit = $params['limit']; |
37 | 37 | |
38 | | - if (strlen($substr) == 0) |
| 38 | + if ( strlen( $substr ) == 0 ) |
39 | 39 | { |
40 | | - $this->dieUsage("The substring must be specified", 'param_substr'); |
| 40 | + $this->dieUsage( "The substring must be specified", 'param_substr' ); |
41 | 41 | } |
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 != '' ) { |
51 | 51 | // special handling for main (blank) namespace |
52 | | - if ($namespace == 'main') |
| 52 | + if ( $namespace == 'main' ) |
53 | 53 | $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 ); |
57 | 57 | } else { |
58 | 58 | $data = array(); |
59 | 59 | } |
60 | | - if (count($data)<=0) { |
| 60 | + if ( count( $data ) <= 0 ) { |
61 | 61 | return; |
62 | 62 | } |
63 | 63 | |
64 | 64 | // Set top-level elements |
65 | 65 | $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 ); |
68 | 68 | } |
69 | 69 | |
70 | 70 | protected function getAllowedParams() { |
— | — | @@ -114,40 +114,40 @@ |
115 | 115 | return __CLASS__ . ': $Id$'; |
116 | 116 | } |
117 | 117 | |
118 | | - public static function getAllValuesForProperty($is_relation, $property_name, $substring = null) { |
| 118 | + public static function getAllValuesForProperty( $is_relation, $property_name, $substring = null ) { |
119 | 119 | global $sfgMaxAutocompleteValues; |
120 | 120 | |
121 | 121 | $values = array(); |
122 | 122 | $db = wfGetDB( DB_SLAVE ); |
123 | 123 | $sql_options = array(); |
124 | 124 | $sql_options['LIMIT'] = $sfgMaxAutocompleteValues; |
125 | | - if ($is_relation) { |
| 125 | + if ( $is_relation ) { |
126 | 126 | $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"; |
128 | 128 | } else { |
129 | 129 | $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"; |
131 | 131 | } |
132 | | - $property_name = str_replace(' ', '_', $property_name); |
| 132 | + $property_name = str_replace( ' ', '_', $property_name ); |
133 | 133 | $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 ) ); |
136 | 136 | // utf8 conversion is needed in case MediaWiki is using |
137 | 137 | // binary data storage |
138 | 138 | $conditions .= " AND (REPLACE(LOWER(CONVERT($value_field USING utf8)),'_',' ') LIKE '" . $substring . "%' OR REPLACE(LOWER(CONVERT($value_field USING utf8)),'_',' ') LIKE '% " . $substring . "%')"; |
139 | 139 | } |
140 | 140 | $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] ) ); |
146 | 146 | } 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 ); |
149 | 149 | } |
150 | 150 | } |
151 | | - $db->freeResult($res); |
| 151 | + $db->freeResult( $res ); |
152 | 152 | return $values; |
153 | 153 | } |
154 | 154 | } |
Index: trunk/extensions/SemanticForms/includes/SF_CreatePageJob.php |
— | — | @@ -23,7 +23,7 @@ |
24 | 24 | wfProfileOut( __METHOD__ ); |
25 | 25 | return false; |
26 | 26 | } |
27 | | - $article = new Article($this->title); |
| 27 | + $article = new Article( $this->title ); |
28 | 28 | if ( !$article ) { |
29 | 29 | $this->error = 'createPage: Article not found "' . $this->title->getPrefixedDBkey() . '"'; |
30 | 30 | wfProfileOut( __METHOD__ ); |
— | — | @@ -36,9 +36,9 @@ |
37 | 37 | // replacement |
38 | 38 | global $wgUser; |
39 | 39 | $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 ); |
43 | 43 | $wgUser = $actual_user; |
44 | 44 | wfProfileOut( __METHOD__ ); |
45 | 45 | return true; |
Index: trunk/extensions/SemanticForms/languages/SF_LanguageEs.php |
— | — | @@ -7,13 +7,13 @@ |
8 | 8 | |
9 | 9 | /* private */ var $m_SpecialProperties = array( |
10 | 10 | // 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 |
13 | 13 | ); |
14 | 14 | |
15 | 15 | 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 |
18 | 18 | ); |
19 | 19 | |
20 | 20 | } |
Index: trunk/extensions/SemanticForms/languages/SF_LanguageFr.php |
— | — | @@ -6,7 +6,7 @@ |
7 | 7 | class SF_LanguageFr extends SF_Language { |
8 | 8 | |
9 | 9 | /* private */ var $m_SpecialProperties = array( |
10 | | - //always start upper-case |
| 10 | + // always start upper-case |
11 | 11 | SF_SP_HAS_DEFAULT_FORM => 'Utilise le formulaire', |
12 | 12 | SF_SP_HAS_ALTERNATE_FORM => 'Utilise le formulaire alternatif' |
13 | 13 | ); |
Index: trunk/extensions/SemanticForms/languages/SF_LanguageNl.php |
— | — | @@ -7,7 +7,7 @@ |
8 | 8 | |
9 | 9 | class SF_LanguageNl extends SF_Language { |
10 | 10 | /* private */ var $m_SpecialProperties = array( |
11 | | - //always start upper-case |
| 11 | + // always start upper-case |
12 | 12 | SF_SP_HAS_DEFAULT_FORM => 'Heeft standaard formulier', |
13 | 13 | SF_SP_HAS_ALTERNATE_FORM => 'Heeft formulier', |
14 | 14 | ); |
Index: trunk/extensions/SemanticForms/languages/SF_LanguageCa.php |
— | — | @@ -7,13 +7,13 @@ |
8 | 8 | |
9 | 9 | /* private */ var $m_SpecialProperties = array( |
10 | 10 | // 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 |
13 | 13 | ); |
14 | 14 | |
15 | 15 | 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 |
18 | 18 | ); |
19 | 19 | |
20 | 20 | } |
Index: trunk/extensions/SemanticForms/languages/SF_LanguageFa.php |
— | — | @@ -6,14 +6,14 @@ |
7 | 7 | class SF_LanguageFa extends SF_Language { |
8 | 8 | |
9 | 9 | /* 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 |
13 | 13 | ); |
14 | 14 | |
15 | 15 | 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 |
18 | 18 | ); |
19 | 19 | |
20 | 20 | } |
Index: trunk/extensions/SemanticForms/languages/SF_LanguageDe_formal.php |
— | — | @@ -6,7 +6,7 @@ |
7 | 7 | class SF_LanguageDe_formal extends SF_Language { |
8 | 8 | |
9 | 9 | /* private */ var $m_SpecialProperties = array( |
10 | | - //always start upper-case |
| 10 | + // always start upper-case |
11 | 11 | SF_SP_HAS_DEFAULT_FORM => 'Hat Standardformular', |
12 | 12 | SF_SP_HAS_ALTERNATE_FORM => 'Hat Alternativformular' |
13 | 13 | ); |
Index: trunk/extensions/SemanticForms/languages/SF_LanguageDe.php |
— | — | @@ -6,7 +6,7 @@ |
7 | 7 | class SF_LanguageDe extends SF_Language { |
8 | 8 | |
9 | 9 | /* private */ var $m_SpecialProperties = array( |
10 | | - //always start upper-case |
| 10 | + // always start upper-case |
11 | 11 | SF_SP_HAS_DEFAULT_FORM => 'Hat Standardformular', |
12 | 12 | SF_SP_HAS_ALTERNATE_FORM => 'Hat Alternativformular' |
13 | 13 | ); |
Index: trunk/extensions/SemanticForms/languages/SF_LanguageZh_tw.php |
— | — | @@ -6,9 +6,9 @@ |
7 | 7 | class SF_LanguageZh_tw extends SF_Language { |
8 | 8 | |
9 | 9 | /* 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) |
13 | 13 | ); |
14 | 14 | |
15 | 15 | var $m_Namespaces = array( |
— | — | @@ -18,5 +18,5 @@ |
19 | 19 | |
20 | 20 | } |
21 | 21 | |
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 “預設表單”. |
23 | 23 | |
Index: trunk/extensions/SemanticForms/languages/SF_LanguageArz.php |
— | — | @@ -7,13 +7,13 @@ |
8 | 8 | |
9 | 9 | /* private */ var $m_SpecialProperties = array( |
10 | 10 | // 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 |
13 | 13 | ); |
14 | 14 | |
15 | 15 | 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 |
18 | 18 | ); |
19 | 19 | |
20 | 20 | } |
Index: trunk/extensions/SemanticForms/languages/SF_LanguageHe.php |
— | — | @@ -6,7 +6,7 @@ |
7 | 7 | class SF_LanguageHe extends SF_Language { |
8 | 8 | |
9 | 9 | /* private */ var $m_SpecialProperties = array( |
10 | | - //always start upper-case |
| 10 | + // always start upper-case |
11 | 11 | SF_SP_HAS_DEFAULT_FORM => 'משתמש בטופס', |
12 | 12 | SF_SP_HAS_ALTERNATE_FORM => 'משתמש בטופס' |
13 | 13 | ); |
Index: trunk/extensions/SemanticForms/languages/SF_LanguageZh_cn.php |
— | — | @@ -6,9 +6,9 @@ |
7 | 7 | class SF_LanguageZh_cn extends SF_Language { |
8 | 8 | |
9 | 9 | /* 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) |
13 | 13 | ); |
14 | 14 | |
15 | 15 | var $m_Namespaces = array( |
— | — | @@ -18,5 +18,5 @@ |
19 | 19 | |
20 | 20 | } |
21 | 21 | |
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 “预设表单". |
23 | 23 | |
Index: trunk/extensions/SemanticForms/languages/SF_LanguageAr.php |
— | — | @@ -7,13 +7,13 @@ |
8 | 8 | |
9 | 9 | /* private */ var $m_SpecialProperties = array( |
10 | 10 | // 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 |
13 | 13 | ); |
14 | 14 | |
15 | 15 | 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 |
18 | 18 | ); |
19 | 19 | |
20 | 20 | } |
Index: trunk/extensions/SemanticForms/languages/SF_LanguagePt_br.php |
— | — | @@ -6,7 +6,7 @@ |
7 | 7 | class SF_LanguagePt_br extends SF_Language { |
8 | 8 | |
9 | 9 | /* private */ var $m_SpecialProperties = array( |
10 | | - //always start upper-case |
| 10 | + // always start upper-case |
11 | 11 | SF_SP_HAS_DEFAULT_FORM => 'Has default form', |
12 | 12 | SF_SP_HAS_ALTERNATE_FORM => 'Has alternate form' |
13 | 13 | ); |