r46866 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r46865‎ | r46866 | r46867 >
Date:17:34, 5 February 2009
Author:yaron
Status:deferred
Tags:
Comment:
createCategoryText() turned into a class function
Modified paths:
  • /trunk/extensions/SemanticForms/specials/SF_CreateCategory.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticForms/specials/SF_CreateCategory.php
@@ -18,38 +18,38 @@
1919 wfLoadExtensionMessages('SemanticForms');
2020 }
2121
22 - function execute() {
 22+ function execute($query) {
2323 $this->setHeaders();
2424 doSpecialCreateCategory();
2525 }
26 -}
2726
28 -function createCategoryText($default_form, $category_name, $parent_category) {
29 - wfLoadExtensionMessages('SemanticForms');
 27+ static function createCategoryText($default_form, $category_name, $parent_category) {
 28+ wfLoadExtensionMessages('SemanticForms');
3029
31 - if ($default_form == '') {
32 - $text = wfMsgForContent('sf_category_desc', $category_name);
33 - } else {
34 - global $sfgContLang;
35 - $specprops = $sfgContLang->getPropertyLabels();
36 - // a simpler call is possible in SMW 1.4 and higher
37 - if (class_exists('SMWPropertyValue')) {
38 - $form_tag = "[[" . $specprops[SF_SP_HAS_DEFAULT_FORM] . "::$default_form]]";
 30+ if ($default_form == '') {
 31+ $text = wfMsgForContent('sf_category_desc', $category_name);
3932 } else {
40 - $namespace_labels = $sfgContLang->getNamespaces();
41 - $form_label = $namespace_labels[SF_NS_FORM];
42 - $form_tag = "[[" . $specprops[SF_SP_HAS_DEFAULT_FORM] .
43 - "::$form_label:$default_form|$default_form]]";
 33+ global $sfgContLang;
 34+ $specprops = $sfgContLang->getPropertyLabels();
 35+ // a simpler call is possible in SMW 1.4 and higher
 36+ if (class_exists('SMWPropertyValue')) {
 37+ $form_tag = "[[" . $specprops[SF_SP_HAS_DEFAULT_FORM] . "::$default_form]]";
 38+ } else {
 39+ $namespace_labels = $sfgContLang->getNamespaces();
 40+ $form_label = $namespace_labels[SF_NS_FORM];
 41+ $form_tag = "[[" . $specprops[SF_SP_HAS_DEFAULT_FORM] .
 42+ "::$form_label:$default_form|$default_form]]";
 43+ }
 44+ $text = wfMsgForContent('sf_category_hasdefaultform', $form_tag);
4445 }
45 - $text = wfMsgForContent('sf_category_hasdefaultform', $form_tag);
 46+ if ($parent_category != '') {
 47+ global $wgContLang;
 48+ $namespace_labels = $wgContLang->getNamespaces();
 49+ $category_namespace = $namespace_labels[NS_CATEGORY];
 50+ $text .= "\n\n[[$category_namespace:$parent_category]]";
 51+ }
 52+ return $text;
4653 }
47 - if ($parent_category != '') {
48 - global $wgContLang;
49 - $namespace_labels = $wgContLang->getNamespaces();
50 - $category_namespace = $namespace_labels[NS_CATEGORY];
51 - $text .= "\n\n[[$category_namespace:$parent_category]]";
52 - }
53 - return $text;
5454 }
5555
5656 function doSpecialCreateCategory() {
@@ -75,8 +75,8 @@
7676 # redirect to wiki interface
7777 $wgOut->setArticleBodyOnly(true);
7878 $namespace = NS_CATEGORY;
79 - $title = Title::newFromText($category_name, $namespace);
80 - $full_text = createCategoryText($default_form, $category_name, $parent_category);
 79+ $title = Title::makeTitleSafe($namespace, $category_name);
 80+ $full_text = SFCreateCategory::createCategoryText($default_form, $category_name, $parent_category);
8181 // HTML-encode
8282 $full_text = str_replace('"', '"', $full_text);
8383 $text = SFUtils::printRedirectForm($title, $full_text, "", $save_page, $preview_page, false, false, false, null, null);

Status & tagging log