r95329 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r95328‎ | r95329 | r95330 >
Date:20:01, 23 August 2011
Author:yaron
Status:deferred
Tags:
Comment:
Some improvements to loadAllFromPageSchema()
Modified paths:
  • /trunk/extensions/SemanticDrilldown/includes/SD_Filter.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticDrilldown/includes/SD_Filter.php
@@ -30,22 +30,30 @@
3131 $sd_array = $object_values['sd'];
3232 $smw_array = $fieldObj->getObject('semanticmediawiki_Property'); //this returns an array with property values filled
3333 $prop_array = $smw_array['smw'];
34 - $f->name = $sd_array['Label'];
 34+ if ( array_key_exists( 'Label', $sd_array ) ) {
 35+ $f->name = $sd_array['Label'];
 36+ } else {
 37+ $f->name = $prop_array['name'];
 38+ }
3539 $f->property = $prop_array['name'];
3640 $f->escaped_property = str_replace( array( ' ', "'" ), array( '_', "\'" ), $f->property );
3741 $f->is_relation = true;
 42+ if ( array_key_exists( 'Type', $prop_array ) && $prop_array['Type'] != 'Page' ) {
 43+ $f->is_relation = false;
 44+ }
3845 $f->input_type = $sd_array['InputType'];
39 - if ( $sd_array['ValuesFromCategory'] != null ) {
 46+ if ( array_key_exists( 'ValuesFromCategory', $sd_array ) ) {
4047 $f->category = $sd_array['ValuesFromCategory'];
4148 $f->allowed_values = SDUtils::getCategoryChildren( $f->category, false, 5 );
42 - } elseif ( $sd_array['TimePeriod'] != null ) {
 49+ } elseif ( array_key_exists( 'TimePeriod', $sd_array ) ) {
4350 $f->time_period = $sd_array['TimePeriod'];
4451 $f->allowed_values = array();
4552 } elseif ( $f->is_boolean ) {
4653 $f->allowed_values = array( '0', '1' );
 54+ } elseif ( array_key_exists( 'Values', $sd_array ) ) {
 55+ $f->allowed_values = $sd_array['Values'];
4756 } else {
48 - $values = $sd_array['Values'];
49 - $f->allowed_values = $values;
 57+ $f->allowed_values = array();
5058 }
5159 $filters_ps[] = $f ;
5260 }