function CreateControls() { require_once 'xhtml/xhtml-element.class.php'; require_once 'xhtml/forms/form-part.class.php'; require_once 'xhtml/forms/textbox.class.php'; $this->AddCssClass('legacy-form'); $o_comp = $this->GetDataObject(); /* @var $o_type IdValue */ /* @var $o_comp Competition */ /* @var $o_season Season */ # add name $o_name_box = new TextBox('name', $o_comp->GetName(), $this->IsValidSubmit()); $o_name_box->AddAttribute('maxlength', 100); $o_name = new FormPart('Competition name', $o_name_box); $this->AddControl($o_name); # Add seasons once competition saved if ($o_comp->GetId()) { $a_seasons = $o_comp->GetSeasons(); $o_season_part = new FormPart('Seasons'); $o_season_control = new Placeholder(); # List exisiting seasons if (is_array($a_seasons) and count($a_seasons)) { $o_seasons = new XhtmlElement('ul'); foreach ($a_seasons as $o_season) { $o_season_link = new XhtmlAnchor(Html::Encode($o_season->GetName()), $o_season->GetEditSeasonUrl()); $o_seasons->AddControl(new XhtmlElement('li', $o_season_link)); } $o_season_control->AddControl($o_seasons); } $o_new_season = new XhtmlAnchor('Add season', '/play/competitions/seasonedit.php?competition=' . $o_comp->GetId()); $o_season_control->AddControl($o_new_season); $o_season_part->SetControl($o_season_control); $this->AddControl($o_season_part); } # Still going? $this->AddControl(new CheckBox('active', 'This competition is still played', 1, $o_comp->GetIsActive(), $this->IsValidSubmit())); # add player type $o_type_list = new XhtmlSelect('playerType', null, $this->IsValidSubmit()); $o_type_list->AddControl(new XhtmlOption(PlayerType::Text(PlayerType::MIXED), PlayerType::MIXED)); $o_type_list->AddControl(new XhtmlOption(PlayerType::Text(PlayerType::LADIES), PlayerType::LADIES)); $o_type_list->AddControl(new XhtmlOption(PlayerType::Text(PlayerType::JUNIOR_MIXED), PlayerType::JUNIOR_MIXED)); $o_type_list->AddControl(new XhtmlOption(PlayerType::Text(PlayerType::GIRLS), PlayerType::GIRLS)); $o_type_list->AddControl(new XhtmlOption(PlayerType::Text(PlayerType::MEN), PlayerType::MEN)); $o_type_list->AddControl(new XhtmlOption(PlayerType::Text(PlayerType::BOYS), PlayerType::BOYS)); if (!is_null($o_comp->GetPlayerType()) and $this->IsValidSubmit()) { $o_type_list->SelectOption($o_comp->GetPlayerType()); } $o_type_part = new FormPart('Player type', $o_type_list); $this->AddControl($o_type_part); # add players per team $players_box = new TextBox('players', $o_comp->GetMaximumPlayersPerTeam(), $this->IsValidSubmit()); $players_box->SetMaxLength(2); $players = new FormPart('Max players in league/cup team', $players_box); $this->AddControl($players); # add overs $overs_box = new TextBox('overs', $o_comp->GetOvers(), $this->IsValidSubmit()); $overs_box->SetMaxLength(2); $overs = new FormPart('Overs per innings', $overs_box); $this->AddControl($overs); # category $cat_select = new CategorySelectControl($this->categories, $this->IsValidSubmit()); $cat_select->SetXhtmlId($this->GetNamingPrefix() . 'category'); if (!is_null($o_comp->GetCategory()) and $this->IsValidSubmit()) { $cat_select->SelectOption($o_comp->GetCategory()->GetId()); } $this->AddControl(new FormPart('Category', $cat_select)); # add intro $o_intro_box = new TextBox('intro', $o_comp->GetIntro(), $this->IsValidSubmit()); $o_intro_box->SetMode(TextBoxMode::MultiLine()); $o_intro = new FormPart('Introduction', $o_intro_box); $this->AddControl($o_intro); # add contact info $o_contact_box = new TextBox('contact', $o_comp->GetContact(), $this->IsValidSubmit()); $o_contact_box->SetMode(TextBoxMode::MultiLine()); $o_contact = new FormPart('Contact details', $o_contact_box); $this->AddControl($o_contact); # Add notification email $o_notify_box = new TextBox('notification', $o_comp->GetNotificationEmail(), $this->IsValidSubmit()); $o_notify_box->SetMaxLength(200); $o_notify = new FormPart('Notification email', $o_notify_box); $this->AddControl($o_notify); # add website $o_website_box = new TextBox('website', $o_comp->GetWebsiteUrl(), $this->IsValidSubmit()); $o_website_box->SetMaxLength(250); $o_website = new FormPart('Website', $o_website_box); $this->AddControl($o_website); # Remember short URL $o_short_url = new TextBox($this->GetNamingPrefix() . 'ShortUrl', $o_comp->GetShortUrl(), $this->IsValidSubmit()); $this->AddControl(new FormPart('Short URL', $o_short_url)); }