function CreateControls() { /* @var $email Zend_Mail */ $email = $this->GetDataObject(); if (!is_object($email)) { $email = new Zend_Mail('UTF-8'); } # Your details $name = new TextBox('fromName', '', $this->IsValidSubmit()); $name->SetMaxLength(100); $name_part = new FormPart('Your name', $name); $this->AddControl($name_part); $from = new TextBox('from', '', $this->IsValidSubmit()); $from->AddAttribute("type", "email"); $from->SetMaxLength(250); $from_part = new FormPart('Your email address', $from); $this->AddControl($from_part); # Your email $subj = new TextBox('subject', '', $this->IsValidSubmit()); $subj->SetMaxLength(250); $subj_part = new FormPart('Subject', $subj); $this->AddControl($subj_part); $body = new TextBox('body', '', $this->IsValidSubmit()); $body->SetMode(TextBoxMode::MultiLine()); $body_part = new FormPart('Your message', $body); $this->AddControl($body_part); }
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); }
function CreateControls() { /* @var $o_ground Ground */ require_once 'xhtml/xhtml-element.class.php'; require_once 'xhtml/forms/form-part.class.php'; require_once 'xhtml/forms/textbox.class.php'; $o_ground = $this->GetDataObject(); # add address $this->o_address_edit->SetDataObject($o_ground->GetAddress()); $this->AddControl($this->o_address_edit); # add directions $o_dir_box = new TextBox('directions', $o_ground->GetDirections()); $o_dir_box->SetMode(TextBoxMode::MultiLine()); $o_dir_part = new FormPart('Directions', $o_dir_box); $this->AddControl($o_dir_part); # add parking $o_park_box = new TextBox('parking', $o_ground->GetParking()); $o_park_box->SetMode(TextBoxMode::MultiLine()); $o_park_part = new FormPart('Parking', $o_park_box); $this->AddControl($o_park_part); # add facilities $o_facilities_box = new TextBox('facilities', $o_ground->GetFacilities()); $o_facilities_box->SetMode(TextBoxMode::MultiLine()); $o_facilities_part = new FormPart('Facilities', $o_facilities_box); $this->AddControl($o_facilities_part); # Remember short URL $o_short_url = new TextBox($this->GetNamingPrefix() . 'ShortUrl', $o_ground->GetShortUrl()); $this->AddControl(new FormPart('Short URL', $o_short_url)); }
function CreateControls() { require_once 'xhtml/forms/form-part.class.php'; require_once 'xhtml/forms/textbox.class.php'; $role = $this->GetDataObject(); # add id $id_box = new TextBox('item', (string) $role->getRoleId()); $id_box->SetMode(TextBoxMode::Hidden()); $this->AddControl($id_box); # add name $name_box = new TextBox('name', $role->getRoleName(), $this->IsValidSubmit()); $name_box->AddAttribute('maxlength', 100); $name = new FormPart('Role name', $name_box); $this->AddControl($name); # Permissions if (!$this->IsPostback() or $this->IsValidSubmit()) { $permissions = $role->Permissions()->ToArray(); foreach ($permissions as $permission => $scopes) { foreach ($scopes as $scope => $ignore) { if ($scope == PermissionType::GLOBAL_PERMISSION_SCOPE) { $scope = ""; } $this->permissions_editor->DataObjects()->Add(new IdValue($permission, $scope)); } } } $this->AddControl(new FormPart("Permissions", $this->permissions_editor)); }
/** * Constructor ColorPicker * @param Page|Form $page_or_form_object * @param string $name * @param string $id * @param string $value * @param string $width * @param double $length [default value: 0] */ function __construct($page_or_form_object, $name = '', $id = '', $value = '', $width = '', $length = 0) { parent::__construct($page_or_form_object, $name, $id, $value, $width, $length); $this->isButton(false); $this->setClass("color {}"); $this->addJavaScript(BASE_URL . "wsp/js/jscolor.js", "", true); }
/** * Constructor ContactForm * @param Page $page_object * @param string $send_method * @param string $table_style */ function __construct($page_object, $send_method, $table_style = '') { parent::__construct(); if (!isset($page_object) || !isset($send_method)) { throw new NewException("2 arguments for " . get_class($this) . "::__construct() are mandatory", 0, getDebugBacktrace(1)); } if (gettype($page_object) != "object" || !is_subclass_of($page_object, "Page")) { throw new NewException("Argument page_object for " . get_class($this) . "::__construct() error", 0, getDebugBacktrace(1)); } $this->page_object = $page_object; $this->mail_to = SMTP_MAIL; $this->mail_to_name = SMTP_NAME; $table_main = new Table(); $table_main->setClass($table_style); $form = new Form($this->page_object); $name = new TextBox($form, "contact_name"); $name_validation = new LiveValidation(); $name->setLiveValidation($name_validation->addValidatePresence()->setFieldName(__(CONTACTFORM_NAME))); $table_main->addRowColumns(__(CONTACTFORM_NAME) . ": ", $name->setFocus())->setColumnWidth(2, "100%"); $email = new TextBox($form, "contact_email"); $email_validation = new LiveValidation(); $email->setLiveValidation($email_validation->addValidateEmail()->addValidatePresence()->setFieldName(__(CONTACTFORM_EMAIL))); $table_main->addRowColumns(__(CONTACTFORM_EMAIL) . ": ", $email); $subject = new TextBox($form, "contact_subject"); $subject_validation = new LiveValidation(); $subject->setLiveValidation($subject_validation->addValidatePresence()->setFieldName(__(CONTACTFORM_SUBJECT))); $table_main->addRowColumns(__(CONTACTFORM_SUBJECT) . ": ", $subject); $table_main->addRow(); $editor = new Editor($form, "contact_message"); $editor_validation = new LiveValidation(); $editor->setLiveValidation($editor_validation->addValidatePresence()->setFieldName(__(CONTACTFORM_MESSAGE))); $editor->setToolbar(Editor::TOOLBAR_SIMPLE); $table_main->addRow(new Object(__(CONTACTFORM_MESSAGE) . ": ", "<br/>", $editor))->setColspan(3)->setAlign(RowTable::ALIGN_LEFT); $table_main->addRow(); $this->captcha = new Captcha($form, "contact_captcha"); $table_main->addRow($this->captcha)->setColspan(3); $table_main->addRow(); $this->send_button = new Button($form, "contact_send", "", __(CONTACTFORM_SEND)); $this->send_button->assignEnterKey()->onClick($send_method)->setAjaxEvent(); $table_main->addRow($this->send_button)->setColspan(3); $table_main->addRow(); $form->setContent($table_main); $this->render = $form; }
function CreateControls() { $club = $this->GetDataObject(); /* @var $club Club */ $this->AddControl(new FormPart('', new CheckBox('school', 'This is a school', 1, $this->GetDataObject()->GetTypeOfClub() === Club::SCHOOL, $this->IsValidSubmit()))); $o_name_box = new TextBox('name', $this->GetDataObject()->GetName(), $this->IsValidSubmit()); $o_name_box->AddAttribute('maxlength', 250); $o_name = new FormPart('Name', $o_name_box); $this->AddControl($o_name); $how_many_box = new TextBox('how_many_players', $club->GetHowManyPlayers(), $this->IsValidSubmit()); $how_many_box->SetMaxLength(4); $how_many_box->AddAttribute("type", "number"); $how_many = new FormPart('How many players?', new XhtmlElement('div', $how_many_box)); $this->AddControl($how_many); $age_range_lower_box = new TextBox('age_range_lower', $club->GetAgeRangeLower(), $this->IsValidSubmit()); $age_range_lower_box->SetMaxLength(2); $age_range_lower_box->AddAttribute("type", "number"); $age_range_lower = new FormPart('Age range (from)', new XhtmlElement('div', $age_range_lower_box)); $this->AddControl($age_range_lower); $age_range_upper_box = new TextBox('age_range_upper', $club->GetAgeRangeUpper(), $this->IsValidSubmit()); $age_range_upper_box->SetMaxLength(2); $age_range_upper_box->AddAttribute("type", "number"); $age_range_upper = new FormPart('Age range (to)', new XhtmlElement('div', $age_range_upper_box)); $this->AddControl($age_range_upper); $twitter_box = new TextBox('twitter', $this->GetDataObject()->GetTwitterAccount(), $this->IsValidSubmit()); $twitter_box->AddAttribute('maxlength', 16); $twitter = new FormPart('Twitter account', $twitter_box); $this->AddControl($twitter); $facebook_box = new TextBox('facebook', $this->GetDataObject()->GetFacebookUrl(), $this->IsValidSubmit()); $facebook_box->AddAttribute('maxlength', 250); $facebook = new FormPart('Facebook URL', $facebook_box); $this->AddControl($facebook); $instagram_box = new TextBox('instagram', $this->GetDataObject()->GetInstagramAccount(), $this->IsValidSubmit()); $instagram_box->AddAttribute('maxlength', 50); $instagram = new FormPart('Instagram account', $instagram_box); $this->AddControl($instagram); $this->AddControl(new FormPart('', new CheckBox('outdoors', 'Plays outdoors', 1, $this->GetDataObject()->GetPlaysOutdoors(), $this->IsValidSubmit()))); $this->AddControl(new FormPart('', new CheckBox('indoors', 'Plays indoors', 1, $this->GetDataObject()->GetPlaysIndoors(), $this->IsValidSubmit()))); $this->AddControl(new FormPart('', new CheckBox('clubmark', 'Clubmark accredited', 1, $this->GetDataObject()->GetClubmarkAccredited(), $this->IsValidSubmit()))); # Remember short URL $o_short_url = new TextBox($this->GetNamingPrefix() . 'ShortUrl', $this->GetDataObject()->GetShortUrl()); $this->AddControl(new FormPart('Short URL', $o_short_url)); }
function CreateControls() { require_once 'xhtml/forms/form-part.class.php'; require_once 'xhtml/forms/checkbox.class.php'; require_once 'xhtml/forms/textbox.class.php'; $this->AddCssClass('legacy-form'); $user = $this->GetDataObject(); # add id $id_box = new TextBox('item', (string) $user->GetId()); $id_box->SetMode(TextBoxMode::Hidden()); $this->AddControl($id_box); # add name $name_box = new TextBox('known_as', $user->GetName(), $this->IsValidSubmit()); $name_box->AddAttribute('maxlength', 210); $name = new FormPart('Nickname', $name_box); $this->AddControl($name); # add first name $fname_box = new TextBox('name_first', $user->GetFirstName(), $this->IsValidSubmit()); $fname_box->AddAttribute('maxlength', 100); $fname = new FormPart('First name', $fname_box); $this->AddControl($fname); # add last name $lname_box = new TextBox('name_last', $user->GetLastName(), $this->IsValidSubmit()); $lname_box->AddAttribute('maxlength', 100); $lname = new FormPart('Last name', $lname_box); $this->AddControl($lname); # add email $email_box = new TextBox('email', $user->GetEmail(), $this->IsValidSubmit()); $email_box->AddAttribute('maxlength', 100); $email = new FormPart('Email', $email_box); $this->AddControl($email); # Is account disabled? $this->AddControl(new CheckBox("disabled", "Account disabled", 1, $user->GetAccountDisabled(), $this->IsValidSubmit())); # Permissions if (!$this->IsPostback() or $this->IsValidSubmit()) { foreach ($user->Roles() as $role) { /* @var $role Role */ $this->roles_editor->DataObjects()->Add($role); } } $this->AddControl(new FormPart("Roles", $this->roles_editor)); }
public function __construct($name, $value = '', array $attributes = array()) { parent::__construct($name, $value); if (is_object($value)) { $value = \System\Std\Object::getPropertyValue($value, $name); } $attributes['value'] = $value; $attributes['name'] = !array_key_exists('name', $attributes) ? $name : $attributes['name']; $attributes['id'] = !array_key_exists('id', $attributes) ? $name : $attributes['id']; $this->attributes = array_merge($this->attributes, $attributes); }
function reflow_text(&$driver) { if (is_null(parent::reflow_text($driver))) { return null; } // Override widths $letter_spacing = $this->getCSSProperty(CSS_LETTER_SPACING); $word_spacing = $this->getCSSProperty(CSS_WORD_SPACING); $this->width = $this->height * WHITESPACE_FONT_SIZE_FRACTION + $letter_spacing->getPoints() + $word_spacing->getPoints(); return true; }
public function CreateControls() { $this->AddCssClass('form'); require_once 'xhtml/forms/textbox.class.php'; $this->SetButtonText('Add new school'); $school = new Club($this->GetSettings()); /* @var $school Club */ # add name $name_box = new TextBox('school-name', '', $this->IsValidSubmit()); $name_box->AddAttribute('maxlength', 100); $name_box->AddAttribute('autocomplete', "off"); $name_box->AddCssClass("searchable"); $name = new XhtmlElement('label', 'School name'); $name->AddAttribute('for', $name_box->GetXhtmlId()); $this->AddControl($name); $this->AddControl($name_box); # add town $town_box = new TextBox('town', '', $this->IsValidSubmit()); $town_box->AddAttribute('maxlength', 100); $town_box->AddAttribute('autocomplete', "off"); $town_box->AddCssClass("searchable town"); $town = new XhtmlElement('label', 'Town or village'); $town->AddAttribute('for', $town_box->GetXhtmlId()); $this->AddControl($town); $this->AddControl($town_box); # add hook for suggestions $this->AddControl('<div class="suggestions"></div>'); }
function CreateControls() { require_once 'xhtml/forms/xhtml-select.class.php'; require_once 'xhtml/forms/form-part.class.php'; require_once 'xhtml/forms/textbox.class.php'; /* @var $o_category Category */ $o_category = $this->GetDataObject(); # add categories $o_parent_list = new XhtmlSelect('parent_id'); $o_parent_list->SetBlankFirst(true); $a_categories = $this->o_categories->GetItems(); foreach ($a_categories as $o_parent) { if (is_object($o_parent)) { $o_opt = new XhtmlOption($o_parent->GetName(), $o_parent->GetId()); $o_opt->AddAttribute('style', 'padding-left:' . ($o_parent->GetHierarchyLevel() - 1) . '0px'); $o_parent_list->AddControl($o_opt); unset($o_opt); } } $o_parent_list->SelectOption($o_category->GetParentId()); $o_parent_part = new FormPart('Create in', $o_parent_list); $this->AddControl($o_parent_part); # add name $o_url_box = new TextBox('name', $o_category->GetUrl()); $o_url = new FormPart('Name', $o_url_box); $this->AddControl($o_url); # add display name $o_name_box = new TextBox('displayName', $o_category->GetName()); $o_name_box->AddAttribute('maxlength', 255); $o_name = new FormPart('Display name', $o_name_box); $this->AddControl($o_name); # add sort override $o_sort_box = new TextBox('sort', $o_category->GetSortOverride()); $o_sort = new FormPart('Sort order', $o_sort_box); $this->AddControl($o_sort); }
function setup_content($text, &$pipeline) { /** * Contents of the text box are somewhat similar to the inline box: * a sequence of the text and whitespace boxes; we generate this sequence using * the InlineBox, then copy contents of the created inline box to our button. * * @todo probably, create_from_text() function should be extracted to the common parent * of inline boxes. */ $ibox = InlineBox::create_from_text($text, WHITESPACE_PRE, $pipeline); if (count($ibox->content) == 0) { $this->append_child(TextBox::create(' ', 'iso-8859-1', $pipeline)); } else { for ($i = 0, $size = count($ibox->content); $i < $size; $i++) { $this->append_child($ibox->content[$i]); } } }
function reflow_text(&$viewport) { // In XHTML images are treated as a common inline elements; they are affected by line-height and font-size global $g_config; if ($g_config['mode'] == 'xhtml') { $width = $this->width; $height = $this->height; $default_baseline = $this->default_baseline; if (is_null(TextBox::reflow_text($viewport))) { return null; } $this->height = $height; $this->width = $width; $this->default_baseline = $default_baseline; } else { $this->ascender = $this->get_height(); $this->descender = 0; } return true; }
function &create(&$root, &$pipeline) { $box = new ListItemBox($root, $pipeline); $box->readCSS($pipeline->getCurrentCSSState()); /** * Create text box containing item number */ $css_state =& $pipeline->getCurrentCSSState(); $css_state->pushState(); $css_state->setProperty(CSS_COLOR, CSSColor::parse('transparent')); $list_style = $css_state->getProperty(CSS_LIST_STYLE); $box->str_number_box = TextBox::create(CSSListStyleType::format_number($list_style->type, $css_state->getProperty(CSS_HTML2PS_LIST_COUNTER)) . ". ", 'iso-8859-1', $pipeline); $box->str_number_box->baseline = $box->str_number_box->default_baseline; $css_state->popState(); /** * Create nested items */ $box->create_content($root, $pipeline); return $box; }
function ListItemBox(&$root, &$pipeline) { // Call parent constructor $this->BlockBox($root); // Pseudo-CSS properties // '-list-counter' $counter =& get_css_handler('-list-counter'); $background_color =& get_css_handler('background-color'); $background_color->push_css('transparent', $pipeline); $this->str_number_box = TextBox::create(CSSListStyleType::format_number($this->list_style->type, $counter->get()), 'iso-8859-1'); $this->str_number_box->baseline = $this->str_number_box->default_baseline; $background_color->pop(); // increase counter value $counter->pop(); // remove inherited value $counter->replace($counter->get() + 1); $counter->push($counter->get()); // open the marker image if specified if (!$this->list_style->image->is_default()) { $this->marker_image = $this->list_style->image->_image; } else { $this->marker_image = null; } }
/** * Sets up controls for page 4 of the wizard * @param Match $match * @return void */ private function CreateHighlightsControls(Match $match) { $b_got_teams = !(is_null($match->GetHomeTeam()) || is_null($match->GetAwayTeam())); // Move CSS class to div element $match_outer_1 = new XhtmlElement('div'); $match_outer_1->SetCssClass('matchResultEdit panel'); $match_outer_2 = new XhtmlElement('div'); $match_box = new XhtmlElement('div'); $this->AddControl($match_outer_1); $match_outer_1->AddControl($match_outer_2); $match_outer_2->AddControl($match_box); $o_title_inner_1 = new XhtmlElement('span', "Match highlights"); $o_title_inner_2 = new XhtmlElement('span', $o_title_inner_1); $o_title_inner_3 = new XhtmlElement('span', $o_title_inner_2); $o_heading = new XhtmlElement('h2', $o_title_inner_3); $match_box->AddControl($o_heading); # Who's playing? $o_home_name = new TextBox($this->GetNamingPrefix() . 'Home'); $o_away_name = new TextBox($this->GetNamingPrefix() . 'Away'); $o_home_name->SetMode(TextBoxMode::Hidden()); $o_away_name->SetMode(TextBoxMode::Hidden()); if (!is_null($match->GetHomeTeam())) { $o_home_name->SetText($match->GetHomeTeam()->GetId() . MatchHighlightsEditControl::DATA_SEPARATOR . $match->GetHomeTeam()->GetName()); } if (!is_null($match->GetAwayTeam())) { $o_away_name->SetText($match->GetAwayTeam()->GetId() . MatchHighlightsEditControl::DATA_SEPARATOR . $match->GetAwayTeam()->GetName()); } $this->AddControl($o_home_name); $this->AddControl($o_away_name); # When? (for validator message only) $when = new TextBox($this->GetNamingPrefix() . 'Date', $match->GetStartTime()); $when->SetMode(TextBoxMode::Hidden()); $this->AddControl($when); # Who won? $o_winner = new XhtmlSelect($this->GetNamingPrefix() . 'Result'); $o_winner->AddControl(new XhtmlOption("Don't know", '')); $result_types = array(MatchResult::HOME_WIN, MatchResult::AWAY_WIN, MatchResult::TIE, MatchResult::ABANDONED); foreach ($result_types as $result_type) { if ($b_got_teams) { $o_winner->AddControl(new XhtmlOption($this->NameTeams(MatchResult::Text($result_type), $match->GetHomeTeam(), $match->GetAwayTeam()), $result_type)); } else { $o_winner->AddControl(new XhtmlOption(MatchResult::Text($result_type), $result_type)); } } if ($this->IsValidSubmit()) { if ($match->Result()->GetResultType() == MatchResult::UNKNOWN and !is_null($match->Result()->GetHomeRuns()) and !is_null($match->Result()->GetAwayRuns())) { # If match result is not known but we can guess from the entered scores, select it if ($match->Result()->GetHomeRuns() > $match->Result()->GetAwayRuns()) { $o_winner->SelectOption(MatchResult::HOME_WIN); } else { if ($match->Result()->GetHomeRuns() < $match->Result()->GetAwayRuns()) { $o_winner->SelectOption(MatchResult::AWAY_WIN); } else { if ($match->Result()->GetHomeRuns() == $match->Result()->GetAwayRuns()) { $o_winner->SelectOption(MatchResult::TIE); } } } } else { $o_winner->SelectOption($match->Result()->GetResultType()); } } $o_win_part = new FormPart('Who won?', $o_winner); $match_box->AddControl($o_win_part); # Get current player of match $player = $match->Result()->GetPlayerOfTheMatch(); $home_player = $match->Result()->GetPlayerOfTheMatchHome(); $away_player = $match->Result()->GetPlayerOfTheMatchAway(); $current_pom = MatchHighlightsEditControl::PLAYER_OF_THE_MATCH_NONE; if ($player instanceof Player) { $current_pom = MatchHighlightsEditControl::PLAYER_OF_THE_MATCH_OVERALL; } else { if ($home_player instanceof Player or $away_player instanceof Player) { $current_pom = MatchHighlightsEditControl::PLAYER_OF_THE_MATCH_HOME_AND_AWAY; } } # Choose from different types of player of the match require_once 'xhtml/forms/radio-button.class.php'; $pom_container = new XhtmlElement('fieldset', new XhtmlElement('legend', 'Player of the match', 'formLabel')); $pom_container->SetCssClass('formPart'); $pom_options = new XhtmlElement('div', null, 'formControl radioButtonList'); $pom_options->SetXhtmlId($this->GetNamingPrefix() . "PlayerOptions"); $pom_container->AddControl($pom_options); $match_box->AddControl($pom_container); $pom_options->AddControl(new RadioButton($this->GetNamingPrefix() . 'POM' . MatchHighlightsEditControl::PLAYER_OF_THE_MATCH_NONE, $this->GetNamingPrefix() . 'POM', "none chosen", MatchHighlightsEditControl::PLAYER_OF_THE_MATCH_NONE, $current_pom == MatchHighlightsEditControl::PLAYER_OF_THE_MATCH_NONE, $this->IsValidSubmit())); $pom_options->AddControl(new RadioButton($this->GetNamingPrefix() . 'POM' . MatchHighlightsEditControl::PLAYER_OF_THE_MATCH_OVERALL, $this->GetNamingPrefix() . 'POM', "yes, one chosen", MatchHighlightsEditControl::PLAYER_OF_THE_MATCH_OVERALL, $current_pom == MatchHighlightsEditControl::PLAYER_OF_THE_MATCH_OVERALL, $this->IsValidSubmit())); $pom_options->AddControl(new RadioButton($this->GetNamingPrefix() . 'POM' . MatchHighlightsEditControl::PLAYER_OF_THE_MATCH_HOME_AND_AWAY, $this->GetNamingPrefix() . 'POM', "yes, one from each team", MatchHighlightsEditControl::PLAYER_OF_THE_MATCH_HOME_AND_AWAY, $current_pom == MatchHighlightsEditControl::PLAYER_OF_THE_MATCH_HOME_AND_AWAY, $this->IsValidSubmit())); # Controls for entering a single player of the match $player_name = new TextBox($this->GetNamingPrefix() . 'Player', $player instanceof Player ? $player->GetName() : '', $this->IsValidSubmit()); $player_name->SetMaxLength(100); $player_name->AddCssClass("player"); $player_name->AddCssClass("team" . $match->GetHomeTeamId()); $player_name->AddCssClass("team" . $match->GetAwayTeamId()); $player_name->AddAttribute("autocomplete", "off"); $player_box = new XhtmlElement("div", $player_name); $player_team = new XhtmlSelect($this->GetNamingPrefix() . "PlayerTeam", " playing for", $this->IsValidSubmit()); $player_team->SetCssClass("playerTeam"); # for JS $player_team->AddControl(new XhtmlOption("Don't know", "")); $player_team->AddControl(new XhtmlOption($match->GetHomeTeam()->GetName(), $match->GetHomeTeamId())); $player_team->AddControl(new XhtmlOption($match->GetAwayTeam()->GetName(), $match->GetAwayTeamId())); if ($player instanceof Player) { $player_team->SelectOption($player->Team()->GetId()); } $player_box->AddControl($player_team); $player_part = new FormPart("Player's name", $player_box); $player_part->SetXhtmlId($this->GetNamingPrefix() . "OnePlayer"); $player_part->GetLabel()->AddAttribute("for", $player_name->GetXhtmlId()); $match_box->AddControl($player_part); # Controls for entering home and away players of the match $home_box = new TextBox($this->GetNamingPrefix() . 'PlayerHome', $home_player instanceof Player ? $home_player->GetName() : '', $this->IsValidSubmit()); $home_box->SetMaxLength(100); $home_box->AddCssClass("player"); $home_box->AddCssClass("team" . $match->GetHomeTeamId()); $home_box->AddAttribute("autocomplete", "off"); $home_part = new FormPart($this->NameTeams('Home player', $match->GetHomeTeam(), $match->GetAwayTeam()), $home_box); $home_part->SetCssClass("formPart multiPlayer"); $match_box->AddControl($home_part); $away_box = new TextBox($this->GetNamingPrefix() . 'PlayerAway', $away_player instanceof Player ? $away_player->GetName() : '', $this->IsValidSubmit()); $away_box->SetMaxLength(100); $away_box->AddCssClass("player"); $away_box->AddCssClass("team" . $match->GetAwayTeamId()); $away_box->AddAttribute("autocomplete", "off"); $away_part = new FormPart($this->NameTeams('Away player', $match->GetHomeTeam(), $match->GetAwayTeam()), $away_box); $away_part->SetCssClass("formPart multiPlayer"); $match_box->AddControl($away_part); # Any comments? $comments = new TextBox($this->GetNamingPrefix() . 'Comments', '', $this->IsValidSubmit()); $comments->SetMode(TextBoxMode::MultiLine()); $comments->AddAttribute('class', 'matchReport'); $comments_label = new XhtmlElement('label'); $comments_label->AddAttribute('for', $comments->GetXhtmlId()); $comments_label->AddCssClass('matchReport'); $comments_label->AddControl('Add a match report:'); $match_box->AddControl($comments_label); $match_box->AddControl($comments); if ($match->GetLastAudit() != null) { require_once "data/audit-control.class.php"; $match_box->AddControl(new AuditControl($match->GetLastAudit(), "match")); } $this->SetButtonText('Save match'); }
function &create($text, $encoding, &$pipeline) { $box =& TextBox::create_empty($pipeline); $box->add_subword($text, $encoding, array()); return $box; }
/** * Creates the controls when the editor is in its season view * */ private function CreateSeasonControls(Match $match, XhtmlElement $match_box) { /* @var $season Season */ $css_class = 'TournamentEdit checkBoxList'; if ($this->GetCssClass()) { $css_class .= ' ' . $this->GetCssClass(); } $match_outer_1 = new XhtmlElement('div'); $match_outer_1->SetCssClass($css_class); $this->SetCssClass(''); $match_outer_1->SetXhtmlId($this->GetNamingPrefix()); $match_outer_2 = new XhtmlElement('div'); $this->AddControl($match_outer_1); $match_outer_1->AddControl($match_outer_2); $match_outer_2->AddControl($match_box); $heading = 'Select seasons'; if ($this->show_step_number) { $heading .= ' – step 3 of 3'; } $o_title_inner_1 = new XhtmlElement('span', $heading); $o_title_inner_2 = new XhtmlElement('span', $o_title_inner_1); $o_title_inner_3 = new XhtmlElement('span', $o_title_inner_2); $match_box->AddControl(new XhtmlElement('h2', $o_title_inner_3, "large")); # Preserve match title, because we need it to send the email when the seasons are saved $title = new TextBox($this->GetNamingPrefix() . 'Title', $match->GetTitle(), $this->IsValidSubmit()); $title->SetMode(TextBoxMode::Hidden()); $match_box->AddControl($title); # If the list of seasons includes ones in which the only match type is tournament, then # they're annual tournaments like Expo and Seaford. Although those tournaments can be listed # in other seasons (they're of interest to the league teams), we don't want other tournaments # listed on pages which are supposed to be just about those annual tournaments. So exclude them # from the collection of possible seasons. Next bit of code will add them back in for any # tournaments which actually are meant to be in those seasons. $seasons = $this->seasons->GetItems(); $len = count($seasons); for ($i = 0; $i < $len; $i++) { # Make sure only seasons which contain tournaments are listed. Necessary to include all match types # in the Seasons() collection from the database so that we can test what other match types seasons support. if (!$seasons[$i]->MatchTypes()->Contains(MatchType::TOURNAMENT)) { unset($seasons[$i]); continue; } if ($seasons[$i]->MatchTypes()->GetCount() == 1 and $seasons[$i]->MatchTypes()->GetFirst() == MatchType::TOURNAMENT) { unset($seasons[$i]); } } $this->seasons->SetItems($seasons); # If the list of possible seasons doesn't include the one(s) the match is already in, # or the ones the context team plays in, add those to the list of possibles $a_season_ids = array(); foreach ($this->seasons as $season) { $a_season_ids[] = $season->GetId(); } foreach ($match->Seasons() as $season) { if (!in_array($season->GetId(), $a_season_ids, true)) { $this->seasons->Insert($season); $a_season_ids[] = $season->GetId(); } } if (isset($this->context_team)) { $match_year = Date::Year($match->GetStartTime()); foreach ($this->context_team->Seasons() as $team_in_season) { /* @var $team_in_season TeamInSeason */ if (!in_array($team_in_season->GetSeasonId(), $a_season_ids, true) and ($team_in_season->GetSeason()->GetStartYear() == $match_year or $team_in_season->GetSeason()->GetEndYear() == $match_year)) { $this->seasons->Insert($team_in_season->GetSeason()); $a_season_ids[] = $team_in_season->GetSeasonId(); } } } require_once 'xhtml/forms/checkbox.class.php'; $seasons_list = ''; if ($this->seasons->GetCount()) { # Sort the seasons by name, because they've been messed up by the code above $this->seasons->SortByProperty('GetCompetitionName'); $match_box->AddControl(new XhtmlElement('p', 'Tick all the places we should list your tournament:')); $match_box->AddControl('<div class="radioButtonList">'); foreach ($this->seasons as $season) { # Select season if it's one of the seasons the match is already in $b_season_selected = false; foreach ($match->Seasons() as $match_season) { $b_season_selected = ($b_season_selected or $match_season->GetId() == $season->GetId()); } /* @var $season Season */ $box = new CheckBox($this->GetNamingPrefix() . 'Season' . $season->GetId(), $season->GetCompetitionName(), $season->GetId(), $b_season_selected, $this->IsValidSubmit()); $seasons_list .= $season->GetId() . ';'; $match_box->AddControl($box); } $match_box->AddControl('</div>'); # Remember all the season ids to make it much easier to find the data on postback $seasons = new TextBox($this->GetNamingPrefix() . 'Seasons', $seasons_list, $this->IsValidSubmit()); $seasons->SetMode(TextBoxMode::Hidden()); $match_box->AddControl($seasons); } else { $match_month = 'in ' . Date::MonthAndYear($match->GetStartTime()); $type = strtolower(PlayerType::Text($match->GetPlayerType())); $match_box->AddControl(new XhtmlElement('p', "Unfortunately we don't have details of any {$type} competitions {$match_month} to list your tournament in.")); $match_box->AddControl(new XhtmlElement('p', 'Please click \'Save tournament\' to continue.')); } }
/** * Creates the controls to edit the matches * */ private function CreateMatchControls(Match $tournament, XhtmlElement $box) { $css_class = 'TournamentEdit'; $box->SetCssClass($css_class); $this->SetCssClass(''); $box->SetXhtmlId($this->GetNamingPrefix()); $this->AddControl($box); # Preserve tournament title and date, because we need them for the page title when "add" is clicked $title = new TextBox($this->GetNamingPrefix() . 'Title', $tournament->GetTitle(), $this->IsValidSubmit()); $title->SetMode(TextBoxMode::Hidden()); $box->AddControl($title); $date = new TextBox($this->GetNamingPrefix() . 'Start', $tournament->GetStartTime(), $this->IsValidSubmit()); $date->SetMode(TextBoxMode::Hidden()); $box->AddControl($date); # Matches editor $this->EnsureAggregatedEditors(); $this->matches_editor->DataObjects()->SetItems($tournament->GetMatchesInTournament()); $this->matches_editor->SetTeams($tournament->GetAwayTeams()); $box->AddControl($this->matches_editor); }
/** * Method prepareFieldsArray * @access public * @param mixed $properties [default value: array(] * @return mixed * @since 1.2.1 */ public function prepareFieldsArray($properties = array()) { $this->fields_array = array(); $list_attribute = $this->database_object->getDbTableAttributes(); $list_attribute_type = $this->database_object->getDbTableAttributesType(); $auto_increment_id = $this->database_object->getDbTableAutoIncrement(); // Add properties to apply on all fields if (isset($properties[ModelViewMapper::PROPERTIES_ALL]) && is_array($properties[ModelViewMapper::PROPERTIES_ALL])) { $apply_all_array = $properties[ModelViewMapper::PROPERTIES_ALL]; foreach ($apply_all_array as $property_name => $property_value) { for ($i = 0; $i < sizeof($list_attribute); $i++) { $property[$property_name] = $property_value; if (isset($properties[$list_attribute[$i]])) { // Handle child override of global property if (!isset($properties[$list_attribute[$i]][$property_name])) { $properties[$list_attribute[$i]] = array_merge($properties[$list_attribute[$i]], $property); } } else { $properties[$list_attribute[$i]] = $property; } } } } // check foreign keys $db_table_foreign_keys = $this->database_object->getDbTableForeignKeys(); foreach ($db_table_foreign_keys as $fk_attribute => $value) { if (isset($properties[$fk_attribute])) { $fk_property = $properties[$fk_attribute]; if (isset($fk_property["fk_attribute"])) { // create combobox $cmb = new ComboBox($this->form_or_page); // get foreign key data $query = "select distinct " . $value["column"] . " as id, " . $fk_property["fk_attribute"] . " as value from " . $value["table"]; if (isset($fk_property["fk_where"])) { $query .= " where " . $fk_property["fk_where"]; } if (isset($fk_property["fk_orderby"])) { $query .= " order by " . $fk_property["fk_orderby"]; } $stmt = DataBase::getInstance()->prepareStatement($query); $row = DataBase::getInstance()->stmtBindAssoc($stmt, $row); while ($stmt->fetch()) { $cmb->addItem(utf8encode($row['id']), utf8encode($row['value'])); } // add combo box in properties $value['cmb_obj'] = $cmb; $properties[$fk_attribute] = array_merge($properties[$fk_attribute], $value); } } } foreach ($list_attribute as $i => $attribute) { $wspobject = "TextBox"; $attribute_properties = array(); if (is_array($properties[$attribute])) { $attribute_properties = $properties[$attribute]; } if (isset($attribute_properties["display"]) && $attribute_properties["display"] == false) { continue; } $is_update_ok = true; if (isset($attribute_properties["update"]) && $attribute_properties["update"] == false) { $is_update_ok = false; } $method = "get" . $this->getFormatValue($attribute); $value = call_user_func_array(array($this->database_model_object, $method), array()); if ($attribute != $auto_increment_id && $is_update_ok) { // get property cmb_obj if (isset($attribute_properties['cmb_obj'])) { $field = $attribute_properties['cmb_obj']; } else { if (isset($attribute_properties["wspobject"]) && $attribute_properties["wspobject"] != "") { $wspobject = $attribute_properties["wspobject"]; } else { if ($list_attribute_type[$i] == "datetime") { $wspobject = "Calendar"; } else { if ($list_attribute_type[$i] == "boolean") { $wspobject = "CheckBox"; } } } if ($wspobject == "Calendar") { $field = new Calendar($this->form_or_page); } else { if ($wspobject == "CheckBox") { $field = new CheckBox($this->form_or_page); } else { if ($wspobject == "TextArea") { $field = new TextArea($this->form_or_page); } else { if ($wspobject == "Editor") { $field = new Editor($this->form_or_page); if (isset($attribute_properties["editor_param"]) && $attribute_properties["editor_param"] != "") { $field->setToolbar($attribute_properties["editor_param"]); } } else { if ($wspobject == "ComboBox") { $field = new ComboBox($this->form_or_page); if (isset($attribute_properties["combobox_values"])) { if (is_array($attribute_properties["combobox_values"])) { for ($j = 0; $j < sizeof($attribute_properties["combobox_values"]); $j++) { $field->addItem($attribute_properties["combobox_values"][$j]['value'], $attribute_properties["combobox_values"][$j]['text']); } } else { throw new NewException(get_class($this) . "->prepareFieldsArray() error: the property combobox_values need to be an array.", 0, getDebugBacktrace(1)); } } } else { $field = new TextBox($this->form_or_page); if ($list_attribute_type[$i] == "integer" || $list_attribute_type[$i] == "double") { $field->setWidth(70); } if (in_array($attribute, $key_attributes)) { $lv = new LiveValidation(); $field->setLiveValidation($lv->addValidatePresence()); } } } } } } } // Handle Checkbox case that only support value as "on" or "off" if (get_class($field) == "CheckBox") { if ($value == "1") { $field->setValue("on"); } else { $field->setValue("off"); } } else { if (get_class($field) == "Calendar") { $field->setValue($value); } else { $field->setValue(utf8encode($value)); } } if (isset($attribute_properties["width"]) && method_exists($field, "setWidth")) { $field->setWidth($attribute_properties["width"]); } if (isset($attribute_properties["height"]) && method_exists($field, "setHeight")) { $field->setHeight($attribute_properties["height"]); } if (isset($attribute_properties["class"]) && method_exists($field, "setClass")) { $field->setClass($attribute_properties["class"]); } if (isset($attribute_properties["style"]) && method_exists($field, "setStyle")) { $field->setStyle($attribute_properties["style"]); } if (isset($attribute_properties["disable"])) { if ($attribute_properties["disable"] == true && method_exists($field, "disable")) { $field->disable(); } else { if ($attribute_properties["disable"] == false && method_exists($field, "enable")) { $field->enable(); } } } if (get_class($field) != "Calendar") { if (isset($attribute_properties["strip_tags"]) && $attribute_properties["strip_tags"] == true && method_exists($field, "setStripTags")) { if (isset($attribute_properties["allowable_tags"])) { $field->setStripTags($attribute_properties["allowable_tags"]); } else { $field->setStripTags(""); // no tag allowed } } } } else { if (isset($attribute_properties['cmb_obj'])) { $field_tmp = $attribute_properties['cmb_obj']; $field_tmp->setValue($value); $value = $field_tmp->getText(); } if (get_class($value) == "DateTime") { $value = $value->format("Y-m-d"); } $field = new Object(utf8encode($value)); } $this->fields_array[$attribute] = $field; } return $this->fields_array; }
/** * Get style array */ public function testStyleArray() { $oTextBox = new TextBox(array('width' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(4.5), 'height' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(17.5), 'positioning' => 'absolute', 'marginLeft' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(15.4), 'marginTop' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(9.9), 'stroke' => 0, 'innerMargin' => 0, 'borderSize' => 1, 'borderColor' => '')); $this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\TextBox', $oTextBox->getStyle()); }
function CreateControls() { $this->AddCssClass('legacy-form'); /* @var $team Team */ /* @var $comp Competition */ $season = $this->GetDataObject(); /* @var $season Season */ require_once 'xhtml/forms/form-part.class.php'; require_once 'xhtml/forms/textbox.class.php'; require_once 'xhtml/forms/radio-button.class.php'; require_once 'xhtml/forms/checkbox.class.php'; # Show fewer options for a new season than when editing, beacause a new season gets settings copied from last year to save time $b_is_new_season = !(bool) $season->GetId(); # Add competition $comp = $season->GetCompetition(); $competition = new TextBox($this->GetNamingPrefix() . 'competition', $comp->GetId()); $competition->SetMode(TextBoxMode::Hidden()); $this->AddControl($competition); # Make current short URL available, because then it can match the suggested one and be left alone $short_url = new TextBox($this->GetNamingPrefix() . 'ShortUrl', $season->GetShortUrl()); $short_url->SetMode(TextBoxMode::Hidden()); $this->AddControl($short_url); # add years $start_box = new TextBox('start', is_null($season->GetStartYear()) ? Date::Year(gmdate('U')) : $season->GetStartYear(), $this->IsValidSubmit()); $start_box->AddAttribute('maxlength', 4); $start = new FormPart('Year season starts', $start_box); $this->AddControl($start); $summer = new RadioButton('summer', 'when', 'Summer season', 0); $winter = new RadioButton('winter', 'when', 'Winter season', 1); if ($season->GetEndYear() > $season->GetStartYear()) { $winter->SetChecked(true); } else { $summer->SetChecked(true); } $when = new XhtmlElement('div', $summer); $when->AddControl($winter); $when->SetCssClass('formControl'); $when_legend = new XhtmlElement('legend', 'Time of year'); $when_legend->SetCssClass('formLabel'); $when_fs = new XhtmlElement('fieldset', $when_legend); $when_fs->SetCssClass('formPart'); $when_fs->AddControl($when); $this->AddControl($when_fs); # add intro $intro_box = new TextBox('intro', $season->GetIntro(), $this->IsValidSubmit()); $intro_box->SetMode(TextBoxMode::MultiLine()); $intro = new FormPart('Introduction', $intro_box); $this->AddControl($intro); if (!$b_is_new_season) { # add types of matches if (!$this->IsPostback() or $this->b_saving_new and $this->IsValidSubmit()) { foreach ($season->MatchTypes()->GetItems() as $i_type) { $this->match_types_editor->DataObjects()->Add(new IdValue($i_type, ucfirst(MatchType::Text($i_type)))); } } $this->AddControl(new FormPart('Match types', $this->match_types_editor)); # add results $result_container = new XhtmlElement('div'); $result_box = new TextBox('results', $season->GetResults(), $this->IsValidSubmit()); $result_box->SetMode(TextBoxMode::MultiLine()); $result_container->AddControl($result_box); $result = new FormPart('Results', $result_container); $result->GetLabel()->AddAttribute('for', $result_box->GetXhtmlId()); $this->AddControl($result); # Add rules table $rules = new XhtmlTable(); $rules->SetCaption('Points for each result'); $header = new XhtmlRow(array('Result', 'Points for home team', 'Points for away team')); $header->SetIsHeader(true); $rules->AddRow($header); foreach ($this->result_types as $result) { /* @var $result MatchResult */ # Shouldn't ever need to assign points to a postponed match if ($result->GetResultType() == MatchResult::POSTPONED) { continue; } # Populate result with points from season rule $season->PossibleResults()->ResetCounter(); while ($season->PossibleResults()->MoveNext()) { if ($season->PossibleResults()->GetItem()->GetResultType() == $result->GetResultType()) { $result->SetHomePoints($season->PossibleResults()->GetItem()->GetHomePoints()); $result->SetAwayPoints($season->PossibleResults()->GetItem()->GetAwayPoints()); break; } } # Create table row $home_box = new TextBox($this->GetNamingPrefix() . 'Result' . $result->GetResultType() . 'Home', $result->GetHomePoints(), $this->IsValidSubmit()); $away_box = new TextBox($this->GetNamingPrefix() . 'Result' . $result->GetResultType() . 'Away', $result->GetAwayPoints(), $this->IsValidSubmit()); $home_box->AddAttribute('class', 'pointsBox'); $away_box->AddAttribute('class', 'pointsBox'); $result_row = new XhtmlRow(array(MatchResult::Text($result->GetResultType()), $home_box, $away_box)); $rules->AddRow($result_row); } $result_container->AddControl($rules); # Add points adjustments $this->adjustments_editor->SetTeams($season->GetTeams()); if (!$this->IsPostback() or $this->b_saving_new and $this->IsValidSubmit()) { $this->adjustments_editor->DataObjects()->SetItems($season->PointsAdjustments()->GetItems()); } $result_container->AddControl($this->adjustments_editor); # Show league table? $table = new CheckBox('showTable', 'Show results table', 1, $season->GetShowTable()); $this->AddControl($table); $this->AddControl(new CheckBox('runsScored', 'Include runs scored', 1, $season->GetShowTableRunsScored())); $this->AddControl(new CheckBox('runsConceded', 'Include runs conceded', 1, $season->GetShowTableRunsConceded())); # add teams if (!$this->IsPostback() or $this->b_saving_new and $this->IsValidSubmit()) { $teams_in_season = array(); foreach ($season->GetTeams() as $team) { $teams_in_season[] = new TeamInSeason($team, $season, is_object($season->TeamsWithdrawnFromLeague()->GetItemByProperty('GetId', $team->GetId()))); } $this->teams_editor->DataObjects()->SetItems($teams_in_season); } $this->AddControl(new FormPart('Teams', $this->teams_editor)); } }
/** * Constructor Password * @param mixed $page_or_form_object * @param string $name * @param string $id * @param string $value * @param string $width * @param double $length [default value: 0] */ function __construct($page_or_form_object, $name = '', $id = '', $value = '', $width = '', $length = 0) { parent::__construct($page_or_form_object, $name, $id, $value, $width, $length); $this->type = "password"; }
function process_word($raw_content, &$pipeline) { if ($raw_content === '') { return false; } $ptr = 0; $word = ''; $hyphens = array(); $encoding = 'iso-8859-1'; $manager_encoding =& ManagerEncoding::get(); $text_box =& TextBox::create_empty($pipeline); $len = strlen($raw_content); while ($ptr < $len) { $char = $manager_encoding->getNextUTF8Char($raw_content, $ptr); // Check if current char is a soft hyphen character. It it is, // remove it from the word (as it should not be drawn normally) // and store its location if ($char == SYMBOL_SHY) { $hyphens[] = strlen($word); } else { $mapping = $manager_encoding->getMapping($char); /** * If this character is not found in predefined encoding vectors, * we'll use "Custom" encoding and add single-character TextBox * * @TODO: handle characters without known glyph names */ if (is_null($mapping)) { /** * No mapping to default encoding vectors found for this character */ /** * Add last word */ if ($word !== '') { $text_box->add_subword($word, $encoding, $hyphens); } /** * Add current symbol */ $custom_char = $manager_encoding->addCustomChar(utf8_to_code($char)); $text_box->add_subword($custom_char, $manager_encoding->getCustomEncodingName(), $hyphens); $word = ''; } else { if (isset($mapping[$encoding])) { $word .= $mapping[$encoding]; } else { // This condition prevents empty text boxes from appearing; say, if word starts with a national // character, an () - text box with no letters will be generated, in rare case causing a random line // wraps, if container is narrow if ($word !== '') { $text_box->add_subword($word, $encoding, $hyphens); } reset($mapping); list($encoding, $add) = each($mapping); $word = $mapping[$encoding]; $hyphens = array(); } } } } if ($word !== '') { $text_box->add_subword($word, $encoding, $hyphens); } $this->add_child($text_box); return true; }
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)); }
/** * (non-PHPdoc) * @see xhtml/XhtmlElement#GetOpenTagXhtml() */ public function GetOpenTagXhtml() { # For a file upload control, use the maxlength attribute to set a max file size $max_size = ''; if ($this->i_mode == TextBoxMode::File()) { $max_size = new TextBox('MAX_FILE_SIZE', $this->GetMaxLength()); $max_size->SetMode(TextBoxMode::Hidden()); $this->RemoveAttribute('maxlength'); // not valid option } return $max_size . parent::GetOpenTagXhtml(); }
/** * Creates the controls when the editor is in its fixture view * */ private function CreateFixtureControls(Match $match, XhtmlElement $match_box) { $css_class = 'TournamentEdit'; if ($this->GetCssClass()) { $css_class .= ' ' . $this->GetCssClass(); } $match_outer_1 = new XhtmlElement('div'); $match_outer_1->SetCssClass($css_class); $this->SetCssClass(''); $match_outer_1->SetXhtmlId($this->GetNamingPrefix()); $match_outer_2 = new XhtmlElement('div'); $this->AddControl($match_outer_1); $match_outer_1->AddControl($match_outer_2); $match_outer_2->AddControl($match_box); if ($match->GetId()) { $heading = "Edit tournament"; } else { $heading = "Add your tournament"; } if ($this->show_step_number) { $heading .= ' – step 1 of 3'; } $o_title_inner_1 = new XhtmlElement('span', $heading); $o_title_inner_2 = new XhtmlElement('span', $o_title_inner_1); $o_title_inner_3 = new XhtmlElement('span', $o_title_inner_2); $match_box->AddControl(new XhtmlElement('h2', $o_title_inner_3, "large")); # Tournament title $suggested_title = $match->GetTitle(); if (isset($this->context_season)) { $suggested_title = $this->GetContextSeason()->GetCompetition()->GetName(); if (strpos(strtolower($suggested_title), 'tournament') === false) { $suggested_title .= ' tournament'; } } else { if (isset($this->context_team)) { $suggested_title = $this->GetContextTeam()->GetName(); if (strpos(strtolower($suggested_title), 'tournament') === false) { $suggested_title .= ' tournament'; } } } if ($suggested_title == "To be confirmed tournament") { $suggested_title = ""; } if ($suggested_title == "To be confirmed v To be confirmed") { $suggested_title = ""; } $title = new TextBox($this->GetNamingPrefix() . 'Title', $suggested_title, $this->IsValidSubmit()); $title->SetMaxLength(200); $match_box->AddControl(new FormPart('Tournament name', $title)); # Open or invite? require_once 'xhtml/forms/radio-button.class.php'; $qualify_set = new XhtmlElement('fieldset'); $qualify_set->SetCssClass('formPart radioButtonList'); $qualify_set->AddControl(new XhtmlElement('legend', 'Who can play?', 'formLabel')); $qualify_radios = new XhtmlElement('div', null, 'formControl'); $qualify_set->AddControl($qualify_radios); $qualify_radios->AddControl(new RadioButton($this->GetNamingPrefix() . 'Open', $this->GetNamingPrefix() . 'Qualify', 'any team may enter', MatchQualification::OPEN_TOURNAMENT, $match->GetQualificationType() === MatchQualification::OPEN_TOURNAMENT or !$match->GetId(), $this->IsValidSubmit())); $qualify_radios->AddControl(new RadioButton($this->GetNamingPrefix() . 'Qualify', $this->GetNamingPrefix() . 'Qualify', 'only invited or qualifying teams can enter', MatchQualification::CLOSED_TOURNAMENT, $match->GetQualificationType() === MatchQualification::CLOSED_TOURNAMENT, $this->IsValidSubmit())); $match_box->AddControl($qualify_set); # Player type $suggested_type = 2; if (isset($this->context_season)) { $suggested_type = $this->context_season->GetCompetition()->GetPlayerType(); } elseif (isset($this->context_team)) { $suggested_type = $this->context_team->GetPlayerType(); } if (!is_null($match->GetPlayerType())) { $suggested_type = $match->GetPlayerType(); } # Saved value overrides suggestion $player_set = new XhtmlElement('fieldset'); $player_set->SetCssClass('formPart radioButtonList'); $player_set->AddControl(new XhtmlElement('legend', 'Type of teams', 'formLabel')); $player_radios = new XhtmlElement('div', null, 'formControl'); $player_set->AddControl($player_radios); $player_radios_1 = new XhtmlElement('div', null, 'column'); $player_radios_2 = new XhtmlElement('div', null, 'column'); $player_radios->AddControl($player_radios_1); $player_radios->AddControl($player_radios_2); $player_radios_1->AddControl(new RadioButton($this->GetNamingPrefix() . 'Ladies', $this->GetNamingPrefix() . 'PlayerType', 'Ladies', 2, $suggested_type === 2, $this->IsValidSubmit())); $player_radios_1->AddControl(new RadioButton($this->GetNamingPrefix() . 'Mixed', $this->GetNamingPrefix() . 'PlayerType', 'Mixed', 1, $suggested_type === 1, $this->IsValidSubmit())); $player_radios_2->AddControl(new RadioButton($this->GetNamingPrefix() . 'Girls', $this->GetNamingPrefix() . 'PlayerType', 'Junior girls', 5, $suggested_type === 5, $this->IsValidSubmit())); $player_radios_2->AddControl(new RadioButton($this->GetNamingPrefix() . 'Children', $this->GetNamingPrefix() . 'PlayerType', 'Junior mixed', 4, $suggested_type === 6, $this->IsValidSubmit())); $match_box->AddControl($player_set); # How many? $per_side_box = new XhtmlSelect($this->GetNamingPrefix() . "Players", null, $this->IsValid()); $per_side_box->SetBlankFirst(true); for ($i = 6; $i <= 16; $i++) { $per_side_box->AddControl(new XhtmlOption($i)); } if ($match->GetIsMaximumPlayersPerTeamKnown()) { $per_side_box->SelectOption($match->GetMaximumPlayersPerTeam()); } else { if (!$match->GetId()) { # Use eight as sensible default for new tournaments $per_side_box->SelectOption(8); } } $players_per_team = new XhtmlElement("label", $per_side_box); $players_per_team->AddAttribute("for", $this->GetNamingPrefix() . "Players"); $players_per_team->AddControl(" players per team"); $players_part = new FormPart("How many players?", $players_per_team); $players_part->AddCssClass("playersPerTeam"); $match_box->AddControl($players_part); # Overs $overs_box = new XhtmlSelect($this->GetNamingPrefix() . "Overs", null, $this->IsValid()); $overs_box->SetBlankFirst(true); for ($i = 2; $i <= 8; $i++) { $overs_box->AddControl(new XhtmlOption($i)); } if ($match->GetIsOversKnown()) { $overs_box->SelectOption($match->GetOvers()); } $overs_label = new XhtmlElement("label", "Overs per innings"); $overs_label->AddAttribute("for", $overs_box->GetXhtmlId()); $overs_part = new FormPart($overs_label, new XhtmlElement("div", $overs_box)); $overs_part->AddCssClass("overs"); $match_box->AddControl($overs_part); # Start date and time if (!$match->GetStartTime()) { # if no date set, use specified default if ($this->i_default_time) { $match->SetStartTime($this->i_default_time); } else { # if no date set and no default, default to today at 10.30am BST # NOTE that if this is a new tournament in an old season, this date won't be selected because the available # dates will be limited below and won't include today. It'll be the same day in the relevant year though. $i_now = gmdate('U'); $match->SetStartTime(gmmktime(9, 30, 00, (int) gmdate('n', $i_now), (int) gmdate('d', $i_now), (int) gmdate('Y', $i_now))); $match->SetIsStartTimeKnown(true); } } $o_date = new DateControl($this->GetNamingPrefix() . 'Start', $match->GetStartTime(), $match->GetIsStartTimeKnown(), $this->IsValidSubmit()); $o_date->SetShowTime(true); $o_date->SetRequireTime(false); $o_date->SetMinuteInterval(5); # if only one season to choose from, limit available dates to the length of that season if ($this->context_season instanceof Season) { if ($this->context_season->GetStartYear() == $this->context_season->GetEndYear()) { $i_mid_season = gmmktime(0, 0, 0, 6, 30, $this->context_season->GetStartYear()); } else { $i_mid_season = gmmktime(0, 0, 0, 12, 31, $this->context_season->GetStartYear()); } $season_dates = Season::SeasonDates($i_mid_season); $season_start_month = gmdate('n', $season_dates[0]); $season_end_month = gmdate('n', $season_dates[1]); if ($season_start_month) { $o_date->SetMonthStart($season_start_month); } if ($season_end_month) { $o_date->SetMonthEnd($season_end_month); } $season_start_year = $this->context_season->GetStartYear(); $season_end_year = $this->context_season->GetEndYear(); if ($season_start_year) { $o_date->SetYearStart($season_start_year); } if ($season_end_year) { $o_date->SetYearEnd($season_end_year); } } $o_date_part = new FormPart('When?', $o_date); $o_date_part->SetIsFieldset(true); $match_box->AddControl($o_date_part); # Where? $o_ground_list = new XhtmlSelect($this->GetNamingPrefix() . 'Ground'); $o_ground_list->AddControl(new XhtmlOption("Don't know", -1)); $o_ground_list->AddControl(new XhtmlOption('Not listed (type the address in the notes field)', -2)); # Promote the most likely grounds to the top of the list $likely_ground_ids = array(); if ($match->GetGroundId()) { $likely_ground_ids[] = $match->GetGroundId(); } foreach ($this->probable_teams as $o_team) { $likely_ground_ids[] = $o_team->GetGround()->GetId(); } if (isset($this->context_season)) { foreach ($this->context_season->GetTeams() as $o_team) { $likely_ground_ids[] = $o_team->GetGround()->GetId(); } } if (isset($this->context_team) and is_object($this->context_team->GetGround())) { $likely_ground_ids[] = $this->context_team->GetGround()->GetId(); } $likely_grounds = array(); $a_other_grounds = array(); /* @var $o_ground Ground */ foreach ($this->grounds->GetItems() as $o_ground) { if (array_search($o_ground->GetId(), $likely_ground_ids) > -1) { $likely_grounds[] = $o_ground; } else { $a_other_grounds[] = $o_ground; } } # Add home grounds foreach ($likely_grounds as $o_ground) { $option = new XhtmlOption($o_ground->GetNameAndTown(), $o_ground->GetId()); $option->SetGroupName('Likely grounds'); $o_ground_list->AddControl($option); } # Add away grounds foreach ($a_other_grounds as $o_ground) { $option = new XhtmlOption($o_ground->GetNameAndTown(), $o_ground->GetId()); $option->SetGroupName('Other grounds'); $o_ground_list->AddControl($option); } # Select ground if ($match->GetGroundId()) { $o_ground_list->SelectOption($match->GetGroundId()); } elseif (isset($this->context_team)) { $o_ground_list->SelectOption($this->context_team->GetGround()->GetId()); } $o_ground_part = new FormPart('Where?', $o_ground_list); $match_box->AddControl($o_ground_part); # Notes $o_notes = new TextBox($this->GetNamingPrefix() . 'Notes', $match->GetNotes()); $o_notes->SetMode(TextBoxMode::MultiLine()); $o_notes_part = new FormPart('Notes<br />(remember to include contact details)', $o_notes); $match_box->AddControl($o_notes_part); # Remember short URL $o_short_url = new TextBox($this->GetNamingPrefix() . 'ShortUrl', $match->GetShortUrl()); $o_short_url->SetMode(TextBoxMode::Hidden()); $match_box->AddControl($o_short_url); # Note the context team to be added to the tournament by default if (isset($this->context_team)) { $context_team_box = new TextBox($this->GetNamingPrefix() . 'ContextTeam', $this->context_team->GetId()); $context_team_box->SetMode(TextBoxMode::Hidden()); $match_box->AddControl($context_team_box); } # Change Save button to "Next" button if ($this->show_step_number) { $this->SetButtonText('Next »'); } }
/** * @param TextBox $textBox */ public function RenderTextBox($textBox) { $this->result = $textBox->GetCaption(); }
/** * Method createDbAttributeObject * @access private * @param mixed $row * @param mixed $list_attribute * @param mixed $list_attribute_type * @param mixed $i * @param mixed $ind * @param mixed $key_attributes * @return mixed * @since 1.1.6 */ private function createDbAttributeObject($row, $list_attribute, $list_attribute_type, $i, $ind, $key_attributes) { // get property cmb_obj (created by method loadFromSqlDataView) if (isset($this->from_sql_data_view_properties[$list_attribute[$i]]['cmb_obj'])) { $input_obj_tmp = $this->from_sql_data_view_properties[$list_attribute[$i]]['cmb_obj']; $input_obj = clone $input_obj_tmp; $input_obj->setName($this->id . "_input_" . $list_attribute[$i] . "_ind_" . $ind); $register_objects = WebSitePhpObject::getRegisterObjects(); $register_objects[] = $input_obj; $_SESSION['websitephp_register_object'] = $register_objects; } else { $wspobject = "TextBox"; $attribute_properties = array(); if (is_array($this->from_sql_data_view_properties[$list_attribute[$i]])) { $attribute_properties = $this->from_sql_data_view_properties[$list_attribute[$i]]; } if (isset($attribute_properties["wspobject"]) && $attribute_properties["wspobject"] != "") { $wspobject = $attribute_properties["wspobject"]; } else { if ($list_attribute_type[$i] == "datetime") { $wspobject = "Calendar"; } else { if ($list_attribute_type[$i] == "boolean") { $wspobject = "CheckBox"; } } } if ($wspobject == "Calendar") { $input_obj = new Calendar($this->table_form_object, $this->id . "_input_" . $list_attribute[$i] . "_ind_" . $ind); } else { if ($wspobject == "CheckBox") { $input_obj = new CheckBox($this->table_form_object, $this->id . "_input_" . $list_attribute[$i] . "_ind_" . $ind); } else { if ($wspobject == "TextArea") { $input_obj = new TextArea($this->table_form_object, $object_id); } else { if ($wspobject == "Editor") { $input_obj = new Editor($this->table_form_object, $object_id); if (isset($attribute_properties["editor_param"]) && $attribute_properties["editor_param"] != "") { $input_obj->setToolbar($attribute_properties["editor_param"]); } } else { if ($wspobject == "ComboBox") { $input_obj = new ComboBox($this->table_form_object, $object_id); if (isset($attribute_properties["combobox_values"])) { if (is_array($attribute_properties["combobox_values"])) { for ($j = 0; $j < sizeof($attribute_properties["combobox_values"]); $j++) { $input_obj->addItem($attribute_properties["combobox_values"][$j]['value'], $attribute_properties["combobox_values"][$j]['text']); } } else { throw new NewException(get_class($this) . "->loadFromSqlDataView() error: the property combobox_values need to be an array.", 0, getDebugBacktrace(1)); } } } else { $input_obj = new TextBox($this->table_form_object, $this->id . "_input_" . $list_attribute[$i] . "_ind_" . $ind); if ($list_attribute_type[$i] == "integer" || $list_attribute_type[$i] == "double") { $input_obj->setWidth(70); } if (in_array($list_attribute[$i], $key_attributes)) { $lv = new LiveValidation(); $input_obj->setLiveValidation($lv->addValidatePresence()); } } } } } } } // get properties width and strip_tags if (is_array($this->from_sql_data_view_properties[$list_attribute[$i]])) { $attribute_properties = $this->from_sql_data_view_properties[$list_attribute[$i]]; if (isset($attribute_properties["width"]) && method_exists($input_obj, "setWidth")) { $input_obj->setWidth($attribute_properties["width"]); } if (isset($attribute_properties["height"]) && method_exists($input_obj, "setHeight")) { $input_obj->setHeight($attribute_properties["height"]); } if (isset($attribute_properties["class"]) && method_exists($input_obj, "setClass")) { $input_obj->setClass($attribute_properties["class"]); } if (isset($attribute_properties["style"]) && method_exists($input_obj, "setStyle")) { $input_obj->setStyle($attribute_properties["style"]); } if (isset($attribute_properties["disable"])) { if ($attribute_properties["disable"] == true && method_exists($input_obj, "disable")) { $input_obj->disable(); } else { if ($attribute_properties["disable"] == false && method_exists($input_obj, "enable")) { $input_obj->enable(); } } } if (get_class($input_obj) != "Calendar") { if (isset($attribute_properties["strip_tags"]) && $attribute_properties["strip_tags"] == true && method_exists($input_obj, "setStripTags")) { if (isset($attribute_properties["allowable_tags"])) { $input_obj->setStripTags($attribute_properties["allowable_tags"]); } else { $input_obj->setStripTags(""); // no tag allowed } } } } if ($row != null) { // get property db_attribute $field_value = $row->getValue($list_attribute[$i]); if (isset($this->from_sql_data_view_properties[$list_attribute[$i]]["db_attribute"])) { $db_attribute = $this->from_sql_data_view_properties[$list_attribute[$i]]["db_attribute"]; $field_value = $row->getValue($db_attribute); } $input_obj->onChange("onChangeTableFromSqlDataView")->setAjaxEvent()->disableAjaxWaitMessage(); if (get_class($input_obj) == "TextBox") { $input_obj->onKeyUpJs("if (\$(this)[0].defaultValue != \$(this).val()) { \$('#" . $this->id . "_img_" . $ind . "_cancel_" . $list_attribute[$i] . "').hide(); } else { \$('#" . $this->id . "_img_" . $ind . "_cancel_" . $list_attribute[$i] . "').show(); }"); } if ($list_attribute_type[$i] == "boolean") { if (!$input_obj->isChanged()) { $input_obj->setValue($field_value == true ? "on" : "off"); } } else { if (gettype($field_value) == "object") { $input_obj->setValue($field_value); } else { $input_obj->setValue(utf8encode($field_value)); } } } return $input_obj; }