Plugin Directory

Changeset 507131


Ignore:
Timestamp:
02/19/2012 12:01:45 AM (14 years ago)
Author:
anaximander
Message:

check in 1.2.1

Location:
chessonline/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • chessonline/trunk/chessonline.css

    r505708 r507131  
    33 */
    44
     5.co_wrap {
     6    clear: both;
     7}
     8
    59.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;
    718}
    819
     
    1324}
    1425
     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,
    1550.co_sidetomove {
    1651    float: left;
     52    padding-right: 5px;
    1753}
    1854
  • chessonline/trunk/chessonline.php

    r506447 r507131  
    44Text Domain: chessonline
    55Description: 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
     6Version: 1.2.1
    77Author: Alexander Mainzer
    88Author URI: http://www.w3edv.de
     
    6767function co_CreateBoard( $content ) {
    6868    $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';
    7070    $content = preg_replace_callback( $fenregex,
    7171                    create_function( "\$matches" , "return co_SetupBoard( \$matches );" ) ,
     
    9292        $pieces[ 'q' ] = '♛';
    9393        $pieces[ ' ' ] = '';
     94
     95    /* Cols Array */
     96    $cols = array( 'a' , 'b' , 'c' , 'd' , 'e' , 'f' , 'g' , 'h' );
    9497
    9598    /* Get FEN  */
     
    159162        $darksquare = "background: $darksquarecolor;";
    160163        $lightsquare = "background: $lightsquarecolor;";
    161     $bordercolor = "border-color: $darksquarecolor;";
    162 
     164    $bordercolor = "border: solid 1px $darksquarecolor;";
     165    $boardborder = "border-color: $darksquarecolor;";
     166   
    163167        /* 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;
    170188
    171189    /* Get link text */
     
    196214
    197215    /* 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\">";
    202237    for( $i = 7 ; $i >= 0 ; $i-- ) {
    203238            for( $j = 0 ; $j <= 7 ; $j++ ) {
    204239                $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>';
    206241            }
    207242        }
    208243    $strout .= '</div>';
    209244
     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
    210265    /* 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    }
    215271   
    216272    /* Include link */
     
    219275    $strout .= ($link) ? "<div class=\"co_link\"><a href=\"$link\" $hreftarget>" . co_htmlentities( $linktext ) . '</a></div>' : '';
    220276
    221     /* Include white castling 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    }
    232288
    233289    /* 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>';
    235296
    236297    /* Close wrapping div */
     
    256317
    257318    /* Register settings */
    258     register_setting( 'co-settings-group' , 'co_chessboard_size' , 'intval' );
     319    register_setting( 'co-settings-group' , 'co_chessboard_size' , 'co_sani_boardsize' );
    259320        register_setting( 'co-settings-group' , 'co_chessboard_alignment' , 'co_sani_alignment' );
    260321    register_setting( 'co-settings-group' , 'co_lightsquare_color' , 'co_sani_htmlcolor' );
    261322    register_setting( 'co-settings-group' , 'co_darksquare_color' , 'co_sani_htmlcolor' );
     323    register_setting( 'co-settings-group' , 'co_display_infolabel' , 'co_sani_yesno' );
    262324    register_setting( 'co-settings-group' , 'co_link_text' , 'trim' );
    263325    register_setting( 'co-settings-group' , 'co_link_url' , 'co_sani_url' );
     
    265327
    266328    /* Sanitize setting option values */
     329    function co_sani_boardsize( $val ) {
     330        return max( 200 , intval( $val ) );
     331        }
    267332    function co_sani_alignment( $val ) {
    268333        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';
    269337        }
    270338    function co_sani_htmlcolor( $val ) {
     
    318386        </tr>
    319387    <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">
    320395        <th scope="row"><? echo co__( 'Link URL' ); ?></th>
    321396        <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>
     
    446521
    447522        /* Editor chessboard */
    448             $cols = Array( 'a' , 'b' , 'c' , 'd' , 'e' , 'f' , 'g' , 'h' );
     523            $cols = array( 'a' , 'b' , 'c' , 'd' , 'e' , 'f' , 'g' , 'h' );
    449524            $strout = '<div class="co_editorboard">';
    450525            for( $i = 9 ; $i >= 0 ; $i-- ) {
  • chessonline/trunk/readme.txt

    r506244 r507131  
    44Requires at least: 2.7.0
    55Tested up to: 3.3.1
    6 Stable tag: 1.2
     6Stable tag: 1.2.1
    77
    88The ChessOnline WordPress plugin allows you to display a chessboard and to set up positions using the Forsyth-Edwards-Notation (FEN).
     
    1818* e.g. [r1bk2nr/p2p1pNp/n2B4/1p1NP2P/6P1/3P1Q2/P1P1K3/q5b1 w - - 1 52]
    1919
    20 It is also possible to add some info text:
     20It is possible to add some info text:
    2121
    2222* e.g. [r1bk2nr/p2p1pNp/n2B4/1p1NP2P/6P1/3P1Q2/P1P1K3/q5b1 w - - 1 52 mate in 2]
     23
     24Adding 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]
    2327
    2428= Deutsch =
     
    3438* ZB. [r1bk2nr/p2p1pNp/n2B4/1p1NP2P/6P1/3P1Q2/P1P1K3/q5b1 w - - 1 52 matt in 2]
    3539
     40Ein 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
    3644= Nederlands =
    3745
     
    4654* b.v. [r1bk2nr/p2p1pNp/n2B4/1p1NP2P/6P1/3P1Q2/P1P1K3/q5b1 w - - 1 52 mat in 2]
    4755
     56Een 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
    4860== Installation ==
    4961
     
    5264DE - Laden Sie das ChessOnline-Plugin hoch über Ihre Plugin-Seite und aktivieren Sie es.
    5365
    54 NL - Upload het ChessOnline-Plugin in uw blog en activeer het.
     66NL - Upload het ChessOnline-Plugin in jouw blog en activeer het.
    5567 
    5668== Frequently Asked Questions ==
     
    7082== Changelog ==
    7183
     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
    7289= 1.2 =
    7390* TinyMCE plugin added
     
    8299== Upgrade Notice ==
    83100
     101= 1.2.1 =
     102Files and ranks are labeled. You can toggle the info text label visibility. Hiding partial FEN information is supported.
     103
    84104= 1.2 =
    85105The 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.