Index: trunk/extensions/SQL2Wiki/SQL2Wiki.body.php |
— | — | @@ -16,7 +16,7 @@ |
17 | 17 | private $mError = null; |
18 | 18 | |
19 | 19 | private $ignoreAttributes = array( 'database', 'inline', 'fieldseparator', 'lineseparator', 'cache', 'expand', 'preexpand', 'quiet' ); |
20 | | - private $ignoteTabAttributes = array( 'tablestyle', 'hrowstyle', 'hcellstyle', 'rowstyle', 'cellstyle', 'style', 'noheader' ); |
| 20 | + private $ignoreTabAttributes = array( 'tableclass', 'tablestyle', 'hrowstyle', 'hcellstyle', 'rowstyle', 'cellstyle', 'style', 'noheader' ); |
21 | 21 | |
22 | 22 | public static function initTags( &$parser ) { |
23 | 23 | $parser->setHook( "sql2wiki", "SQL2Wiki::renderSQL" ); |
— | — | @@ -30,7 +30,9 @@ |
31 | 31 | |
32 | 32 | $sql = ( $s2w->shouldPreexpand() ) ? $parser->recursiveTagParse( $input ) : $input; |
33 | 33 | |
34 | | - $s2w->execute( $sql ); |
| 34 | + if ( !$s2w->execute( $sql ) ) { |
| 35 | + return $s2w->mError; |
| 36 | + } |
35 | 37 | |
36 | 38 | if ( ( $inline = $s2w->getInlineTag() ) !== false ) |
37 | 39 | $ret = $s2w->parseInline(); |
— | — | @@ -56,7 +58,9 @@ |
57 | 59 | |
58 | 60 | $sql = ( $s2w->shouldPreexpand() ) ? $parser->recursiveTagParse( $input ) : $input; |
59 | 61 | |
60 | | - $s2w->execute( $sql ); |
| 62 | + if ( !$s2w->execute( $sql ) ) { |
| 63 | + return $s2w->mError; |
| 64 | + } |
61 | 65 | |
62 | 66 | $ret = $s2w->parseInline(); |
63 | 67 | |
— | — | @@ -71,7 +75,7 @@ |
72 | 76 | |
73 | 77 | public function __construct( $args, $PLSQLMode = false ) { |
74 | 78 | global $wgExSql2WikiDatabases; |
75 | | - |
| 79 | + |
76 | 80 | $this->mArgs = $args; |
77 | 81 | $this->mPLSQLMode = $PLSQLMode; |
78 | 82 | |
— | — | @@ -129,22 +133,18 @@ |
130 | 134 | |
131 | 135 | public function execute( $sql ) { |
132 | 136 | |
133 | | - $ignore = $this->mDB->ignoreErrors( true ); |
134 | 137 | $this->initDBMSOutput(); |
135 | | - |
136 | | - $this->mResult = $this->mDB->query( $sql ); |
137 | 138 | |
138 | | - $this->getDBMSOutput(); |
139 | | - $this->mDB->ignoreErrors( $ignore ); |
140 | | - |
141 | | - if ( $this->mDB->lastError() != null ) { |
142 | | - if ( ( isset( $this->mArgs["quiet"] ) && $this->mArgs["quiet"] == 'true' ) ) { |
143 | | - $this->mError = wfMsgForContent( 'sql2wiki-err-failed_to_execute', $sql, $this->mDB->lastError() ); |
| 139 | + try { |
| 140 | + $this->mResult = $this->mDB->query( $sql, 'SQL2Wiki::execute', true ); |
| 141 | + $this->getDBMSOutput(); |
| 142 | + } catch (DBQueryError $ex) { |
| 143 | + if ( !( isset( $this->mArgs["quiet"] ) && $this->mArgs["quiet"] == 'true' ) ) { |
| 144 | + $this->mError = wfMsgForContent( 'sql2wiki-err-failed_to_execute', $sql, $ex->error ); |
144 | 145 | } |
| 146 | + return false; |
| 147 | + } |
145 | 148 | |
146 | | - return false; |
147 | | - } |
148 | | - |
149 | 149 | return true; |
150 | 150 | } |
151 | 151 | |
— | — | @@ -233,11 +233,12 @@ |
234 | 234 | return ''; |
235 | 235 | } |
236 | 236 | |
| 237 | + $tableClass = isset( $this->mArgs["tableclass"] ) ? $this->mArgs["tableclass"] : 'wikitable'; |
237 | 238 | $tableStyle = isset( $this->mArgs["tablestyle"] ) ? $this->mArgs["tablestyle"] : 'border: black solid 1px;'; |
238 | 239 | |
239 | | - $attributes = array_diff_key( $this->mArgs, array_flip( $this->ignoreAttributes ), array_flip( $this->ignoteTabAttributes ) ); |
| 240 | + $attributes = array_diff_key( $this->mArgs, array_flip( $this->ignoreAttributes ), array_flip( $this->ignoreTabAttributes ) ); |
240 | 241 | |
241 | | - $output = Xml::openElement( 'table', array_merge( $attributes, array( 'style' => $tableStyle ) ) ); |
| 242 | + $output = Xml::openElement( 'table', array_merge( $attributes, array( 'style' => $tableStyle, 'class' => $tableClass ) ) ); |
242 | 243 | |
243 | 244 | if ( !isset( $this->mArgs["noheader"] ) || $this->mArgs["noheader"] != 'true' ) { |
244 | 245 | $headerRowStyle = isset( $this->mArgs["hrowstyle"] ) ? $this->mArgs["hrow_style"] : ''; |