function theme_webform_validation_manage_add_rule in Webform Validation 7
Same name and namespace in other branches
- 6 webform_validation.module \theme_webform_validation_manage_add_rule()
Theme the 'add rule' list.
1 theme call to theme_webform_validation_manage_add_rule()
- webform_validation_manage in ./
webform_validation.admin.inc - Menu callback function.
File
- ./
webform_validation.module, line 376
Code
function theme_webform_validation_manage_add_rule($variables) {
$nid = $variables['nid'];
$output = '';
$validators = webform_validation_get_validators();
if ($validators) {
$results = db_query('SELECT DISTINCT type FROM {webform_component} WHERE nid = :nid', array(
'nid' => $nid,
));
$types = array();
while ($item = $results
->fetch()) {
$types[] = $item->type;
}
$output = '<h3>' . t('Add a validation rule') . '</h3>';
$output .= '<dl>';
foreach ($validators as $validator_key => $validator_info) {
$validator_types = webform_validation_valid_component_types($validator_key);
$title = $validator_info['name'];
if (array_intersect($types, $validator_types)) {
$url = 'node/' . $nid . '/webform/validation/add/' . $validator_key;
$title = l($title, $url, array(
'query' => drupal_get_destination(),
));
$component_list_postfix = '';
}
else {
$component_list_postfix = '; ' . t('none present in this form');
}
$item = '<dt>' . $title . '</dt>';
$item .= '<dd>';
$item .= $validator_info['description'];
$item .= ' ' . t('Works with: @component_types.', array(
'@component_types' => implode(', ', $validator_types) . $component_list_postfix,
)) . '</dd>';
$output .= $item;
}
$output .= '</dl>';
}
return $output;
}