r89202 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r89201‎ | r89202 | r89203 >
Date:04:24, 31 May 2011
Author:yaron
Status:deferred
Tags:
Comment:
SFUtils::getSMWPropertyValues() now returns values, instead of objects
Modified paths:
  • /trunk/extensions/SemanticForms/includes/SF_FormLinker.php (modified) (history)
  • /trunk/extensions/SemanticForms/includes/SF_TemplateField.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticForms/includes/SF_FormLinker.php
@@ -133,27 +133,14 @@
134134 }
135135
136136 $store = smwfGetStore();
137 - $res = SFUtils::getSMWPropertyValues( $store, $page_name, $page_namespace, $prop_smw_id );
 137+ $form_names = SFUtils::getSMWPropertyValues( $store, $page_name, $page_namespace, $prop_smw_id );
138138
139 - $form_names = array();
140 - foreach ( $res as $wiki_page_value ) {
141 - // SMW 1.6+
142 - if ( $wiki_page_value instanceof SMWDIWikiPage ) {
143 - $form_names[] = $wiki_page_value->getDBkey();
144 - } else {
145 - $form_title = $wiki_page_value->getTitle();
146 - if ( ! is_null( $form_title ) ) {
147 - $form_names[] = $form_title->getText();
148 - }
149 - }
150 - }
151 - // if we're using a non-English language, check for the English string as well
 139+ // If we're using a non-English language, check for the English
 140+ // string as well.
152141 if ( ! class_exists( 'SF_LanguageEn' ) || ! $sfgContLang instanceof SF_LanguageEn ) {
153 - $res = SFUtils::getSMWPropertyValues( $store, $page_name, $page_namespace, $backup_prop_smw_id );
154 - foreach ( $res as $wiki_page_value )
155 - $form_names[] = $wiki_page_value->getTitle()->getText();
 142+ $backup_form_names = SFUtils::getSMWPropertyValues( $store, $page_name, $page_namespace, $backup_prop_smw_id );
 143+ $form_names = array_merge( $form_names, $backup_form_names );
156144 }
157 - $form_names = array_unique( $form_names );
158145 // Add this data to the "cache".
159146 self::$mLinkedForms[$page_key][$form_connection_type] = $form_names;
160147 return $form_names;
@@ -298,8 +285,9 @@
299286 // See if the page itself has a default form (or forms), and
300287 // return it/them if so.
301288 $default_forms = self::getFormsThatPagePointsTo( $title->getText(), $title->getNamespace(), self::PAGE_DEFAULT_FORM );
302 - if ( count( $default_forms ) > 0 )
 289+ if ( count( $default_forms ) > 0 ) {
303290 return $default_forms;
 291+ }
304292 // If this is not a category page, look for a default form
305293 // for its parent category or categories.
306294 $namespace = $title->getNamespace();
Index: trunk/extensions/SemanticForms/includes/SF_TemplateField.php
@@ -72,15 +72,14 @@
7373 }
7474 // TODO - need handling for the case of more than one type.
7575 if ( count( $types ) > 0 ) {
76 - $this->field_type = $types[0]->getWikiValue();
 76+ $this->field_type = $types[0];
7777 }
7878
79 - foreach ( $allowed_values as $value ) {
 79+ foreach ( $allowed_values as $allowed_value ) {
8080 // HTML-unencode each value
81 - $wiki_value = html_entity_decode( $value->getWikiValue() );
82 - $this->possible_values[] = $wiki_value;
 81+ $this->possible_values[] = html_entity_decode( $allowed_value );
8382 if ( count( $label_formats ) > 0 ) {
84 - $label_format = $label_formats[0]->getWikiValue();
 83+ $label_format = $label_formats[0];
8584 $prop_instance = SMWDataValueFactory::findTypeID( $this->field_type );
8685 $label_value = SMWDataValueFactory::newTypeIDValue( $prop_instance, $wiki_value );
8786 $label_value->setOutputFormat( $label_format );