r99697 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r99696‎ | r99697 | r99698 >
Date:16:43, 13 October 2011
Author:yaron
Status:deferred
Tags:
Comment:
Fixes to loadAllFromPageSchema() - filter name is now set correctly
Modified paths:
  • /trunk/extensions/SemanticDrilldown/includes/SD_Filter.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticDrilldown/includes/SD_Filter.php
@@ -19,21 +19,27 @@
2020 var $allowed_values;
2121 var $possible_applied_filters = array();
2222
23 - static function loadAllFromPageSchema( $psSchemaObj ){
 23+ static function loadAllFromPageSchema( $psSchemaObj ){
2424 $filters_ps = array();
2525 $template_all = $psSchemaObj->getTemplates();
2626 foreach ( $template_all as $template ) {
2727 $field_all = $template->getFields();
2828 foreach( $field_all as $fieldObj ) { //for each Field, retrieve smw properties and fill $prop_name , $prop_type
2929 $f = new SDFilter();
30 - $object_values = $fieldObj->getObject('semanticdrilldown_Filter');//this returns an array with property values filled
31 - $sd_array = $object_values['sd'];
32 - $smw_array = $fieldObj->getObject('semanticmediawiki_Property'); //this returns an array with property values filled
 30+ $object_values = $fieldObj->getObject('semanticdrilldown_Filter');
 31+ if ( !array_key_exists( 'sd', $object_values ) ) {
 32+ continue;
 33+ }
 34+ $sd_array = $object_values['sd'];
 35+ $smw_array = $fieldObj->getObject('semanticmediawiki_Property');
 36+ if ( !array_key_exists( 'smw', $smw_array ) ) {
 37+ continue;
 38+ }
3339 $prop_array = $smw_array['smw'];
3440 if ( array_key_exists( 'Name', $sd_array ) ) {
3541 $f->name = $sd_array['Name'];
3642 } else {
37 - $f->name = $prop_array['name'];
 43+ $f->name = $fieldObj->getName();
3844 }
3945 $f->property = $prop_array['name'];
4046 $f->escaped_property = str_replace( array( ' ', "'" ), array( '_', "\'" ), $f->property );
@@ -41,7 +47,9 @@
4248 if ( array_key_exists( 'Type', $prop_array ) && $prop_array['Type'] != 'Page' ) {
4349 $f->is_relation = false;
4450 }
45 - $f->input_type = $sd_array['InputType'];
 51+ if ( array_key_exists( 'InputType', $sd_array ) ) {
 52+ $f->input_type = $sd_array['InputType'];
 53+ }
4654 if ( array_key_exists( 'ValuesFromCategory', $sd_array ) ) {
4755 $f->category = $sd_array['ValuesFromCategory'];
4856 $f->allowed_values = SDUtils::getCategoryChildren( $f->category, false, 5 );