function clientside_validation_settings_overview in Clientside Validation 7
Same name and namespace in other branches
- 7.2 clientside_validation.admin.inc \clientside_validation_settings_overview()
1 string reference to 'clientside_validation_settings_overview'
- clientside_validation_menu in ./
clientside_validation.module - Implements hook_menu().
File
- ./
clientside_validation.admin.inc, line 563 - Admin settings for Clientside Validation
Code
function clientside_validation_settings_overview($form, $form_state, $cvs_type) {
$form = array();
$settings = clientside_validation_settings_load($cvs_type, NULL, TRUE);
$definedforms = array();
$empty_text = "";
switch ($cvs_type) {
case 'content-types':
$destination = array(
'destination' => 'admin/config/validation/clientside_validation/content-types',
);
$settinguri = 'admin/config/validation/clientside_validation/content-types/';
$headerlabel = t('Content type');
$empty_text = t('No content types available');
$content_types = node_type_get_types();
foreach ($content_types as $content_type) {
$definedforms[] = array(
'id' => $content_type->type,
'label' => t($content_type->name),
);
}
break;
case 'webforms':
$destination = array(
'destination' => 'admin/config/validation/clientside_validation/webforms',
);
$settinguri = 'admin/config/validation/clientside_validation/webforms/';
$headerlabel = t('Webforms');
$empty_text = t('No webforms available');
$webform_types = webform_variable_get('webform_node_types');
$nodes = array();
if ($webform_types) {
$nodes = db_select('node', 'n')
->fields('n')
->condition('n.type', $webform_types, 'IN')
->execute()
->fetchAllAssoc('nid');
foreach ($nodes as $node) {
$definedforms[] = array(
'id' => $node->nid,
'label' => l($node->title, 'node/' . $node->nid),
);
}
}
break;
case 'custom-forms':
$destination = array(
'destination' => 'admin/config/validation/clientside_validation/custom-forms',
);
$settinguri = 'admin/config/validation/clientside_validation/custom-forms/';
$headerlabel = t('Form Id');
$empty_text = t('No custom forms added yet');
foreach ($settings as $customform) {
$definedforms[] = array(
'id' => $customform->form_id,
'label' => $customform->form_id,
);
}
$form['cvs_type'] = array(
'#type' => 'value',
'#value' => $cvs_type,
);
$form['add_formid'] = array(
'#type' => 'fieldset',
'#collapsible' => TRUE,
'#collapsed' => FALSE,
'#title' => t('Add a new custom form'),
'#description' => t('Enter the formid of the form you want to override.'),
);
$form['add_formid']['cvs_formid'] = array(
'#title' => t('Form Id'),
'#type' => 'textfield',
);
$form['add_formid']['submit'] = array(
'#type' => 'submit',
'#value' => t('Add Form Id'),
'#weight' => 50,
);
break;
}
$rows = array();
if ($definedforms) {
foreach ($definedforms as $definedform) {
$row = array();
$row[] = $definedform['label'];
if (isset($settings[$definedform['id']]) && $settings[$definedform['id']]->status) {
$cvs_formid = check_plain($definedform['id']);
$row[] = _cv_setting_status(TRUE);
$actions = array(
'edit' => array(
'title' => t('edit'),
'href' => $settinguri . $cvs_formid . '/edit',
'query' => $destination,
),
'disable' => array(
'title' => t('disable'),
'href' => $settinguri . $cvs_formid . '/disable',
'query' => $destination,
),
'delete' => array(
'title' => t('delete'),
'href' => $settinguri . $cvs_formid . '/delete',
'query' => $destination,
),
);
}
else {
$row[] = _cv_setting_status(FALSE);
if (isset($settings[$definedform['id']])) {
$cvs_formid = check_plain($definedform['id']);
$actions = array(
'edit' => array(
'title' => t('edit'),
'href' => $settinguri . $cvs_formid . '/edit',
'query' => $destination,
),
'enable' => array(
'title' => t('enable'),
'href' => $settinguri . $cvs_formid . '/enable',
'query' => $destination,
),
'delete' => array(
'title' => t('delete'),
'href' => $settinguri . $cvs_formid . '/delete',
'query' => $destination,
),
);
}
else {
$actions = array(
'edit' => array(
'title' => t('create'),
'href' => $settinguri . check_plain($definedform['id']) . '/edit',
'query' => $destination,
),
);
}
}
$row[] = array(
'data' => array(
'#theme' => 'links__node_operations',
'#links' => $actions,
'#attributes' => array(
'class' => array(
'links',
'inline',
),
),
),
);
$rows[] = $row;
}
}
$header = array(
$headerlabel,
t('Status'),
t('Actions'),
);
$form[str_replace('-', '', $cvs_type)] = array(
'#theme' => 'table',
'#header' => $header,
'#rows' => $rows,
'#empty' => $empty_text,
);
return $form;
}