r60139 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r60138‎ | r60139 | r60140 >
Date:20:36, 16 December 2009
Author:yaron
Status:deferred
Tags:
Comment:
Removed handling of SMW < 1.4
Modified paths:
  • /trunk/extensions/SemanticForms/includes/SF_LinkUtils.inc (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticForms/includes/SF_LinkUtils.inc
@@ -76,53 +76,19 @@
7777 die("ERROR: <a href=\"http://semantic-mediawiki.org\">Semantic MediaWiki</a> must be installed for Semantic Forms to run!");
7878 $store = smwfGetStore();
7979 $title = Title::makeTitleSafe($page_namespace, $page_name);
80 - // we can do this easily if we're using SMW 1.4 or higher
81 - if (class_exists('SMWPropertyValue')) {
82 - $property = SMWPropertyValue::makeProperty($prop_smw_id);
83 - $res = $store->getPropertyValues($title, $property);
84 - $form_names = array();
 80+ $property = SMWPropertyValue::makeProperty($prop_smw_id);
 81+ $res = $store->getPropertyValues($title, $property);
 82+ $form_names = array();
 83+ foreach ($res as $wiki_page_value)
 84+ $form_names[] = $wiki_page_value->getTitle()->getText();
 85+ // if we're using a non-English language, check for the English string as well
 86+ if (! $sfgContLang instanceof SF_LanguageEn) {
 87+ $backup_property = SMWPropertyValue::makeProperty($backup_prop_smw_id);
 88+ $res = $store->getPropertyValues($title, $backup_property);
8589 foreach ($res as $wiki_page_value)
8690 $form_names[] = $wiki_page_value->getTitle()->getText();
87 - // if we're using a non-English language, check for the English string as well
88 - if (! $sfgContLang instanceof SF_LanguageEn) {
89 - $backup_property = SMWPropertyValue::makeProperty($backup_prop_smw_id);
90 - $res = $store->getPropertyValues($title, $backup_property);
91 - foreach ($res as $wiki_page_value)
92 - $form_names[] = $wiki_page_value->getTitle()->getText();
93 - }
94 - return $form_names;
9591 }
96 -
97 - // otherwise, it's a bit more complex
98 - $sf_props = $sfgContLang->getPropertyLabels();
99 - $default_form_property = str_replace(' ', '_', $sf_props[$prop_id]);
100 - $property = SFUtils::createProperty($default_form_property);
101 - $prop_vals = $store->getPropertyValues($title, $property);
102 - $form_names = array();
103 - foreach ($prop_vals as $prop_val) {
104 - // make sure it's in the form namespace
105 - if (($prop_val instanceof SMWWikiPageValue || $prop_val instanceof Title) &&
106 - ($prop_val->getNamespace() == SF_NS_FORM)) {
107 - $form_names[] = str_replace(' ', '_', $prop_val->getTitle()->getText());
108 - }
109 - }
110 - // if that didn't work, try any aliases that may exist
111 - // for this property
112 - $sf_props_aliases = $sfgContLang->getPropertyAliases();
113 - foreach ($sf_props_aliases as $alias => $prop_code) {
114 - if ($prop_code == $prop_id) {
115 - $property = SFUtils::createProperty($alias);
116 - $res = $store->getPropertyValues($title, $property);
117 - if (isset($res[0]) && ($res[0] instanceof SMWWikiPageValue || $res[0] instanceof Title)) {
118 - // make sure it's in the form namespace
119 - if ($res[0]->getNamespace() == SF_NS_FORM) {
120 - $form_name = $res[0]->getTitle()->getText();
121 - return array($form_name);
122 - }
123 - }
124 - }
125 - }
126 - return array();
 92+ return $form_names;
12793 }
12894
12995 /**

Status & tagging log