/** * Creates a select list * * * example: list with multiple select options * * SPHtml_Input::select( * 'fieldname', * array( 'translate:[perms.can_delete]' => 'can_delete', 'translate:[perms.can_edit]' => 'can_edit', 'translate:[perms.can_see]' => 'can_see' ), * array( 'can_see', 'can_delete' ), * true, * array( 'class' => 'inputbox', 'size' => 5 ) * ); * * * example: list with multiple select options and optgroups * * SPHtml_Input::select( * 'fieldname', * array( * 'categories' => array( 'translate:[perms.can_delete_categories]' => 'can_delete_categories', 'translate:[perms.can_edit_categories]' => 'can_edit_categories', 'translate:[perms.can_see_categories]' => 'can_see_categories' ), * 'entries' => array( 'translate:[perms.can_delete_entries]' => 'can_delete_entries', 'translate:[perms.can_edit_entries]' => 'can_edit_entries', 'translate:[perms.can_see_entries]' => 'can_see_entries' ), * ) * array( 'can_see_categories', 'can_delete_entries', 'can_edit_entries' ), * true, * array( 'class' => 'inputbox', 'size' => 5 ) * ) * * @param string $name - name of the html field * @param array $values - two-dimensional array with values and their labels. array( 'enabled' => 1, 'disabled' => 0 ) * @param array $selected - one-dimensional array with selected values * @param bool $multi - multiple select is allowed or not * @param array $params - two-dimensional array with additional html parameters. Can be also string defined, comma separated array with equal sign as key to index separator. * @return string * @internal param string $title - language section for the title tags. If given, the options/optgroup will get a title tag. The title will be search in the language file under the given section */ public static function _select($name, $values, $selected = null, $multi = false, $params = null) { if (Sobi::Cfg('template.bootstrap3-styles')) { SPHtml_Input::checkArray($params); if (isset($params['class'])) { $params['class'] .= ' form-control'; } else { $params['class'] = ' form-control'; } } if (is_array($params) && (isset($params['size']) && $params['size'] == 1)) { unset($params['size']); } $data = self::createDataTag($params); $params = self::params($params); if (strstr($name, '_array')) { self::checkArray($selected); } self::checkArray($values); if ($selected !== null && !is_array($selected)) { $selected = array((string) $selected); } elseif (!is_array($selected)) { $selected = array(); } $cells = self::createOptions($values, $selected); if ($multi) { $multi = ' multiple="multiple" '; $name .= '[]'; } $cells = implode("\n\t", $cells); $f = "<select name=\"{$name}\"{$multi}{$params}{$data}>\n\t{$cells}\n</select>"; Sobi::Trigger('Field', ucfirst(__FUNCTION__), array(&$f)); // return "\n<!-- SelectList '{$name}' Output -->{$f}<!-- SelectList '{$name}' End -->\n\n"; return "\n{$f}\n\n"; }