/** * Add mailing list option when importing users. * * @return string */ protected function customImportFields() { $all_lists = ['' => ''] + Database::getInstance()->selectColumn('message_list', 'name', [], 'message_list_id'); $output = 'Add all imported users to this mailing list: ' . BasicHTML::select('message_list_id', $all_lists); $output .= 'Or add them to a new mailing list: ' . Text::textField('new_message_list', ''); return $output; }
public function renderControls() { return BasicHTML::select('start', [-7 => 'Last 7 Days', -30 => 'Last 30 Days', -60 => 'Last 60 Days', -90 => 'Last 90 Days']); }
public static function yearPop($field, $year = 0, $allow_zero = false, $first_year = null, $last_year = null, $attributes = array()) { $values = array(); if ($allow_zero) { $values[''] = ''; } if (empty($first_year)) { $first_year = date('Y') - 1; } if (empty($last_year)) { $last_year = date('Y') + 10; } $values += array_combine(range($first_year, $last_year), range($first_year, $last_year)); // Set the default class. BasicHTML::setDefaultClass($attributes, 'datePop'); // TODO: Pass the class into this renderer. return BasicHTML::select($field, $values, intval($year), $attributes); }
/** * Create a dropdown selection of page layouts. * * @param integer $default * The current selected layout. * * @return string * The rendered HTML. */ public static function layoutOptions($default) { $options = array(0 => 'Right Column', 1 => 'Full Width'); return BasicHTML::select('page_layout', $options, intval($default)); }
/** * Render the edit field component. * * @param array $field * The field settings. * @param array $row * The data row. * * @return string * The rendered HTML. */ protected function renderEditField($field, &$row = array()) { // Make sure the form_field is set. if (!isset($field['form_field'])) { $field['form_field'] = $field['field']; } // Get the default field value. if (!empty($_POST)) { $v = Request::post($field['form_field']); } elseif (empty($row)) { $v = isset($field['default']) ? $field['default'] : ''; } elseif (isset($field['edit_value'])) { if (is_callable($field['edit_value'])) { $v = $row[] = $field['edit_value']($row); } else { $v = $row[] = $field['edit_value']; } } elseif (!empty($row[$field['field']])) { $v = $row[$field['field']]; } if (isset($this->preset[$field['field']]['render_' . $this->action . '_field'])) { $this->get_row(false); return $this->preset[$field['field']]['render_' . $this->action . '_field']($this->list); } // Prepare value. if (!isset($field['Value'])) { $field['Value'] = isset($v) ? $v : null; } if (!empty($field['encrypted'])) { $field['Value'] = $this->decrypt($field['Value']); } // Set the default value if new. if ($this->action == "new" && isset($field['default'])) { $field['Value'] = $field['default']; } // Print form input. $options = array(); $return = ''; switch (preg_replace('/\\([0-9]+\\)/', '', $field['type'])) { case 'text': case 'mediumtext': case 'longtext': case 'html': $config = array(); $editor = !empty($field['editor']) ? strtolower($field['editor']) : 'default'; switch ($editor) { case 'full': $config['toolbar'] = "CKEDITOR.config.toolbar_Full"; break; case 'print': $config['toolbar'] = "CKEDITOR.config.toolbar_Print"; break; case 'basic_image': $config['toolbar'] = "CKEDITOR.config.toolbar_Basic_Image"; break; case 'basic': default: $config['toolbar'] = "CKEDITOR.config.toolbar_Basic"; break; } if (!empty($field['full_page'])) { $config['fullPage'] = true; $config['allowedContent'] = true; } if (!empty($field['height'])) { $config['height'] = $field['height']; } if (!empty($field['upload'])) { $config['finder'] = true; } return CKEditor::iframe($field['form_field'], $field['Value'], $config); break; case 'div': if ($field['Value'] == '') { $field['Value'] = "<p></p>"; } return "<input type='hidden' name='{$field['form_field']}' id='{$field['form_field']}' value='" . $this->convert_quotes($field['Value']) . "' />\n\t\t\t\t\t\t\t<div id='{$field['form_field']}_div' spellcheck='true'>{$field['Value']}</div>"; break; case 'plaintext': return "<textarea name='{$field['form_field']}' id='{$field['form_field']}' spellcheck='true' cols='90' rows='10'>{$field['Value']}</textarea>"; break; case 'hidden': return "<input type='hidden' name='{$field['form_field']}' id='{$field['form_field']}' value='" . $this->convert_quotes($field['Value']) . "' />"; break; case 'image': if (!empty($field['Value'])) { $return .= '<img src="' . $this->getImageLocationWeb($field, $field['Value']) . '" class="table_edit_image" />'; } // Fall through. // Fall through. case 'file': if ($field['Value'] != '' && (!isset($field['replaceable']) || empty($field['replaceable'])) || $field['Value'] == '') { $return .= "<input type='file' name='{$field['form_field']}' id='{$field['form_field']}' />"; } return $return; break; case 'time': return Time::timePop($field['form_field'], $field['Value'], !empty($field['allow_blank'])); break; case 'date': $return = Time::datePop($field['form_field'], !empty($field['Value']) ? $field['Value'] : 0, !empty($field['allow_blank']), !empty($field['start_year']) ? $field['start_year'] : 0); return $return; break; case 'datetime': return Time::dateTimePop($field['form_field'], $field['Value'], !empty($field['allow_blank']), isset($field['start_year']) ? $field['start_year'] : date('Y') - 10); break; case 'lookup': case 'yesno': case 'state': case 'country': case 'select': if ($field['type'] == 'lookup') { $options = Database::getInstance()->selectColumn($field['lookuptable'], $field['display_column'], !empty($field['filter']) ? $field['filter'] : array(), !empty($field['lookupkey']) ? $field['lookupkey'] : $field['field']); } elseif ($field['type'] == "yesno") { $options = array(1 => 'No', 2 => 'Yes'); } elseif ($field['type'] == "state") { $options = Location::getStateOptions(); } elseif ($field['type'] == "country") { $options = Location::getCountryOptions(); } else { $options = $field['options']; } if (!is_array($options)) { return false; } if (!empty($field['allow_blank'])) { $options = array('' => '') + $options; } $output = BasicHTML::select($field['form_field'], $options, $field['Value']); if (!empty($field['pop_add'])) { if ($field['table_url']) { $location = $field['table_url']; } else { $location = "table.php?table=" . $field['lookuptable']; } $output .= "<a onclick='lightning.table.newPop(\"{$location}\",\"{$field['form_field']}\",\"{$field['display_column']}\")'>Add New Item</a>"; } return $output; break; case 'range': $output = "<select name='{$field['form_field']}' id='{$field['form_field']}'>"; if ($field['allow_blank']) { $output .= '<option value="0"></option>'; } if ($field['start'] < $field['end']) { for ($k = $field['start']; $k <= $field['end']; $k++) { $output .= "<option value='{$k}'" . ($field['Value'] == $k ? 'selected="selected"' : '') . ">{$k}</option>"; } } $output .= '</select>'; return $output; break; case 'checkbox': return "<input type='checkbox' name='{$field['form_field']}' id='{$field['form_field']}' value='1' " . ($field['Value'] == 1 ? "checked" : '') . " />"; break; case 'note': return $field['note']; break; case 'checklist': $vals = $this->decode_bool_group($field['Value']); $output = ''; foreach ($field['options'] as $i => $opt) { if (is_array($opt)) { $id = $opt[0]; $name = $opt[1]; } else { $id = $i; $name = $opt; } $output .= "<div class='checlist_item'><input type='checkbox' name='{$field['form_field']}_{$id}' value='1' " . ($vals[$id] == 1 ? "checked" : '') . " />{$name}</div>"; } return $output; break; case 'varchar': case 'char': preg_match('/(.+)\\(([0-9]+)\\)/i', $field['type'], $array); $options['size'] = $array[2]; default: if (!empty($field['autocomplete'])) { $options['classes'] = array('table_autocomplete'); $options['autocomplete'] = false; } return Text::textfield($field['form_field'], $field['Value'], $options); break; } }