Index: trunk/extensions/SemanticDrilldown/includes/SD_Filter.php |
— | — | @@ -12,7 +12,8 @@ |
13 | 13 | var $is_relation; |
14 | 14 | var $is_boolean; |
15 | 15 | var $category; |
16 | | - var $time_period = NULL; |
| 16 | + var $time_period = null; |
| 17 | + var $input_type = null; |
17 | 18 | var $allowed_values; |
18 | 19 | var $possible_applied_filters = array(); |
19 | 20 | |
— | — | @@ -22,44 +23,31 @@ |
23 | 24 | |
24 | 25 | $f = new SDFilter(); |
25 | 26 | $f->name = $filter_name; |
26 | | - $relations_used = sdfGetValuesForProperty($filter_name, SD_NS_FILTER, SD_SP_COVERS_PROPERTY, true, SMW_NS_RELATION); |
27 | | - $smw_version = SMW_VERSION; |
28 | | - if ($smw_version{0} == '0') { |
29 | | - $attribute_ns = SMW_NS_ATTRIBUTE; |
30 | | - } else { |
31 | | - $attribute_ns = SMW_NS_PROPERTY; |
| 27 | + $properties_used = sdfGetValuesForProperty($filter_name, SD_NS_FILTER, SD_SP_COVERS_PROPERTY, SMW_NS_PROPERTY); |
| 28 | + if (count($properties_used) > 0) { |
| 29 | + $f->property = $properties_used[0]; |
32 | 30 | } |
33 | | - $attributes_used = sdfGetValuesForProperty($filter_name, SD_NS_FILTER, SD_SP_COVERS_PROPERTY, true, $attribute_ns); |
34 | | - if (count($relations_used) > 0) { |
35 | | - $f->property = $relations_used[0]; |
36 | | - $f->is_relation = true; |
37 | | - } elseif (count($attributes_used) > 0) { |
38 | | - $f->property = $attributes_used[0]; |
39 | | - $f->is_relation = false; |
40 | | - } |
41 | | - // handling of SMW 1.0 is somewhat awkward - the above code |
42 | | - // retrieves the property correctly for SMW 1.0, but not the |
43 | | - // "is_relation" value; for that, we need to get this |
44 | | - // "special value" separately |
45 | | - if ($smw_version{0} != '0') { |
46 | | - $f->is_relation = false; |
47 | | - $proptitle = Title::newFromText($f->property, SMW_NS_PROPERTY); |
48 | | - if ($proptitle != NULL) { |
49 | | - $store = smwfGetStore(); |
| 31 | + $f->is_relation = false; |
| 32 | + $proptitle = Title::newFromText($f->property, SMW_NS_PROPERTY); |
| 33 | + if ($proptitle != NULL) { |
| 34 | + $store = smwfGetStore(); |
| 35 | + if (class_exists('SMWPropertyValue')) { |
| 36 | + $types = $store->getPropertyValues($proptitle, SMWPropertyValue::makeUserProperty('Has type')); |
| 37 | + } else { |
50 | 38 | $types = $store->getSpecialValues($proptitle, SMW_SP_HAS_TYPE); |
51 | | - global $smwgContLang; |
52 | | - $datatypeLabels = $smwgContLang->getDatatypeLabels(); |
53 | | - if (count($types) > 0) { |
54 | | - if ($types[0]->getWikiValue() == $datatypeLabels['_wpg']) { |
55 | | - $f->is_relation = true; |
56 | | - } elseif ($types[0]->getWikiValue() == $datatypeLabels['_boo']) { |
57 | | - $f->is_boolean = true; |
58 | | - } |
| 39 | + } |
| 40 | + global $smwgContLang; |
| 41 | + $datatypeLabels = $smwgContLang->getDatatypeLabels(); |
| 42 | + if (count($types) > 0) { |
| 43 | + if ($types[0]->getWikiValue() == $datatypeLabels['_wpg']) { |
| 44 | + $f->is_relation = true; |
| 45 | + } elseif ($types[0]->getWikiValue() == $datatypeLabels['_boo']) { |
| 46 | + $f->is_boolean = true; |
59 | 47 | } |
60 | 48 | } |
61 | 49 | } |
62 | | - $categories = sdfGetValuesForProperty($filter_name, SD_NS_FILTER, SD_SP_GETS_VALUES_FROM_CATEGORY, true, NS_CATEGORY); |
63 | | - $time_periods = sdfGetValuesForProperty($filter_name, SD_NS_FILTER, SD_SP_USES_TIME_PERIOD, false, null); |
| 50 | + $categories = sdfGetValuesForProperty($filter_name, SD_NS_FILTER, SD_SP_GETS_VALUES_FROM_CATEGORY, NS_CATEGORY); |
| 51 | + $time_periods = sdfGetValuesForProperty($filter_name, SD_NS_FILTER, SD_SP_USES_TIME_PERIOD, null); |
64 | 52 | if (count($categories) > 0) { |
65 | 53 | $f->category = $categories[0]; |
66 | 54 | $f->allowed_values = sdfGetCategoryChildren($f->category, false, 5); |
— | — | @@ -69,9 +57,13 @@ |
70 | 58 | } elseif ($f->is_boolean) { |
71 | 59 | $f->allowed_values = array('0', '1'); |
72 | 60 | } else { |
73 | | - $values = sdfGetValuesForProperty($filter_name, SD_NS_FILTER, SD_SP_HAS_VALUE, false, null); |
| 61 | + $values = sdfGetValuesForProperty($filter_name, SD_NS_FILTER, SD_SP_HAS_VALUE, null); |
74 | 62 | $f->allowed_values = $values; |
75 | 63 | } |
| 64 | + $input_types = sdfGetValuesForProperty($filter_name, SD_NS_FILTER, SD_SP_HAS_INPUT_TYPE, null); |
| 65 | + if (count($input_types) > 0) { |
| 66 | + $f->input_type = $input_types[0]; |
| 67 | + } |
76 | 68 | // set list of possible applied filters if allowed values |
77 | 69 | // array was set |
78 | 70 | foreach($f->allowed_values as $allowed_value) { |