r97281 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r97280‎ | r97281 | r97282 >
Date:14:52, 16 September 2011
Author:yaron
Status:deferred
Tags:
Comment:
Added support for new collapsed-sections feature in Page Schemas extension's 'edit schema' page
Modified paths:
  • /trunk/extensions/SemanticDrilldown/includes/SD_Utils.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticDrilldown/includes/SD_Utils.php
@@ -28,9 +28,10 @@
2929 $sdarray[$prop] = (string)$value;
3030 }
3131 }
 32+ $object['sd'] = $sdarray;
 33+ return true;
3234 }
3335 }
34 - $object['sd'] = $sdarray;
3536 }
3637 return true;
3738 }
@@ -47,11 +48,15 @@
4849 // from wiki's
4950 //$require_filter_label = wfMsg( 'sd_createfilter_requirefilter' );
5051
 52+ $filter_array = array();
5153 if ( !is_null( $field ) ) {
5254 $sd_array = $field->getObject('semanticdrilldown_Filter');
53 - $filter_array = $sd_array['sd'];
54 - } else {
55 - $filter_array = array();
 55+ if ( array_key_exists( 'sd', $sd_array ) ) {
 56+ $filter_array = $sd_array['sd'];
 57+ $hasExistingValues = true;
 58+ } else {
 59+ $hasExistingValues = false;
 60+ }
5661 }
5762
5863 if ( array_key_exists( 'Label', $filter_array ) ) {
@@ -159,26 +164,26 @@
160165 $html_text .= Html::rawElement( 'select', array( 'name' => 'sd_input_type_num', 'id' => 'input_type_dropdown' ), $inputTypeOptionsHTML ) . "\n";
161166 $html_text .= "</p>\n";
162167
163 - $text_extensions['sd'] = array( 'Filter', '#FDD', $html_text );
 168+ $text_extensions['sd'] = array( 'Filter', '#FDD', $html_text, $hasExistingValues );
164169
165170 return true;
166171 }
167172
168173 public static function getFieldXMLForPS( $request, &$xmlArray ) {
169 - $templateNum = -1;
 174+ $fieldNum = -1;
170175 $xmlPerField = array();
171176 foreach ( $request->getValues() as $var => $val ) {
172177 if ( substr( $var, 0, 15 ) == 'sd_filter_name_' ) {
173178 $xml = '<semanticdrilldown_Filter>';
174 - $templateNum = substr( $var, 15 );
 179+ $fieldNum = substr( $var, 15 );
175180 $xml .= '<Label>'.$val.'</Label>';
176181 } elseif ( substr( $var, 0, 17 ) == 'sd_values_source_') {
177182 if ( $val == 'category' ) {
178 - $xml .= '<ValuesFromCategory>' . $request->getText('sd_category_name_' . $templateNum) . '</ValuesFromCategory>';
 183+ $xml .= '<ValuesFromCategory>' . $request->getText('sd_category_name_' . $fieldNum) . '</ValuesFromCategory>';
179184 } elseif ( $val == 'dates' ) {
180 - $xml .= '<TimePeriod>' . $request->getText('sd_time_period_' . $templateNum) . '</TimePeriod>';
 185+ $xml .= '<TimePeriod>' . $request->getText('sd_time_period_' . $fieldNum) . '</TimePeriod>';
181186 } elseif ( $val == 'manual' ) {
182 - $filter_manual_values_str = $request->getText('sd_filter_values_'.$templateNum);
 187+ $filter_manual_values_str = $request->getText('sd_filter_values_' . $fieldNum);
183188 // replace the comma substitution character that has no chance of
184189 // being included in the values list - namely, the ASCII beep
185190 $listSeparator = ',';
@@ -197,7 +202,7 @@
198203 $xml .= '<InputType>' . $val . '</InputType>';
199204 }
200205 $xml .= '</semanticdrilldown_Filter>';
201 - $xmlPerField[] = $xml;
 206+ $xmlPerField[$fieldNum] = $xml;
202207 }
203208 }
204209
@@ -224,7 +229,7 @@
225230 $text .= PageSchemas::tableMessageRowHTML("paramAttrMsg", $prop, $value );
226231 }
227232 }
228 - $text_object['sd']=$text;
 233+ $text_object['sd'] = $text;
229234 }
230235 }
231236 return true;