Index: trunk/extensions/SemanticDrilldown/includes/SD_PageSchemas.php |
— | — | @@ -0,0 +1,239 @@ |
| 2 | +<?php |
| 3 | +/** |
| 4 | + * Static functions for Semantic Drilldown, for use by the Page Schemas |
| 5 | + * extension. |
| 6 | + * |
| 7 | + * @author Yaron Koren |
| 8 | + * @author Ankit Garg |
| 9 | + */ |
| 10 | + |
| 11 | +class SDPageSchemas { |
| 12 | + |
| 13 | + /** |
| 14 | + * Return an object containing information on a filter, based on XML |
| 15 | + * from the Page Schemas extensions |
| 16 | + */ |
| 17 | + public static function createPageSchemasObject( $objectName, $xmlForField, &$object ) { |
| 18 | + $sdarray = array(); |
| 19 | + if ( $objectName == "semanticdrilldown_Filter" ) { |
| 20 | + foreach ( $xmlForField->children() as $tag => $child ) { |
| 21 | + if ( $tag == $objectName ) { |
| 22 | + foreach ( $child->children() as $prop => $value) { |
| 23 | + if( $prop == "Values" ){ |
| 24 | + $l_values = array(); |
| 25 | + foreach ( $value->children() as $val_i => $val ) { |
| 26 | + $l_values[] = (string)$val; |
| 27 | + } |
| 28 | + $sdarray['Values'] = $l_values; |
| 29 | + } else { |
| 30 | + $sdarray[$prop] = (string)$value; |
| 31 | + } |
| 32 | + } |
| 33 | + $object['sd'] = $sdarray; |
| 34 | + return true; |
| 35 | + } |
| 36 | + } |
| 37 | + } |
| 38 | + return true; |
| 39 | + } |
| 40 | + |
| 41 | + /** |
| 42 | + * Returns the HTML for setting the filter options, for the |
| 43 | + * Semantic Drilldown section in Page Schemas' "edit schema" page |
| 44 | + */ |
| 45 | + public static function getFieldHTML( $field, &$text_extensions ){ |
| 46 | + // TODO - add these options to the XML and HTML |
| 47 | + //$property_label = wfMsg( 'sd_createfilter_property' ); |
| 48 | + //$label_label = wfMsg( 'sd_createfilter_label' ); |
| 49 | + // need both label and value, in case user's language is different |
| 50 | + // from wiki's |
| 51 | + //$require_filter_label = wfMsg( 'sd_createfilter_requirefilter' ); |
| 52 | + |
| 53 | + $filter_array = array(); |
| 54 | + if ( !is_null( $field ) ) { |
| 55 | + $sd_array = $field->getObject('semanticdrilldown_Filter'); |
| 56 | + if ( array_key_exists( 'sd', $sd_array ) ) { |
| 57 | + $filter_array = $sd_array['sd']; |
| 58 | + $hasExistingValues = true; |
| 59 | + } else { |
| 60 | + $hasExistingValues = false; |
| 61 | + } |
| 62 | + } |
| 63 | + |
| 64 | + if ( array_key_exists( 'Label', $filter_array ) ) { |
| 65 | + $filterLabel = $filter_array['Label']; |
| 66 | + } else { |
| 67 | + $filterLabel = ''; |
| 68 | + } |
| 69 | + $fromCategoryAttrs = array(); |
| 70 | + if ( array_key_exists( 'ValuesFromCategory', $filter_array ) ) { |
| 71 | + $selectedCategory = $filter_array['ValuesFromCategory']; |
| 72 | + $fromCategoryAttrs['checked'] = true; |
| 73 | + } else { |
| 74 | + $selectedCategory = ''; |
| 75 | + } |
| 76 | + $dateRangesAttrs = array(); |
| 77 | + $yearOptionAttrs = array( 'value' => $year_value ); |
| 78 | + $monthOptionAttrs = array( 'value' => $month_value ); |
| 79 | + if ( array_key_exists( 'TimePeriod', $filter_array ) ) { |
| 80 | + $year_value = wfMsgForContent( 'sd_filter_year' ); |
| 81 | + // This value may eventually get checked against. |
| 82 | + //$month_value = wfMsgForContent( 'sd_filter_month' ); |
| 83 | + $filterTimePeriod = $filter_array['TimePeriod']; |
| 84 | + $dateRangesAttrs['checked'] = true; |
| 85 | + if ( $filterTimePeriod == $year_value ) { |
| 86 | + $yearOptionAttrs['selected'] = true; |
| 87 | + } else { |
| 88 | + $monthOptionAttrs['selected'] = true; |
| 89 | + } |
| 90 | + } else { |
| 91 | + $filterTimePeriod = ''; |
| 92 | + } |
| 93 | + $manualSourceAttrs = array(); |
| 94 | + $filterValuesAttrs = array( 'size' => 40 ); |
| 95 | + if ( array_key_exists( 'Values', $filter_array ) ) { |
| 96 | + $manualSourceAttrs['checked'] = true; |
| 97 | + $values_array = $filter_array['Values']; |
| 98 | + $filterValuesStr = implode( ', ', $values_array ); |
| 99 | + } else { |
| 100 | + $filterValuesStr = ''; |
| 101 | + } |
| 102 | + // Have the first radiobutton ("Use all values of this |
| 103 | + // property for the filter") checked if none of the other |
| 104 | + // options have been selected - unlike the others, there's |
| 105 | + // no XML to define this option. |
| 106 | + $usePropertyValuesAttr = array(); |
| 107 | + if ( empty( $selectedCategory ) && empty( $filterTimePeriod ) && empty( $filterValuesStr ) ) { |
| 108 | + $usePropertyValuesAttr['checked'] = true; |
| 109 | + } |
| 110 | + |
| 111 | + // The "input type" field |
| 112 | + $combo_box_value = wfMsgForContent( 'sd_filter_combobox' ); |
| 113 | + $date_range_value = wfMsgForContent( 'sd_filter_daterange' ); |
| 114 | + $valuesListAttrs = array( 'value' => '' ); |
| 115 | + $comboBoxAttrs = array( 'value' => $combo_box_value ); |
| 116 | + $dateRangeAttrs = array( 'value' => $date_range_value ); |
| 117 | + if ( array_key_exists( 'InputType', $filter_array ) ) { |
| 118 | + $input_type_val = $filter_array['InputType']; |
| 119 | + } else { |
| 120 | + $input_type_val = ''; |
| 121 | + } |
| 122 | + if ( $input_type_val == $combo_box_value ) { |
| 123 | + $comboBoxAttrs['selected'] = true; |
| 124 | + } elseif ( $input_type_val == $date_range_value ) { |
| 125 | + $dateRangeAttrs['selected'] = true; |
| 126 | + } else { |
| 127 | + $valuesListAttrs['selected'] = true; |
| 128 | + } |
| 129 | + |
| 130 | + $html_text = '<p>' . wfMsg( 'sd_createfilter_name' ) . ' '; |
| 131 | + $html_text .= Html::input( 'sd_filter_name_num', $filterLabel, 'text', array( 'size' => 25 ) ) . "</p>\n"; |
| 132 | + $html_text .= '<p>' . Html::input( 'sd_values_source_num', 'property', 'radio', $usePropertyValuesAttr ) . ' '; |
| 133 | + $html_text .= wfMsg( 'sd_createfilter_usepropertyvalues' ) . "</p>\n"; |
| 134 | + $html_text .= "\t<p>\n"; |
| 135 | + $html_text .= Html::input( 'sd_values_source_num', 'category', 'radio', $fromCategoryAttrs ) . "\n"; |
| 136 | + $html_text .= "\t" . wfMsg( 'sd_createfilter_usecategoryvalues' ) . "\n"; |
| 137 | + $categories = SDUtils::getTopLevelCategories(); |
| 138 | + $categoriesHTML = ""; |
| 139 | + foreach ( $categories as $category ) { |
| 140 | + $categoryOptionAttrs = array(); |
| 141 | + $category = str_replace( '_', ' ', $category ); |
| 142 | + if ( $category == $selectedCategory) { |
| 143 | + $categoryOptionAttrs['selected'] = true; |
| 144 | + } |
| 145 | + $categoriesHTML .= "\t" . Html::element( 'option', $categoryOptionAttrs, $category ) . "\n"; |
| 146 | + } |
| 147 | + $html_text .= "\t" . Html::rawElement( 'select', array( 'id' => 'category_dropdown', 'name' => 'sd_category_name_num' ), "\n" . $categoriesHTML ) . "\n"; |
| 148 | + $html_text .= "\t</p>\n"; |
| 149 | + |
| 150 | + $html_text .= "\t<p>\n"; |
| 151 | + $html_text .= "\t" . Html::input( 'sd_values_source_num', 'dates', 'radio', $dateRangesAttrs ) . "\n"; |
| 152 | + $html_text .= "\t" . wfMsg( 'sd_createfilter_usedatevalues' ) . "\n"; |
| 153 | + $dateRangeDropdown = Html::element( 'option', $yearOptionAttrs, wfMsg( 'sd_filter_year' ) ) . "\n"; |
| 154 | + $dateRangeDropdown .= Html::element( 'option', $monthOptionAttrs, wfMsg( 'sd_filter_month' ) ) . "\n"; |
| 155 | + $html_text .= Html::rawElement( 'select', array( 'name' => 'sd_time_period_num', 'id' => 'time_period_dropdown' ), "\n" . $dateRangeDropdown ) . "\n"; |
| 156 | + $html_text .= "</p>\n<p>\n"; |
| 157 | + $html_text .= "\t" . Html::input( 'sd_values_source_num', 'manual', 'radio', $manualSourceAttrs ) . "\n"; |
| 158 | + $html_text .= "\t" . wfMsg( 'sd_createfilter_entervalues' ) . "\n"; |
| 159 | + $html_text .= "\t" . Html::input( 'sd_filter_values_num', $filterValuesStr, 'text', $filterValuesAttrs ) . "\n"; |
| 160 | + $html_text .= "\t</p>\n"; |
| 161 | + |
| 162 | + $html_text .= '<p>' . wfMsg( 'sd_createfilter_inputtype' ) . "\n"; |
| 163 | + $inputTypeOptionsHTML = "\t" . Html::element( 'option', $valuesListAttrs, wfMsg( 'sd_createfilter_listofvalues' ) ) . "\n"; |
| 164 | + $inputTypeOptionsHTML .= "\t" . Html::element( 'option', $comboBoxAttrs, wfMsg( 'sd_filter_combobox' ) ) . "\n"; |
| 165 | + $inputTypeOptionsHTML .= "\t" . Html::element( 'option', $dateRangeAttrs, wfMsg( 'sd_filter_daterange' ) ) . "\n"; |
| 166 | + $html_text .= Html::rawElement( 'select', array( 'name' => 'sd_input_type_num', 'id' => 'input_type_dropdown' ), $inputTypeOptionsHTML ) . "\n"; |
| 167 | + $html_text .= "</p>\n"; |
| 168 | + |
| 169 | + $text_extensions['sd'] = array( 'Filter', '#FDD', $html_text, $hasExistingValues ); |
| 170 | + |
| 171 | + return true; |
| 172 | + } |
| 173 | + |
| 174 | + public static function getFieldXML( $request, &$xmlArray ) { |
| 175 | + $fieldNum = -1; |
| 176 | + $xmlPerField = array(); |
| 177 | + foreach ( $request->getValues() as $var => $val ) { |
| 178 | + if ( substr( $var, 0, 15 ) == 'sd_filter_name_' ) { |
| 179 | + $xml = '<semanticdrilldown_Filter>'; |
| 180 | + $fieldNum = substr( $var, 15 ); |
| 181 | + $xml .= '<Label>'.$val.'</Label>'; |
| 182 | + } elseif ( substr( $var, 0, 17 ) == 'sd_values_source_') { |
| 183 | + if ( $val == 'category' ) { |
| 184 | + $xml .= '<ValuesFromCategory>' . $request->getText('sd_category_name_' . $fieldNum) . '</ValuesFromCategory>'; |
| 185 | + } elseif ( $val == 'dates' ) { |
| 186 | + $xml .= '<TimePeriod>' . $request->getText('sd_time_period_' . $fieldNum) . '</TimePeriod>'; |
| 187 | + } elseif ( $val == 'manual' ) { |
| 188 | + $filter_manual_values_str = $request->getText('sd_filter_values_' . $fieldNum); |
| 189 | + // replace the comma substitution character that has no chance of |
| 190 | + // being included in the values list - namely, the ASCII beep |
| 191 | + $listSeparator = ','; |
| 192 | + $filter_manual_values_str = str_replace( "\\$listSeparator", "\a", $filter_manual_values_str ); |
| 193 | + $filter_manual_values_array = explode( $listSeparator, $filter_manual_values_str ); |
| 194 | + $xml .= '<Values>'; |
| 195 | + foreach ( $filter_manual_values_array as $i => $value ) { |
| 196 | + // replace beep back with comma, trim |
| 197 | + $value = str_replace( "\a", $listSeparator, trim( $value ) ); |
| 198 | + $xml .= '<Value>'.$value.'</Value>'; |
| 199 | + } |
| 200 | + $xml .= '</Values>'; |
| 201 | + } |
| 202 | + } elseif ( substr( $var, 0, 14 ) == 'sd_input_type_' ) { |
| 203 | + if ( !empty( $val ) ) { |
| 204 | + $xml .= '<InputType>' . $val . '</InputType>'; |
| 205 | + } |
| 206 | + $xml .= '</semanticdrilldown_Filter>'; |
| 207 | + $xmlPerField[$fieldNum] = $xml; |
| 208 | + } |
| 209 | + } |
| 210 | + |
| 211 | + $xmlArray['sd'] = $xmlPerField; |
| 212 | + return true; |
| 213 | + } |
| 214 | + |
| 215 | + /** |
| 216 | + * Displays the information about filters contained in the |
| 217 | + * Page Schemas XML. |
| 218 | + */ |
| 219 | + public static function parseFieldElements( $field_xml, &$text_object ) { |
| 220 | + foreach ( $field_xml->children() as $tag => $child ) { |
| 221 | + if ( $tag == "semanticdrilldown_Filter" ) { |
| 222 | + $text = ""; |
| 223 | + $text = PageSchemas::tableMessageRowHTML( "paramAttr", "SemanticDrillDown", (string)$tag ); |
| 224 | + foreach ( $child->children() as $prop => $value) { |
| 225 | + if( $prop == "Values" ){ |
| 226 | + $l_values = ""; |
| 227 | + foreach ( $value->children() as $val_i => $val ) { |
| 228 | + $l_values .= $val.", "; |
| 229 | + } |
| 230 | + $text .= PageSchemas::tableMessageRowHTML("paramAttrMsg", $prop, $l_values ); |
| 231 | + } else { |
| 232 | + $text .= PageSchemas::tableMessageRowHTML("paramAttrMsg", $prop, $value ); |
| 233 | + } |
| 234 | + } |
| 235 | + $text_object['sd'] = $text; |
| 236 | + } |
| 237 | + } |
| 238 | + return true; |
| 239 | + } |
| 240 | +} |
Index: trunk/extensions/SemanticDrilldown/includes/SD_Utils.php |
— | — | @@ -5,238 +5,9 @@ |
6 | 6 | * @author Yaron Koren |
7 | 7 | */ |
8 | 8 | |
9 | | -if ( !defined( 'MEDIAWIKI' ) ) die(); |
10 | | - |
11 | 9 | class SDUtils { |
12 | 10 | |
13 | 11 | /** |
14 | | - * Function to return the Property based on the xml passed from the PageSchema extension |
15 | | - */ |
16 | | - public static function createPageSchemasObject( $objectName, $xmlForField, &$object ) { |
17 | | - $sdarray = array(); |
18 | | - if ( $objectName == "semanticdrilldown_Filter" ) { |
19 | | - foreach ( $xmlForField->children() as $tag => $child ) { |
20 | | - if ( $tag == $objectName ) { |
21 | | - foreach ( $child->children() as $prop => $value) { |
22 | | - if( $prop == "Values" ){ |
23 | | - $l_values = array(); |
24 | | - foreach ( $value->children() as $val_i => $val ) { |
25 | | - $l_values[] = (string)$val; |
26 | | - } |
27 | | - $sdarray['Values'] = $l_values; |
28 | | - } else { |
29 | | - $sdarray[$prop] = (string)$value; |
30 | | - } |
31 | | - } |
32 | | - $object['sd'] = $sdarray; |
33 | | - return true; |
34 | | - } |
35 | | - } |
36 | | - } |
37 | | - return true; |
38 | | - } |
39 | | - |
40 | | - /** |
41 | | - * Returns the HTML for setting the filter options, for the |
42 | | - * Semantic Drilldown section in Page Schemas' "edit schema" page |
43 | | - */ |
44 | | - public static function getFieldHTMLForPS( $field, &$text_extensions ){ |
45 | | - // TODO - add these options to the XML and HTML |
46 | | - //$property_label = wfMsg( 'sd_createfilter_property' ); |
47 | | - //$label_label = wfMsg( 'sd_createfilter_label' ); |
48 | | - // need both label and value, in case user's language is different |
49 | | - // from wiki's |
50 | | - //$require_filter_label = wfMsg( 'sd_createfilter_requirefilter' ); |
51 | | - |
52 | | - $filter_array = array(); |
53 | | - if ( !is_null( $field ) ) { |
54 | | - $sd_array = $field->getObject('semanticdrilldown_Filter'); |
55 | | - if ( array_key_exists( 'sd', $sd_array ) ) { |
56 | | - $filter_array = $sd_array['sd']; |
57 | | - $hasExistingValues = true; |
58 | | - } else { |
59 | | - $hasExistingValues = false; |
60 | | - } |
61 | | - } |
62 | | - |
63 | | - if ( array_key_exists( 'Label', $filter_array ) ) { |
64 | | - $filterLabel = $filter_array['Label']; |
65 | | - } else { |
66 | | - $filterLabel = ''; |
67 | | - } |
68 | | - $fromCategoryAttrs = array(); |
69 | | - if ( array_key_exists( 'ValuesFromCategory', $filter_array ) ) { |
70 | | - $selectedCategory = $filter_array['ValuesFromCategory']; |
71 | | - $fromCategoryAttrs['checked'] = true; |
72 | | - } else { |
73 | | - $selectedCategory = ''; |
74 | | - } |
75 | | - $dateRangesAttrs = array(); |
76 | | - $yearOptionAttrs = array( 'value' => $year_value ); |
77 | | - $monthOptionAttrs = array( 'value' => $month_value ); |
78 | | - if ( array_key_exists( 'TimePeriod', $filter_array ) ) { |
79 | | - $year_value = wfMsgForContent( 'sd_filter_year' ); |
80 | | - // This value may eventually get checked against. |
81 | | - //$month_value = wfMsgForContent( 'sd_filter_month' ); |
82 | | - $filterTimePeriod = $filter_array['TimePeriod']; |
83 | | - $dateRangesAttrs['checked'] = true; |
84 | | - if ( $filterTimePeriod == $year_value ) { |
85 | | - $yearOptionAttrs['selected'] = true; |
86 | | - } else { |
87 | | - $monthOptionAttrs['selected'] = true; |
88 | | - } |
89 | | - } else { |
90 | | - $filterTimePeriod = ''; |
91 | | - } |
92 | | - $manualSourceAttrs = array(); |
93 | | - $filterValuesAttrs = array( 'size' => 40 ); |
94 | | - if ( array_key_exists( 'Values', $filter_array ) ) { |
95 | | - $manualSourceAttrs['checked'] = true; |
96 | | - $values_array = $filter_array['Values']; |
97 | | - $filterValuesStr = implode( ', ', $values_array ); |
98 | | - } else { |
99 | | - $filterValuesStr = ''; |
100 | | - } |
101 | | - // Have the first radiobutton ("Use all values of this |
102 | | - // property for the filter") checked if none of the other |
103 | | - // options have been selected - unlike the others, there's |
104 | | - // no XML to define this option. |
105 | | - $usePropertyValuesAttr = array(); |
106 | | - if ( empty( $selectedCategory ) && empty( $filterTimePeriod ) && empty( $filterValuesStr ) ) { |
107 | | - $usePropertyValuesAttr['checked'] = true; |
108 | | - } |
109 | | - |
110 | | - // The "input type" field |
111 | | - $combo_box_value = wfMsgForContent( 'sd_filter_combobox' ); |
112 | | - $date_range_value = wfMsgForContent( 'sd_filter_daterange' ); |
113 | | - $valuesListAttrs = array( 'value' => '' ); |
114 | | - $comboBoxAttrs = array( 'value' => $combo_box_value ); |
115 | | - $dateRangeAttrs = array( 'value' => $date_range_value ); |
116 | | - if ( array_key_exists( 'InputType', $filter_array ) ) { |
117 | | - $input_type_val = $filter_array['InputType']; |
118 | | - } else { |
119 | | - $input_type_val = ''; |
120 | | - } |
121 | | - if ( $input_type_val == $combo_box_value ) { |
122 | | - $comboBoxAttrs['selected'] = true; |
123 | | - } elseif ( $input_type_val == $date_range_value ) { |
124 | | - $dateRangeAttrs['selected'] = true; |
125 | | - } else { |
126 | | - $valuesListAttrs['selected'] = true; |
127 | | - } |
128 | | - |
129 | | - $html_text = '<p>' . wfMsg( 'sd_createfilter_name' ) . ' '; |
130 | | - $html_text .= Html::input( 'sd_filter_name_num', $filterLabel, 'text', array( 'size' => 25 ) ) . "</p>\n"; |
131 | | - $html_text .= '<p>' . Html::input( 'sd_values_source_num', 'property', 'radio', $usePropertyValuesAttr ) . ' '; |
132 | | - $html_text .= wfMsg( 'sd_createfilter_usepropertyvalues' ) . "</p>\n"; |
133 | | - $html_text .= "\t<p>\n"; |
134 | | - $html_text .= Html::input( 'sd_values_source_num', 'category', 'radio', $fromCategoryAttrs ) . "\n"; |
135 | | - $html_text .= "\t" . wfMsg( 'sd_createfilter_usecategoryvalues' ) . "\n"; |
136 | | - $categories = SDUtils::getTopLevelCategories(); |
137 | | - $categoriesHTML = ""; |
138 | | - foreach ( $categories as $category ) { |
139 | | - $categoryOptionAttrs = array(); |
140 | | - $category = str_replace( '_', ' ', $category ); |
141 | | - if ( $category == $selectedCategory) { |
142 | | - $categoryOptionAttrs['selected'] = true; |
143 | | - } |
144 | | - $categoriesHTML .= "\t" . Html::element( 'option', $categoryOptionAttrs, $category ) . "\n"; |
145 | | - } |
146 | | - $html_text .= "\t" . Html::rawElement( 'select', array( 'id' => 'category_dropdown', 'name' => 'sd_category_name_num' ), "\n" . $categoriesHTML ) . "\n"; |
147 | | - $html_text .= "\t</p>\n"; |
148 | | - |
149 | | - $html_text .= "\t<p>\n"; |
150 | | - $html_text .= "\t" . Html::input( 'sd_values_source_num', 'dates', 'radio', $dateRangesAttrs ) . "\n"; |
151 | | - $html_text .= "\t" . wfMsg( 'sd_createfilter_usedatevalues' ) . "\n"; |
152 | | - $dateRangeDropdown = Html::element( 'option', $yearOptionAttrs, wfMsg( 'sd_filter_year' ) ) . "\n"; |
153 | | - $dateRangeDropdown .= Html::element( 'option', $monthOptionAttrs, wfMsg( 'sd_filter_month' ) ) . "\n"; |
154 | | - $html_text .= Html::rawElement( 'select', array( 'name' => 'sd_time_period_num', 'id' => 'time_period_dropdown' ), "\n" . $dateRangeDropdown ) . "\n"; |
155 | | - $html_text .= "</p>\n<p>\n"; |
156 | | - $html_text .= "\t" . Html::input( 'sd_values_source_num', 'manual', 'radio', $manualSourceAttrs ) . "\n"; |
157 | | - $html_text .= "\t" . wfMsg( 'sd_createfilter_entervalues' ) . "\n"; |
158 | | - $html_text .= "\t" . Html::input( 'sd_filter_values_num', $filterValuesStr, 'text', $filterValuesAttrs ) . "\n"; |
159 | | - $html_text .= "\t</p>\n"; |
160 | | - |
161 | | - $html_text .= '<p>' . wfMsg( 'sd_createfilter_inputtype' ) . "\n"; |
162 | | - $inputTypeOptionsHTML = "\t" . Html::element( 'option', $valuesListAttrs, wfMsg( 'sd_createfilter_listofvalues' ) ) . "\n"; |
163 | | - $inputTypeOptionsHTML .= "\t" . Html::element( 'option', $comboBoxAttrs, wfMsg( 'sd_filter_combobox' ) ) . "\n"; |
164 | | - $inputTypeOptionsHTML .= "\t" . Html::element( 'option', $dateRangeAttrs, wfMsg( 'sd_filter_daterange' ) ) . "\n"; |
165 | | - $html_text .= Html::rawElement( 'select', array( 'name' => 'sd_input_type_num', 'id' => 'input_type_dropdown' ), $inputTypeOptionsHTML ) . "\n"; |
166 | | - $html_text .= "</p>\n"; |
167 | | - |
168 | | - $text_extensions['sd'] = array( 'Filter', '#FDD', $html_text, $hasExistingValues ); |
169 | | - |
170 | | - return true; |
171 | | - } |
172 | | - |
173 | | - public static function getFieldXMLForPS( $request, &$xmlArray ) { |
174 | | - $fieldNum = -1; |
175 | | - $xmlPerField = array(); |
176 | | - foreach ( $request->getValues() as $var => $val ) { |
177 | | - if ( substr( $var, 0, 15 ) == 'sd_filter_name_' ) { |
178 | | - $xml = '<semanticdrilldown_Filter>'; |
179 | | - $fieldNum = substr( $var, 15 ); |
180 | | - $xml .= '<Label>'.$val.'</Label>'; |
181 | | - } elseif ( substr( $var, 0, 17 ) == 'sd_values_source_') { |
182 | | - if ( $val == 'category' ) { |
183 | | - $xml .= '<ValuesFromCategory>' . $request->getText('sd_category_name_' . $fieldNum) . '</ValuesFromCategory>'; |
184 | | - } elseif ( $val == 'dates' ) { |
185 | | - $xml .= '<TimePeriod>' . $request->getText('sd_time_period_' . $fieldNum) . '</TimePeriod>'; |
186 | | - } elseif ( $val == 'manual' ) { |
187 | | - $filter_manual_values_str = $request->getText('sd_filter_values_' . $fieldNum); |
188 | | - // replace the comma substitution character that has no chance of |
189 | | - // being included in the values list - namely, the ASCII beep |
190 | | - $listSeparator = ','; |
191 | | - $filter_manual_values_str = str_replace( "\\$listSeparator", "\a", $filter_manual_values_str ); |
192 | | - $filter_manual_values_array = explode( $listSeparator, $filter_manual_values_str ); |
193 | | - $xml .= '<Values>'; |
194 | | - foreach ( $filter_manual_values_array as $i => $value ) { |
195 | | - // replace beep back with comma, trim |
196 | | - $value = str_replace( "\a", $listSeparator, trim( $value ) ); |
197 | | - $xml .= '<Value>'.$value.'</Value>'; |
198 | | - } |
199 | | - $xml .= '</Values>'; |
200 | | - } |
201 | | - } elseif ( substr( $var, 0, 14 ) == 'sd_input_type_' ) { |
202 | | - if ( !empty( $val ) ) { |
203 | | - $xml .= '<InputType>' . $val . '</InputType>'; |
204 | | - } |
205 | | - $xml .= '</semanticdrilldown_Filter>'; |
206 | | - $xmlPerField[$fieldNum] = $xml; |
207 | | - } |
208 | | - } |
209 | | - |
210 | | - $xmlArray['sd'] = $xmlPerField; |
211 | | - return true; |
212 | | - } |
213 | | - |
214 | | - /** |
215 | | - * This function parses the Field elements in the xml of the pages. Hooks for Page Schemas extension |
216 | | - */ |
217 | | - public static function parseFieldElements( $field_xml, &$text_object ) { |
218 | | - foreach ( $field_xml->children() as $tag => $child ) { |
219 | | - if ( $tag == "semanticdrilldown_Filter" ) { |
220 | | - $text = ""; |
221 | | - $text = PageSchemas::tableMessageRowHTML( "paramAttr", "SemanticDrillDown", (string)$tag ); |
222 | | - foreach ( $child->children() as $prop => $value) { |
223 | | - if( $prop == "Values" ){ |
224 | | - $l_values = ""; |
225 | | - foreach ( $value->children() as $val_i => $val ) { |
226 | | - $l_values .= $val.", "; |
227 | | - } |
228 | | - $text .= PageSchemas::tableMessageRowHTML("paramAttrMsg", $prop, $l_values ); |
229 | | - } else { |
230 | | - $text .= PageSchemas::tableMessageRowHTML("paramAttrMsg", $prop, $value ); |
231 | | - } |
232 | | - } |
233 | | - $text_object['sd'] = $text; |
234 | | - } |
235 | | - } |
236 | | - return true; |
237 | | - } |
238 | | - |
239 | | - |
240 | | - /** |
241 | 12 | * Helper function to handle getPropertyValues() in both SMW 1.6 |
242 | 13 | * and earlier versions. |
243 | 14 | */ |
Index: trunk/extensions/SemanticDrilldown/SemanticDrilldown.php |
— | — | @@ -58,22 +58,21 @@ |
59 | 59 | $wgAutoloadClasses['SDFilter'] = $sdgIP . '/includes/SD_Filter.php'; |
60 | 60 | $wgAutoloadClasses['SDFilterValue'] = $sdgIP . '/includes/SD_FilterValue.php'; |
61 | 61 | $wgAutoloadClasses['SDAppliedFilter'] = $sdgIP . '/includes/SD_AppliedFilter.php'; |
| 62 | +$wgAutoloadClasses['SDPageSchemas'] = $sdgIP . '/includes/SD_PageSchemas.php'; |
62 | 63 | |
63 | 64 | $wgHooks['smwInitProperties'][] = 'sdfInitProperties'; |
64 | 65 | $wgHooks['AdminLinks'][] = 'SDUtils::addToAdminLinks'; |
65 | 66 | $wgHooks['MagicWordwgVariableIDs'][] = 'SDUtils::addMagicWordVariableIDs'; |
66 | 67 | $wgHooks['LanguageGetMagic'][] = 'SDUtils::addMagicWordLanguage'; |
67 | 68 | $wgHooks['ParserBeforeTidy'][] = 'SDUtils::handleShowAndHide'; |
| 69 | +$wgHooks['PSParseFieldElements'][] = 'SDPageSchemas::parseFieldElements'; |
| 70 | +$wgHooks['PageSchemasGetObject'][] = 'SDPageSchemas::createPageSchemasObject'; |
| 71 | +$wgHooks['PageSchemasGetFieldHTML'][] = 'SDPageSchemas::getFieldHTML'; |
| 72 | +$wgHooks['PageSchemasGetFieldXML'][] = 'SDPageSchemas::getFieldXML'; |
68 | 73 | |
69 | 74 | $wgPageProps['hidefromdrilldown'] = 'Whether or not the page is set as HIDEFROMDRILLDOWN'; |
70 | 75 | $wgPageProps['showindrilldown'] = 'Whether or not the page is set as SHOWINDRILLDOWN'; |
71 | | -$wgHooks['PSParseFieldElements'][] = 'SDUtils::parseFieldElements'; |
72 | | -$wgHooks['PageSchemasGetObject'][] = 'SDUtils::createPageSchemasObject'; |
73 | | -$wgHooks['PageSchemasGetFieldHTML'][] = 'SDUtils::getFieldHTMLForPS'; |
74 | | -$wgHooks['PageSchemasGetStarterFieldHTML'][] = 'SDUtils::getStarterFieldHTMLForPS'; |
75 | | -$wgHooks['PageSchemasGetFieldXML'][] = 'SDUtils::getFieldXMLForPS'; |
76 | 76 | |
77 | | - |
78 | 77 | # ## |
79 | 78 | # This is the path to your installation of Semantic Drilldown as |
80 | 79 | # seen from the web. Change it if required ($wgScriptPath is the |