http://www.mediawiki.org/wiki/Special:Code/MediaWiki/95095
Revision: 95095
Author: jeroendedauw
Date: 2011-08-20 16:31:23 +0000 (Sat, 20 Aug 2011)
Log Message:
-----------
use MediaWikis native table sort stuff
Modified Paths:
--------------
trunk/extensions/SemanticMediaWiki/RELEASE-NOTES
trunk/extensions/SemanticMediaWiki/includes/SMW_Setup.php
trunk/extensions/SemanticMediaWiki/includes/SMW_SetupLight.php
trunk/extensions/SemanticMediaWiki/includes/queryprinters/SMW_QP_Table.php
Modified: trunk/extensions/SemanticMediaWiki/RELEASE-NOTES
===================================================================
--- trunk/extensions/SemanticMediaWiki/RELEASE-NOTES 2011-08-20 15:40:10 UTC
(rev 95094)
+++ trunk/extensions/SemanticMediaWiki/RELEASE-NOTES 2011-08-20 16:31:23 UTC
(rev 95095)
@@ -1,6 +1,10 @@
For a documentation of all features, see http://semantic-mediawiki.org
+== S%W 1.6.2 ==
+
+* Use of native MediaWiki sortable tables for the table formats.
+
== SMW 1.6.1 ==
Released on August 20, 2011.
Modified: trunk/extensions/SemanticMediaWiki/includes/SMW_Setup.php
===================================================================
--- trunk/extensions/SemanticMediaWiki/includes/SMW_Setup.php 2011-08-20
15:40:10 UTC (rev 95094)
+++ trunk/extensions/SemanticMediaWiki/includes/SMW_Setup.php 2011-08-20
16:31:23 UTC (rev 95095)
@@ -8,7 +8,7 @@
*/
// The SMW version number.
-define( 'SMW_VERSION', '1.6.1' );
+define( 'SMW_VERSION', '1.6.2 alpha' );
// A flag used to indicate SMW defines a semantic extension type for extension
crdits.
define( 'SEMANTIC_EXTENSION_TYPE', true );
Modified: trunk/extensions/SemanticMediaWiki/includes/SMW_SetupLight.php
===================================================================
--- trunk/extensions/SemanticMediaWiki/includes/SMW_SetupLight.php
2011-08-20 15:40:10 UTC (rev 95094)
+++ trunk/extensions/SemanticMediaWiki/includes/SMW_SetupLight.php
2011-08-20 16:31:23 UTC (rev 95095)
@@ -14,7 +14,7 @@
* @ingroup SMW
*/
-define( 'SMW_VERSION', '1.6.1 light' );
+define( 'SMW_VERSION', '1.6.2 alpha light' );
require_once( 'SMW_GlobalFunctions.php' );
Modified:
trunk/extensions/SemanticMediaWiki/includes/queryprinters/SMW_QP_Table.php
===================================================================
--- trunk/extensions/SemanticMediaWiki/includes/queryprinters/SMW_QP_Table.php
2011-08-20 15:40:10 UTC (rev 95094)
+++ trunk/extensions/SemanticMediaWiki/includes/queryprinters/SMW_QP_Table.php
2011-08-20 16:31:23 UTC (rev 95095)
@@ -11,16 +11,6 @@
*/
class SMWTableResultPrinter extends SMWResultPrinter {
- /**
- * List of printrequests for which numeric sort keys are used.
- * print request hash => true
- *
- * @since 1.6.1
- *
- * @var array
- */
- protected $columnsWithSortKey = array();
-
public function getName() {
smwfLoadExtensionMessages( 'SemanticMediaWiki' );
return wfMsg( 'smw_printername_' . $this->mFormat );
@@ -28,7 +18,6 @@
protected function getResultText( SMWQueryResult $res, $outputmode ) {
global $smwgIQRunningNumber;
- SMWOutputs::requireHeadItem( SMW_HEADER_SORTTABLE );
$tableRows = array();
@@ -37,9 +26,9 @@
}
// print header
- $result = '<table class="smwtable"' .
+ $result = '<table class="sortable wikitable"' .
( $this->mFormat == 'broadtable' ? ' width="100%"' :
'' ) .
- " id=\"querytable$smwgIQRunningNumber\">\n";
+ ">\n";
if ( $this->mShowHeaders != SMW_HEADERS_HIDE ) { // building
headers
$headers = array();
@@ -47,10 +36,6 @@
foreach ( $res->getPrintRequests() as $pr ) {
$attribs = array();
- if ( array_key_exists( $pr->getHash(),
$this->columnsWithSortKey ) ) {
- $attribs['class'] = 'numericsort';
- }
-
$headers[] = Html::rawElement(
'th',
$attribs,
@@ -58,10 +43,10 @@
);
}
- array_unshift( $tableRows, '<tr>' . implode( "\n",
$headers ) . '</tr>' );
+ array_unshift( $tableRows, '<thead><tr>' . implode(
"\n", $headers ) . '</tr></thead><tbody>' );
}
- $result .= implode( "\n", $tableRows );
+ $result .= implode( "\n", $tableRows ) . '</tbody>';
// print further results footer
if ( $this->linkFurtherResults( $res ) ) {
@@ -109,18 +94,39 @@
* @return string
*/
protected function getCellForPropVals( SMWResultArray $resultArray,
$outputmode ) {
+ $dataValues = array();
+
+ while ( ( $dv = $resultArray->getNextDataValue() ) !== false ) {
+ $dataValues[] = $dv;
+ }
+
$attribs = array();
+ $content = null;
- $alignment = trim(
$resultArray->getPrintRequest()->getParameter( 'align' ) );
+ if ( count( $dataValues ) > 0 ) {
+ $sortkey = $dataValues[0]->getDataItem()->getSortKey();
+
+ if ( is_numeric( $sortkey ) ) {
+ $attribs['data-sort-value'] = $sortkey;
+ }
+
+ $alignment = trim(
$resultArray->getPrintRequest()->getParameter( 'align' ) );
- if ( in_array( $alignment, array( 'right', 'left', 'center' ) )
) {
- $attribs['style'] = "text-align:' . $alignment . ';";
+ if ( in_array( $alignment, array( 'right', 'left',
'center' ) ) ) {
+ $attribs['style'] = "text-align:' . $alignment
. ';";
+ }
+
+ $content = $this->getCellContent(
+ $dataValues,
+ $outputmode,
+ $resultArray->getPrintRequest()->getMode() ==
SMWPrintRequest::PRINT_THIS
+ );
}
return Html::rawElement(
'td',
$attribs,
- $this->getCellContent( $resultArray, $outputmode )
+ $content
);
}
@@ -129,34 +135,21 @@
*
* @since 1.6.1
*
- * @param SMWResultArray $resultArray
+ * @param array $dataValues
* @param $outputmode
+ * @param boolean $isSubject
*
* @return string
*/
- protected function getCellContent( SMWResultArray $resultArray,
$outputmode ) {
+ protected function getCellContent( array /* of SMWDataValue */
$dataValues, $outputmode, $isSubject ) {
$values = array();
- $isFirst = true;
- while ( ( $dv = $resultArray->getNextDataValue() ) !== false ) {
- $sortKey = '';
-
- if ( $isFirst ) {
- $isFirst = false;
- $sortkey = $dv->getDataItem()->getSortKey();
-
- if ( is_numeric( $sortkey ) ) { // additional
hidden sortkey for numeric entries
-
$this->columnsWithSortKey[$resultArray->getPrintRequest()->getHash()] = true;
- $sortKey .= '<span class="smwsortkey">'
. $sortkey . '</span>';
- }
- }
-
- $isSubject = $resultArray->getPrintRequest()->getMode()
== SMWPrintRequest::PRINT_THIS;
+ foreach ( $dataValues as $dv ) {
$value = ( ( $dv->getTypeID() == '_wpg' ) || (
$dv->getTypeID() == '__sin' ) ) ?
$dv->getLongText( $outputmode,
$this->getLinker( $isSubject ) ) :
$dv->getShortText( $outputmode,
$this->getLinker( $isSubject ) );
- $values[] = $sortKey . $value;
+ $values[] = $value;
}
return implode( '<br />', $values );
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs