Index: trunk/extensions/SemanticMediaWiki/RELEASE-NOTES |
— | — | @@ -1,6 +1,10 @@ |
2 | 2 | For a documentation of all features, see http://semantic-mediawiki.org |
3 | 3 | |
4 | 4 | |
| 5 | +== S%W 1.6.2 == |
| 6 | + |
| 7 | +* Use of native MediaWiki sortable tables for the table formats. |
| 8 | + |
5 | 9 | == SMW 1.6.1 == |
6 | 10 | |
7 | 11 | Released on August 20, 2011. |
Index: trunk/extensions/SemanticMediaWiki/includes/queryprinters/SMW_QP_Table.php |
— | — | @@ -11,16 +11,6 @@ |
12 | 12 | */ |
13 | 13 | class SMWTableResultPrinter extends SMWResultPrinter { |
14 | 14 | |
15 | | - /** |
16 | | - * List of printrequests for which numeric sort keys are used. |
17 | | - * print request hash => true |
18 | | - * |
19 | | - * @since 1.6.1 |
20 | | - * |
21 | | - * @var array |
22 | | - */ |
23 | | - protected $columnsWithSortKey = array(); |
24 | | - |
25 | 15 | public function getName() { |
26 | 16 | smwfLoadExtensionMessages( 'SemanticMediaWiki' ); |
27 | 17 | return wfMsg( 'smw_printername_' . $this->mFormat ); |
— | — | @@ -28,7 +18,6 @@ |
29 | 19 | |
30 | 20 | protected function getResultText( SMWQueryResult $res, $outputmode ) { |
31 | 21 | global $smwgIQRunningNumber; |
32 | | - SMWOutputs::requireHeadItem( SMW_HEADER_SORTTABLE ); |
33 | 22 | |
34 | 23 | $tableRows = array(); |
35 | 24 | |
— | — | @@ -37,9 +26,9 @@ |
38 | 27 | } |
39 | 28 | |
40 | 29 | // print header |
41 | | - $result = '<table class="smwtable"' . |
| 30 | + $result = '<table class="sortable wikitable"' . |
42 | 31 | ( $this->mFormat == 'broadtable' ? ' width="100%"' : '' ) . |
43 | | - " id=\"querytable$smwgIQRunningNumber\">\n"; |
| 32 | + ">\n"; |
44 | 33 | |
45 | 34 | if ( $this->mShowHeaders != SMW_HEADERS_HIDE ) { // building headers |
46 | 35 | $headers = array(); |
— | — | @@ -47,10 +36,6 @@ |
48 | 37 | foreach ( $res->getPrintRequests() as $pr ) { |
49 | 38 | $attribs = array(); |
50 | 39 | |
51 | | - if ( array_key_exists( $pr->getHash(), $this->columnsWithSortKey ) ) { |
52 | | - $attribs['class'] = 'numericsort'; |
53 | | - } |
54 | | - |
55 | 40 | $headers[] = Html::rawElement( |
56 | 41 | 'th', |
57 | 42 | $attribs, |
— | — | @@ -58,10 +43,10 @@ |
59 | 44 | ); |
60 | 45 | } |
61 | 46 | |
62 | | - array_unshift( $tableRows, '<tr>' . implode( "\n", $headers ) . '</tr>' ); |
| 47 | + array_unshift( $tableRows, '<thead><tr>' . implode( "\n", $headers ) . '</tr></thead><tbody>' ); |
63 | 48 | } |
64 | 49 | |
65 | | - $result .= implode( "\n", $tableRows ); |
| 50 | + $result .= implode( "\n", $tableRows ) . '</tbody>'; |
66 | 51 | |
67 | 52 | // print further results footer |
68 | 53 | if ( $this->linkFurtherResults( $res ) ) { |
— | — | @@ -109,18 +94,39 @@ |
110 | 95 | * @return string |
111 | 96 | */ |
112 | 97 | protected function getCellForPropVals( SMWResultArray $resultArray, $outputmode ) { |
| 98 | + $dataValues = array(); |
| 99 | + |
| 100 | + while ( ( $dv = $resultArray->getNextDataValue() ) !== false ) { |
| 101 | + $dataValues[] = $dv; |
| 102 | + } |
| 103 | + |
113 | 104 | $attribs = array(); |
| 105 | + $content = null; |
114 | 106 | |
115 | | - $alignment = trim( $resultArray->getPrintRequest()->getParameter( 'align' ) ); |
| 107 | + if ( count( $dataValues ) > 0 ) { |
| 108 | + $sortkey = $dataValues[0]->getDataItem()->getSortKey(); |
| 109 | + |
| 110 | + if ( is_numeric( $sortkey ) ) { |
| 111 | + $attribs['data-sort-value'] = $sortkey; |
| 112 | + } |
| 113 | + |
| 114 | + $alignment = trim( $resultArray->getPrintRequest()->getParameter( 'align' ) ); |
116 | 115 | |
117 | | - if ( in_array( $alignment, array( 'right', 'left', 'center' ) ) ) { |
118 | | - $attribs['style'] = "text-align:' . $alignment . ';"; |
| 116 | + if ( in_array( $alignment, array( 'right', 'left', 'center' ) ) ) { |
| 117 | + $attribs['style'] = "text-align:' . $alignment . ';"; |
| 118 | + } |
| 119 | + |
| 120 | + $content = $this->getCellContent( |
| 121 | + $dataValues, |
| 122 | + $outputmode, |
| 123 | + $resultArray->getPrintRequest()->getMode() == SMWPrintRequest::PRINT_THIS |
| 124 | + ); |
119 | 125 | } |
120 | 126 | |
121 | 127 | return Html::rawElement( |
122 | 128 | 'td', |
123 | 129 | $attribs, |
124 | | - $this->getCellContent( $resultArray, $outputmode ) |
| 130 | + $content |
125 | 131 | ); |
126 | 132 | } |
127 | 133 | |
— | — | @@ -129,34 +135,21 @@ |
130 | 136 | * |
131 | 137 | * @since 1.6.1 |
132 | 138 | * |
133 | | - * @param SMWResultArray $resultArray |
| 139 | + * @param array $dataValues |
134 | 140 | * @param $outputmode |
| 141 | + * @param boolean $isSubject |
135 | 142 | * |
136 | 143 | * @return string |
137 | 144 | */ |
138 | | - protected function getCellContent( SMWResultArray $resultArray, $outputmode ) { |
| 145 | + protected function getCellContent( array /* of SMWDataValue */ $dataValues, $outputmode, $isSubject ) { |
139 | 146 | $values = array(); |
140 | | - $isFirst = true; |
141 | 147 | |
142 | | - while ( ( $dv = $resultArray->getNextDataValue() ) !== false ) { |
143 | | - $sortKey = ''; |
144 | | - |
145 | | - if ( $isFirst ) { |
146 | | - $isFirst = false; |
147 | | - $sortkey = $dv->getDataItem()->getSortKey(); |
148 | | - |
149 | | - if ( is_numeric( $sortkey ) ) { // additional hidden sortkey for numeric entries |
150 | | - $this->columnsWithSortKey[$resultArray->getPrintRequest()->getHash()] = true; |
151 | | - $sortKey .= '<span class="smwsortkey">' . $sortkey . '</span>'; |
152 | | - } |
153 | | - } |
154 | | - |
155 | | - $isSubject = $resultArray->getPrintRequest()->getMode() == SMWPrintRequest::PRINT_THIS; |
| 148 | + foreach ( $dataValues as $dv ) { |
156 | 149 | $value = ( ( $dv->getTypeID() == '_wpg' ) || ( $dv->getTypeID() == '__sin' ) ) ? |
157 | 150 | $dv->getLongText( $outputmode, $this->getLinker( $isSubject ) ) : |
158 | 151 | $dv->getShortText( $outputmode, $this->getLinker( $isSubject ) ); |
159 | 152 | |
160 | | - $values[] = $sortKey . $value; |
| 153 | + $values[] = $value; |
161 | 154 | } |
162 | 155 | |
163 | 156 | return implode( '<br />', $values ); |
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_SetupLight.php |
— | — | @@ -14,7 +14,7 @@ |
15 | 15 | * @ingroup SMW |
16 | 16 | */ |
17 | 17 | |
18 | | -define( 'SMW_VERSION', '1.6.1 light' ); |
| 18 | +define( 'SMW_VERSION', '1.6.2 alpha light' ); |
19 | 19 | |
20 | 20 | require_once( 'SMW_GlobalFunctions.php' ); |
21 | 21 | |
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_Setup.php |
— | — | @@ -8,7 +8,7 @@ |
9 | 9 | */ |
10 | 10 | |
11 | 11 | // The SMW version number. |
12 | | -define( 'SMW_VERSION', '1.6.1' ); |
| 12 | +define( 'SMW_VERSION', '1.6.2 alpha' ); |
13 | 13 | |
14 | 14 | // A flag used to indicate SMW defines a semantic extension type for extension crdits. |
15 | 15 | define( 'SEMANTIC_EXTENSION_TYPE', true ); |