r17720 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r17719‎ | r17720 | r17721 >
Date:12:37, 16 November 2006
Author:mkroetzsch
Status:old
Tags:
Comment:
Removed bug that disabled the distinction between link="subject" and link="all"
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_InlineQueries.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/includes/SMW_InlineQueries.php
@@ -184,6 +184,8 @@
185185 private $mConditionCount; // count the number of conditions used so far
186186 private $mTableCount; // count the number of tables joined so far
187187 private $mPrintoutCount; // count the number of fields selected for separate printout so far
 188+ private $mFurtherResults=false; // true if not all results to the query were shown
 189+ private $mDisplayCount=0; // number of results that were displayed
188190
189191 // fields used for output formatting:
190192 private $mHeaderText; // text to be printed before the output of the results
@@ -286,6 +288,22 @@
287289 }
288290
289291 /**
 292+ * Returns true if a query was executed and the chosen limit did not
 293+ * allow all results to be displayed
 294+ */
 295+ function hasFurtherResults() {
 296+ return $this->mFurtherResults;
 297+ }
 298+
 299+ /**
 300+ * After a query was executed, this function returns the number of results that have been
 301+ * displayed (which is different from the overall number of results that exist).
 302+ */
 303+ function getDisplayCount() {
 304+ return $this->mDisplayCount;
 305+ }
 306+
 307+ /**
290308 * Main entry point for parsing, executing, and printing a given query text.
291309 */
292310 function getHTMLResult( $text ) {
@@ -315,7 +333,7 @@
316334 $sq->mSelect[1] .= ' AS page_title';
317335 $sq->mSelect[2] .= ' AS page_namespace';
318336
319 - $sql_options = array('LIMIT' => $this->mLimit, 'OFFSET' => $this->mOffset); // additional options (order by, limit)
 337+ $sql_options = array('LIMIT' => $this->mLimit + 1, 'OFFSET' => $this->mOffset); // additional options (order by, limit)
320338 if ( $smwgIQSortingEnabled ) {
321339 if ( NULL == $sq->mOrderBy ) {
322340 $sql_options['ORDER BY'] = "page_title $this->mOrder "; // default
@@ -361,19 +379,22 @@
362380 $result = $this->mHeaderText;
363381
364382 // Print main content (if any results were returned)
365 - $firstrow = true;
366383 $row = $this->dbr->fetchRow( $res );
367 - while ( $row ) {
 384+ $this->mDisplayCount = 0;
 385+ while ( $row && ( $this->mDisplayCount < $this->mLimit ) ) {
368386 $nextrow = $this->dbr->fetchRow( $res ); // look ahead
369 - if (!$firstrow) {
370 - if ($nextrow)
 387+ $this->mDisplayCount++;
 388+ if ($this->mDisplayCount > 1) {
 389+ if ($nextrow && $this->mDisplayCount < $this->mLimit)
371390 $result .= $this->mRowSep;
372391 else $result .= $this->mLastRowSep;
373392 }
374393 $result .= $this->makeRow($row, $sq->mPrint);
375394 $row = $nextrow;
376 - $firstrow = false;
377395 }
 396+ if ($row) // there are more results
 397+ $this->mFurtherResults = true;
 398+
378399 $this->dbr->freeResult($res); // Things that should be free: #42 "Possibly large query results"
379400
380401 $result .= $this->mFooterText;
@@ -899,6 +920,7 @@
900921 $result .= '---';
901922 break;
902923 }
 924+ $firstcol = false;
903925 }
904926 return $result;
905927 }

Status & tagging log