3 # FILE: HtmlRadioButtonSet.php 5 # Part of the ScoutLib application support library 6 # Copyright 2017 Edward Almasy and Internet Scout Research Group 7 # http://scout.wisc.edu 16 # ---- PUBLIC INTERFACE -------------------------------------------------- 26 public function __construct($ResultVar, $Options, $SelectedValue = NULL)
28 $this->ResultVar = $ResultVar;
29 $this->Options = $Options;
47 # start out with empty HTML 50 # if there are options or we are supposed to print even if no options 54 foreach ($this->Options as $Value => $Label)
56 # generate ID for elements 57 $Id = $this->ResultVar.
"_" 58 .preg_replace(
"%[^a-z0-9]%i",
"", $Value);
61 $Html .=
" <input type=\"radio\"" 62 .
" id=\"".htmlspecialchars($Id).
"\"" 63 .
" name=\"".htmlspecialchars($this->ResultVar).
"\"" 64 .
" value=\"".htmlspecialchars($Value).
"\"";
66 # add in selected attribute if appropriate 74 # add in disabled attribute if appropriate 85 $Html .=
" <label for=\"".$Id.
"\">" 86 .htmlspecialchars($Label).
"</label>\n";
90 # return generated HTML to caller 104 if ($Options !== NULL)
106 if (is_array($Options))
115 return $this->DisabledOptions;
126 if ($NewValue !== NULL)
130 return $this->SelectedValue;
144 if ($NewValue !== NULL)
148 return $this->PrintIfEmpty;
160 if ($NewValue !== NULL)
162 $this->
Disabled = $NewValue ? TRUE : FALSE;
164 return $this->Disabled;
168 # ---- PRIVATE INTERFACE ------------------------------------------------- 173 private $Disabled = FALSE;
174 private $DisabledOptions = array();
175 private $PrintIfEmpty = TRUE;
176 private $SelectedValue;