public function CreateControls()
 {
     $this->AddCssClass('form');
     $this->SetButtonText("Save player");
     # get player to edit
     $player = $this->GetDataObject();
     if (!$player instanceof Player) {
         $player = new Player($this->GetSettings());
     }
     require_once "xhtml/forms/radio-button.class.php";
     if ($this->GetCurrentPage() == PlayerEditor::MERGE_PLAYER) {
         $this->AddControl("<p>There's another player named '" . htmlentities($player->GetName(), ENT_QUOTES, "UTF-8", false) . "' in this team. What would you like to do?</p>");
         $this->AddControl("<dl class=\"decision\"><dt>");
         $this->AddControl(new RadioButton($this->GetNamingPrefix() . "Merge", $this->GetNamingPrefix() . "MergeOptions", htmlentities("Merge with the other " . $player->GetName(), ENT_QUOTES, "UTF-8", false), 1, false, $this->IsValid()));
         $this->AddControl("</dt><dd>If they're the same person you can merge the records so there's only one " . htmlentities($player->GetName(), ENT_QUOTES, "UTF-8", false) . ". Don't choose this for a player who's got married and changed their name though.</dd>");
         $this->AddControl("<dt>");
         $this->AddControl(new RadioButton($this->GetNamingPrefix() . "Rename", $this->GetNamingPrefix() . "MergeOptions", "Choose a new name for this player", 2, false, $this->IsValid()));
         $this->AddControl("</dt><dd>If they're different people you need to pick a different name. For example, if you have two players called 'Jane Smith',\n\t\t\t\tchange one to 'Jane A Smith'.</dd></dl>");
     }
     # Container for form elements, useful for JavaScript to hide them
     $container = new XhtmlElement("div", null, "#playerEditorFields");
     $this->AddControl($container);
     # add name
     $name = new XhtmlElement("label", "Name");
     $name->AddAttribute("for", $this->GetNamingPrefix() . 'Name');
     $container->AddControl($name);
     $name_box = new TextBox($this->GetNamingPrefix() . 'Name', $player->GetName(), $this->IsValid());
     $name_box->AddAttribute('maxlength', 100);
     #$name = new FormPart('Name', $name_box);
     $container->AddControl($name_box);
 }
 public function OnPreRender()
 {
     $by = $this->player->GetPlayerRole() == \Player::PLAYER ? ", " : " conceded by ";
     $this->AddControl('<h1><span property="schema:name">' . \Html::Encode($this->player->GetName()) . '</span>' . \Html::Encode($by . ' ' . $this->player->Team()->GetName() . $this->filter_description) . "</h1>");
     # When has this player played?
     $match_or_matches = $this->player->GetTotalMatches() == 1 ? " match" : " matches";
     $years = $this->player->GetPlayingYears();
     $filtered = "";
     if ($this->filter_description) {
         # If first played date is missing, the player came from PlayerManager because there were no statistics found
         if (!$this->filter_matched_nothing) {
             $filtered = " matching this filter";
         } else {
             $filtered = ", but none match this filter";
             $years = '';
         }
     }
     $team_name = '<span rel="schema:memberOf"><span about="' . \Html::Encode($this->player->Team()->GetLinkedDataUri()) . '" typeof="schema:SportsTeam"><a property="schema:name" rel="schema:url" href="' . \Html::Encode($this->player->Team()->GetNavigateUrl()) . "\">" . \Html::Encode($this->player->Team()->GetName()) . "</a></span></span>";
     if ($this->player->GetPlayerRole() == \Player::PLAYER) {
         if ($this->player->GetTotalMatches() == 0) {
             $played_total = " hasn't played any " . $match_or_matches;
         } else {
             $played_total = ' played <a href="/play/statistics/player-performances' . $this->filter_querystring . '">' . $this->player->GetTotalMatches() . $match_or_matches . '</a>';
         }
         $this->AddControl("<p>" . \Html::Encode($this->player->GetName()) . $played_total . " for {$team_name}{$filtered}{$years}.</p>");
         # Player of match
         if ($this->player->GetTotalPlayerOfTheMatchNominations() > 0) {
             $match_or_matches = $this->player->GetTotalPlayerOfTheMatchNominations() == 1 ? " match." : " matches.";
             $this->AddControl('<p>Nominated <a href="/play/statistics/player-of-match' . $this->filter_querystring . '">player of the match</a> in ' . $this->player->GetTotalPlayerOfTheMatchNominations() . $match_or_matches . "</p>");
         }
     } else {
         $this->AddControl("<p>{$team_name} recorded " . \Html::Encode($this->player->TotalRuns() . " " . strtolower($this->player->GetName()) . " in " . $this->player->GetTotalMatches() . $match_or_matches . "{$filtered}{$years}.") . "</p>");
     }
 }
 public function __construct(Player $player)
 {
     $this->searchable = new SearchItem("player", "player" . $player->GetId(), $player->GetPlayerUrl());
     $this->searchable->Description($player->GetPlayerDescription());
     $this->searchable->WeightOfType(20);
     if ($player->GetPlayerRole() == Player::PLAYER) {
         $this->searchable->Title($player->GetName() . ", " . $player->Team()->GetName());
         $this->searchable->WeightWithinType($player->GetTotalMatches());
     } else {
         $this->searchable->Title($player->GetName() . " conceded by " . $player->Team()->GetName());
     }
     $this->searchable->Keywords($this->searchable->Title());
 }
    public function OnPageLoad()
    {
        echo "<h1>" . htmlentities($this->GetPageTitle(), ENT_QUOTES, "UTF-8", false) . "</h1>";
        if ($this->add_player_already_exists) {
            ?>
            <p><a href="<?php 
            echo Html::Encode($this->player->GetPlayerUrl());
            ?>
"><?php 
            echo Html::Encode($this->player->GetName());
            ?>
</a> is already listed as a player.</p>
            <p>Return to <a href="<?php 
            echo Html::Encode($this->player->Team()->GetPlayersNavigateUrl());
            ?>
">players for <?php 
            echo Html::Encode($this->player->Team()->GetName());
            ?>
</a>.</p>
            <?php 
        } else {
            if ($this->player->GetPlayerRole() == Player::PLAYER) {
                $this->editor->SetDataObject($this->player);
                echo $this->editor;
            } else {
                ?>
Sorry, an extras player can't be renamed.<?php 
            }
        }
    }
    public function OnPrePageLoad()
    {
        if ($this->not_found) {
            $this->SetPageTitle("Page not found");
            return;
        }
        if ($this->regenerating) {
            require_once "stoolball/statistics/regenerating-control.class.php";
            $this->regenerating_control = new \Stoolball\Statistics\RegeneratingControl();
            $title = $this->regenerating_control->GetPageTitle();
        } else {
            $title = $this->player->GetPlayerRole() == Player::PLAYER ? ", a player for " : " conceded by ";
            $title = $this->player->GetName() . $title . $this->player->Team()->GetName() . " stoolball team";
            if ($this->player->GetPlayerRole() == Player::PLAYER) {
                $this->SetOpenGraphTitle($this->player->GetName() . ", " . $this->player->Team()->GetName() . " stoolball team");
            }
            if ($this->filter) {
                $this->filter = ", " . $this->filter;
                $title .= $this->filter;
            }
            $this->SetPageDescription($this->player_unfiltered->GetPlayerDescription());
        }
        $this->SetPageTitle($title);
        $this->SetOpenGraphType("athlete");
        $this->SetContentConstraint(StoolballPage::ConstrainColumns());
        $this->SetContentCssClass("playerStats");
        $this->LoadClientScript("/scripts/lib/jquery-ui-1.8.11.custom.min.js");
        $this->LoadClientScript("/play/statistics/statistics-filter.js");
        $this->LoadClientScript("/scripts/lib/chart.min.js");
        $this->LoadClientScript("/scripts/chart.js?v=2");
        $this->LoadClientScript("/scripts/lib/Chart.StackedBar.js");
        $this->LoadClientScript("/play/statistics/player-batting.js");
        ?>
<link rel="stylesheet" href="/css/custom-theme/jquery-ui-1.8.11.custom.css" media="screen" />
<!--[if lte IE 8]><script src="/scripts/lib/excanvas.compiled.js"></script><![endif]-->
		<?php 
    }
    function OnPageLoad()
    {
        if (!$this->player instanceof Player) {
            echo new XhtmlElement('h1', 'Player already deleted');
            echo new XhtmlElement('p', "The player you're trying to delete does not exist or has already been deleted.");
            return;
        }
        echo new XhtmlElement('h1', 'Delete player: <cite>' . Html::Encode($this->player->GetName()) . '</cite>');
        if ($this->player->GetPlayerRole() != Player::PLAYER) {
            ?>
Sorry, an extras player can't be deleted.<?php 
            return;
        }
        if ($this->b_deleted) {
            echo "<p>" . Html::Encode($this->player->GetName()) . "'s information has been deleted.</p>\n\t\t\t<p><a href=\"" . Html::Encode($this->player->Team()->GetPlayersNavigateUrl()) . "\">List players for " . Html::Encode($this->player->Team()->GetName()) . "</a></p>";
        } else {
            $has_permission = AuthenticationManager::GetUser()->Permissions()->HasPermission(PermissionType::MANAGE_PLAYERS);
            if ($has_permission) {
                $s_detail = $this->player->GetName() . " has ";
                switch ($this->player->GetTotalMatches()) {
                    case 0:
                        $s_detail .= "not played any matches";
                        break;
                    case 1:
                        $s_detail .= "played one match";
                        break;
                    default:
                        $s_detail .= "played " . $this->player->GetTotalMatches() . " matches";
                        break;
                }
                $s_detail .= " for " . $this->player->Team()->GetName() . '. ';
                echo new XhtmlElement('p', Html::Encode($s_detail));
                ?>
<p>Deleting a player cannot be undone. Their scores and performances
will be removed from all match scorecards and statistics.</p>
<p>Are you sure you want to delete this player?</p>
<form action="<?php 
                echo Html::Encode($this->player->GetDeleteUrl());
                ?>
" method="post"
	class="deleteButtons">
<div><input type="submit" value="Delete player" name="delete" /> <input
	type="submit" value="Cancel" name="cancel" /></div>
</form>
				<?php 
                $this->AddSeparator();
                require_once 'stoolball/user-edit-panel.class.php';
                $panel = new UserEditPanel($this->GetSettings(), $this->player->GetName());
                $panel->AddLink("view this player", $this->player->GetPlayerUrl());
                $panel->AddLink("rename this player", $this->player->GetEditUrl());
                echo $panel;
            } else {
                ?>
<p>Sorry, you can't delete a player unless you're responsible for
updating their team.</p>
<p><a href="<?php 
                echo Html::Encode($this->player->GetPlayerUrl());
                ?>
">Go back to <?php 
                echo Html::Encode($this->player->GetName());
                ?>
's
profile</a></p>
				<?php 
            }
        }
    }