Index: trunk/extensions/RecordAdmin/RecordAdmin_body.php |
— | — | @@ -320,7 +320,7 @@ |
321 | 321 | /** |
322 | 322 | * Render a set of records returned by getRecords() as an HTML table |
323 | 323 | */ |
324 | | - function renderRecords( $records, $cols = false, $sortable = true, $template = false, $name = 'wpSelect' ) { |
| 324 | + function renderRecords( $records, $cols = false, $sortable = true, $template = false, $name = 'wpSelect', $export = true ) { |
325 | 325 | global $wgParser, $wgTitle, $wgRequest; |
326 | 326 | if ( count( $records ) < 1 ) return wfMsg( 'recordadmin-nomatch' ); |
327 | 327 | |
— | — | @@ -404,6 +404,7 @@ |
405 | 405 | global $wgOut; |
406 | 406 | $wgOut->disable(); |
407 | 407 | |
| 408 | + # PDF export |
408 | 409 | if ( $wgRequest->getText( 'format' ) == 'pdf' ) { |
409 | 410 | global $wgUploadDirectory; |
410 | 411 | $file = "$wgUploadDirectory/" . uniqid( 'recordadmin' ); |
— | — | @@ -417,6 +418,7 @@ |
418 | 419 | @unlink( $file ); |
419 | 420 | } |
420 | 421 | |
| 422 | + # CSV export |
421 | 423 | else { |
422 | 424 | header("Content-Type: text/html"); |
423 | 425 | header("Content-Disposition: attachment; filename=\"$quid.csv\""); |
— | — | @@ -428,8 +430,7 @@ |
429 | 431 | $csv .= "\n"; |
430 | 432 | $sep = ""; |
431 | 433 | } else $sep = "\t"; |
432 | | - $cell = preg_replace( "|<!--.+?-->|s", "", $cell ); |
433 | | - if ( preg_match( "|<p>\s*(.+?)\s*</p>|s", $cell, $m ) ) $cell = $m[1]; |
| 434 | + $cell = strip_tags( $cell ); |
434 | 435 | $cell = preg_replace( "/[\\r\\n]+/m", "\\n", $cell ); |
435 | 436 | $csv .= "$sep$cell"; |
436 | 437 | } |
— | — | @@ -439,12 +440,17 @@ |
440 | 441 | } |
441 | 442 | |
442 | 443 | # Otherwise add export links |
443 | | - else { |
| 444 | + elseif ( $export ) { |
| 445 | + $export = $export === true ? array( 'pdf', 'csv' ) : preg_split( "/\s*,\s*/", strtolower( $export ) ); |
444 | 446 | $qs = "wpType=$type&wpFind=1&quid={$this->quid}"; |
445 | 447 | foreach ( $this->filter as $k => $v ) $qs .= "&ra_$k=" . urlencode( $v ); |
446 | 448 | $url = $wgTitle->getLocalURL( $qs ); |
447 | | - $table .= "\n<a class=\"recordadmin-export\" href=\"$url\">" . wfMsg( 'recrodadmin-export-csv' ) . "</a>"; |
448 | | - $table .= "\n<a class=\"recordadmin-export\" href=\"$url&format=pdf\">" . wfMsg( 'recrodadmin-export-pdf' ) . "</a>"; |
| 449 | + if ( in_array( 'csv', $export ) ) { |
| 450 | + $table .= "\n<a class=\"recordadmin-export-csv\" href=\"$url\">" . wfMsg( 'recrodadmin-export-csv' ) . "</a>"; |
| 451 | + } |
| 452 | + if ( in_array( 'pdf', $export ) ) { |
| 453 | + $table .= "\n<a class=\"recordadmin-export-pdf\" href=\"$url&format=pdf\">" . wfMsg( 'recrodadmin-export-pdf' ) . "</a>"; |
| 454 | + } |
449 | 455 | } |
450 | 456 | |
451 | 457 | return $table; |
— | — | @@ -733,6 +739,7 @@ |
734 | 740 | $sortable = true; |
735 | 741 | $template = false; |
736 | 742 | $count = false; |
| 743 | + $export = false; |
737 | 744 | foreach ( func_get_args() as $arg ) if ( !is_object( $arg ) ) { |
738 | 745 | if ( preg_match( "|^(.+?)\s*=\s*(.+)$|i", $arg, $match ) ) { |
739 | 746 | list( , $k, $v ) = $match; |
— | — | @@ -744,6 +751,7 @@ |
745 | 752 | elseif ( $k == 'sortable' ) $sortable = eregi( '1|yes|true|on', $v ); |
746 | 753 | elseif ( $k == 'template' ) $template = $v; |
747 | 754 | elseif ( $k == 'count' ) $count = $v; |
| 755 | + elseif ( $k == 'export' ) $export = $v; |
748 | 756 | else $filter[$match[1]] = $match[2]; |
749 | 757 | } |
750 | 758 | } |
— | — | @@ -752,7 +760,7 @@ |
753 | 761 | $this->examineForm(); |
754 | 762 | $records = $this->getRecords( $type, $filter, $title, $invert, $orderby ); |
755 | 763 | if ( $count ) while ( count( $records ) > $count ) array_pop( $records ); |
756 | | - $table = $this->renderRecords( $records, $cols, $sortable, $template, $name ); |
| 764 | + $table = $this->renderRecords( $records, $cols, $sortable, $template, $name, $export ); |
757 | 765 | |
758 | 766 | return array( $table, 'noparse' => true, 'isHTML' => true ); |
759 | 767 | } |
Index: trunk/extensions/RecordAdmin/RecordAdmin.php |
— | — | @@ -11,7 +11,7 @@ |
12 | 12 | * @licence GNU General Public Licence 2.0 or later |
13 | 13 | */ |
14 | 14 | |
15 | | -define( 'RECORDADMIN_VERSION', '0.8.8, 2009-10-15' ); |
| 15 | +define( 'RECORDADMIN_VERSION', '0.8.9, 2009-10-17' ); |
16 | 16 | |
17 | 17 | $wgRecordAdminUseNamespaces = false; # Whether record articles should be in a namespace of the same name as their type |
18 | 18 | $wgRecordAdminCategory = 'Records'; # Category containing record types |