function sbp_paths_edit_form in Search by Page 6
Same name and namespace in other branches
- 7 sbp_paths.module \sbp_paths_edit_form()
Returns a form for editing a path item.
See also
1 string reference to 'sbp_paths_edit_form'
- _sbp_paths_edit in ./
sbp_paths.module - Edits or adds new path.
File
- ./
sbp_paths.module, line 327 - Module file for Search by Page Paths, a sub-module for Search by Page.
Code
function sbp_paths_edit_form(&$form_state, $edit = array()) {
global $language;
$edit = array_merge(array(
'pid' => 0,
'page_path' => '',
'title' => '',
'page_type' => 'Page',
'snippet' => 'yes',
'environment' => 0,
'role' => DRUPAL_ANONYMOUS_RID,
'languages' => array(),
), $edit);
$edit['environment'] = intval($edit['environment']);
$form = array();
$form['path'] = array(
'#type' => 'textfield',
'#title' => t('Page to index'),
'#default_value' => $edit['page_path'],
'#size' => 45,
'#description' => t('Specify a page on your site that you want to index. Do not include the language prefix, if any.'),
'#field_prefix' => search_by_page_path_field_prefix(),
'#required' => TRUE,
);
$form['title'] = array(
'#type' => 'textfield',
'#title' => t('Title of page'),
'#default_value' => $edit['title'],
'#size' => 45,
'#description' => t('Title to display in search results for this page'),
'#required' => TRUE,
);
$form['type'] = array(
'#type' => 'textfield',
'#title' => t('Type of page'),
'#default_value' => $edit['page_type'],
'#size' => 45,
'#description' => t('Type to display in search results for this page'),
'#required' => TRUE,
);
$form['snippet'] = array(
'#type' => 'textarea',
'#title' => t('Snippet'),
'#default_value' => $edit['snippet'],
'#cols' => 45,
'#rows' => 5,
'#description' => t('Enter "yes" (without the quotes, in English) to show a "snippet" of this page in search results, extracted from the page (it should show a portion of the page that contains the search results). Enter "no" (without the quotes, in English) to omit the snippet entirely. Or, enter any other text to use that custom text as the snippet for search results display.'),
'#required' => TRUE,
);
if (module_exists('locale')) {
$form['texthelp'] = array(
'#type' => 'markup',
'#value' => '<p>' . t("Enter the title, type, and snippet above in your site's default language. If you have a multi-lingual site with the Internationalization project's String Translation module installed and enabled, you can use Drupal's translation interface to translate them.") . '</p>',
);
$form['languages'] = array(
'#type' => 'checkboxes',
'#title' => t('Languages'),
'#description' => t('Indicate which languages this page can be viewed in. It will be indexed in each language for searching.'),
'#options' => locale_language_list('name'),
'#default_value' => $edit['languages'],
);
}
else {
$form['languages'] = array(
'#type' => 'value',
'#value' => array(
$language->language => TRUE,
),
);
}
$form['role'] = array(
'#type' => 'radios',
'#title' => t('Role for indexing'),
'#options' => user_roles(),
'#default_value' => $edit['role'],
'#weight' => 4,
'#description' => t("When Search by Page indexes this page for searching, the page will be viewed from the perspective and permissions of a user with this role."),
);
if ($edit['pid']) {
$form['pid'] = array(
'#type' => 'value',
'#value' => $edit['pid'],
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Update indexed page'),
);
}
else {
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Create new indexed page'),
);
}
$form['submit']['#weight'] = 5;
$form['environment'] = array(
'#type' => 'value',
'#value' => $edit['environment'],
);
$form['cancel'] = array(
'#value' => "<p>" . l(t('Cancel'), 'admin/settings/search_by_page/edit/' . $edit['environment'] . '/paths') . "</p>",
'#weight' => 6,
);
return $form;
}