Index: trunk/extensions/SemanticForms/specials/SF_CreateCategory.php |
— | — | @@ -18,38 +18,38 @@ |
19 | 19 | wfLoadExtensionMessages('SemanticForms'); |
20 | 20 | } |
21 | 21 | |
22 | | - function execute() { |
| 22 | + function execute($query) { |
23 | 23 | $this->setHeaders(); |
24 | 24 | doSpecialCreateCategory(); |
25 | 25 | } |
26 | | -} |
27 | 26 | |
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'); |
30 | 29 | |
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); |
39 | 32 | } 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); |
44 | 45 | } |
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; |
46 | 53 | } |
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; |
54 | 54 | } |
55 | 55 | |
56 | 56 | function doSpecialCreateCategory() { |
— | — | @@ -75,8 +75,8 @@ |
76 | 76 | # redirect to wiki interface |
77 | 77 | $wgOut->setArticleBodyOnly(true); |
78 | 78 | $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); |
81 | 81 | // HTML-encode |
82 | 82 | $full_text = str_replace('"', '"', $full_text); |
83 | 83 | $text = SFUtils::printRedirectForm($title, $full_text, "", $save_page, $preview_page, false, false, false, null, null); |