r94874 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r94873‎ | r94874 | r94875 >
Date:07:03, 18 August 2011
Author:devayon
Status:deferred
Tags:
Comment:
added ability to generate exports and honour smwgQPrintoutLimit
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/specials/AskSpecial/SMW_QueryUIHelper.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/specials/AskSpecial/SMW_QueryUIHelper.php
@@ -67,7 +67,7 @@
6868 array(),
6969 false );
7070 if ( $this->uiCore->getQueryString() != "" ) {
71 - $this->uiCore->execute( $p );
 71+ $this->uiCore->execute();
7272 }
7373 } else {
7474 // the user has entered this page from a wiki-page using an infolink,
@@ -549,11 +549,12 @@
550550 * @global WebRequest $wgRequest
551551 * @global OutputPage $wgOut
552552 * @global string $smwgScriptPath
 553+ * @global integer $smwgQPrintoutLimit
553554 * @param mixed $enableAutocomplete
554555 * @return string
555556 */
556557 protected function getPoSortFormBox( $enableAutocomplete = SMWQueryUI::ENABLE_AUTO_SUGGEST ) {
557 - global $smwgQSortingSupport, $wgRequest, $wgOut, $smwgScriptPath;
 558+ global $smwgQSortingSupport, $wgRequest, $wgOut, $smwgScriptPath, $smwgQPrintoutLimit;
558559
559560 $this->enableJQueryUI();
560561 $wgOut->addScriptFile( "$smwgScriptPath/libs/jquery-ui/jquery-ui.dialog.min.js" );
@@ -928,7 +929,6 @@
929930 // create hidden form elements to be cloned later
930931 $hiddenProperty = Html::openElement( 'div',
931932 array( 'id' => 'property_starter',
932 - 'class' => 'smwsort',
933933 'style' => 'display:none' )
934934 ) .
935935 '<span class="smwquisortlabel">' .
@@ -956,7 +956,6 @@
957957
958958 $hiddenCategory = Html::openElement( 'div',
959959 array( 'id' => 'category_starter',
960 - 'class' => 'smwsort',
961960 'style' => 'display:none' )
962961 ) .
963962 '<span class="smwquisortlabel">' .
@@ -975,7 +974,6 @@
976975
977976 $hiddenMainColumn = Html::openElement( 'div',
978977 array( 'id' => 'maincol_starter',
979 - 'class' => 'smwsort',
980978 'style' => 'display:none' )
981979 ) .
982980 '<span class="smwquisortlabel">' .
@@ -1073,6 +1071,7 @@
10741072 $javascriptText = <<<EOT
10751073 <script type="text/javascript">
10761074 var num_elements = {$numSortValues};
 1075+ var smwgQPrintoutLimit={$smwgQPrintoutLimit};
10771076 EOT;
10781077 // add autocomplete
10791078 if ( $enableAutocomplete == SMWQueryUI::ENABLE_AUTO_SUGGEST ) {
@@ -1165,6 +1164,8 @@
11661165 // code for handling adding and removing the "sort" inputs
11671166
11681167 function smw_addPropertyInstance(starter_div_id, main_div_id) {
 1168+ if( jQuery( '.smwsort' ).length > smwgQPrintoutLimit ) return;
 1169+
11691170 var starter_div = document.getElementById(starter_div_id);
11701171 var main_div = document.getElementById(main_div_id);
11711172
@@ -1174,6 +1175,7 @@
11751176 new_div.id = div_id;
11761177 new_div.style.display = 'block';
11771178 jQuery(new_div.getElementsByTagName('label')).attr('for', 'display'+num_elements);
 1179+ jQuery(new_div).addClass( 'smwsort' );
11781180 var children = new_div.getElementsByTagName('*');
11791181 var x;
11801182 for (x = 0; x < children.length; x++) {
@@ -1184,7 +1186,7 @@
11851187 }
11861188 }
11871189
1188 - //Create 'more' link
 1190+ //Create 'options' link
11891191 var more_button =document.createElement('span');
11901192 more_button.innerHTML = ' <a class="smwq-more" href="javascript:smw_makePropDialog(\'' + num_elements + '\')">{$optionsMsg}</a> ';
11911193 more_button.id = 'more'+num_elements;
@@ -1201,6 +1203,8 @@
12021204 }
12031205
12041206 function smw_addCategoryInstance(starter_div_id, main_div_id) {
 1207+ if( jQuery( '.smwsort' ).length > smwgQPrintoutLimit ) return;
 1208+
12051209 var starter_div = document.getElementById(starter_div_id);
12061210 var main_div = document.getElementById(main_div_id);
12071211
@@ -1210,6 +1214,7 @@
12111215 new_div.id = div_id;
12121216 new_div.style.display = 'block';
12131217 jQuery(new_div.getElementsByTagName('label')).attr('for', 'display'+num_elements);
 1218+ jQuery(new_div).addClass( 'smwsort' );
12141219 var children = new_div.getElementsByTagName('*');
12151220 var x;
12161221 for (x = 0; x < children.length; x++) {
@@ -1220,7 +1225,7 @@
12211226 }
12221227 }
12231228
1224 - //Create 'more' link
 1229+ //Create 'options' link
12251230 var more_button =document.createElement('span');
12261231 more_button.innerHTML = ' <a class="smwq-more" href="javascript:smw_makeCatDialog(\'' + num_elements + '\')">{$optionsMsg}</a> ';
12271232 more_button.id = 'more'+num_elements;
@@ -1237,12 +1242,15 @@
12381243 }
12391244 var smw_mainLabelHidden=true;
12401245 function smw_addMainColInstance(starter_div_id, main_div_id) {
1241 - if(smw_mainLabelHidden && jQuery('#smwposortbox').find('.smw-remove').length==1){
 1246+ if(smw_mainLabelHidden && jQuery('.smwsort').length==1){
12421247 jQuery('#mainlabelhid').attr('value','');
12431248 jQuery('#mainlabelvis').attr('value','');
12441249 jQuery('#smwmainlabel').show();
12451250 smw_mainLabelHidden=false;
12461251 } else {
 1252+ if( jQuery( '.smwsort' ).length > smwgQPrintoutLimit ){
 1253+ return;
 1254+ }
12471255 var starter_div = document.getElementById(starter_div_id);
12481256 var main_div = document.getElementById(main_div_id);
12491257
@@ -1252,6 +1260,7 @@
12531261 new_div.id = div_id;
12541262 new_div.style.display = 'block';
12551263 jQuery(new_div.getElementsByTagName('label')).attr('for', 'display'+num_elements);
 1264+ jQuery(new_div).addClass( 'smwsort' );
12561265 var children = new_div.getElementsByTagName('*');
12571266 var x;
12581267 for (x = 0; x < children.length; x++) {
@@ -2279,6 +2288,28 @@
22802289 }
22812290 }
22822291 // END: Try to be smart for rss/ical if no description/title is given and we have a concept query
 2292+
 2293+ /*
 2294+ * If parameters have been passed in the infolink-style and the
 2295+ * mimie-type of format is defined, generate the export, instead of
 2296+ * showing more html.
 2297+ */
 2298+ $printer = SMWQueryProcessor::getResultPrinter(
 2299+ $this->parameters['format'],
 2300+ SMWQueryProcessor::SPECIAL_PAGE
 2301+ );
 2302+ $resultMime = $printer->getMimeType( $res );
 2303+ if ( $this->context == self::WIKI_LINK && $resultMime != false ) {
 2304+ global $wgOut;
 2305+ $result = $printer->getResult( $res, $this->parameters, SMW_OUTPUT_FILE );
 2306+ $resultName = $printer->getFileName( $res );
 2307+ $wgOut->disable();
 2308+ header( "Content-type: $resultMime; charset=UTF-8" );
 2309+ if ( $resultName !== false ) {
 2310+ header( "content-disposition: attachment; filename=$resultName" );
 2311+ }
 2312+ echo $result;
 2313+ }
22832314 }
22842315 }
22852316