Changeset 507131
- Timestamp:
- 02/19/2012 12:01:45 AM (14 years ago)
- Location:
- chessonline/trunk
- Files:
-
- 5 edited
-
chessonline.css (modified) (2 diffs)
-
chessonline.php (modified) (10 diffs)
-
readme.txt (modified) (7 diffs)
-
screenshot-1.png (modified) (previous)
-
screenshot-2.png (modified) (previous)
Legend:
- Unmodified
- Added
- Removed
-
chessonline/trunk/chessonline.css
r505708 r507131 3 3 */ 4 4 5 .co_wrap { 6 clear: both; 7 } 8 5 9 .co_board { 6 border: solid 1px; 10 border-width: 4px; 11 border-style: double; 12 padding: 4px; 13 } 14 15 .co_placement { 16 margin: 1px; 17 float: left; 7 18 } 8 19 … … 13 24 } 14 25 26 .co_corner, 27 .co_col { 28 float: left; 29 text-align: center; 30 } 31 32 .co_rank { 33 text-align: center; 34 float: left; 35 margin: 2px 0; 36 } 37 38 .co_vtop { 39 height: 100%; 40 vertical-align: top; 41 } 42 43 .co_vbottom { 44 height: 100%; 45 vertical-align: bottom; 46 } 47 48 49 .co_movenumber, 15 50 .co_sidetomove { 16 51 float: left; 52 padding-right: 5px; 17 53 } 18 54 -
chessonline/trunk/chessonline.php
r506447 r507131 4 4 Text Domain: chessonline 5 5 Description: ChessOnline is a plugin that allows you to display a chessboard and to set up positions using the Forsyth-Edwards-Notation (FEN). You can specify an external URL for linking purposes. 6 Version: 1.2 6 Version: 1.2.1 7 7 Author: Alexander Mainzer 8 8 Author URI: http://www.w3edv.de … … 67 67 function co_CreateBoard( $content ) { 68 68 $fenregex = '/\[((([pbnrqkPBNRQK0-8]{0,8}\/){7}[pbnrqkPBNRQK0-8]{0,8})' 69 . ' ( b|w) (-|[KQkq]{1,4}) (-|[abcdefg][36]) ([0-9]+) ([0-9]+))(|.*)\]/U';69 . ' (!?b|!?w) (!?-|!?[KQkq]{1,4}) (!?-|!?[abcdefg][36]) (!?[0-9]+) (!?[0-9]+))(!?| !?.*)\]/U'; 70 70 $content = preg_replace_callback( $fenregex, 71 71 create_function( "\$matches" , "return co_SetupBoard( \$matches );" ) , … … 92 92 $pieces[ 'q' ] = '♛'; 93 93 $pieces[ ' ' ] = ''; 94 95 /* Cols Array */ 96 $cols = array( 'a' , 'b' , 'c' , 'd' , 'e' , 'f' , 'g' , 'h' ); 94 97 95 98 /* Get FEN */ … … 159 162 $darksquare = "background: $darksquarecolor;"; 160 163 $lightsquare = "background: $lightsquarecolor;"; 161 $bordercolor = "border-color: $darksquarecolor;"; 162 164 $bordercolor = "border: solid 1px $darksquarecolor;"; 165 $boardborder = "border-color: $darksquarecolor;"; 166 163 167 /* Get chessboard size option */ 164 $squarepx = get_option( 'co_chessboard_size' ) ? floor( get_option( 'co_chessboard_size' ) / 8 ) : 30; 165 $wrapsize = 'width: ' . ( ( $squarepx * 8 ) + 2 ) . 'px;'; 166 $squaresize = 'width:' . $squarepx . 'px; height: '. $squarepx . 'px;'; 167 $boardsize = 'width: ' . ( $squarepx * 8 ) . 'px; height: ' . ( $squarepx * 8 ) . 'px;'; 168 $lineheight = 'line-height: ' . $squarepx . 'px;'; 169 $fontsize = 'font-size: ' . floor( $squarepx * 0.80 ) . 'px;'; 168 $boardmargin = 16; 169 $squarepx = get_option( 'co_chessboard_size' ) ? floor( ( get_option( 'co_chessboard_size' ) - ( $boardmargin * 2 ) - 20 ) / 8 ) : 30; 170 171 /* Setup board CSS */ 172 $wrapsize = 'width: ' . ( ( $squarepx * 8 ) + ( $boardmargin * 2 ) + 20 ) . 'px;'; 173 $boardsize = 'width: ' . ( ( $squarepx * 8 ) + ( $boardmargin * 2 ) + 4 ) . 'px; height: ' . ( ( $squarepx * 8 ) + ( $boardmargin * 2 ) + 4 ) . 'px;'; 174 $placementsize = 'width: ' . ( $squarepx * 8 ) . 'px; height: ' . ( $squarepx * 8 ) . 'px;'; 175 $squaresize = 'width:' . $squarepx . 'px; height: '. $squarepx . 'px;'; 176 $squarelineheight = 'line-height: ' . $squarepx . 'px;'; 177 $squarefontsize = 'font-size: ' . floor( $squarepx * 0.80 ) . 'px;'; 178 $colsize = 'width: ' . $squarepx . 'px; height: '. $boardmargin . 'px;'; 179 $collineheight = 'line-height: ' . ( $boardmargin ) . 'px;'; 180 $colfontsize = 'font-size: ' . ( $boardmargin - 2 ) . 'px;'; 181 $ranksize = 'width:' . $boardmargin . 'px; height: ' . ( $squarepx * 8 ) . 'px;'; 182 $ranklineheight = 'line-height: ' . $squarepx . 'px;'; 183 $rankfontsize = 'font-size: ' . ( $boardmargin - 2 ) . 'px;'; 184 $cornersize = 'width: ' . ( $boardmargin + 2 ) . 'px; height: '. ( $boardmargin + 2 ) . 'px;'; 185 186 /* Get display infolabel value */ 187 $displayinfolabel = ( get_option( 'co_display_infolabel' ) == 'no' ) ? false : true; 170 188 171 189 /* Get link text */ … … 196 214 197 215 /* Include info */ 198 $strout .= ( strlen( $info ) > 0 ) ? '<div class="co_info">' . co__( 'Info' ) . ': ' . co_htmlentities( $info ) . '</div>' : ''; 199 200 /* Create and include chessboard with pieces */ 201 $strout .= "<div class=\"co_board\" style=\"$boardsize $bordercolor\">"; 216 if( strpos( $info , '!' ) !== 0 && strlen( $info ) > 0 ) { 217 $strout .= '<div class="co_info">' . ( $displayinfolabel ? co__( 'Info' ) . ': ' : '' ) . co_htmlentities( $info ) . '</div>'; 218 } 219 220 /* Create chessboard div */ 221 $strout .= "<div class=\"co_board\" style=\"$boardsize $boardborder\">"; 222 223 /* Create top cols and left ranks */ 224 for( $i = 0 ; $i <= 9 ; $i++ ) { 225 if( $i != 0 && $i != 9 ) { 226 $strout .= "<div class=\"co_col\" style=\"$colsize $collineheight $colfontsize\"><span class=\"co_vbottom\">" . $cols[ $i - 1 ] . '</span></div>'; 227 } else { 228 $strout .= "<div class=\"co_corner\" style=\"$margin $cornersize\"></div>"; 229 } 230 } 231 $strout .= "<div class=\"co_rank\" style=\"$ranksize $ranklineheight $rankfontsize\">"; 232 for( $i = 8 ; $i >= 1 ; $i-- ) { $strout .= "$i<br>"; } 233 $strout .= '</div>'; 234 235 /* Create placement */ 236 $strout .= "<div class=\"co_placement\" style=\"$placementsize $bordercolor\">"; 202 237 for( $i = 7 ; $i >= 0 ; $i-- ) { 203 238 for( $j = 0 ; $j <= 7 ; $j++ ) { 204 239 $background = ( ( $i + $j ) % 2 == 0 ) ? $darksquare : $lightsquare; 205 $strout .= "<div class=\"co_square\" style=\"$background $squaresize $ lineheight $fontsize\">" . $pieces[ $efen[ ( ( 7 - $i ) * 8 + $j ) ] ]. '</div>';240 $strout .= "<div class=\"co_square\" style=\"$background $squaresize $squarelineheight $squarefontsize\">" . $pieces[ $efen[ ( ( 7 - $i ) * 8 + $j ) ] ]. '</div>'; 206 241 } 207 242 } 208 243 $strout .= '</div>'; 209 244 245 /* Create right ranks and bottom cols */ 246 $strout .= "<div class=\"co_rank\" style=\"$ranksize $ranklineheight $rankfontsize\">"; 247 for( $i = 8 ; $i >= 1 ; $i-- ) { $strout .= "$i<br>"; } 248 $strout .= '</div>'; 249 for( $i = 0 ; $i <= 9 ; $i++ ) { 250 if( $i != 0 && $i != 9 ) { 251 $strout .= "<div class=\"co_col\" style=\"$colsize $collineheight $colfontsize\"><span class=\"co_vtop\">" . $cols[ $i - 1 ] . '</span></div>'; 252 } else { 253 $strout .= "<div class=\"co_corner\" style=\"$margin $cornersize\"></div>"; 254 } 255 } 256 257 /* Close chessboard div */ 258 $strout .= '</div>'; 259 260 /* Include move number */ 261 if( strpos( $fullmove , '!' ) !== 0 ) { 262 $strout .= '<div class="co_movenumber">' . ( ( $fullmove > 0 ) ? "#" . $fullmove . " " : "" ) . '</div>'; 263 } 264 210 265 /* Include side to move */ 211 $strout .= '<div class="co_sidetomove">' 212 . ( ( $fullmove > 0 ) ? "#" . $fullmove . " " : "" ) 213 . ( ( $color == "w" ) ? co__( 'White' , chessonline) : co__( 'Black' ) ) 214 . ' ' . co__( 'to move' ) . '</div>'; 266 if( strpos( $color , '!' ) !== 0 ) { 267 $strout .= '<div class="co_sidetomove">' 268 . ( ( $color == "w" ) ? co__( 'White' , chessonline) : co__( 'Black' ) ) 269 . ' ' . co__( 'to move' ) . '</div>'; 270 } 215 271 216 272 /* Include link */ … … 219 275 $strout .= ($link) ? "<div class=\"co_link\"><a href=\"$link\" $hreftarget>" . co_htmlentities( $linktext ) . '</a></div>' : ''; 220 276 221 /* Include whitecastling availability */222 $strout .= '<div class="co_castlingwhite">' . co__( 'Castling' ) . ' ' . co__( 'white' )223 . ':' . ( preg_match( '/K/' , $castling ) ? ' O-O' : '' )224 . ( preg_match( '/Q/' , $castling ) ? ' O-O-O' : '' )225 . ( !preg_match( '/[KW]/' , $castling ) ? ' ' . co__( 'not allowed' ) : '' ) . '</div>';226 227 /* Include black castling availability */228 $strout .= '<div class="co_castlingblack">' . co__( 'Castling' ) . ' ' . co__( 'black' )229 . ':' . ( preg_match( '/k/' , $castling ) ? ' O-O' : '' ) 230 . ( preg_match( '/q/' , $castling ) ? ' O-O-O' : '' ) 231 . ( !preg_match( '/[kq]/' , $castling ) ? ' ' . co__( 'not allowed' ) : '' ) . '</div>'; 277 /* Include castling availability */ 278 if( strpos( $castling , '!' ) !== 0 ) { 279 $strout .= '<div class="co_castlingwhite">' . co__( 'Castling' ) . ' ' . co__( 'white' ) 280 . ':' . ( preg_match( '/K/' , $castling ) ? ' O-O' : '' ) 281 . ( preg_match( '/Q/' , $castling ) ? ' O-O-O' : '' ) 282 . ( !preg_match( '/[KW]/' , $castling ) ? ' ' . co__( 'not allowed' ) : '' ) . '</div>'; 283 $strout .= '<div class="co_castlingblack">' . co__( 'Castling' ) . ' ' . co__( 'black' ) 284 . ':' . ( preg_match( '/k/' , $castling ) ? ' O-O' : '' ) 285 . ( preg_match( '/q/' , $castling ) ? ' O-O-O' : '' ) 286 . ( !preg_match( '/[kq]/' , $castling ) ? ' ' . co__( 'not allowed' ) : '' ) . '</div>'; 287 } 232 288 233 289 /* Include en passant target square */ 234 $strout .= '<div class="co_enpassant">' . co__( 'En passant target square' ) . ': ' . ( ( $ep != "-" ) ? co_htmlentities( $ep ) : co__( 'none' ) ) . '</div>'; 290 if( strpos( $ep , '!' ) !== 0 ) { 291 $strout .= '<div class="co_enpassant">' . co__( 'En passant target square' ) . ': ' . ( ( $ep != "-" ) ? co_htmlentities( $ep ) : co__( 'none' ) ) . '</div>'; 292 } 293 294 /* Clear all floatings */ 295 $strout .= '<div style="clear: both"></div>'; 235 296 236 297 /* Close wrapping div */ … … 256 317 257 318 /* Register settings */ 258 register_setting( 'co-settings-group' , 'co_chessboard_size' , ' intval' );319 register_setting( 'co-settings-group' , 'co_chessboard_size' , 'co_sani_boardsize' ); 259 320 register_setting( 'co-settings-group' , 'co_chessboard_alignment' , 'co_sani_alignment' ); 260 321 register_setting( 'co-settings-group' , 'co_lightsquare_color' , 'co_sani_htmlcolor' ); 261 322 register_setting( 'co-settings-group' , 'co_darksquare_color' , 'co_sani_htmlcolor' ); 323 register_setting( 'co-settings-group' , 'co_display_infolabel' , 'co_sani_yesno' ); 262 324 register_setting( 'co-settings-group' , 'co_link_text' , 'trim' ); 263 325 register_setting( 'co-settings-group' , 'co_link_url' , 'co_sani_url' ); … … 265 327 266 328 /* Sanitize setting option values */ 329 function co_sani_boardsize( $val ) { 330 return max( 200 , intval( $val ) ); 331 } 267 332 function co_sani_alignment( $val ) { 268 333 return preg_match( '/^(center|align left|align right|float left|float right)$/' , $val ) ? $val : 'center'; 334 } 335 function co_sani_yesno( $val ) { 336 return preg_match( '/^(yes|no)$/' , $val ) ? $val : 'no'; 269 337 } 270 338 function co_sani_htmlcolor( $val ) { … … 318 386 </tr> 319 387 <tr valign="top"> 388 <th scope="row"><? echo co__( 'Display info text label' ); ?></th> 389 <td><select name="co_display_infolabel"> 390 <option value="yes"><?php echo co__( 'yes' ); ?></option> 391 <option value="no" <?php echo get_option( 'co_display_infolabel' ) == "no" ? "selected" : ""; ?>><?php echo co__( 'no' ); ?></option> 392 </select></td> 393 </tr> 394 <tr valign="top"> 320 395 <th scope="row"><? echo co__( 'Link URL' ); ?></th> 321 396 <td><input type="text" name="co_link_url" value="<?php echo get_option( 'co_link_url' ); ?>" /> <?php echo co__( 'Use {FEN} as placeholder to pass the FEN' ); ?></td> … … 446 521 447 522 /* Editor chessboard */ 448 $cols = Array( 'a' , 'b' , 'c' , 'd' , 'e' , 'f' , 'g' , 'h' );523 $cols = array( 'a' , 'b' , 'c' , 'd' , 'e' , 'f' , 'g' , 'h' ); 449 524 $strout = '<div class="co_editorboard">'; 450 525 for( $i = 9 ; $i >= 0 ; $i-- ) { -
chessonline/trunk/readme.txt
r506244 r507131 4 4 Requires at least: 2.7.0 5 5 Tested up to: 3.3.1 6 Stable tag: 1.2 6 Stable tag: 1.2.1 7 7 8 8 The ChessOnline WordPress plugin allows you to display a chessboard and to set up positions using the Forsyth-Edwards-Notation (FEN). … … 18 18 * e.g. [r1bk2nr/p2p1pNp/n2B4/1p1NP2P/6P1/3P1Q2/P1P1K3/q5b1 w - - 1 52] 19 19 20 It is alsopossible to add some info text:20 It is possible to add some info text: 21 21 22 22 * e.g. [r1bk2nr/p2p1pNp/n2B4/1p1NP2P/6P1/3P1Q2/P1P1K3/q5b1 w - - 1 52 mate in 2] 23 24 Adding an exclamation mark (!) hides the marked section: 25 26 * e.g. [r1bk2nr/p2p1pNp/n2B4/1p1NP2P/6P1/3P1Q2/P1P1K3/q5b1 w !- !- !1 !52 mate in 2] 23 27 24 28 = Deutsch = … … 34 38 * ZB. [r1bk2nr/p2p1pNp/n2B4/1p1NP2P/6P1/3P1Q2/P1P1K3/q5b1 w - - 1 52 matt in 2] 35 39 40 Ein vorangestelltes Ausrufezeichen (!) verhindert die Ausgabe der jeweiligen Information: 41 42 * ZB. [r1bk2nr/p2p1pNp/n2B4/1p1NP2P/6P1/3P1Q2/P1P1K3/q5b1 w !- !- !1 !52 matt in 2] 43 36 44 = Nederlands = 37 45 … … 46 54 * b.v. [r1bk2nr/p2p1pNp/n2B4/1p1NP2P/6P1/3P1Q2/P1P1K3/q5b1 w - - 1 52 mat in 2] 47 55 56 Een voorafgaand uitroepteken (!) onderdrukt de weergave van de betreffende informatie: 57 58 * b.v. [r1bk2nr/p2p1pNp/n2B4/1p1NP2P/6P1/3P1Q2/P1P1K3/q5b1 w !- !- !1 !52 mat in 2] 59 48 60 == Installation == 49 61 … … 52 64 DE - Laden Sie das ChessOnline-Plugin hoch über Ihre Plugin-Seite und aktivieren Sie es. 53 65 54 NL - Upload het ChessOnline-Plugin in uw blog en activeer het.66 NL - Upload het ChessOnline-Plugin in jouw blog en activeer het. 55 67 56 68 == Frequently Asked Questions == … … 70 82 == Changelog == 71 83 84 = 1.2.1 = 85 * Files and ranks labeled 86 * Option to toggle the info text label visibility added 87 * Support of hiding partial FEN information added 88 72 89 = 1.2 = 73 90 * TinyMCE plugin added … … 82 99 == Upgrade Notice == 83 100 101 = 1.2.1 = 102 Files and ranks are labeled. You can toggle the info text label visibility. Hiding partial FEN information is supported. 103 84 104 = 1.2 = 85 105 The FEN editor can be used while writing posts. You don't have to switch to the tools page anymore.
Note: See TracChangeset
for help on using the changeset viewer.