Example #1
0
function chess_board_markup($base_href, $board, $clickable, $selected, $player, $flip_board)
{
    $board_flipped = $player == WHITES_MOVE;
    if ($flip_board) {
        $board_flipped = !$board_flipped;
    }
    $pieces = get_pieces($board);
    $class = $player == WHITES_MOVE ? GET_WHITE : GET_BLACK;
    $class .= $flip_board ? ' flipped' : '';
    $html = "<table class=\"{$class}\">\n";
    // Create horizontal legend (A .. H) table row
    $legend = "<tr><th></th>";
    for ($row = 0; $row < 8; $row++) {
        $legend .= '<th>';
        if ($board_flipped) {
            $legend .= chr(ord('A') + $row);
        } else {
            $legend .= chr(ord('A') + (7 - $row));
        }
        $legend .= '</th>';
    }
    $legend .= "<th></th></tr>\n";
    $html .= $legend;
    // Create main part of the table
    for ($row = 0; $row < 8; $row++) {
        if ($board_flipped) {
            $row_name = 8 - $row;
        } else {
            $row_name = $row + 1;
        }
        // Start row with left legend
        $html .= "<tr><th>{$row_name}</th>\n";
        for ($col = 0; $col < 8; $col++) {
            if ($board_flipped) {
                $col_name = chr(ord('A') + $col);
            } else {
                $col_name = chr(ord('A') + (7 - $col));
            }
            $field_name = $col_name . $row_name;
            $class = in_array($field_name, $selected) ? ' class="selected"' : '';
            //$base_link
            $has_href = in_array($field_name, $clickable);
            if (get_parameter(GET_FROM) != get_parameter(GET_TO)) {
                $href = update_href($base_href, GET_TO, $field_name);
            } else {
                $href = update_href($base_href, GET_FROM, $field_name);
            }
            // Add TD for field
            $html .= "\t<td{$class}>";
            if ($has_href) {
                $html .= "<a href=\"{$href}\">";
            }
            $p = piece_in_field($pieces, $selected, $field_name);
            if ($p != '') {
                $html .= $p;
            } else {
                $html .= '.';
            }
            if ($has_href) {
                $html .= "</a>";
            }
            $html .= "</td>\n";
        }
        // Right legend, finalize row
        $html .= "<th>{$row_name}</th></tr>\n";
    }
    // Add second legend row and finalize
    $html .= "{$legend}</table>\n";
    return $html;
}
Example #2
0
function log_in_form($o = ''){
	$o = setDefaults($o);
	$output = 'There was a problem with your log in form options.  Please make sure things are set correctly and try again.';
	if($o['get'] == 'form'){
		$output = get_form($o);
	} else if($o['get'] == 'pieces'){
		$output = get_pieces($o);
	}
	return $output;
}