function system_build_element
Search API
4.x system.module | system_build_element($name, $type = "", $label = "", $description = "", $default_value = "", $csv_to_array = FALSE) |
5.x system.module | system_build_element($name, $type = "", $label = "", $description = "", $default_value = "", $csv_to_array = FALSE) |
Construct an HTML element and return it.
File
- modules/
system/ system.module, line 3399
Code
function system_build_element($name, $type = "", $label = "", $description = "", $default_value = "", $csv_to_array = FALSE) {
$rtn = "";
if (!$default_value) {
$default_value = $GLOBALS ["fp_system_settings"][$name];
}
if (is_array($default_value)) {
$default_value = @join(", ", $default_value);
}
if (!$type) {
$type = "textfield";
}
if (!$label) {
$label = $name;
}
if ($type == "textfield") {
$rtn .= "<div class='fp-system-settings-element fp-system-settings-textfield'>
<label>$label:</label>
<div class='fp-system-settings-input'>
<input type='textfield' name='$name' value='$default_value'>
</div>
";
if ($description) {
$rtn .= "<div class='fp-system-settings-element-description'>$description</div>";
}
$rtn .= "</div>";
}
if ($type == "textarea") {
$rtn .= "<div class='fp-system-settings-element fp-system-settings-textarea'>
<label>$label:</label>
<div class='fp-system-settings-input'>
<textarea name='$name'>$default_value</textarea>
</div>
";
if ($description) {
$rtn .= "<div class='fp-system-settings-element-description'>$description</div>";
}
$rtn .= "</div>";
}
if ($type == "boolean") {
$sel_f = $sel_t = "";
if ($default_value) {
$sel_t = "selected";
}
$rtn .= "<div class='fp-system-settings-element fp-system-settings-boolean'>
<label>$label:</label>
<div class='fp-system-settings-input'>
<select name='$name'>
<option value='' $sel_f>FALSE</option>
<option value='1' $sel_t>TRUE</option>
</select>
</div>
";
if ($description) {
$rtn .= "<div class='fp-system-settings-element-description'>$description</div>";
}
$rtn .= "</div>";
}
// We need to convert this CSV back into an array when we save it!
if ($csv_to_array) {
if (!isset($_SESSION ["fp_system"]["csv_to_array"])) {
$_SESSION ["fp_system"]["csv_to_array"] = array();
}
// Add to our list.
$_SESSION ["fp_system"]["csv_to_array"][] = $name;
}
return $rtn;
}