id stringlengths 22 22 | drupal_version stringclasses 1
value | source_type stringclasses 1
value | source_url stringlengths 70 167 | instruction stringlengths 87 500 | context stringlengths 16 10.7k | response stringlengths 68 5.97k | tags listlengths 2 2 | created_at timestamp[s]date 2026-09-30 00:00:00 2026-09-30 00:00:00 |
|---|---|---|---|---|---|---|---|---|
api-drupal7-699085fc9c | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21system.admin.inc/function/system_add_date_format_type_form_submit/7.x | I need the code for `system_add_date_format_type_form_submit($form, &$form_state)` in Drupal 7 (modules/system/system.admin.inc). It must do this: Process system_add_date_format_type form submissions. | File: modules/system/system.admin.inc | function system_add_date_format_type_form_submit($form, &$form_state) {
$machine_name = trim($form_state['values']['machine_name']);
$format_type = array();
$format_type['title'] = trim($form_state['values']['date_type']);
$format_type['type'] = $machine_name;
$format_type['locked'] = 0;
$format_type['is_n... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-69b46b94ce | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21overlay%21overlay.module/function/overlay_preprocess_page/7.x | Implement `overlay_preprocess_page(&$variables)` in PHP for Drupal 7. Required behavior: Implements hook_preprocess_page(). | If the current page request is inside the overlay, hide the tabs.
File: modules/overlay/overlay.module | function overlay_preprocess_page(&$variables) {
if (overlay_get_mode() == 'child') {
unset($variables['tabs']['#primary']);
}
} | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-69c40c0c10 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21menu.inc/function/_menu_update_parental_status/7.x | In Drupal 7, write the function `_menu_update_parental_status($item, $exclude = FALSE)` (file includes/menu.inc) so that it does the following: Checks and updates the 'has_children' status for the parent of a link. | File: includes/menu.inc | function _menu_update_parental_status($item, $exclude = FALSE) {
// If plid == 0, there is nothing to update.
if ($item['plid']) {
// Check if at least one visible child exists in the table.
$query = db_select('menu_links');
$query->addField('menu_links', 'mlid');
$query->condition('menu_name', $ite... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-69c5149e2d | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21batch.inc/function/_batch_shutdown/7.x | I need the code for `_batch_shutdown()` in Drupal 7 (includes/batch.inc). It must do this: Shutdown function: Stores the current batch data for the next request. | File: includes/batch.inc | function _batch_shutdown() {
if ($batch = batch_get()) {
db_update('batch')
->fields(array('batch' => serialize($batch)))
->condition('bid', $batch['id'])
->execute();
}
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-69e68424a7 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21install.core.inc/function/install_tasks/7.x | I need the code for `install_tasks($install_state)` in Drupal 7 (includes/install.core.inc). It must do this: Returns a list of all tasks the installer currently knows about. | This function will return tasks regardless of whether or not they are intended to run on the current page request. However, the list can change based on the installation state (for example, if an installation profile hasn't been selected yet, we don't yet know which profile tasks will be available).
Parameters:
- $ins... | function install_tasks($install_state) {
// Determine whether translation import tasks will need to be performed.
$needs_translations = count($install_state['locales']) > 1 && !empty($install_state['parameters']['locale']) && $install_state['parameters']['locale'] != 'en';
// Start with the core installation tas... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-69e7d283b3 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21search%21search.pages.inc/function/search_view/7.x | Implement `search_view($module = NULL, $keys = '')` in PHP for Drupal 7. Required behavior: Menu callback; presents the search form and/or search results. | Parameters:
- $module: Search module to use for the search.
- $keys: Keywords to use for the search.
File: modules/search/search.pages.inc | function search_view($module = NULL, $keys = '') {
$info = FALSE;
$keys = trim($keys);
// Also try to pull search keywords out of the $_REQUEST variable to
// support old GET format of searches for existing links.
if (!$keys && !empty($_REQUEST['keys'])) {
$keys = trim($_REQUEST['keys']);
}
if (!empt... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-69ec240d1a | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21common.inc/function/drupal_parse_info_file/7.x | Implement `drupal_parse_info_file($filename)` in PHP for Drupal 7. Required behavior: Parses Drupal module and theme .info files. | Info files are NOT for placing arbitrary theme and module-specific settings. Use variable_get() and variable_set() for that.
Information stored in a module .info file:
- name: The real name of the module for display purposes.
- description: A brief description of the module.
- dependencies: An array of dependency stri... | function drupal_parse_info_file($filename) {
$info = &drupal_static(__FUNCTION__, array());
if (!isset($info[$filename])) {
if (!file_exists($filename)) {
$info[$filename] = array();
}
else {
$data = file_get_contents($filename);
$info[$filename] = drupal_parse_info_format($data);
... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-69ec520732 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21module.inc/function/module_load_all/7.x | I need the code for `module_load_all($bootstrap = FALSE)` in Drupal 7 (includes/module.inc). It must do this: Loads all the modules that have been enabled in the system table. | Parameters:
- $bootstrap: Whether to load only the reduced set of modules loaded in "bootstrap mode" for cached pages. See bootstrap.inc.
Returns: If $bootstrap is NULL, return a boolean indicating whether all modules have been loaded.
File: includes/module.inc | function module_load_all($bootstrap = FALSE) {
static $has_run = FALSE;
if (isset($bootstrap)) {
foreach (module_list(TRUE, $bootstrap) as $module) {
drupal_load('module', $module);
}
// $has_run will be TRUE if $bootstrap is FALSE.
$has_run = !$bootstrap;
}
return $has_run;
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-6a05eb52b4 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21xmlrpcs.inc/function/xmlrpc_server_set/7.x | I need the code for `xmlrpc_server_set($xmlrpc_server = NULL)` in Drupal 7 (includes/xmlrpcs.inc). It must do this: Stores a copy of an XML-RPC request temporarily. | Parameters:
- $xmlrpc_server (object): (optional) Request object created by xmlrpc_server(). Omit to leave the previous server object saved.
Returns: The latest stored request.
File: includes/xmlrpcs.inc | function xmlrpc_server_set($xmlrpc_server = NULL) {
static $server;
if (!isset($server)) {
$server = $xmlrpc_server;
}
return $server;
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-6a3c80e610 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21user%21user.module/function/user_mail_tokens/7.x | Implement `user_mail_tokens(&$replacements, $data, $options)` in PHP for Drupal 7. Required behavior: Token callback to add unsafe tokens for user mails. | This function is used by the token_replace() call at the end of _user_mail_text() to set up some additional tokens that can be used in email messages generated by user_mail().
Parameters:
- $replacements: An associative array variable containing mappings from token names to values (for use with strtr()).
- $data: An a... | function user_mail_tokens(&$replacements, $data, $options) {
if (isset($data['user'])) {
$replacements['[user:one-time-login-url]'] = user_pass_reset_url($data['user']);
$replacements['[user:cancel-url]'] = user_cancel_url($data['user']);
}
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-6a52dcf7af | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21tablesort.inc/function/tablesort_header/7.x | Implement `tablesort_header($cell, $header, $ts)` in PHP for Drupal 7. Required behavior: Formats a column header. | If the cell in question is the column header for the current sort criterion, it gets special formatting. All possible sort criteria become links.
Parameters:
- $cell: The cell to format.
- $header: An array of column headers in the format described in theme_table().
- $ts: The current table sort context as returned fr... | function tablesort_header($cell, $header, $ts) {
// Special formatting for the currently sorted column header.
if (is_array($cell) && isset($cell['field'])) {
$title = t('sort by @s', array('@s' => $cell['data']));
if ($cell['data'] == $ts['name']) {
$ts['sort'] = (($ts['sort'] == 'asc') ? 'desc' : 'a... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-6a5de77e11 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21user%21user.module/function/user_validate_mail/7.x | I need the code for `user_validate_mail($mail)` in Drupal 7 (modules/user/user.module). It must do this: Validates a user's email address. | Checks that a user's email address exists and follows all standard validation rules. Returns error messages when the address is invalid.
Parameters:
- $mail: A user's email address.
Returns: If the address is invalid, a human-readable error message is returned. If the address is valid, nothing is returned.
File: mod... | function user_validate_mail($mail) {
if (!$mail) {
return t('You must enter an e-mail address.');
}
if (!valid_email_address($mail)) {
return t('The e-mail address %mail is not valid.', array('%mail' => $mail));
}
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-6a6988b5ee | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21system.api.php/function/hook_install/7.x | Give me the example code for `hook_install()` in Drupal 7. Hook description: Perform setup tasks when the module is installed. | If the module implements hook_schema(), the database tables will be created before this hook is fired.
Implementations of this hook are by convention declared in the module's .install file. The implementation can rely on the .module file being loaded. The hook will only be called the first time a module is enabled or ... | function hook_install() {
// Populate the default {node_access} record.
db_insert('node_access')
->fields(array(
'nid' => 0,
'gid' => 0,
'realm' => 'all',
'grant_view' => 1,
'grant_update' => 0,
'grant_delete' => 0,
))
->execute();
} | [
"code-task",
"hook-definition"
] | 2026-09-30T00:00:00 |
api-drupal7-6a7b27c068 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21image%21image.effects.inc/function/image_scale_dimensions/7.x | In Drupal 7, write the function `image_scale_dimensions(array &$dimensions, array $data)` (file modules/image/image.effects.inc) so that it does the following: Image dimensions callback; Scale. | Parameters:
- $dimensions: Dimensions to be modified - an array with components width and height, in pixels.
- $data: An array of attributes to use when performing the scale effect with the following items: - "width": An integer representing the desired width in pixels. - "height": An integer representing the desired h... | function image_scale_dimensions(array &$dimensions, array $data) {
if ($dimensions['width'] && $dimensions['height']) {
image_dimensions_scale($dimensions, $data['width'], $data['height'], $data['upscale']);
}
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-6a9d58b737 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21file%21file.module/function/file_managed_file_submit/7.x | Implement `file_managed_file_submit($form, &$form_state)` in PHP for Drupal 7. Required behavior: Form submission handler for upload / remove buttons of managed_file elements. | File: modules/file/file.module | function file_managed_file_submit($form, &$form_state) {
// Determine whether it was the upload or the remove button that was clicked,
// and set $element to the managed_file element that contains that button.
$parents = $form_state['triggering_element']['#array_parents'];
$button_key = array_pop($parents);
$... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-6a9da7861e | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21system.admin.inc/function/system_action_delete_orphans_post/7.x | In Drupal 7, write the function `system_action_delete_orphans_post($orphaned)` (file modules/system/system.admin.inc) so that it does the following: Post-deletion operations for deleting action orphans. | Parameters:
- $orphaned: An array of orphaned actions.
File: modules/system/system.admin.inc | function system_action_delete_orphans_post($orphaned) {
foreach ($orphaned as $callback) {
drupal_set_message(t("Deleted orphaned action (%action).", array('%action' => $callback)));
}
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-6aa12d0a0f | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21search%21search.pages.inc/function/template_preprocess_search_results/7.x | I need the code for `template_preprocess_search_results(&$variables)` in Drupal 7 (modules/search/search.pages.inc). It must do this: Process variables for search-results.tpl.php. | The $variables array contains the following arguments:
- $results: Search results array.
- $module: Module the search results came from (module implementing
hook_search_info()).
File: modules/search/search.pages.inc | function template_preprocess_search_results(&$variables) {
$variables['search_results'] = '';
if (!empty($variables['module'])) {
$variables['module'] = check_plain($variables['module']);
}
foreach ($variables['results'] as $result) {
$variables['search_results'] .= theme('search_result', array('result'... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-6aad95d755 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21form.inc/function/date_validate/7.x | I need the code for `date_validate($element)` in Drupal 7 (includes/form.inc). It must do this: Validates the date type to prevent invalid dates (e.g., February 30, 2006). | File: includes/form.inc | function date_validate($element) {
if (!checkdate($element['#value']['month'], $element['#value']['day'], $element['#value']['year'])) {
form_error($element, t('The specified date is invalid.'));
}
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-6ab8e4a76c | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21image.inc/function/image_toolkit_invoke/7.x | In Drupal 7, write the function `image_toolkit_invoke($method, stdClass $image, array $params = array())` (file includes/image.inc) so that it does the following: Invokes the given method using the currently selected toolkit. | Parameters:
- $method: A string containing the method to invoke.
- $image: An image object returned by image_load().
- $params: An optional array of parameters to pass to the toolkit method.
Returns (Mixed): values (typically Boolean indicating successful operation).
File: includes/image.inc | function image_toolkit_invoke($method, stdClass $image, array $params = array()) {
$function = 'image_' . $image->toolkit . '_' . $method;
if (function_exists($function)) {
array_unshift($params, $image);
return call_user_func_array($function, $params);
}
watchdog('image', 'The selected image handling t... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-6abd30ed7d | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21filter%21filter.admin.inc/function/filter_admin_disable/7.x | I need the code for `filter_admin_disable($form, &$form_state, $format)` in Drupal 7 (modules/filter/filter.admin.inc). It must do this: Form constructor for the text format deletion confirmation form. | Parameters:
- $format: An object representing a text format.
File: modules/filter/filter.admin.inc | function filter_admin_disable($form, &$form_state, $format) {
$form['#format'] = $format;
return confirm_form($form,
t('Are you sure you want to disable the text format %format?', array('%format' => $format->name)),
'admin/config/content/formats',
t('Disabled text formats are completely removed from th... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-6ac776a181 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21aggregator%21aggregator.admin.inc/function/aggregator_form_feed_submit/7.x | In Drupal 7, write the function `aggregator_form_feed_submit($form, &$form_state)` (file modules/aggregator/aggregator.admin.inc) so that it does the following: Form submission handler for aggregator_form_feed(). | File: modules/aggregator/aggregator.admin.inc | function aggregator_form_feed_submit($form, &$form_state) {
if ($form_state['values']['op'] == t('Delete')) {
$title = $form_state['values']['title'];
// Unset the title.
unset($form_state['values']['title']);
}
aggregator_save_feed($form_state['values']);
if (isset($form_state['values']['fid'])) {
... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-6ae233c400 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21install.core.inc/function/install_tasks_to_perform/7.x | In Drupal 7, write the function `install_tasks_to_perform($install_state)` (file includes/install.core.inc) so that it does the following: Returns a list of tasks to perform during the current installation request. | Note that the list of tasks can change based on the installation state as the page request evolves (for example, if an installation profile hasn't been selected yet, we don't yet know which profile tasks need to be run).
You can override this using hook_install_tasks() or hook_install_tasks_alter().
Parameters:
- $in... | function install_tasks_to_perform($install_state) {
// Start with a list of all currently available tasks.
$tasks = install_tasks($install_state);
foreach ($tasks as $name => $task) {
// Remove any tasks that were already performed or that never should run.
// Also, if we started this page request with an... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-6ae43153fd | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21field%21modules%21list%21list.module/function/list_field_validate/7.x | I need the code for `list_field_validate($entity_type, $entity, $field, $instance, $langcode, $items, &$errors)` in Drupal 7 (modules/field/modules/list/list.module). It must do this: Implements hook_field_validate(). | Possible error codes:
- 'list_illegal_value': The value is not part of the list of allowed values.
File: modules/field/modules/list/list.module | function list_field_validate($entity_type, $entity, $field, $instance, $langcode, $items, &$errors) {
// Flatten the array before validating to account for optgroups.
$allowed_values = options_array_flatten(list_allowed_values($field, $instance, $entity_type, $entity));
foreach ($items as $delta => $item) {
i... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-6afeb84641 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21common.inc/function/drupal_get_destination/7.x | I need the code for `drupal_get_destination()` in Drupal 7 (includes/common.inc). It must do this: Prepares a 'destination' URL query parameter for use with drupal_goto(). | Used to direct the user back to the referring page after completing a form. By default the current URL is returned. If a destination exists in the previous request, that destination is returned. As such, a destination can persist across multiple pages.
Returns: An associative array containing the key: - destination: T... | function drupal_get_destination() {
$destination = &drupal_static(__FUNCTION__);
if (isset($destination)) {
return $destination;
}
if (isset($_GET['destination'])) {
$destination = array('destination' => $_GET['destination']);
}
else {
$path = $_GET['q'];
$query = drupal_http_build_query(d... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-6b2a06693a | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21common.inc/function/drupal_render_page/7.x | Implement `drupal_render_page($page)` in PHP for Drupal 7. Required behavior: Renders the page, including all theming. | Parameters:
- $page: A string or array representing the content of a page. The array consists of the following keys: - #type: Value is always 'page'. This pushes the theming through page.tpl.php (required). - #show_messages: Suppress drupal_get_message() items. Used by Batch API (optional).
File: includes/common.inc | function drupal_render_page($page) {
$main_content_display = &drupal_static('system_main_content_added', FALSE);
// Allow menu callbacks to return strings or arbitrary arrays to render.
// If the array returned is not of #type page directly, we need to fill
// in the page with defaults.
if (is_string($page) ... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-6b37cf6994 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21overlay%21overlay.module/function/overlay_form_alter/7.x | Implement `overlay_form_alter(&$form, &$form_state)` in PHP for Drupal 7. Required behavior: Implements hook_form_alter(). | File: modules/overlay/overlay.module | function overlay_form_alter(&$form, &$form_state) {
// Add a hidden element to prevent dropping out of the overlay when a form is
// submitted inside the overlay using a GET method.
if (isset($form['#method']) && $form['#method'] == 'get' && isset($_REQUEST['render']) && $_REQUEST['render'] == 'overlay' && !isset... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-6b3b9dc248 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21overlay%21overlay.module/function/overlay_batch_alter/7.x | I need the code for `overlay_batch_alter(&$batch)` in Drupal 7 (modules/overlay/overlay.module). It must do this: Implements hook_batch_alter(). | If the current page request is inside the overlay, add ?render=overlay to the success callback URL, so that it appears correctly within the overlay.
File: modules/overlay/overlay.module | function overlay_batch_alter(&$batch) {
if (overlay_get_mode() == 'child') {
if (isset($batch['url_options']['query'])) {
$batch['url_options']['query']['render'] = 'overlay';
}
else {
$batch['url_options']['query'] = array('render' => 'overlay');
}
}
} | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-6b4c7c2e41 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21field%21field.attach.inc/function/_field_invoke_multiple_default/7.x | In Drupal 7, write the function `_field_invoke_multiple_default($op, $entity_type, $entities, &$a = NULL, &$b = NULL, $options = array())` (file modules/field/field.attach.inc) so that it does the following: Invoke field.module's version of a field hook on multiple entities. | This function invokes the field_default_[op]() function. Use _field_invoke_multiple() to invoke the field type implementation, hook_field_[op]().
File: modules/field/field.attach.inc | function _field_invoke_multiple_default($op, $entity_type, $entities, &$a = NULL, &$b = NULL, $options = array()) {
$options['default'] = TRUE;
return _field_invoke_multiple($op, $entity_type, $entities, $a, $b, $options);
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-6b5057c6f1 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21file%21file.module/function/file_icon_url/7.x | Implement `file_icon_url($file, $icon_directory = NULL)` in PHP for Drupal 7. Required behavior: Creates a URL to the icon for a file object. | Parameters:
- $file: A file object.
- $icon_directory: (optional) A path to a directory of icons to be used for files. Defaults to the value of the "file_icon_directory" variable.
Returns: A URL string to the icon, or FALSE if an appropriate icon cannot be found.
File: modules/file/file.module | function file_icon_url($file, $icon_directory = NULL) {
if ($icon_path = file_icon_path($file, $icon_directory)) {
return base_path() . $icon_path;
}
return FALSE;
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-6b64fa6bc6 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21book%21book.pages.inc/function/book_render/7.x | In Drupal 7, write the function `book_render()` (file modules/book/book.pages.inc) so that it does the following: Menu callback: Prints a listing of all books. | Returns (string): A HTML-formatted string with the listing of all books content.
File: modules/book/book.pages.inc | function book_render() {
$book_list = array();
foreach (book_get_books() as $book) {
$book_list[] = l($book['title'], $book['href'], $book['options']);
}
return theme('item_list', array('items' => $book_list));
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-6b65e69081 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/themes%21bartik%21template.php/function/bartik_process_page/7.x | In Drupal 7, write the function `bartik_process_page(&$variables)` (file themes/bartik/template.php) so that it does the following: Override or insert variables into the page template. | File: themes/bartik/template.php | function bartik_process_page(&$variables) {
// Hook into color.module.
if (module_exists('color')) {
_color_page_alter($variables);
}
// Always print the site name and slogan, but if they are toggled off, we'll
// just hide them visually.
$variables['hide_site_name'] = theme_get_setting('toggle_name')... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-6b7de5aae5 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21node%21node.module/function/node_delete_multiple/7.x | In Drupal 7, write the function `node_delete_multiple($nids)` (file modules/node/node.module) so that it does the following: Deletes multiple nodes. | Parameters:
- $nids: An array of node IDs.
File: modules/node/node.module | function node_delete_multiple($nids) {
$transaction = db_transaction();
if (!empty($nids)) {
$nodes = node_load_multiple($nids, array());
try {
foreach ($nodes as $nid => $node) {
// Call the node-specific callback (if any):
node_invoke($node, 'delete');
module_invoke_all('nod... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-6b81aec70e | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21dashboard%21dashboard.module/function/theme_dashboard_disabled_block/7.x | Implement `theme_dashboard_disabled_block($variables)` in PHP for Drupal 7. Required behavior: Returns HTML for disabled blocks, for use in dashboard customization mode. | Parameters:
- $variables: An associative array containing: - block: A block object from _block_rehash().
File: modules/dashboard/dashboard.module | function theme_dashboard_disabled_block($variables) {
extract($variables);
$output = "";
if (isset($block)) {
$output .= '<div id="block-' . $block['module'] . '-' . $block['delta']
. '" class="disabled-block block block-' . $block['module'] . '-' . $block['delta']
. ' module-' . $block['module'] . ' ... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-6ba00c9e45 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21poll%21poll.install/function/poll_update_7004/7.x | I need the code for `poll_update_7004()` in Drupal 7 (modules/poll/poll.install). It must do this: Update the database to match the schema. | File: modules/poll/poll.install | function poll_update_7004() {
// Remove field default.
db_change_field('poll_vote', 'chid', 'chid', array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE));
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-6bb980ae42 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21taxonomy%21taxonomy.module/function/taxonomy_field_widget_info_alter/7.x | In Drupal 7, write the function `taxonomy_field_widget_info_alter(&$info)` (file modules/taxonomy/taxonomy.module) so that it does the following: Implements hook_field_widget_info_alter(). | File: modules/taxonomy/taxonomy.module | function taxonomy_field_widget_info_alter(&$info) {
$info['options_select']['field types'][] = 'taxonomy_term_reference';
$info['options_buttons']['field types'][] = 'taxonomy_term_reference';
} | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-6bd2c024c0 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21menu.inc/function/menu_tree_set_path/7.x | Implement `menu_tree_set_path($menu_name, $path = NULL)` in PHP for Drupal 7. Required behavior: Sets the path for determining the active trail of the specified menu tree. | This path will also affect the breadcrumbs under some circumstances. Breadcrumbs are built using the preferred link returned by menu_link_get_preferred(). If the preferred link is inside one of the menus specified in calls to menu_tree_set_path(), the preferred link will be overridden by the corresponding path returned... | function menu_tree_set_path($menu_name, $path = NULL) {
$paths = &drupal_static(__FUNCTION__);
if (isset($path)) {
$paths[$menu_name] = $path;
}
return isset($paths[$menu_name]) ? $paths[$menu_name] : NULL;
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-6c044f41f9 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21statistics%21statistics.admin.inc/function/statistics_top_referrers/7.x | Implement `statistics_top_referrers()` in PHP for Drupal 7. Required behavior: Page callback: Displays the "top referrers" in the access logs. | This displays the pages with the top referrers in a given time interval that haven't been flushed yet. The flush interval is set on the statistics settings form, but is dependent on cron running.
Returns: A render array containing the top referrers information.
File: modules/statistics/statistics.admin.inc | function statistics_top_referrers() {
drupal_set_title(t('Top referrers in the past %interval', array('%interval' => format_interval(variable_get('statistics_flush_accesslog_timer', 259200)))), PASS_THROUGH);
$header = array(
array('data' => t('Hits'), 'field' => 'hits', 'sort' => 'desc'),
array('data' => ... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-6c10b9ceff | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21ajax.inc/function/ajax_footer/7.x | I need the code for `ajax_footer()` in Drupal 7 (includes/ajax.inc). It must do this: Performs end-of-Ajax-request tasks. | This function is the equivalent of drupal_page_footer(), but for Ajax requests.
File: includes/ajax.inc | function ajax_footer() {
// Even for Ajax requests, invoke hook_exit() implementations. There may be
// modules that need very fast Ajax responses, and therefore, run Ajax
// requests with an early bootstrap.
if (drupal_get_bootstrap_phase() == DRUPAL_BOOTSTRAP_FULL && (!defined('MAINTENANCE_MODE') || MAINTENAN... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-6c15f1f9e2 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21shortcut%21shortcut.module/function/shortcut_theme/7.x | In Drupal 7, write the function `shortcut_theme()` (file modules/shortcut/shortcut.module) so that it does the following: Implements hook_theme(). | File: modules/shortcut/shortcut.module | function shortcut_theme() {
return array(
'shortcut_set_customize' => array(
'render element' => 'form',
'file' => 'shortcut.admin.inc',
),
);
} | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-6c291e2e93 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21file.inc/function/file_usage_delete/7.x | Implement `file_usage_delete(stdClass $file, $module, $type = NULL, $id = NULL, $count = 1)` in PHP for Drupal 7. Required behavior: Removes a record to indicate that a module is no longer using a file. | The file_delete() function is typically called after removing a file usage to remove the record from the file_managed table and delete the file itself.
Parameters:
- $file: A file object.
- $module: The name of the module using the file.
- $type: (optional) The type of the object that contains the referenced file. May... | function file_usage_delete(stdClass $file, $module, $type = NULL, $id = NULL, $count = 1) {
// Delete rows that have a exact or less value to prevent empty rows.
$query = db_delete('file_usage')
->condition('module', $module)
->condition('fid', $file->fid);
if ($type && $id) {
$query
->condition... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-6c310dc2f2 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21block%21block.install/function/block_update_7003/7.x | I need the code for `block_update_7003()` in Drupal 7 (modules/block/block.install). It must do this: Change the weight column to normal int. | File: modules/block/block.install | function block_update_7003() {
db_change_field('block', 'weight', 'weight', array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'description' => 'Block weight within region.',
), array(
'indexes' => array(
'list' => array('theme', 'status', 'region', 'weight', 'module'),
),
)... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-6c59f44d30 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21locale%21locale.module/function/locale_permission/7.x | In Drupal 7, write the function `locale_permission()` (file modules/locale/locale.module) so that it does the following: Implements hook_permission(). | File: modules/locale/locale.module | function locale_permission() {
return array(
'administer languages' => array(
'title' => t('Administer languages'),
),
'translate interface' => array(
'title' => t('Translate interface texts'),
'restrict access' => TRUE,
),
);
} | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-6c7e6309a6 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21user%21user.install/function/user_update_7002/7.x | In Drupal 7, write the function `user_update_7002(&$sandbox)` (file modules/user/user.install) so that it does the following: Convert user time zones from time zone offsets to time zone names. | File: modules/user/user.install | function user_update_7002(&$sandbox) {
$sandbox['#finished'] = 0;
// Multi-part update.
if (!isset($sandbox['user_from'])) {
db_change_field('users', 'timezone', 'timezone', array('type' => 'varchar', 'length' => 32, 'not null' => FALSE));
$sandbox['user_from'] = 0;
$sandbox['user_count'] = db_query(... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-6c94185a7b | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21poll%21poll.module/function/poll_cancel_form/7.x | In Drupal 7, write the function `poll_cancel_form($form, &$form_state, $nid)` (file modules/poll/poll.module) so that it does the following: Builds the cancel form for a poll. | File: modules/poll/poll.module | function poll_cancel_form($form, &$form_state, $nid) {
$form_state['cache'] = TRUE;
// Store the nid so we can get to it in submit functions.
$form['#nid'] = $nid;
$form['actions'] = array('#type' => 'actions');
$form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => t('Cancel your vote... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-6ca5d96ac1 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21menu.inc/function/menu_cache_clear/7.x | In Drupal 7, write the function `menu_cache_clear($menu_name = 'navigation')` (file includes/menu.inc) so that it does the following: Clears the cached data for a single named menu. | File: includes/menu.inc | function menu_cache_clear($menu_name = 'navigation') {
$cache_cleared = &drupal_static(__FUNCTION__, array());
if (empty($cache_cleared[$menu_name])) {
cache_clear_all('links:' . $menu_name . ':', 'cache_menu', TRUE);
$cache_cleared[$menu_name] = 1;
}
elseif ($cache_cleared[$menu_name] == 1) {
drup... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-6cb68e71e9 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21node%21node.admin.inc/function/node_configure_rebuild_confirm/7.x | In Drupal 7, write the function `node_configure_rebuild_confirm()` (file modules/node/node.admin.inc) so that it does the following: Menu callback: confirm rebuilding of permissions. | File: modules/node/node.admin.inc | function node_configure_rebuild_confirm() {
return confirm_form(array(), t('Are you sure you want to rebuild the permissions on site content?'),
'admin/reports/status', t('This action rebuilds all permissions on site content, and may be a lengthy process. This action cannot be undone.'), t('Rebuild ... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-6cca0b826e | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21filter%21filter.module/function/filter_list_format/7.x | In Drupal 7, write the function `filter_list_format($format_id)` (file modules/filter/filter.module) so that it does the following: Retrieves a list of filters for a given text format. | Note that this function returns all associated filters regardless of whether they are enabled or disabled. All functions working with the filter information outside of filter administration should test for $filter->status before performing actions with the filter.
Parameters:
- $format_id: The format ID to retrieve fi... | function filter_list_format($format_id) {
$filters = &drupal_static(__FUNCTION__, array());
$filter_info = filter_get_filters();
if (!isset($filters['all'])) {
if ($cache = cache_get('filter_list_format')) {
$filters['all'] = $cache->data;
}
else {
$result = db_query('SELECT * FROM {filte... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-6ce913f4f4 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21forum%21forum.module/function/forum_node_presave/7.x | In Drupal 7, write the function `forum_node_presave($node)` (file modules/forum/forum.module) so that it does the following: Implements hook_node_presave(). | Assigns the forum taxonomy when adding a topic from within a forum.
File: modules/forum/forum.module | function forum_node_presave($node) {
if (_forum_node_check_node_type($node)) {
// Make sure all fields are set properly:
$node->icon = !empty($node->icon) ? $node->icon : '';
reset($node->taxonomy_forums);
$langcode = key($node->taxonomy_forums);
if (!empty($node->taxonomy_forums[$langcode])) {
... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-6ceabe0007 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21system.api.php/function/hook_modules_disabled/7.x | In Drupal 7, show an example implementation for `hook_modules_disabled($modules)` (modules/system/system.api.php): Perform necessary actions after modules are disabled. | This function differs from hook_disable() in that it gives all other modules a chance to perform actions when modules are disabled, whereas hook_disable() is only called on the module actually being disabled.
Parameters:
- $modules: An array of the modules that were disabled.
File: modules/system/system.api.php | function hook_modules_disabled($modules) {
if (in_array('lousy_module', $modules)) {
mymodule_enable_functionality();
}
} | [
"code-task",
"hook-definition"
] | 2026-09-30T00:00:00 |
api-drupal7-6cefd5aabc | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21contextual%21contextual.module/function/contextual_help/7.x | Implement `contextual_help($path, $arg)` in PHP for Drupal 7. Required behavior: Implements hook_help(). | File: modules/contextual/contextual.module | function contextual_help($path, $arg) {
switch ($path) {
case 'admin/help#contextual':
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
$output .= '<p>' . t('The Contextual links module displays links related to regions of pages on your site to users with <em>access contextual links</em> ... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-6d00f5d64f | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21image%21image.field.inc/function/image_field_formatter_info/7.x | In Drupal 7, write the function `image_field_formatter_info()` (file modules/image/image.field.inc) so that it does the following: Implements hook_field_formatter_info(). | File: modules/image/image.field.inc | function image_field_formatter_info() {
$formatters = array(
'image' => array(
'label' => t('Image'),
'field types' => array('image'),
'settings' => array('image_style' => '', 'image_link' => ''),
),
);
return $formatters;
} | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-6d1b2c0724 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21system.api.php/function/hook_menu_get_item_alter/7.x | Give me the example code for `hook_menu_get_item_alter(&$router_item, $path, $original_map)` in Drupal 7. Hook description: Alter a menu router item right after it has been retrieved from the database or cache. | This hook is invoked by menu_get_item() and allows for run-time alteration of router information (page_callback, title, and so on) before it is translated and checked for access. The passed-in $router_item is statically cached for the current request, so this hook is only invoked once for any router item that is retrie... | function hook_menu_get_item_alter(&$router_item, $path, $original_map) {
// When retrieving the router item for the current path...
if ($path == $_GET['q']) {
// ...call a function that prepares something for this request.
mymodule_prepare_something();
}
} | [
"code-task",
"hook-definition"
] | 2026-09-30T00:00:00 |
api-drupal7-6d1b2ed5c8 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21field%21modules%21number%21number.install/function/number_field_schema/7.x | I need the code for `number_field_schema($field)` in Drupal 7 (modules/field/modules/number/number.install). It must do this: Implements hook_field_schema(). | File: modules/field/modules/number/number.install | function number_field_schema($field) {
switch ($field['type']) {
case 'number_integer' :
$columns = array(
'value' => array(
'type' => 'int',
'not null' => FALSE
),
);
break;
case 'number_float' :
$columns = array(
'value' => array(
... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-6d4433fa52 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21actions.inc/function/actions_actions_map/7.x | Implement `actions_actions_map($actions)` in PHP for Drupal 7. Required behavior: Creates an associative array keyed by hashes of function names or IDs. | Hashes are used to prevent actual function names from going out into HTML forms and coming back.
Parameters:
- $actions: An associative array with function names or action IDs as keys and associative arrays with keys 'label', 'type', etc. as values. This is usually the output of actions_list() or actions_get_all_actio... | function actions_actions_map($actions) {
$actions_map = array();
foreach ($actions as $callback => $array) {
$key = drupal_hash_base64($callback);
$actions_map[$key]['callback'] = isset($array['callback']) ? $array['callback'] : $callback;
$actions_map[$key]['label'] = $array['label'];
$a... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-6d5af760c9 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21update.inc/function/update_fix_d7_install_profile/7.x | Implement `update_fix_d7_install_profile()` in PHP for Drupal 7. Required behavior: Register the currently installed profile in the system table. | Installation profiles are now treated as modules by Drupal, and have an upgrade path based on their schema version in the system table.
The installation profile will be set to schema_version 0, as it has already been installed. Any other hook_update_N functions provided by the installation profile will be run by updat... | function update_fix_d7_install_profile() {
$profile = drupal_get_profile();
// 'Default' profile has been renamed to 'Standard' in D7.
// We change the profile here to prevent a broken record in the system table.
// See system_update_7049().
if ($profile == 'default') {
$profile = 'standard';
variabl... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-6d65949e70 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21block%21block.module/function/block_page_build/7.x | Implement `block_page_build(&$page)` in PHP for Drupal 7. Required behavior: Implements hook_page_build(). | Renders blocks into their regions.
File: modules/block/block.module | function block_page_build(&$page) {
global $theme;
// The theme system might not yet be initialized. We need $theme.
drupal_theme_initialize();
// Fetch a list of regions for the current theme.
$all_regions = system_region_list($theme);
$item = menu_get_item();
if ($item === FALSE || $item['path'] != '... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-6d7066c57a | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21update%21update.authorize.inc/function/update_authorize_install_batch_finished/7.x | I need the code for `update_authorize_install_batch_finished($success, $results)` in Drupal 7 (modules/update/update.authorize.inc). It must do this: Implements callback_batch_finished(). | Performs actions when the authorized install batch is done.
This processes the results and stashes them into SESSION such that authorize.php will render a report. Also responsible for putting the site back online after a successful install if necessary.
Parameters:
- $success: TRUE if the batch operation was a succes... | function update_authorize_install_batch_finished($success, $results) {
foreach ($results['log'] as $project => $messages) {
if (!empty($messages['#abort'])) {
$success = FALSE;
}
}
$offline = variable_get('maintenance_mode', FALSE);
if ($success) {
// Take the site out of maintenance mode if i... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-6d8d0618bd | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21shortcut%21shortcut.admin.inc/function/shortcut_link_edit/7.x | Implement `shortcut_link_edit($form, &$form_state, $shortcut_link)` in PHP for Drupal 7. Required behavior: Form callback: builds the form for editing a shortcut link. | Parameters:
- $form: An associative array containing the structure of the form.
- $form_state: An associative array containing the current state of the form.
- $shortcut_link: An array representing the link that is being edited.
Returns: An array representing the form definition.
File: modules/shortcut/shortcut.admin... | function shortcut_link_edit($form, &$form_state, $shortcut_link) {
drupal_set_title(t('Editing @shortcut', array('@shortcut' => $shortcut_link['link_title'])));
$form['original_shortcut_link'] = array(
'#type' => 'value',
'#value' => $shortcut_link,
);
$form += _shortcut_link_form_elements($shortcut_lin... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-6d8e9668b9 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_get_setting/7.x | In Drupal 7, write the function `theme_get_setting($setting_name, $theme = NULL)` (file includes/theme.inc) so that it does the following: Retrieves a setting for the current theme or for a given theme. | The final setting is obtained from the last value found in the following
sources:
- the default global settings specified in this function
- the default theme-specific settings defined in any base theme's .info file
- the default theme-specific settings defined in the theme's .info file
- the saved values from the glob... | function theme_get_setting($setting_name, $theme = NULL) {
$cache = &drupal_static(__FUNCTION__, array());
// If no key is given, use the current theme if we can determine it.
if (!isset($theme)) {
$theme = !empty($GLOBALS['theme_key']) ? $GLOBALS['theme_key'] : '';
}
if (empty($cache[$theme])) {
//... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-6da66e2b08 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21system.module/function/system_check_http_request/7.x | I need the code for `system_check_http_request()` in Drupal 7 (modules/system/system.module). It must do this: Checks whether the server is capable of issuing HTTP requests. | The function sets the drupal_http_request_fail system variable to TRUE if drupal_http_request() does not work and then the system status report page will contain an error.
Returns: TRUE if this installation can issue HTTP requests.
File: modules/system/system.module | function system_check_http_request() {
// Try to get the content of the front page via drupal_http_request().
$result = drupal_http_request(url('', array('absolute' => TRUE)), array('max_redirects' => 0));
// We only care that we get a http response - this means that Drupal
// can make a http request.
$works ... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-6dbd52c2f5 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21system.admin.inc/function/system_add_date_format_type_form_validate/7.x | In Drupal 7, write the function `system_add_date_format_type_form_validate($form, &$form_state)` (file modules/system/system.admin.inc) so that it does the following: Validate system_add_date_format_type form submissions. | File: modules/system/system.admin.inc | function system_add_date_format_type_form_validate($form, &$form_state) {
if (!empty($form_state['values']['machine_name']) && !empty($form_state['values']['date_type'])) {
if (!preg_match("/^[a-zA-Z0-9_]+$/", trim($form_state['values']['machine_name']))) {
form_set_error('machine_name', t('The date type mu... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-6dc23fd5cc | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21node%21node.install/function/node_update_7013/7.x | I need the code for `node_update_7013()` in Drupal 7 (modules/node/node.install). It must do this: Change {node}.vid default value from 0 to NULL to avoid deadlock issues on MySQL. | File: modules/node/node.install | function node_update_7013() {
db_drop_unique_key('node', 'vid');
db_change_field('node', 'vid', 'vid', array(
'description' => 'The current {node_revision}.vid version identifier.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => FALSE,
'default' => NULL,
));
db_add_unique_key('node', 'vi... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-6dc2f61caa | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21menu.inc/function/_menu_site_is_offline/7.x | Implement `_menu_site_is_offline($check_only = FALSE)` in PHP for Drupal 7. Required behavior: Checks whether the site is in maintenance mode. | This function will log the current user out and redirect to front page if the current user has no 'access site in maintenance mode' permission.
Parameters:
- $check_only: If this is set to TRUE, the function will perform the access checks and return the site offline status, but not log the user out or display any mess... | function _menu_site_is_offline($check_only = FALSE) {
// Check if site is in maintenance mode.
if (variable_get('maintenance_mode', 0)) {
if (user_access('access site in maintenance mode')) {
// Ensure that the maintenance mode message is displayed only once
// (allowing for page redirects) and spec... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-6dc4584e76 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21common.inc/function/format_rss_channel/7.x | In Drupal 7, write the function `format_rss_channel($title, $link, $description, $items, $langcode = NULL, $args = array())` (file includes/common.inc) so that it does the following: Formats an RSS channel. | Arbitrary elements may be added using the $args associative array.
File: includes/common.inc | function format_rss_channel($title, $link, $description, $items, $langcode = NULL, $args = array()) {
global $language_content;
$langcode = $langcode ? $langcode : $language_content->language;
$output = "<channel>\n";
$output .= ' <title>' . check_plain($title) . "</title>\n";
$output .= ' <link>' . check_ur... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-6de734f255 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21system.api.php/function/hook_updater_info/7.x | In Drupal 7, show an example implementation for `hook_updater_info()` (modules/system/system.api.php): Provide information on Updaters (classes that can update Drupal). | An Updater is a class that knows how to update various parts of the Drupal file system, for example to update modules that have newer releases, or to install a new theme.
Returns: An associative array of information about the updater(s) being provided. This array is keyed by a unique identifier for each updater, and t... | function hook_updater_info() {
return array(
'module' => array(
'class' => 'ModuleUpdater',
'name' => t('Update modules'),
'weight' => 0,
),
'theme' => array(
'class' => 'ThemeUpdater',
'name' => t('Update themes'),
'weight' => 0,
),
);
} | [
"code-task",
"hook-definition"
] | 2026-09-30T00:00:00 |
api-drupal7-6e1923d743 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21database%21database.inc/function/db_query_range/7.x | I need the code for `db_query_range($query, $from, $count, array $args = array(), array $options = array())` in Drupal 7 (includes/database/database.inc). It must do this: Executes a query against the active database, restricted to a range. | Parameters:
- $query: The prepared statement query to run. Although it will accept both named and unnamed placeholders, named placeholders are strongly preferred as they are more self-documenting.
- $from: The first record from the result set to return.
- $count: The number of records to return from the result set.
- $... | function db_query_range($query, $from, $count, array $args = array(), array $options = array()) {
if (empty($options['target'])) {
$options['target'] = 'default';
}
return Database::getConnection($options['target'])->queryRange($query, $from, $count, $args, $options);
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-6e2a481d31 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21image.gd.inc/function/image_gd_rotate/7.x | Implement `image_gd_rotate(stdClass $image, $degrees, $background = NULL)` in PHP for Drupal 7. Required behavior: Rotate an image the given number of degrees. | Parameters:
- $image: An image object. The $image->resource, $image->info['width'], and $image->info['height'] values will be modified by this call.
- $degrees: The number of (clockwise) degrees to rotate the image.
- $background: An hexadecimal integer specifying the background color to use for the uncovered area of t... | function image_gd_rotate(stdClass $image, $degrees, $background = NULL) {
// PHP installations using non-bundled GD do not have imagerotate.
if (!function_exists('imagerotate')) {
watchdog('image', 'The image %file could not be rotated because the imagerotate() function is not available in this PHP installation... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-6e4c41ab34 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21path.inc/function/drupal_cache_system_paths/7.x | I need the code for `drupal_cache_system_paths()` in Drupal 7 (includes/path.inc). It must do this: Cache system paths for a page. | Cache an array of the system paths available on each page. We assume that aliases will be needed for the majority of these paths during subsequent requests, and load them in a single query during drupal_lookup_path().
File: includes/path.inc | function drupal_cache_system_paths() {
// Check if the system paths for this page were loaded from cache in this
// request to avoid writing to cache on every request.
$cache = &drupal_static('drupal_lookup_path', array());
if (empty($cache['system_paths']) && !empty($cache['map'])) {
// Generate a cache ID... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-6e4dcece98 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21field%21field.api.php/function/hook_field_extra_fields_alter/7.x | In Drupal 7, show an example implementation for `hook_field_extra_fields_alter(&$info)` (modules/field/field.api.php): Alter "pseudo-field" components on fieldable entities. | Parameters:
- $info: The associative array of 'pseudo-field' components.
File: modules/field/field.api.php | function hook_field_extra_fields_alter(&$info) {
// Force node title to always be at the top of the list by default.
foreach (node_type_get_types() as $bundle) {
if (isset($info['node'][$bundle->type]['form']['title'])) {
$info['node'][$bundle->type]['form']['title']['weight'] = -20;
}
}
} | [
"code-task",
"hook-definition"
] | 2026-09-30T00:00:00 |
api-drupal7-6e6c710c33 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21unicode.inc/function/drupal_substr/7.x | I need the code for `drupal_substr($text, $start, $length = NULL)` in Drupal 7 (includes/unicode.inc). It must do this: Cuts off a piece of a string based on character indices and counts. | Follows the same behavior as PHP's own substr() function. Note that for cutting off a string at a known character/substring location, the usage of PHP's normal strpos/substr is safe and much faster.
Parameters:
- $text: The input string.
- $start: The position at which to start reading.
- $length: The number of charac... | function drupal_substr($text, $start, $length = NULL) {
global $multibyte;
$text = (string) $text;
if ($multibyte == UNICODE_MULTIBYTE) {
return $length === NULL ? mb_substr($text, $start) : mb_substr($text, $start, $length);
}
else {
$strlen = strlen($text);
// Find the starting byte offset.
... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-6e70ec3993 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21date.inc/function/system_default_date_formats/7.x | In Drupal 7, write the function `system_default_date_formats()` (file includes/date.inc) so that it does the following: Provides a default system list of date formats for system_date_formats(). | File: includes/date.inc | function system_default_date_formats() {
$formats = array();
// Short date formats.
$formats[] = array(
'type' => 'short',
'format' => 'm/d/Y - H:i',
'locales' => array('en-us'),
);
$formats[] = array(
'type' => 'short',
'format' => 'd/m/Y - H:i',
'locales' => array('en-gb', 'en-hk', ... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-6e872f47d3 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21batch.inc/function/_batch_page/7.x | I need the code for `_batch_page()` in Drupal 7 (includes/batch.inc). It must do this: Renders the batch processing page based on the current state of the batch. | File: includes/batch.inc | function _batch_page() {
$batch = &batch_get();
if (!isset($_REQUEST['id'])) {
return FALSE;
}
// Retrieve the current state of the batch.
if (!$batch) {
$batch = batch_load($_REQUEST['id']);
if (!$batch) {
drupal_set_message(t('No active batch.'), 'error');
drupal_goto();
}
}
... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-6e8f5c833a | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21field%21field.module/function/field_theme/7.x | In Drupal 7, write the function `field_theme()` (file modules/field/field.module) so that it does the following: Implements hook_theme(). | File: modules/field/field.module | function field_theme() {
return array(
'field' => array(
'render element' => 'element',
),
'field_multiple_value_form' => array(
'render element' => 'element',
),
);
} | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-6e96590c4e | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21menu.inc/function/_menu_load_objects/7.x | In Drupal 7, write the function `_menu_load_objects(&$item, &$map)` (file includes/menu.inc) so that it does the following: Loads objects into the map as defined in the $item['load_functions']. | Parameters:
- $item: A menu router or menu link item
- $map: An array of path arguments; for example, array('node', '5').
Returns: Returns TRUE for success, FALSE if an object cannot be loaded. Names of object loading functions are placed in $item['load_functions']. Loaded objects are placed in $map[]; keys are the sa... | function _menu_load_objects(&$item, &$map) {
if ($load_functions = $item['load_functions']) {
// If someone calls this function twice, then unserialize will fail.
if (!is_array($load_functions)) {
$load_functions = unserialize($load_functions);
}
$path_map = $map;
foreach ($load_functions as... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-6eac85c83a | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21user%21user.admin.inc/function/user_admin_roles/7.x | I need the code for `user_admin_roles($form, $form_state)` in Drupal 7 (modules/user/user.admin.inc). It must do this: Form to re-order roles or add a new one. | File: modules/user/user.admin.inc | function user_admin_roles($form, $form_state) {
$roles = user_roles();
$role_weights = db_query('SELECT r.rid, r.weight FROM {role} r')->fetchAllKeyed();
$form['roles'] = array(
'#tree' => TRUE,
);
foreach ($roles as $rid => $name) {
$form['roles'][$rid]['#role'] = (object) array(
'rid' => $rid... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-6ec8d5b013 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21node%21node.pages.inc/function/node_add/7.x | I need the code for `node_add($type)` in Drupal 7 (modules/node/node.pages.inc). It must do this: Returns a node submission form. | Parameters:
- $type: The node type for the submitted node.
Returns: The themed form.
File: modules/node/node.pages.inc | function node_add($type) {
global $user;
$types = node_type_get_types();
$node = (object) array('uid' => $user->uid, 'name' => (isset($user->name) ? $user->name : ''), 'type' => $type, 'language' => LANGUAGE_NONE);
drupal_set_title(t('Create @name', array('@name' => $types[$type]->name)), PASS_THROUGH);
$out... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-6ecc460208 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21image%21image.module/function/theme_image_style/7.x | In Drupal 7, write the function `theme_image_style($variables)` (file modules/image/image.module) so that it does the following: Returns HTML for an image using a specific image style. | Parameters:
- $variables: An associative array containing: - style_name: The name of the style to be used to alter the original image. - path: The path of the image file relative to the Drupal files directory. This function does not work with images outside the files directory nor with remotely hosted images. This shou... | function theme_image_style($variables) {
// Determine the dimensions of the styled image.
$dimensions = array(
'width' => $variables['width'],
'height' => $variables['height'],
);
image_style_transform_dimensions($variables['style_name'], $dimensions);
$variables['width'] = $dimensions['width'];
$... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-6ecd84ab17 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21comment%21comment.api.php/function/hook_comment_load/7.x | In Drupal 7, show an example implementation for `hook_comment_load($comments)` (modules/comment/comment.api.php): Comments are being loaded from the database. | Parameters:
- $comments: An array of comment objects indexed by cid.
File: modules/comment/comment.api.php | function hook_comment_load($comments) {
$result = db_query('SELECT cid, foo FROM {mytable} WHERE cid IN (:cids)', array(':cids' => array_keys($comments)));
foreach ($result as $record) {
$comments[$record->cid]->foo = $record->foo;
}
} | [
"code-task",
"hook-definition"
] | 2026-09-30T00:00:00 |
api-drupal7-6ed0a10a44 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21field%21field.info.inc/function/field_behaviors_widget/7.x | In Drupal 7, write the function `field_behaviors_widget($op, $instance)` (file modules/field/field.info.inc) so that it does the following: Determines the behavior of a widget with respect to an operation. | Parameters:
- $op: The name of the operation. Currently supported: 'default value', 'multiple values'.
- $instance: The field instance array.
Returns: One of these values: - FIELD_BEHAVIOR_NONE: Do nothing for this operation. - FIELD_BEHAVIOR_CUSTOM: Use the widget's callback function. - FIELD_BEHAVIOR_DEFAULT: Use fi... | function field_behaviors_widget($op, $instance) {
$info = field_info_widget_types($instance['widget']['type']);
return isset($info['behaviors'][$op]) ? $info['behaviors'][$op] : FIELD_BEHAVIOR_DEFAULT;
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-6ee36ce534 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21file.inc/function/file_copy/7.x | In Drupal 7, write the function `file_copy(stdClass $source, $destination = NULL, $replace = FILE_EXISTS_RENAME)` (file includes/file.inc) so that it does the following: Copies a file to a new location and adds a file record to the database. | This function should be used when manipulating files that have records
stored in the database. This is a powerful function that in many ways
performs like an advanced version of copy().
- Checks if $source and $destination are valid and readable/writable.
- If file already exists in $destination either the call will er... | function file_copy(stdClass $source, $destination = NULL, $replace = FILE_EXISTS_RENAME) {
if (!file_valid_uri($destination)) {
if (($realpath = drupal_realpath($source->uri)) !== FALSE) {
watchdog('file', 'File %file (%realpath) could not be copied, because the destination %destination is invalid. This is ... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-6ee47a310f | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21common.inc/function/hide/7.x | I need the code for `hide(&$element)` in Drupal 7 (includes/common.inc). It must do this: Hides an element from later rendering. | The first time render() or drupal_render() is called on an element tree, as each element in the tree is rendered, it is marked with a #printed flag and the rendered children of the element are cached. Subsequent calls to render() or drupal_render() will not traverse the child tree of this element again: they will just ... | function hide(&$element) {
$element['#printed'] = TRUE;
return $element;
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-6f5caa8808 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/update.php/function/update_info_page/7.x | In Drupal 7, write the function `update_info_page()` (file update.php) so that it does the following: Provides an overview of the Drupal database update. | This page provides cautionary suggestions that should happen before proceeding with the update to ensure data integrity.
Returns: Rendered HTML form.
File: update.php | function update_info_page() {
// Change query-strings on css/js files to enforce reload for all users.
_drupal_flush_css_js();
// Flush the cache of all data for the update status module.
if (db_table_exists('cache_update')) {
cache_clear_all('*', 'cache_update', TRUE);
}
update_task_list('info');
dr... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-6f79a066ed | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21field%21field.info.inc/function/field_info_max_weight/7.x | Implement `field_info_max_weight($entity_type, $bundle, $context)` in PHP for Drupal 7. Required behavior: Returns the maximum weight of all the components in an entity. | This includes fields, 'extra_fields', and other components added by third-party modules (e.g. field_group).
Parameters:
- $entity_type: The type of entity; e.g. 'node' or 'user'.
- $bundle: The bundle name.
- $context: The context for which the maximum weight is requested. Either 'form', or the name of a view mode.
R... | function field_info_max_weight($entity_type, $bundle, $context) {
$weights = array();
// Collect weights for fields.
foreach (field_info_instances($entity_type, $bundle) as $instance) {
if ($context == 'form') {
$weights[] = $instance['widget']['weight'];
}
elseif (isset($instance['display'][$c... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-6f88306a86 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21contact%21contact.pages.inc/function/contact_site_form_submit/7.x | Implement `contact_site_form_submit($form, &$form_state)` in PHP for Drupal 7. Required behavior: Form submission handler for contact_site_form(). | File: modules/contact/contact.pages.inc | function contact_site_form_submit($form, &$form_state) {
global $user, $language;
$values = $form_state['values'];
$values['sender'] = clone $user;
$values['sender']->name = $values['name'];
$values['sender']->mail = $values['mail'];
$values['category'] = contact_load($values['cid']);
// Save the anonym... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-6f88ecc1cb | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21database%21database.inc/function/db_transaction/7.x | Implement `db_transaction($name = NULL, array $options = array())` in PHP for Drupal 7. Required behavior: Returns a new transaction object for the active database. | Parameters:
- $name (string): Optional name of the transaction.
- $options (array): An array of options to control how the transaction operates: - target: The database target name.
Returns: DatabaseTransaction A new DatabaseTransaction object for this connection.
File: includes/database/database.inc | function db_transaction($name = NULL, array $options = array()) {
if (empty($options['target'])) {
$options['target'] = 'default';
}
return Database::getConnection($options['target'])->startTransaction($name);
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-6f9e52b6e8 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21profile%21profile.module/function/profile_user_view/7.x | Implement `profile_user_view($account)` in PHP for Drupal 7. Required behavior: Implements hook_user_view(). | File: modules/profile/profile.module | function profile_user_view($account) {
// Show private fields to administrators and people viewing their own account.
if (user_access('administer users') || $GLOBALS['user']->uid == $account->uid) {
$result = db_query('SELECT * FROM {profile_field} WHERE visibility <> :hidden ORDER BY category, weight', array('... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-6fb41c3552 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21field%21modules%21text%21text.module/function/text_field_formatter_settings_form/7.x | I need the code for `text_field_formatter_settings_form($field, $instance, $view_mode, $form, &$form_state)` in Drupal 7 (modules/field/modules/text/text.module). It must do this: Implements hook_field_formatter_settings_form(). | File: modules/field/modules/text/text.module | function text_field_formatter_settings_form($field, $instance, $view_mode, $form, &$form_state) {
$display = $instance['display'][$view_mode];
$settings = $display['settings'];
$element = array();
if (strpos($display['type'], '_trimmed') !== FALSE) {
$element['trim_length'] = array(
'#title' => t('T... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-6fc7173f06 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21block%21block.module/function/block_block_view/7.x | In Drupal 7, write the function `block_block_view($delta = '')` (file modules/block/block.module) so that it does the following: Implements hook_block_view(). | Generates the administrator-defined blocks for display.
File: modules/block/block.module | function block_block_view($delta = '') {
$block = db_query('SELECT body, format FROM {block_custom} WHERE bid = :bid', array(':bid' => $delta))->fetchObject();
$data['subject'] = NULL;
$data['content'] = check_markup($block->body, $block->format, '', TRUE);
return $data;
} | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-6fca183d7a | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21theme.inc/function/template_preprocess_html/7.x | In Drupal 7, write the function `template_preprocess_html(&$variables)` (file includes/theme.inc) so that it does the following: Preprocess variables for html.tpl.php | File: includes/theme.inc | function template_preprocess_html(&$variables) {
// Compile a list of classes that are going to be applied to the body element.
// This allows advanced theming based on context (home page, node of certain type, etc.).
// Add a class that tells us whether we're on the front page or not.
$variables['classes_array... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-6fd2a7efc7 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21authorize.inc/function/authorize_get_filetransfer/7.x | I need the code for `authorize_get_filetransfer($backend, $settings = array())` in Drupal 7 (includes/authorize.inc). It must do this: Gets a FileTransfer class for a specific transfer method and settings. | Parameters:
- $backend: The FileTransfer backend to get the class for.
- $settings: Array of settings for the FileTransfer.
Returns: An instantiated FileTransfer object for the requested method and settings, or FALSE if there was an error finding or instantiating it.
File: includes/authorize.inc | function authorize_get_filetransfer($backend, $settings = array()) {
$filetransfer = FALSE;
if (!empty($_SESSION['authorize_filetransfer_info'][$backend])) {
$backend_info = $_SESSION['authorize_filetransfer_info'][$backend];
if (!empty($backend_info['file'])) {
$file = $backend_info['file path'] . '/... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-6fe2b6db5a | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21install.inc/function/drupal_get_schema_versions/7.x | I need the code for `drupal_get_schema_versions($module)` in Drupal 7 (includes/install.inc). It must do this: Returns an array of available schema versions for a module. | Parameters:
- $module: A module name.
Returns: If the module has updates, an array of available updates sorted by version. Otherwise, FALSE.
File: includes/install.inc | function drupal_get_schema_versions($module) {
$updates = &drupal_static(__FUNCTION__, NULL);
if (!isset($updates[$module])) {
$updates = array();
foreach (module_list() as $loaded_module) {
$updates[$loaded_module] = array();
}
// Prepare regular expression to match all possible defined hoo... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-6fe602137c | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21poll%21poll.tokens.inc/function/poll_tokens/7.x | In Drupal 7, write the function `poll_tokens($type, $tokens, array $data = array(), array $options = array())` (file modules/poll/poll.tokens.inc) so that it does the following: Implements hook_tokens(). | File: modules/poll/poll.tokens.inc | function poll_tokens($type, $tokens, array $data = array(), array $options = array()) {
$sanitize = !empty($options['sanitize']);
if (isset($options['language'])) {
$url_options['language'] = $options['language'];
$language_code = $options['language']->language;
}
else {
$language_code = NULL;
}
... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-6fffcbfe91 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21ajax.inc/function/ajax_set_verification_header/7.x | In Drupal 7, write the function `ajax_set_verification_header()` (file includes/ajax.inc) so that it does the following: Sets a response header for ajax.js to trust the response body. | It is not safe to invoke Ajax commands within user-uploaded files, so this header protects against those being invoked.
File: includes/ajax.inc | function ajax_set_verification_header() {
$added = &drupal_static(__FUNCTION__);
// User-uploaded files cannot set any response headers, so a custom header is
// used to indicate to ajax.js that this response is safe. Note that most
// Ajax requests bound using the Form API will be protected by having the URL
... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-70146ffe40 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21system.api.php/function/hook_element_info/7.x | Give me the example code for `hook_element_info()` in Drupal 7. Hook description: Allows modules to declare their own Form API element types and specify their default values. | This hook allows modules to declare their own form element types and to specify their default values. The values returned by this hook will be merged with the elements returned by hook_form() implementations and so can return defaults for any Form APIs keys in addition to those explicitly mentioned below.
Each of the ... | function hook_element_info() {
$types['filter_format'] = array(
'#input' => TRUE,
);
return $types;
} | [
"code-task",
"hook-definition"
] | 2026-09-30T00:00:00 |
api-drupal7-701c16853a | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21bootstrap.inc/function/drupal_check_trusted_hosts/7.x | I need the code for `drupal_check_trusted_hosts($host, array $host_patterns)` in Drupal 7 (includes/bootstrap.inc). It must do this: Checks trusted HTTP Host headers to protect against header injection attacks. | Parameters:
- $host (string|null): The host name.
- $host_patterns (array): The array of trusted host patterns.
Returns (bool): TRUE if the host is trusted, FALSE otherwise.
File: includes/bootstrap.inc | function drupal_check_trusted_hosts($host, array $host_patterns) {
if (!empty($host) && !empty($host_patterns)) {
// Trim and remove the port number from host; host is lowercase as per
// RFC 952/2181.
$host = strtolower(preg_replace('/:\d+$/', '', trim($host)));
foreach ($host_patterns as $pattern) ... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-70206a5b57 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21statistics%21statistics.module/function/statistics_get/7.x | Implement `statistics_get($nid)` in PHP for Drupal 7. Required behavior: Retrieves a node's "view statistics". | Parameters:
- $nid: The node ID.
Returns: An associative array containing: - totalcount: Integer for the total number of times the node has been viewed. - daycount: Integer for the total number of times the node has been viewed "today". For the daycount to be reset, cron must be enabled. - timestamp: Integer for the t... | function statistics_get($nid) {
if ($nid > 0) {
// Retrieve an array with both totalcount and daycount.
return db_query('SELECT totalcount, daycount, timestamp FROM {node_counter} WHERE nid = :nid', array(':nid' => $nid), array('target' => 'slave'))->fetchAssoc();
}
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-70315e3e08 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21node%21node.admin.inc/function/node_node_operations/7.x | Implement `node_node_operations()` in PHP for Drupal 7. Required behavior: Implements hook_node_operations(). | File: modules/node/node.admin.inc | function node_node_operations() {
$operations = array(
'publish' => array(
'label' => t('Publish selected content'),
'callback' => 'node_mass_update',
'callback arguments' => array('updates' => array('status' => NODE_PUBLISHED)),
),
'unpublish' => array(
'label' => t('Unpublish sel... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-7037dfcd88 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21node%21node.module/function/node_form_block_admin_configure_alter/7.x | Implement `node_form_block_admin_configure_alter(&$form, &$form_state)` in PHP for Drupal 7. Required behavior: Implements hook_form_FORMID_alter(). | Adds node-type specific visibility options to block configuration form.
File: modules/node/node.module | function node_form_block_admin_configure_alter(&$form, &$form_state) {
$default_type_options = db_query("SELECT type FROM {block_node_type} WHERE module = :module AND delta = :delta", array(
':module' => $form['module']['#value'],
':delta' => $form['delta']['#value'],
))->fetchCol();
$form['visibility']['... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-7047530ce2 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21node%21content_types.inc/function/node_type_form_validate/7.x | I need the code for `node_type_form_validate($form, &$form_state)` in Drupal 7 (modules/node/content_types.inc). It must do this: Form validation handler for node_type_form(). | File: modules/node/content_types.inc | function node_type_form_validate($form, &$form_state) {
$type = new stdClass();
$type->type = $form_state['values']['type'];
$type->name = trim($form_state['values']['name']);
// Work out what the type was before the user submitted this form
$old_type = $form_state['values']['old_type'];
$types = node_typ... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-7047557db8 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21shortcut%21shortcut.module/function/shortcut_renderable_links/7.x | I need the code for `shortcut_renderable_links($shortcut_set = NULL)` in Drupal 7 (modules/shortcut/shortcut.module). It must do this: Returns an array of shortcut links, suitable for rendering. | Parameters:
- $shortcut_set: (optional) An object representing the set whose links will be displayed. If not provided, the user's current set will be displayed.
Returns: An array of shortcut links, in the format returned by the menu system.
File: modules/shortcut/shortcut.module | function shortcut_renderable_links($shortcut_set = NULL) {
if (!isset($shortcut_set)) {
$shortcut_set = shortcut_current_displayed_set();
}
return menu_tree($shortcut_set->set_name);
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.