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-7055cb8ab0 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21field%21modules%21field_sql_storage%21field_sql_storage.install/function/field_sql_storage_schema/7.x | I need the code for `field_sql_storage_schema()` in Drupal 7 (modules/field/modules/field_sql_storage/field_sql_storage.install). It must do this: Implements hook_schema(). | File: modules/field/modules/field_sql_storage/field_sql_storage.install | function field_sql_storage_schema() {
$schema = array();
// Dynamic (data) tables.
if (db_table_exists('field_config')) {
$fields = field_read_fields(array(), array('include_deleted' => TRUE, 'include_inactive' => TRUE));
drupal_load('module', 'field_sql_storage');
foreach ($fields as $field) {
... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-7094e55c06 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21language.inc/function/language_types_info/7.x | I need the code for `language_types_info()` in Drupal 7 (includes/language.inc). It must do this: Returns all the defined language types. | Returns: An array of language type names. The name will be used as the global variable name the language value will be stored in.
File: includes/language.inc | function language_types_info() {
$language_types = &drupal_static(__FUNCTION__);
if (!isset($language_types)) {
$language_types = module_invoke_all('language_types_info');
// Let other modules alter the list of language types.
drupal_alter('language_types_info', $language_types);
}
return $languag... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-70c4011717 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21image%21image.module/function/image_style_save/7.x | I need the code for `image_style_save($style)` in Drupal 7 (modules/image/image.module). It must do this: Saves an image style. | Parameters:
- $style (array): An image style array containing: - name: A unique name for the style. - isid: (optional) An image style ID.
Returns (array): An image style array containing: - name: An unique name for the style. - old_name: The original name for the style. - isid: An image style ID. - is_new: TRUE if thi... | function image_style_save($style) {
if (isset($style['isid']) && is_numeric($style['isid'])) {
// Load the existing style to make sure we account for renamed styles.
$old_style = image_style_load(NULL, $style['isid']);
image_style_flush($old_style);
drupal_write_record('image_styles', $style, 'isid');... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-70c65a9107 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21comment%21comment.module/function/comment_file_download_access/7.x | In Drupal 7, write the function `comment_file_download_access($field, $entity_type, $entity)` (file modules/comment/comment.module) so that it does the following: Implements hook_file_download_access(). | File: modules/comment/comment.module | function comment_file_download_access($field, $entity_type, $entity) {
if ($entity_type == 'comment') {
if (user_access('access comments') && $entity->status == COMMENT_PUBLISHED || user_access('administer comments')) {
$node = node_load($entity->nid);
return node_access('view', $node);
}
retu... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-70d1b8af58 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21book%21book.module/function/book_block_info/7.x | Implement `book_block_info()` in PHP for Drupal 7. Required behavior: Implements hook_block_info(). | File: modules/book/book.module | function book_block_info() {
$block = array();
$block['navigation']['info'] = t('Book navigation');
$block['navigation']['cache'] = DRUPAL_CACHE_PER_PAGE | DRUPAL_CACHE_PER_ROLE;
return $block;
} | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-70d2c87afc | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21trigger%21trigger.module/function/trigger_user_view/7.x | In Drupal 7, write the function `trigger_user_view($account)` (file modules/trigger/trigger.module) so that it does the following: Implements hook_user_view(). | File: modules/trigger/trigger.module | function trigger_user_view($account) {
$edit = NULL;
_trigger_user('user_view', $edit, $account, NULL);
} | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-70e8278786 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21field%21field.crud.inc/function/field_create_field/7.x | In Drupal 7, write the function `field_create_field($field)` (file modules/field/field.crud.inc) so that it does the following: Creates a field. | This function does not bind the field to any bundle; use field_create_instance() for that.
Parameters:
- $field: A field definition array. The field_name and type properties are required. Other properties, if omitted, will be given the following default values: - cardinality: 1 - locked: FALSE - indexes: the field-typ... | function field_create_field($field) {
// Field name is required.
if (empty($field['field_name'])) {
throw new FieldException('Attempt to create an unnamed field.');
}
// Field type is required.
if (empty($field['type'])) {
throw new FieldException(format_string('Attempt to create field @field_name wit... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-70e8425395 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21taxonomy%21taxonomy.module/function/taxonomy_help/7.x | In Drupal 7, write the function `taxonomy_help($path, $arg)` (file modules/taxonomy/taxonomy.module) so that it does the following: Implements hook_help(). | File: modules/taxonomy/taxonomy.module | function taxonomy_help($path, $arg) {
switch ($path) {
case 'admin/help#taxonomy':
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
$output .= '<p>' . t('The Taxonomy module allows you to classify the content of your website. To classify content, you define <em>vocabularies</em> that cont... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-70f0513df2 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21dashboard%21dashboard.install/function/dashboard_enable/7.x | Implement `dashboard_enable()` in PHP for Drupal 7. Required behavior: Implements hook_enable(). | Restores blocks to the dashboard that were there when the dashboard module was disabled.
File: modules/dashboard/dashboard.install | function dashboard_enable() {
global $theme_key;
if (!$stashed_blocks = variable_get('dashboard_stashed_blocks')) {
return;
}
if (!$admin_theme = variable_get('admin_theme')) {
drupal_theme_initialize();
$admin_theme = $theme_key;
}
foreach ($stashed_blocks as $block) {
db_update('block')
... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-70ff188401 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21search%21search.module/function/template_preprocess_search_block_form/7.x | I need the code for `template_preprocess_search_block_form(&$variables)` in Drupal 7 (modules/search/search.module). It must do this: Process variables for search-block-form.tpl.php. | The $variables array contains the following arguments:
- $form
File: modules/search/search.module | function template_preprocess_search_block_form(&$variables) {
$variables['search'] = array();
$hidden = array();
// Provide variables named after form keys so themers can print each element independently.
foreach (element_children($variables['form']) as $key) {
$type = isset($variables['form'][$key]['#type'... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-7104365b88 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21theme.inc/function/_drupal_theme_access/7.x | I need the code for `_drupal_theme_access($theme)` in Drupal 7 (includes/theme.inc). It must do this: Helper function for determining access to a theme. | File: includes/theme.inc | function _drupal_theme_access($theme) {
$admin_theme = variable_get('admin_theme');
return !empty($theme->status) || ($admin_theme && $theme->name == $admin_theme);
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-710759b228 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21block%21block.install/function/block_install/7.x | I need the code for `block_install()` in Drupal 7 (modules/block/block.install). It must do this: Implements hook_install(). | File: modules/block/block.install | function block_install() {
// Block should go first so that other modules can alter its output
// during hook_page_alter(). Almost everything on the page is a block,
// so before block module runs, there will not be much to alter.
db_update('system')
->fields(array('weight' => -5))
->condition('name', ... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-711245a87d | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21field%21field.api.php/function/hook_field_attach_prepare_translation_alter/7.x | Give me the example code for `hook_field_attach_prepare_translation_alter(&$entity, $context)` in Drupal 7. Hook description: Perform alterations on field_attach_prepare_translation(). | This hook is invoked after the field module has performed the operation.
Parameters:
- $entity: The entity being prepared for translation.
- $context: An associative array containing: - entity_type: The type of $entity; e.g. 'node' or 'user'. - langcode: The language the entity has to be translated in. - source_entity... | function hook_field_attach_prepare_translation_alter(&$entity, $context) {
if ($context['entity_type'] == 'custom_entity_type') {
$entity->custom_field = $context['source_entity']->custom_field;
}
} | [
"code-task",
"hook-definition"
] | 2026-09-30T00:00:00 |
api-drupal7-71206eb8c5 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21forum%21forum.module/function/_forum_user_last_visit/7.x | Implement `_forum_user_last_visit($nid)` in PHP for Drupal 7. Required behavior: Gets the last time the user viewed a node. | Parameters:
- $nid: The node ID.
Returns: The timestamp when the user last viewed this node, if the user has previously viewed the node; otherwise NODE_NEW_LIMIT.
File: modules/forum/forum.module | function _forum_user_last_visit($nid) {
global $user;
$history = &drupal_static(__FUNCTION__, array());
if (empty($history)) {
$result = db_query('SELECT nid, timestamp FROM {history} WHERE uid = :uid', array(':uid' => $user->uid));
foreach ($result as $t) {
$history[$t->nid] = $t->timestamp > NODE... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-71251af70e | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21openid%21openid.inc/function/openid_redirect/7.x | I need the code for `openid_redirect($url, $message)` in Drupal 7 (modules/openid/openid.inc). It must do this: Creates a js auto-submit redirect for (for the 2.x protocol) | File: modules/openid/openid.inc | function openid_redirect($url, $message) {
global $language;
$output = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">' . "\n";
$output .= '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="' . $language->language . '" lang="' . $language->languag... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-712dbd583f | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21search%21search.module/function/search_comment_publish/7.x | I need the code for `search_comment_publish($comment)` in Drupal 7 (modules/search/search.module). It must do this: Implements hook_comment_publish(). | File: modules/search/search.module | function search_comment_publish($comment) {
// Reindex the node when comments are published.
search_touch_node($comment->nid);
} | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-718a1a4371 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21bootstrap.inc/function/_drupal_error_handler/7.x | Implement `_drupal_error_handler($error_level, $message, $filename, $line)` in PHP for Drupal 7. Required behavior: Provides custom PHP error handling. | Parameters:
- $error_level: The level of the error raised.
- $message: The error message.
- $filename: The filename that the error was raised in.
- $line: The line number the error was raised at.
File: includes/bootstrap.inc | function _drupal_error_handler($error_level, $message, $filename, $line) {
require_once DRUPAL_ROOT . '/includes/errors.inc';
_drupal_error_handler_real($error_level, $message, $filename, $line);
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-7192d6c651 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/update.php/function/update_check_requirements/7.x | Implement `update_check_requirements($skip_warnings = FALSE)` in PHP for Drupal 7. Required behavior: Checks update requirements and reports errors and (optionally) warnings. | Parameters:
- $skip_warnings: (optional) If set to TRUE, requirement warnings will be ignored, and a report will only be issued if there are requirement errors. Defaults to FALSE.
File: update.php | function update_check_requirements($skip_warnings = FALSE) {
// Check requirements of all loaded modules.
$requirements = module_invoke_all('requirements', 'update');
$requirements += update_extra_requirements();
$severity = drupal_requirements_severity($requirements);
// If there are errors, always display ... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-7195ca25ea | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21system.install/function/system_update_7045/7.x | I need the code for `system_update_7045()` in Drupal 7 (modules/system/system.install). It must do this: Add expiration field to the {flood} table. | File: modules/system/system.install | function system_update_7045() {
db_add_field('flood', 'expiration', array('description' => 'Expiration timestamp. Expired events are purged on cron run.', 'type' => 'int', 'not null' => TRUE, 'default' => 0));
db_add_index('flood', 'purge', array('expiration'));
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-719afa434e | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21file%21file.field.inc/function/file_field_instance_settings_form/7.x | In Drupal 7, write the function `file_field_instance_settings_form($field, $instance)` (file modules/file/file.field.inc) so that it does the following: Implements hook_field_instance_settings_form(). | File: modules/file/file.field.inc | function file_field_instance_settings_form($field, $instance) {
$settings = $instance['settings'];
$form['file_directory'] = array(
'#type' => 'textfield',
'#title' => t('File directory'),
'#default_value' => $settings['file_directory'],
'#description' => t('Optional subdirectory within the upload ... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-71b2264ca1 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21form.inc/function/theme_select/7.x | In Drupal 7, write the function `theme_select($variables)` (file includes/form.inc) so that it does the following: Returns HTML for a select form element. | It is possible to group options together; to do this, change the format of $options to an associative array in which the keys are group labels, and the values are associative arrays in the normal $options format.
Parameters:
- $variables: An associative array containing: - element: An associative array containing the ... | function theme_select($variables) {
$element = $variables['element'];
element_set_attributes($element, array('id', 'name', 'size'));
_form_set_class($element, array('form-select'));
return '<select' . drupal_attributes($element['#attributes']) . '>' . form_select_options($element) . '</select>';
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-71c6e11b56 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21block%21block.admin.inc/function/block_admin_display_form_submit/7.x | Implement `block_admin_display_form_submit($form, &$form_state)` in PHP for Drupal 7. Required behavior: Form submission handler for block_admin_display_form(). | File: modules/block/block.admin.inc | function block_admin_display_form_submit($form, &$form_state) {
$transaction = db_transaction();
try {
foreach ($form_state['values']['blocks'] as $block) {
$block['status'] = (int) ($block['region'] != BLOCK_REGION_NONE);
$block['region'] = $block['status'] ? $block['region'] : '';
db_update(... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-71ca1d9489 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21form.inc/function/form_process_tableselect/7.x | Implement `form_process_tableselect($element)` in PHP for Drupal 7. Required behavior: Creates checkbox or radio elements to populate a tableselect table. | Parameters:
- $element: An associative array containing the properties and children of the tableselect element.
Returns: The processed element.
File: includes/form.inc | function form_process_tableselect($element) {
if ($element['#multiple']) {
$value = is_array($element['#value']) ? $element['#value'] : array();
}
else {
// Advanced selection behavior makes no sense for radios.
$element['#js_select'] = FALSE;
}
$element['#tree'] = TRUE;
if (count($element['#... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-71d1eb2acd | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21taxonomy%21taxonomy.module/function/taxonomy_vocabulary_load/7.x | Implement `taxonomy_vocabulary_load($vid)` in PHP for Drupal 7. Required behavior: Return the vocabulary object matching a vocabulary ID. | Parameters:
- $vid: The vocabulary's ID.
Returns: The vocabulary object with all of its metadata, if exists, FALSE otherwise. Results are statically cached.
File: modules/taxonomy/taxonomy.module | function taxonomy_vocabulary_load($vid) {
$vocabularies = taxonomy_vocabulary_load_multiple(array($vid));
return reset($vocabularies);
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-71da3cb8a3 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21system.api.php/function/hook_query_TAG_alter/7.x | In Drupal 7, show an example implementation for `hook_query_TAG_alter(QueryAlterableInterface $query)` (modules/system/system.api.php): Perform alterations to a structured query for a given tag. | Parameters:
- $query: An Query object describing the composite parts of a SQL query.
File: modules/system/system.api.php | function hook_query_TAG_alter(QueryAlterableInterface $query) {
// Skip the extra expensive alterations if site has no node access control modules.
if (!node_access_view_all_nodes()) {
// Prevent duplicates records.
$query->distinct();
// The recognized operations are 'view', 'update', 'delete'.
if ... | [
"code-task",
"hook-definition"
] | 2026-09-30T00:00:00 |
api-drupal7-71f2ffa920 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21common.inc/function/drupal_html_id/7.x | I need the code for `drupal_html_id($id)` in Drupal 7 (includes/common.inc). It must do this: Prepares a string for use as a valid HTML ID and guarantees uniqueness. | This function ensures that each passed HTML ID value only exists once on the page. By tracking the already returned ids, this function enables forms, blocks, and other content to be output multiple times on the same page, without breaking (X)HTML validation.
For already existing IDs, a counter is appended to the ID st... | function drupal_html_id($id) {
// If this is an Ajax request, then content returned by this page request will
// be merged with content already on the base page. The HTML IDs must be
// unique for the fully merged content. Therefore, initialize $seen_ids to
// take into account IDs that are already in use on th... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-71fa503066 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21dblog%21dblog.module/function/dblog_cron/7.x | Implement `dblog_cron()` in PHP for Drupal 7. Required behavior: Implements hook_cron(). | Controls the size of the log table, paring it to 'dblog_row_limit' messages.
File: modules/dblog/dblog.module | function dblog_cron() {
// Cleanup the watchdog table.
$row_limit = variable_get('dblog_row_limit', 1000);
// For row limit n, get the wid of the nth row in descending wid order.
// Counting the most recent n rows avoids issues with wid number sequences,
// e.g. auto_increment value > 1 or rows deleted direc... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-720c93d061 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21node%21content_types.inc/function/node_node_type_update/7.x | In Drupal 7, write the function `node_node_type_update($info)` (file modules/node/content_types.inc) so that it does the following: Implements hook_node_type_update(). | File: modules/node/content_types.inc | function node_node_type_update($info) {
if (!empty($info->old_type) && $info->old_type != $info->type) {
$update_count = node_type_update_nodes($info->old_type, $info->type);
if ($update_count) {
drupal_set_message(format_plural($update_count, 'Changed the content type of 1 post from %old-type to %type... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-720f8cd87f | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21xmlrpc.inc/function/xmlrpc_error_get_xml/7.x | I need the code for `xmlrpc_error_get_xml($xmlrpc_error)` in Drupal 7 (includes/xmlrpc.inc). It must do this: Converts an XML-RPC error object into XML. | Parameters:
- $xmlrpc_error: The XML-RPC error object.
Returns (string): An XML representation of the error as an XML methodResponse.
File: includes/xmlrpc.inc | function xmlrpc_error_get_xml($xmlrpc_error) {
return <<<EOD
<methodResponse>
<fault>
<value>
<struct>
<member>
<name>faultCode</name>
<value><int>{$xmlrpc_error->code}</int></value>
</member>
<member>
<name>faultString</name>
<value><string>{$xmlrpc_error->message}</string... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-7237b1d430 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21ajax.inc/function/ajax_command_prepend/7.x | I need the code for `ajax_command_prepend($selector, $html, $settings = NULL)` in Drupal 7 (includes/ajax.inc). It must do this: Creates a Drupal Ajax 'insert/prepend' command. | The 'insert/prepend' command instructs the client to use jQuery's prepend() method to prepend the given HTML content to the inside each element matched by the given selector.
This command is implemented by Drupal.ajax.prototype.commands.insert() defined in misc/ajax.js.
Parameters:
- $selector: A jQuery selector stri... | function ajax_command_prepend($selector, $html, $settings = NULL) {
return array(
'command' => 'insert',
'method' => 'prepend',
'selector' => $selector,
'data' => $html,
'settings' => $settings,
);
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-72614e0c25 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21locale%21locale.module/function/locale_modules_enabled/7.x | Implement `locale_modules_enabled($modules)` in PHP for Drupal 7. Required behavior: Implements hook_modules_enabled(). | File: modules/locale/locale.module | function locale_modules_enabled($modules) {
include_once DRUPAL_ROOT . '/includes/language.inc';
language_types_set();
language_negotiation_purge();
} | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-7278c69428 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21openid%21openid.module/function/_openid_xri_discovery/7.x | I need the code for `_openid_xri_discovery($claimed_id)` in Drupal 7 (modules/openid/openid.module). It must do this: OpenID discovery method: perform an XRI discovery. | Returns: An array of discovered services and claimed identifier or NULL. See openid_discovery() for more specific information.
File: modules/openid/openid.module | function _openid_xri_discovery($claimed_id) {
if (_openid_is_xri($claimed_id)) {
// Resolve XRI using a proxy resolver (Extensible Resource Identifier (XRI)
// Resolution Version 2.0, section 11.2 and 14.3).
$xrds_url = variable_get('xri_proxy_resolver', 'http://xri.net/') . rawurlencode($claimed_id) . '?... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-727c7bf098 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21field_ui%21field_ui.admin.inc/function/field_ui_widget_type_options/7.x | In Drupal 7, write the function `field_ui_widget_type_options($field_type = NULL, $by_label = FALSE)` (file modules/field_ui/field_ui.admin.inc) so that it does the following: Returns an array of widget type options for a field type. | If no field type is provided, returns a nested array of all widget types, keyed by field type human name.
File: modules/field_ui/field_ui.admin.inc | function field_ui_widget_type_options($field_type = NULL, $by_label = FALSE) {
$options = &drupal_static(__FUNCTION__);
if (!isset($options)) {
$options = array();
$field_types = field_info_field_types();
foreach (field_info_widget_types() as $name => $widget_type) {
foreach ($widget_type['field ... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-72822bec42 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21aggregator%21aggregator.module/function/_aggregator_get_variables/7.x | I need the code for `_aggregator_get_variables()` in Drupal 7 (modules/aggregator/aggregator.module). It must do this: Gets the fetcher, parser, and processors. | Returns: An array containing the fetcher, parser, and processors.
File: modules/aggregator/aggregator.module | function _aggregator_get_variables() {
// Fetch the feed.
$fetcher = variable_get('aggregator_fetcher', 'aggregator');
if ($fetcher == 'aggregator') {
include_once DRUPAL_ROOT . '/' . drupal_get_path('module', 'aggregator') . '/aggregator.fetcher.inc';
}
$parser = variable_get('aggregator_parser', 'aggreg... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-728562fce6 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21registry.inc/function/registry_get_parsed_files/7.x | I need the code for `registry_get_parsed_files()` in Drupal 7 (includes/registry.inc). It must do this: Return the list of files in registry_file | File: includes/registry.inc | function registry_get_parsed_files() {
$files = array();
// We want the result as a keyed array.
$files = db_query("SELECT * FROM {registry_file}")->fetchAllAssoc('filename', PDO::FETCH_ASSOC);
return $files;
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-72b0e01cbe | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21form.inc/function/form_type_textfield_value/7.x | In Drupal 7, write the function `form_type_textfield_value($element, $input = FALSE)` (file includes/form.inc) so that it does the following: Determines the value for a textfield form element. | Parameters:
- $element: The form element whose value is being populated.
- $input: The incoming input to populate the form element. If this is FALSE, the element's default value should be returned.
Returns: The data that will appear in $form_state['values'] for this element, or nothing to use the default.
File: inclu... | function form_type_textfield_value($element, $input = FALSE) {
if ($input !== FALSE && $input !== NULL) {
// This should be a string, but allow other scalars since they might be
// valid input in programmatic form submissions.
if (!is_scalar($input)) {
$input = '';
}
return str_replace(array... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-72b5fcf9f8 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21book%21book.module/function/book_block_view/7.x | Implement `book_block_view($delta = '')` in PHP for Drupal 7. Required behavior: Implements hook_block_view(). | Displays the book table of contents in a block when the current page is a single-node view of a book node.
File: modules/book/book.module | function book_block_view($delta = '') {
$block = array();
$current_bid = 0;
if ($node = menu_get_object()) {
$current_bid = empty($node->book['bid']) ? 0 : $node->book['bid'];
}
if (variable_get('book_block_mode', 'all pages') == 'all pages') {
$block['subject'] = t('Book navigation');
$book_menu... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-72b6ceafd1 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21install.inc/function/drupal_uninstall_modules/7.x | Implement `drupal_uninstall_modules($module_list = array(), $uninstall_dependents = TRUE)` in PHP for Drupal 7. Required behavior: Uninstalls a given list of disabled modules. | Parameters:
- $module_list (string[]): The modules to uninstall. It is the caller's responsibility to ensure that all modules in this list have already been disabled before this function is called.
- $uninstall_dependents (bool): (optional) If TRUE, the function will check that all modules which depend on the passed-in... | function drupal_uninstall_modules($module_list = array(), $uninstall_dependents = TRUE) {
if ($uninstall_dependents) {
// Get all module data so we can find dependents and sort.
$module_data = system_rebuild_module_data();
// Create an associative array with weights as values.
$module_list = array_fli... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-72bc61cfaa | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21dashboard%21dashboard.module/function/theme_dashboard_admin/7.x | Implement `theme_dashboard_admin($variables)` in PHP for Drupal 7. Required behavior: Returns HTML for the non-customizable part of the dashboard page. | Parameters:
- $variables: An associative array containing: - element: A render element containing a #message.
File: modules/dashboard/dashboard.module | function theme_dashboard_admin($variables) {
// We only return a simple help message, since the actual content of the page
// will be populated via the dashboard regions in dashboard_page_build().
return '<div class="customize-dashboard js-hide">' . $variables['element']['#message'] . '</div>';
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-72da234adc | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21dashboard%21dashboard.module/function/dashboard_regions/7.x | In Drupal 7, write the function `dashboard_regions()` (file modules/dashboard/dashboard.module) so that it does the following: Returns an array of dashboard region names. | File: modules/dashboard/dashboard.module | function dashboard_regions() {
$regions = &drupal_static(__FUNCTION__);
if (!isset($regions)) {
$regions = array_keys(dashboard_region_descriptions());
}
return $regions;
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-72f3cf4ee5 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21node%21node.module/function/node_search_admin/7.x | Implement `node_search_admin()` in PHP for Drupal 7. Required behavior: Implements hook_search_admin(). | File: modules/node/node.module | function node_search_admin() {
// Output form for defining rank factor weights.
$form['content_ranking'] = array(
'#type' => 'fieldset',
'#title' => t('Content ranking'),
);
$form['content_ranking']['#theme'] = 'node_search_admin';
$form['content_ranking']['info'] = array(
'#markup' => '<p><em>' .... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-7310dc8abb | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21bootstrap.inc/function/language_default/7.x | I need the code for `language_default($property = NULL)` in Drupal 7 (includes/bootstrap.inc). It must do this: Returns the default language, as an object, or one of its properties. | Parameters:
- $property: (optional) The property of the language object to return.
Returns: Either the language object for the default language used on the site, or the property of that object named in the $property parameter.
File: includes/bootstrap.inc | function language_default($property = NULL) {
$language = variable_get('language_default', (object) array('language' => 'en', 'name' => 'English', 'native' => 'English', 'direction' => 0, 'enabled' => 1, 'plurals' => 0, 'formula' => '', 'domain' => '', 'prefix' => '', 'weight' => 0, 'javascript' => ''));
return $pr... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-7331594138 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21system.install/function/system_schema_cache_7054/7.x | In Drupal 7, write the function `system_schema_cache_7054()` (file modules/system/system.install) so that it does the following: The cache schema corresponding to system_update_7054. | Drupal 7 adds several new cache tables. Since they all have identical schema this helper function allows them to re-use the same definition, without relying on system_schema(), which may change with future updates.
File: modules/system/system.install | function system_schema_cache_7054() {
return array(
'description' => 'Generic cache table for caching things not separated out into their own tables. Contributed modules may also use this to store cached items.',
'fields' => array(
'cid' => array(
'description' => 'Primary Key: Unique cache ID.'... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-733f263db4 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21user%21user.module/function/user_menu_link_alter/7.x | In Drupal 7, write the function `user_menu_link_alter(&$link)` (file modules/user/user.module) so that it does the following: Implements hook_menu_link_alter(). | File: modules/user/user.module | function user_menu_link_alter(&$link) {
// The path 'user' must be accessible for anonymous users, but only visible
// for authenticated users. Authenticated users should see "My account", but
// anonymous users should not see it at all. Therefore, invoke
// user_translated_menu_link_alter() to conditionally hi... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-7348b8a6dc | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21comment%21comment.admin.inc/function/comment_multiple_delete_confirm_submit/7.x | Implement `comment_multiple_delete_confirm_submit($form, &$form_state)` in PHP for Drupal 7. Required behavior: Process comment_multiple_delete_confirm form submissions. | File: modules/comment/comment.admin.inc | function comment_multiple_delete_confirm_submit($form, &$form_state) {
if ($form_state['values']['confirm']) {
comment_delete_multiple(array_keys($form_state['values']['comments']));
cache_clear_all();
$count = count($form_state['values']['comments']);
watchdog('content', 'Deleted @count comments.', a... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-736a85dc0c | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21field%21modules%21field_sql_storage%21field_sql_storage.module/function/field_sql_storage_field_storage_update_field/7.x | I need the code for `field_sql_storage_field_storage_update_field($field, $prior_field, $has_data)` in Drupal 7 (modules/field/modules/field_sql_storage/field_sql_storage.module). It must do this: Implements hook_field_storage_update_field(). | File: modules/field/modules/field_sql_storage/field_sql_storage.module | function field_sql_storage_field_storage_update_field($field, $prior_field, $has_data) {
if (! $has_data) {
// There is no data. Re-create the tables completely.
if (Database::getConnection()->supportsTransactionalDDL()) {
// If the database supports transactional DDL, we can go ahead and rely
//... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-73729599a1 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21common.inc/function/drupal_set_page_content/7.x | Implement `drupal_set_page_content($content = NULL)` in PHP for Drupal 7. Required behavior: Sets the main page content value for later use. | Given the nature of the Drupal page handling, this will be called once with a string or array. We store that and return it later as the block is being displayed.
Parameters:
- $content: A string or renderable array representing the body of the page.
Returns: If called without $content, a renderable array representing... | function drupal_set_page_content($content = NULL) {
$content_block = &drupal_static(__FUNCTION__, NULL);
$main_content_display = &drupal_static('system_main_content_added', FALSE);
if (!empty($content)) {
$content_block = (is_array($content) ? $content : array('main' => array('#markup' => $content)));
}
... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-737db73ead | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21menu.inc/function/menu_execute_active_handler/7.x | I need the code for `menu_execute_active_handler($path = NULL, $deliver = TRUE)` in Drupal 7 (includes/menu.inc). It must do this: Execute the page callback associated with the current path. | Parameters:
- $path: The drupal path whose handler is to be be executed. If set to NULL, then the current path is used.
- $deliver: (optional) A boolean to indicate whether the content should be sent to the browser using the appropriate delivery callback (TRUE) or whether to return the result to the caller (FALSE).
Fi... | function menu_execute_active_handler($path = NULL, $deliver = TRUE) {
// Check if site is offline.
$page_callback_result = _menu_site_is_offline() ? MENU_SITE_OFFLINE : MENU_SITE_ONLINE;
// Allow other modules to change the site status but not the path because that
// would not change the global variable. hook... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-73930494a5 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21node%21node.module/function/node_page_default/7.x | In Drupal 7, write the function `node_page_default()` (file modules/node/node.module) so that it does the following: Menu callback: Generates a listing of promoted nodes. | Returns (array): An array in the format expected by drupal_render().
File: modules/node/node.module | function node_page_default() {
$select = db_select('node', 'n')
->fields('n', array('nid', 'sticky', 'created'))
->condition('n.promote', 1)
->condition('n.status', 1)
->orderBy('n.sticky', 'DESC')
->orderBy('n.created', 'DESC')
->extend('PagerDefault')
->limit(variable_get('default_nodes_... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-73a239e17a | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21image%21image.admin.inc/function/theme_image_style_preview/7.x | In Drupal 7, write the function `theme_image_style_preview($variables)` (file modules/image/image.admin.inc) so that it does the following: Returns HTML for a preview of an image style. | Parameters:
- $variables: An associative array containing: - style: The image style array being previewed.
File: modules/image/image.admin.inc | function theme_image_style_preview($variables) {
$style = $variables['style'];
$sample_image = variable_get('image_style_preview_image', drupal_get_path('module', 'image') . '/sample.png');
$sample_width = 160;
$sample_height = 160;
// Set up original file information.
$original_path = $sample_image;
$o... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-73af32b8ac | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21module.inc/function/module_exists/7.x | I need the code for `module_exists($module)` in Drupal 7 (includes/module.inc). It must do this: Determines whether a given module exists. | Parameters:
- $module (string): The name of the module (without the .module extension).
Returns (bool): TRUE if the module is both installed and enabled, FALSE otherwise.
File: includes/module.inc | function module_exists($module) {
$list = module_list();
return isset($list[$module]);
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-740f2fb92b | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21user%21user.module/function/user_form_field_ui_field_edit_form_alter/7.x | I need the code for `user_form_field_ui_field_edit_form_alter(&$form, &$form_state, $form_id)` in Drupal 7 (modules/user/user.module). It must do this: Implements hook_form_FORM_ID_alter(). | Add a checkbox for the 'user_register_form' instance settings on the 'Edit field instance' form.
File: modules/user/user.module | function user_form_field_ui_field_edit_form_alter(&$form, &$form_state, $form_id) {
$instance = $form['#instance'];
if ($instance['entity_type'] == 'user' && !$form['#field']['locked']) {
$form['instance']['settings']['user_register_form'] = array(
'#type' => 'checkbox',
'#title' => t('Display on u... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-742f54f5e1 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21field_ui%21field_ui.api.php/function/hook_field_settings_form/7.x | In Drupal 7, show an example implementation for `hook_field_settings_form($field, $instance, $has_data)` (modules/field_ui/field_ui.api.php): Add settings to a field settings form. | Invoked from field_ui_field_settings_form() to allow the module defining the field to add global settings (i.e. settings that do not depend on the bundle or instance) to the field settings form. If the field already has data, only include settings that are safe to change.
Parameters:
- $field: The field structure bein... | function hook_field_settings_form($field, $instance, $has_data) {
$settings = $field['settings'];
$form['max_length'] = array(
'#type' => 'textfield',
'#title' => t('Maximum length'),
'#default_value' => $settings['max_length'],
'#required' => FALSE,
'#element_validate' => array('element_validat... | [
"code-task",
"hook-definition"
] | 2026-09-30T00:00:00 |
api-drupal7-743e623e8b | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21profile%21profile.admin.inc/function/theme_profile_admin_overview/7.x | I need the code for `theme_profile_admin_overview($variables)` in Drupal 7 (modules/profile/profile.admin.inc). It must do this: Returns HTML for the profile field overview form into a drag and drop enabled table. | Parameters:
- $variables: An associative array containing: - form: A render element representing the form.
File: modules/profile/profile.admin.inc | function theme_profile_admin_overview($variables) {
$form = $variables['form'];
drupal_add_css(drupal_get_path('module', 'profile') . '/profile.css');
// Add javascript if there's more than one field.
if (isset($form['actions'])) {
drupal_add_js(drupal_get_path('module', 'profile') . '/profile.js');
}
... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-7449a4cc73 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21form.inc/function/form_process_fieldset/7.x | Implement `form_process_fieldset(&$element, &$form_state)` in PHP for Drupal 7. Required behavior: Arranges fieldsets into groups. | Parameters:
- $element: An associative array containing the properties and children of the fieldset. Note that $element must be taken by reference here, so processed child elements are taken over into $form_state.
- $form_state: The $form_state array for the form this fieldset belongs to.
Returns: The processed elemen... | function form_process_fieldset(&$element, &$form_state) {
$parents = implode('][', $element['#parents']);
// Each fieldset forms a new group. The #type 'vertical_tabs' basically only
// injects a new fieldset.
$form_state['groups'][$parents]['#group_exists'] = TRUE;
$element['#groups'] = &$form_state['groups... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-744d228582 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21module.inc/function/module_implements_write_cache/7.x | Implement `module_implements_write_cache()` in PHP for Drupal 7. Required behavior: Writes the hook implementation cache. | File: includes/module.inc | function module_implements_write_cache() {
// The list of implementations includes vital modules only before full
// bootstrap, so do not write cache if we are not fully bootstrapped yet.
if (drupal_get_bootstrap_phase() != DRUPAL_BOOTSTRAP_FULL) {
return;
}
$implementations = &drupal_static('module_imple... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-7461e01a09 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21user%21user.module/function/user_get_authmaps/7.x | I need the code for `user_get_authmaps($authname = NULL)` in Drupal 7 (modules/user/user.module). It must do this: Discover which external authentication module(s) authenticated a username. | Parameters:
- $authname: A username used by an external authentication module.
Returns: An associative array with module as key and username as value.
File: modules/user/user.module | function user_get_authmaps($authname = NULL) {
$authmaps = db_query("SELECT module, authname FROM {authmap} WHERE authname = :authname", array(':authname' => $authname))->fetchAllKeyed();
return count($authmaps) ? $authmaps : 0;
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-746c4bd7b1 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21image%21image.field.inc/function/image_field_presave/7.x | I need the code for `image_field_presave($entity_type, $entity, $field, $instance, $langcode, &$items)` in Drupal 7 (modules/image/image.field.inc). It must do this: Implements hook_field_presave(). | File: modules/image/image.field.inc | function image_field_presave($entity_type, $entity, $field, $instance, $langcode, &$items) {
file_field_presave($entity_type, $entity, $field, $instance, $langcode, $items);
// Determine the dimensions if necessary.
foreach ($items as &$item) {
if (!isset($item['width']) || !isset($item['height'])) {
$... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-746f599e12 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21user%21user.install/function/user_update_7008/7.x | Implement `user_update_7008()` in PHP for Drupal 7. Required behavior: If 'user_register' variable was unset in Drupal 6, set it to be the same as the Drupal 6 default setting. | File: modules/user/user.install | function user_update_7008() {
if (!isset($GLOBALS['conf']['user_register'])) {
// Set to the Drupal 6 default, "visitors can create accounts".
variable_set('user_register', USER_REGISTER_VISITORS);
}
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-7491d4daf7 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21menu.inc/function/_menu_router_save/7.x | I need the code for `_menu_router_save($menu, $masks)` in Drupal 7 (includes/menu.inc). It must do this: Saves data from menu_router_build() to the router table. | File: includes/menu.inc | function _menu_router_save($menu, $masks) {
// Delete the existing router since we have some data to replace it.
db_truncate('menu_router')->execute();
// Prepare insert object.
$insert = db_insert('menu_router')
->fields(array(
'path',
'load_functions',
'to_arg_functions',
'access_... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-74a5d24c1d | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21node%21node.install/function/node_update_7010/7.x | In Drupal 7, write the function `node_update_7010()` (file modules/node/node.install) so that it does the following: Add the {block_node_type} table. | File: modules/node/node.install | function node_update_7010() {
$schema['block_node_type'] = array(
'description' => 'Sets up display criteria for blocks based on content types',
'fields' => array(
'module' => array(
'type' => 'varchar',
'length' => 64,
'not null' => TRUE,
'description' => "The block's or... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-74ba113aaa | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21php%21php.install/function/php_enable/7.x | In Drupal 7, write the function `php_enable()` (file modules/php/php.install) so that it does the following: Implements hook_enable(). | File: modules/php/php.install | function php_enable() {
$format_exists = (bool) db_query_range('SELECT 1 FROM {filter_format} WHERE name = :name', 0, 1, array(':name' => 'PHP code'))->fetchField();
// Add a PHP code text format, if it does not exist. Do this only for the
// first install (or if the format has been manually deleted) as there is ... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-74c4a7fd67 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21block%21block.module/function/_block_get_cache_id/7.x | In Drupal 7, write the function `_block_get_cache_id($block)` (file modules/block/block.module) so that it does the following: Assemble the cache_id to use for a given block. | The cache_id string reflects the viewing context for the current block instance, obtained by concatenating the relevant context information (user, page, ...) according to the block's cache settings (BLOCK_CACHE_* constants). Two block instances can use the same cached content when they share the same cache_id.
Theme a... | function _block_get_cache_id($block) {
global $user;
// User 1 being out of the regular 'roles define permissions' schema,
// it brings too many chances of having unwanted output get in the cache
// and later be served to other users. We therefore exclude user 1 from
// block caching.
if (variable_get('blo... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-74ff6264cf | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21simpletest%21simpletest.pages.inc/function/simpletest_settings_form_validate/7.x | I need the code for `simpletest_settings_form_validate($form, &$form_state)` in Drupal 7 (modules/simpletest/simpletest.pages.inc). It must do this: Validation handler for simpletest_settings_form(). | File: modules/simpletest/simpletest.pages.inc | function simpletest_settings_form_validate($form, &$form_state) {
// If a username was provided but a password wasn't, preserve the existing
// password.
if (!empty($form_state['values']['simpletest_httpauth_username']) && empty($form_state['values']['simpletest_httpauth_password'])) {
$form_state['values']['... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-7501367869 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21file%21file.field.inc/function/file_field_widget_info/7.x | Implement `file_field_widget_info()` in PHP for Drupal 7. Required behavior: Implements hook_field_widget_info(). | File: modules/file/file.field.inc | function file_field_widget_info() {
return array(
'file_generic' => array(
'label' => t('File'),
'field types' => array('file'),
'settings' => array(
'progress_indicator' => 'throbber',
),
'behaviors' => array(
'multiple values' => FIELD_BEHAVIOR_CUSTOM,
'defa... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-751200d104 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21dashboard%21dashboard.module/function/template_preprocess_dashboard_admin_display_form/7.x | Implement `template_preprocess_dashboard_admin_display_form(&$variables)` in PHP for Drupal 7. Required behavior: Preprocesses variables for block-admin-display-form.tpl.php. | File: modules/dashboard/dashboard.module | function template_preprocess_dashboard_admin_display_form(&$variables) {
template_preprocess_block_admin_display_form($variables);
if (isset($variables['block_regions'][BLOCK_REGION_NONE])) {
$variables['block_regions'][BLOCK_REGION_NONE] = t('Other blocks');
}
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-752cf8843b | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21menu%21menu.admin.inc/function/menu_edit_item_validate/7.x | In Drupal 7, write the function `menu_edit_item_validate($form, &$form_state)` (file modules/menu/menu.admin.inc) so that it does the following: Validate form values for a menu link being added or edited. | File: modules/menu/menu.admin.inc | function menu_edit_item_validate($form, &$form_state) {
$item = &$form_state['values'];
$normal_path = drupal_get_normal_path($item['link_path']);
if ($item['link_path'] != $normal_path) {
drupal_set_message(t('The menu system stores system paths only, but will use the URL alias for display. %link_path has be... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-75982fd3c6 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21image%21image.install/function/image_update_7002/7.x | Implement `image_update_7002(array &$sandbox)` in PHP for Drupal 7. Required behavior: Add width and height columns to image field schema and populate. | File: modules/image/image.install | function image_update_7002(array &$sandbox) {
if (empty($sandbox)) {
// Setup the sandbox.
$sandbox = array(
'tables' => array(),
'total' => 0,
'processed' => 0,
'last_fid' => NULL,
);
$fields = _update_7000_field_read_fields(array(
'module' => 'image',
'storage_ty... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-75b6ef9c70 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21color%21color.module/function/_color_hsl2rgb/7.x | In Drupal 7, write the function `_color_hsl2rgb($hsl)` (file modules/color/color.module) so that it does the following: Converts an HSL triplet into RGB. | File: modules/color/color.module | function _color_hsl2rgb($hsl) {
$h = $hsl[0];
$s = $hsl[1];
$l = $hsl[2];
$m2 = ($l <= 0.5) ? $l * ($s + 1) : $l + $s - $l*$s;
$m1 = $l * 2 - $m2;
return array(
_color_hue2rgb($m1, $m2, $h + 0.33333),
_color_hue2rgb($m1, $m2, $h),
_color_hue2rgb($m1, $m2, $h - 0.33333),
);
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-75bcb40db1 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21tablesort.inc/function/tablesort_init/7.x | In Drupal 7, write the function `tablesort_init($header)` (file includes/tablesort.inc) so that it does the following: Initialize the table sort context. | File: includes/tablesort.inc | function tablesort_init($header) {
$ts = tablesort_get_order($header);
$ts['sort'] = tablesort_get_sort($header);
$ts['query'] = tablesort_get_query_parameters();
return $ts;
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-75d67fcbcd | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21trigger%21trigger.install/function/trigger_update_7002/7.x | Implement `trigger_update_7002()` in PHP for Drupal 7. Required behavior: Renames nodeapi to node. | File: modules/trigger/trigger.install | function trigger_update_7002() {
$result = db_query("SELECT hook, aid FROM {trigger_assignments}");
foreach($result as $record) {
$new_hook = str_replace('nodeapi', 'node', $record->hook);
db_update('trigger_assignments')
->fields(array('hook' => $new_hook))
->condition('hook', $record->hook)
... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-75e7884418 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21syslog%21syslog.install/function/syslog_uninstall/7.x | In Drupal 7, write the function `syslog_uninstall()` (file modules/syslog/syslog.install) so that it does the following: Implements hook_uninstall(). | File: modules/syslog/syslog.install | function syslog_uninstall() {
variable_del('syslog_identity');
variable_del('syslog_facility');
variable_del('syslog_format');
} | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-75e9666b8b | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21system.admin.inc/function/system_date_time_settings/7.x | In Drupal 7, write the function `system_date_time_settings()` (file modules/system/system.admin.inc) so that it does the following: Form builder; Configure the site date and time settings. | File: modules/system/system.admin.inc | function system_date_time_settings() {
// Get list of all available date types.
drupal_static_reset('system_get_date_types');
$format_types = system_get_date_types();
// Get list of all available date formats.
$all_formats = array();
drupal_static_reset('system_get_date_formats');
$date_formats = system_... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-7603802db3 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21token.inc/function/token_info/7.x | In Drupal 7, write the function `token_info()` (file includes/token.inc) so that it does the following: Returns metadata describing supported tokens. | The metadata array contains token type, name, and description data as well as an optional pointer indicating that the token chains to another set of tokens.
For example:
Returns: An associative array of token information, grouped by token type.
File: includes/token.inc | function token_info() {
$data = &drupal_static(__FUNCTION__);
if (!isset($data)) {
$data = module_invoke_all('token_info');
drupal_alter('token_info', $data);
}
return $data;
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-7639223984 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21system.admin.inc/function/system_run_cron_submit/7.x | Implement `system_run_cron_submit($form, &$form_state)` in PHP for Drupal 7. Required behavior: Submit callback; run cron. | File: modules/system/system.admin.inc | function system_run_cron_submit($form, &$form_state) {
// Run cron manually from Cron form.
if (drupal_cron_run()) {
drupal_set_message(t('Cron run successfully.'));
}
else {
drupal_set_message(t('Cron run failed.'), 'error');
}
drupal_goto('admin/config/system/cron');
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-764302c594 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21color%21color.module/function/color_scheme_form/7.x | I need the code for `color_scheme_form($complete_form, &$form_state, $theme)` in Drupal 7 (modules/color/color.module). It must do this: Form constructor for the color configuration form for a particular theme. | Parameters:
- $theme: The machine name of the theme whose color settings are being configured.
File: modules/color/color.module | function color_scheme_form($complete_form, &$form_state, $theme) {
$base = drupal_get_path('module', 'color');
$info = color_get_info($theme);
$info['schemes'][''] = array('title' => t('Custom'), 'colors' => array());
$color_sets = array();
$schemes = array();
foreach ($info['schemes'] as $key => $scheme) ... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-764db47ba6 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21aggregator%21aggregator.module/function/aggregator_help/7.x | I need the code for `aggregator_help($path, $arg)` in Drupal 7 (modules/aggregator/aggregator.module). It must do this: Implements hook_help(). | File: modules/aggregator/aggregator.module | function aggregator_help($path, $arg) {
switch ($path) {
case 'admin/help#aggregator':
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
$output .= '<p>' . t('The Aggregator module is an on-site syndicator and news reader that gathers and displays fresh content from RSS-, RDF-, and Atom-ba... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-765091b932 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/profiles%21minimal%21minimal.profile/function/minimal_form_install_configure_form_alter/7.x | In Drupal 7, write the function `minimal_form_install_configure_form_alter(&$form, $form_state)` (file profiles/minimal/minimal.profile) so that it does the following: Implements hook_form_FORM_ID_alter() for install_configure_form(). | Allows the profile to alter the site configuration form.
File: profiles/minimal/minimal.profile | function minimal_form_install_configure_form_alter(&$form, $form_state) {
// Pre-populate the site name with the server name.
$form['site_information']['site_name']['#default_value'] = $_SERVER['SERVER_NAME'];
} | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-76660e374b | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21system.api.php/function/hook_css_alter/7.x | Give me the example code for `hook_css_alter(&$css)` in Drupal 7. Hook description: Alter CSS files before they are output on the page. | Parameters:
- $css: An array of all CSS items (files and inline CSS) being requested on the page.
File: modules/system/system.api.php | function hook_css_alter(&$css) {
// Remove defaults.css file.
unset($css[drupal_get_path('module', 'system') . '/defaults.css']);
} | [
"code-task",
"hook-definition"
] | 2026-09-30T00:00:00 |
api-drupal7-7668b5f23f | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21image%21image.effects.inc/function/image_rotate_effect/7.x | I need the code for `image_rotate_effect(&$image, $data)` in Drupal 7 (modules/image/image.effects.inc). It must do this: Image effect callback; Rotate an image resource. | Parameters:
- $image: An image object returned by image_load().
- $data: An array of attributes to use when performing the rotate effect containing the following items: - "degrees": The number of (clockwise) degrees to rotate the image. - "random": A boolean indicating that a random rotation angle should be used for th... | function image_rotate_effect(&$image, $data) {
// Set sane default values.
$data += array(
'degrees' => 0,
'bgcolor' => NULL,
'random' => FALSE,
);
// Convert short #FFF syntax to full #FFFFFF syntax.
if (strlen((string) $data['bgcolor']) == 4) {
$c = $data['bgcolor'];
$data['bgcolor'] = ... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-76831ac6b5 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21menu.inc/function/menu_get_active_title/7.x | I need the code for `menu_get_active_title()` in Drupal 7 (includes/menu.inc). It must do this: Gets the title of the current page, as determined by the active trail. | File: includes/menu.inc | function menu_get_active_title() {
$active_trail = menu_get_active_trail();
$local_task_title = NULL;
foreach (array_reverse($active_trail) as $item) {
// Local task titles are displayed as tabs and therefore should not be
// repeated as the page title. However, if the local task appears in a
// top-... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-7695c1c52a | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21common.inc/function/drupal_pre_render_link/7.x | I need the code for `drupal_pre_render_link($element)` in Drupal 7 (includes/common.inc). It must do this: #pre_render callback to render a link into #markup. | Doing so during pre_render gives modules a chance to alter the link parts.
Parameters:
- $elements: A structured array whose keys form the arguments to l(): - #title: The link text to pass as argument to l(). - #href: The URL path component to pass as argument to l(). - #options: (optional) An array of options to pass... | function drupal_pre_render_link($element) {
// By default, link options to pass to l() are normally set in #options.
$element += array('#options' => array());
// However, within the scope of renderable elements, #attributes is a valid
// way to specify attributes, too. Take them into account, but do not overrid... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-76acb80cc8 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21user%21user.api.php/function/hook_user_flood_control/7.x | In Drupal 7, show an example implementation for `hook_user_flood_control($ip, $username = FALSE)` (modules/user/user.api.php): Respond to user flood control events. | This hook allows you act when an unsuccessful user login has triggered flood control. This means that either an IP address or a specific user account has been temporarily blocked from logging in.
Parameters:
- $ip: The IP address that triggered flood control.
- $username: The username that has been temporarily blocked... | function hook_user_flood_control($ip, $username = FALSE) {
if (!empty($username)) {
// Do something with the blocked $username and $ip. For example, send an
// e-mail to the user and/or site administrator.
// Drupal core uses this hook to log the event:
watchdog('user', 'Flood control blocked login a... | [
"code-task",
"hook-definition"
] | 2026-09-30T00:00:00 |
api-drupal7-76adeb5949 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21book%21book.admin.inc/function/_book_admin_table/7.x | Implement `_book_admin_table($node, &$form)` in PHP for Drupal 7. Required behavior: Builds the table portion of the form for the book administration page. | Parameters:
- $node: The node of the top-level page in the book.
- $form: The form that is being modified, passed by reference.
File: modules/book/book.admin.inc | function _book_admin_table($node, &$form) {
$form['table'] = array(
'#theme' => 'book_admin_table',
'#tree' => TRUE,
);
$tree = book_menu_subtree_data($node->book);
$tree = array_shift($tree); // Do not include the book item itself.
if ($tree['below']) {
$hash = drupal_hash_base64(serialize($tree... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-76d3063a27 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21update.inc/function/update_get_update_list/7.x | In Drupal 7, write the function `update_get_update_list()` (file includes/update.inc) so that it does the following: Returns a list of all the pending database updates. | Returns: An associative array keyed by module name which contains all information about database updates that need to be run, and any updates that are not going to proceed due to missing requirements. The system module will always be listed first. The subarray for each module can contain the following keys: - start: Th... | function update_get_update_list() {
// Make sure that the system module is first in the list of updates.
$ret = array('system' => array());
$modules = drupal_get_installed_schema_version(NULL, FALSE, TRUE);
foreach ($modules as $module => $schema_version) {
// Skip uninstalled and incompatible modules.
... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-76f357dbf1 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21install.inc/function/drupal_get_database_types/7.x | Implement `drupal_get_database_types()` in PHP for Drupal 7. Required behavior: Returns all supported database installer objects that are compiled into PHP. | Returns: An array of database installer objects compiled into PHP.
File: includes/install.inc | function drupal_get_database_types() {
$databases = array();
// We define a driver as a directory in /includes/database that in turn
// contains a database.inc file. That allows us to drop in additional drivers
// without modifying the installer.
// Because we have no registry yet, we need to also include th... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-76fc1b0c83 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21contact%21contact.install/function/contact_update_7003/7.x | I need the code for `contact_update_7003()` in Drupal 7 (modules/contact/contact.install). It must do this: Change the weight column to normal int. | File: modules/contact/contact.install | function contact_update_7003() {
db_drop_index('contact', 'list');
db_change_field('contact', 'weight', 'weight', array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'description' => "The category's weight.",
), array(
'indexes' => array(
'list' => array('weight', 'category'),
... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-7706137230 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21system.admin.inc/function/system_actions_configure_validate/7.x | In Drupal 7, write the function `system_actions_configure_validate($form, &$form_state)` (file modules/system/system.admin.inc) so that it does the following: Validate system_actions_configure() form submissions. | File: modules/system/system.admin.inc | function system_actions_configure_validate($form, &$form_state) {
$function = actions_function_lookup($form_state['values']['actions_action']) . '_validate';
// Hand off validation to the action.
if (function_exists($function)) {
$function($form, $form_state);
}
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-77424b4d58 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21dblog%21dblog.install/function/dblog_schema/7.x | Implement `dblog_schema()` in PHP for Drupal 7. Required behavior: Implements hook_schema(). | File: modules/dblog/dblog.install | function dblog_schema() {
$schema['watchdog'] = array(
'description' => 'Table that contains logs of all system events.',
'fields' => array(
'wid' => array(
'type' => 'serial',
'not null' => TRUE,
'description' => 'Primary Key: Unique watchdog event ID.',
),
'uid' => ... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-7744b6e40f | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21bootstrap.inc/function/drupal_get_title/7.x | Implement `drupal_get_title()` in PHP for Drupal 7. Required behavior: Gets the title of the current page. | The title is displayed on the page and in the title bar.
Returns: The current page's title.
File: includes/bootstrap.inc | function drupal_get_title() {
$title = drupal_set_title();
// During a bootstrap, menu.inc is not included and thus we cannot provide a title.
if (!isset($title) && function_exists('menu_get_active_title')) {
$title = check_plain(menu_get_active_title());
}
return $title;
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-77745e593b | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21contact%21contact.admin.inc/function/contact_category_list/7.x | I need the code for `contact_category_list()` in Drupal 7 (modules/contact/contact.admin.inc). It must do this: Categories/list tab. | File: modules/contact/contact.admin.inc | function contact_category_list() {
$header = array(
t('Category'),
t('Recipients'),
t('Selected'),
array('data' => t('Operations'), 'colspan' => 2),
);
$rows = array();
// Get all the contact categories from the database.
$categories = db_select('contact', 'c')
->addTag('translatable')
... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-77812e9654 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21unicode.inc/function/drupal_xml_parser_create/7.x | In Drupal 7, write the function `drupal_xml_parser_create(&$data)` (file includes/unicode.inc) so that it does the following: Prepares a new XML parser. | This is a wrapper around xml_parser_create() which extracts the encoding from the XML data first and sets the output encoding to UTF-8. This function should be used instead of xml_parser_create(), because PHP 4's XML parser doesn't check the input encoding itself. "Starting from PHP 5, the input encoding is automatical... | function drupal_xml_parser_create(&$data) {
// Default XML encoding is UTF-8
$encoding = 'utf-8';
$bom = FALSE;
// Check for UTF-8 byte order mark (PHP5's XML parser doesn't handle it).
if (!strncmp($data, "\xEF\xBB\xBF", 3)) {
$bom = TRUE;
$data = substr($data, 3);
}
// Check for an encoding de... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-7781567dab | 7 | drupal_api_code | https://api.drupal.org/api/drupal/themes%21bartik%21template.php/function/bartik_process_maintenance_page/7.x | I need the code for `bartik_process_maintenance_page(&$variables)` in Drupal 7 (themes/bartik/template.php). It must do this: Override or insert variables into the maintenance page template. | File: themes/bartik/template.php | function bartik_process_maintenance_page(&$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') ? FALSE : TRUE;
$variables['hide_site_slogan'] = theme_get_setting('toggle_slogan') ?... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-7792cb746e | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21comment%21comment.module/function/comment_menu/7.x | In Drupal 7, write the function `comment_menu()` (file modules/comment/comment.module) so that it does the following: Implements hook_menu(). | File: modules/comment/comment.module | function comment_menu() {
$items['admin/content/comment'] = array(
'title' => 'Comments',
'description' => 'List and edit site comments and the comment approval queue.',
'page callback' => 'comment_admin',
'access arguments' => array('administer comments'),
'type' => MENU_LOCAL_TASK | MENU_NORMAL_... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-77976ea33e | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21image%21image.install/function/image_field_schema/7.x | In Drupal 7, write the function `image_field_schema($field)` (file modules/image/image.install) so that it does the following: Implements hook_field_schema(). | File: modules/image/image.install | function image_field_schema($field) {
return array(
'columns' => array(
'fid' => array(
'description' => 'The {file_managed}.fid being referenced in this field.',
'type' => 'int',
'not null' => FALSE,
'unsigned' => TRUE,
),
'alt' => array(
'description' =>... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-77a512c722 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21system.admin.inc/function/system_regional_settings/7.x | I need the code for `system_regional_settings()` in Drupal 7 (modules/system/system.admin.inc). It must do this: Form builder; Configure the site regional settings. | File: modules/system/system.admin.inc | function system_regional_settings() {
include_once DRUPAL_ROOT . '/includes/locale.inc';
$countries = country_get_list();
// Date settings:
$zones = system_time_zones();
$form['locale'] = array(
'#type' => 'fieldset',
'#title' => t('Locale'),
);
$form['locale']['site_default_country'] = array(
... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-77b9969755 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21shortcut%21shortcut.module/function/shortcut_page_alter/7.x | In Drupal 7, write the function `shortcut_page_alter(&$page)` (file modules/shortcut/shortcut.module) so that it does the following: Implements hook_page_alter(). | File: modules/shortcut/shortcut.module | function shortcut_page_alter(&$page) {
if (isset($page['page_top']['toolbar'])) {
// If the toolbar is available, add a pre-render function to display the
// current shortcuts in the toolbar drawer.
$page['page_top']['toolbar']['#pre_render'][] = 'shortcut_toolbar_pre_render';
}
} | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-77c7928bc9 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21comment%21comment.install/function/comment_update_7008/7.x | In Drupal 7, write the function `comment_update_7008()` (file modules/comment/comment.install) so that it does the following: Update database to match Drupal 7 schema. | File: modules/comment/comment.install | function comment_update_7008() {
// Update default status to 1.
db_change_field('comment', 'status', 'status', array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 1,
'size' => 'tiny',
));
// Realign indexes.
db_drop_index('comment', 'comment_status_pid');
db_add... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-77d581b48e | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21file%21file.field.inc/function/_file_generic_settings_extensions/7.x | In Drupal 7, write the function `_file_generic_settings_extensions($element, &$form_state)` (file modules/file/file.field.inc) so that it does the following: Element validate callback for the allowed file extensions field. | This doubles as a convenience clean-up function and a validation routine. Commas are allowed by the end-user, but ultimately the value will be stored as a space-separated list for compatibility with file_validate_extensions().
File: modules/file/file.field.inc | function _file_generic_settings_extensions($element, &$form_state) {
if (!empty($element['#value'])) {
$extensions = preg_replace('/([, ]+\.?)/', ' ', trim(strtolower($element['#value'])));
$extensions = array_filter(explode(' ', $extensions));
$extensions = implode(' ', array_unique($extensions));
if... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-77daedb9c1 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21field%21modules%21text%21text.module/function/text_field_instance_settings_form/7.x | I need the code for `text_field_instance_settings_form($field, $instance)` in Drupal 7 (modules/field/modules/text/text.module). It must do this: Implements hook_field_instance_settings_form(). | File: modules/field/modules/text/text.module | function text_field_instance_settings_form($field, $instance) {
$settings = $instance['settings'];
$form['text_processing'] = array(
'#type' => 'radios',
'#title' => t('Text processing'),
'#default_value' => $settings['text_processing'],
'#options' => array(
t('Plain text'),
t('Filtered... | [
"code-task",
"hook-implementation"
] | 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.