function _autocomplete_widgets_widget_settings in Autocomplete Widgets for Text and Number Fields 6
Implementation of hook_widget_settings().
1 call to _autocomplete_widgets_widget_settings()
- autocomplete_widgets_widget_settings in ./
autocomplete_widgets.module - Implementation of hook_widget_settings().
File
- ./
autocomplete_widgets.admin.inc, line 42 - Administration related code for Autocomplete Widgets module.
Code
function _autocomplete_widgets_widget_settings($op, $widget) {
switch ($op) {
case 'form':
$form = array();
$form['size'] = array(
'#type' => 'textfield',
'#title' => t('Size of textfield'),
'#default_value' => isset($widget['size']) ? $widget['size'] : 60,
'#element_validate' => array(
'_element_validate_integer_positive',
),
'#required' => TRUE,
);
$form['autocomplete_match'] = array(
'#type' => 'select',
'#title' => t('Autocomplete matching'),
'#default_value' => isset($widget['autocomplete_match']) ? $widget['autocomplete_match'] : 'contains',
'#options' => array(
'starts_with' => t('Starts with'),
'contains' => t('Contains'),
),
'#description' => t('Select the method used to collect autocomplete suggestions. Note that <em>Contains</em> can cause performance issues on sites with thousands of records.'),
);
$form['autocomplete_case'] = array(
'#type' => 'radios',
'#title' => t('Case sensitive'),
'#default_value' => isset($widget['autocomplete_case']) ? $widget['autocomplete_case'] : 1,
'#options' => array(
0 => t('Disabled'),
1 => t('Enabled'),
),
);
if ($widget['type'] == 'autocomplete_widgets_flddata') {
$form['autocomplete_case']['#description'] = t('Case-insensitive queries are implemented using the <a href="!function-lower-url">LOWER()</a> function in combination with the <a href="!operator-like-url">LIKE</a> operator.', array(
'!function-lower-url' => 'http://dev.mysql.com/doc/refman/5.1/en/string-functions.html#function_lower',
'!operator-like-url' => 'http://dev.mysql.com/doc/refman/5.1/en/string-comparison-functions.html#operator_like',
));
if (in_array($GLOBALS['db_type'], array(
'mysql',
'mysqli',
))) {
$form['autocomplete_case']['#description'] .= ' ' . t('Note that MySQL might ignore case sensitivity depending on the collation used in your database definition (see <a href="!mysql-i18n-l10n-url">Internationalization and Localization</a> chapter in the MySQL manual). If you need case insensitive checks, it is recommended (for performance reasons) to use a case insensitive collation as well (such as utf8_general_ci), rather than disabling the case sensitive option here.', array(
'!mysql-i18n-l10n-url' => 'http://dev.mysql.com/doc/refman/5.1/en/internationalization-localization.html',
));
}
elseif ($GLOBALS['db_type'] == 'pgsql') {
$form['autocomplete_case']['#description'] .= ' ' . t('You may want to create an expression index using the LOWER() function to speed up this kind of queries in PostgreSQL (See <a href="!indexes-expressional-url">Indexes on Expressions</a>).', array(
'!indexes-expressional-url' => 'http://www.postgresql.org/docs/8.4/static/indexes-expressional.html',
));
}
}
else {
$form['autocomplete_case']['#description'] = t('Case-insensitive queries are implemented using the function <a href="!drupal-strtolower-url">drupal_strtolower()</a>.', array(
'!drupal-strtolower-url' => 'http://api.drupal.org/api/function/drupal_strtolower/6',
));
}
$form['autocomplete_xss'] = array(
'#type' => 'radios',
'#title' => t('Filter HTML'),
'#default_value' => isset($widget['autocomplete_xss']) ? $widget['autocomplete_xss'] : 0,
'#options' => array(
0 => t('Disabled'),
1 => t('Enabled'),
),
'#description' => t('Enable this option to filter out HTML in display of values.'),
);
if ($widget['type'] == 'autocomplete_widgets_flddata' && module_exists('i18n')) {
$form['i18n_flddata'] = array(
'#type' => 'radios',
'#title' => t('Internationalization support'),
'#default_value' => isset($widget['i18n_flddata']) ? $widget['i18n_flddata'] : 0,
'#options' => array(
0 => t('Disabled'),
1 => t('Enabled'),
),
'#description' => t('Enable this option to provide a different set of allowed values based on the language their nodes are assigned to. This option is only available when <a href="@i18n-project-page">Internationalization</a> module is enabled.', array(
'@i18n-project-page' => 'http://drupal.org/project/i18n',
)),
);
}
else {
$form['i18n_flddata'] = array(
'#type' => 'value',
'#value' => 0,
);
}
if ($widget['type'] == 'autocomplete_widgets_flddata') {
$form['obey_access_controls'] = array(
'#type' => 'checkbox',
'#title' => t('Only suggest content from nodes that the current user has permission to access.'),
'#default_value' => isset($widget['obey_access_controls']) ? $widget['obey_access_controls'] : 1,
'#description' => t('Unchecking this means that users might have content suggested to them from nodes to which they do not have access. Proceed with caution.'),
);
}
return $form;
case 'save':
return array(
'size',
'autocomplete_match',
'autocomplete_case',
'autocomplete_xss',
'i18n_flddata',
'obey_access_controls',
);
}
}