function CategorySelectControl(CategoryCollection $o_categories, $page_valid = null)
 {
     # set properties
     parent::XhtmlSelect('category', null, $page_valid);
     $this->SetBlankFirst(true);
     # add categories
     $a_categories = $o_categories->GetItems();
     foreach ($a_categories as $o_category) {
         $o_opt = new XhtmlOption($o_category->GetName(), $o_category->GetId());
         $o_opt->AddAttribute('style', 'padding-left: ' . ($o_category->GetHierarchyLevel() - 1) * 20 . 'px');
         $this->AddControl($o_opt);
         unset($o_opt);
     }
 }
 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);
 }
 /**
  * Creates an XhtmlOption from a category
  *
  * @param int $id
  * @param Category $object
  * @return XhtmlOption
  */
 protected function CreateOption($id, $object)
 {
     $opt = new XhtmlOption(ucfirst($object->__toString()), $id . RelatedItemEditor::VALUE_DIVIDER . ucfirst($object->__toString()));
     $opt->AddAttribute('style', 'padding-left: ' . ($object->GetHierarchyLevel() - 1) * 20 . 'px');
     return $opt;
 }
 /**
  * Alters an option so that it looks disabled
  *
  * @param XhtmlOption $opt
  * @return XhtmlOption
  */
 protected function DisableOption(XhtmlOption $opt)
 {
     $opt->AddAttribute('value', '');
     $s_style = trim($opt->GetAttribute('style'));
     $i_style_len = strlen($s_style);
     if ($i_style_len > 0 and strrpos($s_style, ';') != $i_style_len) {
         $s_style .= ';';
     }
     $s_style .= 'color: #aaa;';
     $opt->AddAttribute('style', $s_style);
     return $opt;
 }
 function OnPageLoad()
 {
     echo "<h1>Stoolball matches</h1>";
     # Filter controls
     $filter_box = new XhtmlForm();
     $filter_box->SetCssClass('dataFilter');
     $filter_box->AddAttribute('method', 'get');
     $filter_box->AddControl(new XhtmlElement('p', 'Show me: ', "follow-on large"));
     $filter_inner = new XhtmlElement('div');
     $filter_box->AddControl($filter_inner);
     $gender = new XhtmlSelect('player', 'Player type');
     $gender->SetHideLabel(true);
     $gender->AddControl(new XhtmlOption("mixed and ladies", ''));
     $gender->AddControl(new XhtmlOption('mixed', 1));
     $gender->AddControl(new XhtmlOption("ladies", 2));
     if (isset($_GET['player'])) {
         $gender->SelectOption($_GET['player']);
     }
     $filter_inner->AddControl($gender);
     $type = new XhtmlSelect('type', 'Match type');
     $type->SetHideLabel(true);
     $type->AddControl(new XhtmlOption('all matches', ''));
     $type->AddControl(new XhtmlOption('league matches', MatchType::LEAGUE));
     $type->AddControl(new XhtmlOption('cup matches', MatchType::CUP));
     $type->AddControl(new XhtmlOption('friendlies', MatchType::FRIENDLY));
     $type->AddControl(new XhtmlOption('tournaments', MatchType::TOURNAMENT));
     $type->AddControl(new XhtmlOption('practices', MatchType::PRACTICE));
     if (isset($_GET['type'])) {
         $type->SelectOption($_GET['type']);
     }
     $filter_inner->AddControl($type);
     $filter_inner->AddControl(' in ');
     $month = new XhtmlSelect('month', 'Month');
     $month->SetHideLabel(true);
     $month->AddControl(new XhtmlOption('next few matches', ''));
     foreach ($this->a_months as $i_month => $i_matches) {
         $opt = new XhtmlOption(Date::MonthAndYear($i_month), $i_month);
         if (isset($_GET['month']) and $_GET['month'] == $i_month) {
             $opt->AddAttribute('selected', 'selected');
         }
         $month->AddControl($opt);
         unset($opt);
     }
     $filter_inner->AddControl($month);
     $update = new XhtmlElement('input');
     $update->AddAttribute('type', 'submit');
     $update->AddAttribute('value', 'Update');
     $filter_inner->AddControl($update);
     # Content container
     $container = new XhtmlElement('div', $filter_box, "box");
     $content = new XhtmlElement("div", null, "box-content");
     $container->AddControl($content);
     # Display the matches
     if (count($this->a_matches)) {
         $list = new MatchListControl($this->a_matches);
         $content->AddControl($list);
     } else {
         $content->AddControl(new XhtmlElement('p', 'Sorry, there are no matches to show you.'));
         $content->AddControl(new XhtmlElement('p', 'If you know of a match which should be listed, please <a href="/play/manage/website/">add the match to the website</a>.'));
     }
     echo $container;
 }
 /**
  * @return bool
  * @param XhtmlOption $o_control
  * @desc Add an XhtmlOption to this list
  */
 function AddControl($o_control)
 {
     /* @var $o_control XhtmlOption */
     if ($this->b_page_valid === false and isset($_POST[$this->GetXhtmlId()]) and $o_control instanceof XhtmlOption and $o_control->GetAttribute('value') == $_POST[$this->GetXhtmlId()]) {
         $o_control->AddAttribute('selected', 'selected');
     }
     parent::AddControl($o_control);
 }