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-081eaaa966 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21update.inc/function/update_batch/7.x | In Drupal 7, write the function `update_batch($start, $redirect = NULL, $url = NULL, $batch = array(), $redirect_callback = 'drupal_goto')` (file includes/update.inc) so that it does the following: Starts the database update batch process. | Parameters:
- $start: An array whose keys contain the names of modules to be updated during the current batch process, and whose values contain the number of the first requested update for that module. The actual updates that are run (and the order they are run in) will depend on the results of passing this data throug... | function update_batch($start, $redirect = NULL, $url = NULL, $batch = array(), $redirect_callback = 'drupal_goto') {
// During the update, bring the site offline so that schema changes do not
// affect visiting users.
$_SESSION['maintenance_mode'] = variable_get('maintenance_mode', FALSE);
if ($_SESSION['mainte... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-0820c290f1 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21file%21file.field.inc/function/file_field_widget_submit/7.x | In Drupal 7, write the function `file_field_widget_submit($form, &$form_state)` (file modules/file/file.field.inc) so that it does the following: Form submission handler for upload/remove button of file_field_widget_form(). | This runs in addition to and after file_managed_file_submit().
File: modules/file/file.field.inc | function file_field_widget_submit($form, &$form_state) {
// During the form rebuild, file_field_widget_form() will create field item
// widget elements using re-indexed deltas, so clear out $form_state['input']
// to avoid a mismatch between old and new deltas. The rebuilt elements will
// have #default_value s... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-0883638889 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21aggregator%21aggregator.admin.inc/function/aggregator_admin_form/7.x | I need the code for `aggregator_admin_form($form, $form_state)` in Drupal 7 (modules/aggregator/aggregator.admin.inc). It must do this: Form constructor for the aggregator system settings. | File: modules/aggregator/aggregator.admin.inc | function aggregator_admin_form($form, $form_state) {
// Global aggregator settings.
$form['aggregator_allowed_html_tags'] = array(
'#type' => 'textfield',
'#title' => t('Allowed HTML tags'),
'#size' => 80,
'#maxlength' => 255,
'#default_value' => variable_get('aggregator_allowed_html_tags', '<a>... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-0889daee9b | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21common.inc/function/entity_uri/7.x | In Drupal 7, write the function `entity_uri($entity_type, $entity)` (file includes/common.inc) so that it does the following: Returns the URI elements of an entity. | Parameters:
- $entity_type: The entity type; e.g. 'node' or 'user'.
- $entity: The entity for which to generate a path.
Returns: An array containing the 'path' and 'options' keys used to build the URI of the entity, and matching the signature of url(). NULL if the entity has no URI of its own.
File: includes/common.i... | function entity_uri($entity_type, $entity) {
$info = entity_get_info($entity_type);
list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);
// A bundle-specific callback takes precedence over the generic one for the
// entity type.
if (isset($info['bundles'][$bundle]['uri callback'])) {
$ur... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-08a79c7bcc | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21aggregator%21aggregator.parser.inc/function/aggregator_aggregator_parse_info/7.x | I need the code for `aggregator_aggregator_parse_info()` in Drupal 7 (modules/aggregator/aggregator.parser.inc). It must do this: Implements hook_aggregator_parse_info(). | File: modules/aggregator/aggregator.parser.inc | function aggregator_aggregator_parse_info() {
return array(
'title' => t('Default parser'),
'description' => t('Parses RSS, Atom and RDF feeds.'),
);
} | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-08b2adb00b | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21openid%21openid.install/function/openid_update_7000/7.x | In Drupal 7, write the function `openid_update_7000()` (file modules/openid/openid.install) so that it does the following: Bind associations to their providers. | File: modules/openid/openid.install | function openid_update_7000() {
db_drop_table('openid_association');
$schema = array(
'description' => 'Stores temporary shared key association information for OpenID authentication.',
'fields' => array(
'idp_endpoint_uri' => array(
'type' => 'varchar',
'length' => 255,
'not n... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-08b47ceeea | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21shortcut%21shortcut.module/function/shortcut_menu/7.x | I need the code for `shortcut_menu()` in Drupal 7 (modules/shortcut/shortcut.module). It must do this: Implements hook_menu(). | File: modules/shortcut/shortcut.module | function shortcut_menu() {
$items['admin/config/user-interface/shortcut'] = array(
'title' => 'Shortcuts',
'description' => 'Add and modify shortcut sets.',
'page callback' => 'shortcut_set_admin',
'access arguments' => array('administer shortcuts'),
'file' => 'shortcut.admin.inc',
);
$items['... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-08c1b9a8ee | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21update%21update.settings.inc/function/update_settings_validate/7.x | Implement `update_settings_validate($form, &$form_state)` in PHP for Drupal 7. Required behavior: Form validation handler for update_settings(). | Validates the e-mail addresses and ensures the field is formatted correctly.
File: modules/update/update.settings.inc | function update_settings_validate($form, &$form_state) {
if (!empty($form_state['values']['update_notify_emails'])) {
$valid = array();
$invalid = array();
foreach (explode("\n", trim($form_state['values']['update_notify_emails'])) as $email) {
$email = trim($email);
if (!empty($email)) {
... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-08c3ec6d4f | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21comment%21comment.module/function/comment_prepare_thread/7.x | I need the code for `comment_prepare_thread(&$comments)` in Drupal 7 (modules/comment/comment.module). It must do this: Loop over comment thread, noting indentation level. | Parameters:
- $comments (array): An array of comment objects, keyed by cid.
Returns: The $comments argument is altered by reference with indentation information.
File: modules/comment/comment.module | function comment_prepare_thread(&$comments) {
// A flag stating if we are still searching for first new comment on the thread.
$first_new = TRUE;
// A counter that helps track how indented we are.
$divs = 0;
foreach ($comments as $key => $comment) {
if ($first_new && $comment->new != MARK_READ) {
... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-08db503810 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21lock.inc/function/lock_acquire/7.x | In Drupal 7, write the function `lock_acquire($name, $timeout = 30.0)` (file includes/lock.inc) so that it does the following: Acquire (or renew) a lock, but do not block if it fails. | Parameters:
- $name: The name of the lock. Limit of name's length is 255 characters.
- $timeout: A number of seconds (float) before the lock expires (minimum of 0.001).
Returns: TRUE if the lock was acquired, FALSE if it failed.
File: includes/lock.inc | function lock_acquire($name, $timeout = 30.0) {
global $locks;
// Insure that the timeout is at least 1 ms.
$timeout = max($timeout, 0.001);
$expire = microtime(TRUE) + $timeout;
if (isset($locks[$name])) {
// Try to extend the expiration of a lock we already acquired.
$success = (bool) db_update('se... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-08fbaa8b0b | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21actions.inc/function/actions_function_lookup/7.x | I need the code for `actions_function_lookup($hash)` in Drupal 7 (includes/actions.inc). It must do this: Returns an action array key (function or ID), given its hash. | Faster than actions_actions_map() when you only need the function name or ID.
Parameters:
- $hash: Hash of a function name or action ID array key. The array key is a key into the return value of actions_list() (array key is the action function name) or actions_get_all_actions() (array key is the action ID).
Returns: ... | function actions_function_lookup($hash) {
// Check for a function name match.
$actions_list = actions_list();
foreach ($actions_list as $function => $array) {
if (drupal_hash_base64($function) == $hash) {
return $function;
}
}
$aid = FALSE;
// Must be a configurable action; check database.
$... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-092a82d686 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21search%21search.module/function/search_touch_node/7.x | In Drupal 7, write the function `search_touch_node($nid)` (file modules/search/search.module) so that it does the following: Changes a node's changed timestamp to 'now' to force reindexing. | Parameters:
- $nid: The node ID of the node that needs reindexing.
File: modules/search/search.module | function search_touch_node($nid) {
db_update('search_dataset')
->fields(array('reindex' => REQUEST_TIME))
->condition('type', 'node')
->condition('sid', $nid)
->execute();
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-0933fc91c8 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21user%21user.module/function/user_register_form/7.x | In Drupal 7, write the function `user_register_form($form, &$form_state)` (file modules/user/user.module) so that it does the following: Form builder; the user registration form. | File: modules/user/user.module | function user_register_form($form, &$form_state) {
global $user;
$admin = user_access('administer users');
// Pass access information to the submit handler. Running an access check
// inside the submit function interferes with form processing and breaks
// hook_form_alter().
$form['administer_users'] = ar... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-093b72f536 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21php%21php.module/function/_php_filter_tips/7.x | In Drupal 7, write the function `_php_filter_tips($filter, $format, $long = FALSE)` (file modules/php/php.module) so that it does the following: Implements callback_filter_tips(). | File: modules/php/php.module | function _php_filter_tips($filter, $format, $long = FALSE) {
global $base_url;
if ($long) {
$output = '<h4>' . t('Using custom PHP code') . '</h4>';
$output .= '<p>' . t('Custom PHP code may be embedded in some types of site content, including posts and blocks. While embedding PHP code inside a post or bloc... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-0940387f1d | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21user%21user.module/function/_user_cancel/7.x | I need the code for `_user_cancel($edit, $account, $method)` in Drupal 7 (modules/user/user.module). It must do this: Implements callback_batch_operation(). | Last step for cancelling a user account.
Since batch and session API require a valid user account, the actual cancellation of a user account needs to happen last.
File: modules/user/user.module | function _user_cancel($edit, $account, $method) {
global $user;
switch ($method) {
case 'user_cancel_block':
case 'user_cancel_block_unpublish':
default:
// Send account blocked notification if option was checked.
if (!empty($edit['user_cancel_notify'])) {
_user_mail_notify('status_... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-095a88021e | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21aggregator%21aggregator.admin.inc/function/aggregator_admin_remove_feed/7.x | In Drupal 7, write the function `aggregator_admin_remove_feed($form, $form_state, $feed)` (file modules/aggregator/aggregator.admin.inc) so that it does the following: Deletes a feed. | Parameters:
- $feed: An associative array describing the feed to be cleared.
File: modules/aggregator/aggregator.admin.inc | function aggregator_admin_remove_feed($form, $form_state, $feed) {
return confirm_form(
array(
'feed' => array(
'#type' => 'value',
'#value' => $feed,
),
),
t('Are you sure you want to remove all items from the feed %feed?', array('%feed' => $feed->title)),
'admin/config/se... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-0972a5e5c2 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21field%21field.module/function/template_process_field/7.x | Implement `template_process_field(&$variables, $hook)` in PHP for Drupal 7. Required behavior: Theme process function for theme_field() and field.tpl.php. | File: modules/field/field.module | function template_process_field(&$variables, $hook) {
// The default theme implementation is a function, so template_process() does
// not automatically run, so we need to flatten the classes and attributes
// here. For best performance, only call drupal_attributes() when needed, and
// note that template_prepr... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-09796f73d8 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21locale%21locale.admin.inc/function/locale_languages_edit_form_submit/7.x | Implement `locale_languages_edit_form_submit($form, &$form_state)` in PHP for Drupal 7. Required behavior: Process the language editing form submission. | File: modules/locale/locale.admin.inc | function locale_languages_edit_form_submit($form, &$form_state) {
db_update('languages')
->fields(array(
'name' => $form_state['values']['name'],
'native' => $form_state['values']['native'],
'domain' => $form_state['values']['domain'],
'prefix' => $form_state['values']['prefix'],
'di... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-09c198dae4 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21comment%21comment.module/function/comment_update_index/7.x | In Drupal 7, write the function `comment_update_index()` (file modules/comment/comment.module) so that it does the following: Implements hook_update_index(). | File: modules/comment/comment.module | function comment_update_index() {
// Store the maximum possible comments per thread (used for ranking by reply count)
variable_set('node_cron_comments_scale', 1.0 / max(1, db_query('SELECT MAX(comment_count) FROM {node_comment_statistics}')->fetchField()));
} | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-09db7f1863 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/themes%21seven%21template.php/function/seven_preprocess_maintenance_page/7.x | I need the code for `seven_preprocess_maintenance_page(&$vars)` in Drupal 7 (themes/seven/template.php). It must do this: Override or insert variables into the maintenance page template. | File: themes/seven/template.php | function seven_preprocess_maintenance_page(&$vars) {
// While markup for normal pages is split into page.tpl.php and html.tpl.php,
// the markup for the maintenance page is all in the single
// maintenance-page.tpl.php template. So, to have what's done in
// seven_preprocess_html() also happen on the maintenanc... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-09ef302cbf | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21user%21user.module/function/user_rdf_mapping/7.x | I need the code for `user_rdf_mapping()` in Drupal 7 (modules/user/user.module). It must do this: Implements hook_rdf_mapping(). | File: modules/user/user.module | function user_rdf_mapping() {
return array(
array(
'type' => 'user',
'bundle' => RDF_DEFAULT_BUNDLE,
'mapping' => array(
'rdftype' => array('sioc:UserAccount'),
'name' => array(
'predicates' => array('foaf:name'),
),
'homepage' => array(
'predi... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-09f3be93fd | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21field%21modules%21list%21list.module/function/list_field_widget_info_alter/7.x | Implement `list_field_widget_info_alter(&$info)` in PHP for Drupal 7. Required behavior: Implements hook_field_widget_info_alter(). | The List module does not implement widgets of its own, but reuses the widgets defined in options.module.
File: modules/field/modules/list/list.module | function list_field_widget_info_alter(&$info) {
$widgets = array(
'options_select' => array('list_integer', 'list_float', 'list_text'),
'options_buttons' => array('list_integer', 'list_float', 'list_text', 'list_boolean'),
'options_onoff' => array('list_boolean'),
);
foreach ($widgets as $widget => $... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-09ff88341a | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21comment%21comment.module/function/comment_menu_alter/7.x | I need the code for `comment_menu_alter(&$items)` in Drupal 7 (modules/comment/comment.module). It must do this: Implements hook_menu_alter(). | File: modules/comment/comment.module | function comment_menu_alter(&$items) {
// Add comments to the description for admin/content.
$items['admin/content']['description'] = 'Administer content and comments.';
// Adjust the Field UI tabs on admin/structure/types/manage/[node-type].
// See comment_entity_info().
$items['admin/structure/types/manage... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-0a03db5d1f | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21file%21file.field.inc/function/file_field_widget_form/7.x | Implement `file_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element)` in PHP for Drupal 7. Required behavior: Implements hook_field_widget_form(). | File: modules/file/file.field.inc | function file_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {
$defaults = array(
'fid' => 0,
'display' => !empty($field['settings']['display_default']),
'description' => '',
);
// Load the items for form rebuilds from the field state as they might no... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-0a10d409d9 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21bootstrap.inc/function/drupal_base64_encode/7.x | Implement `drupal_base64_encode($string)` in PHP for Drupal 7. Required behavior: Returns a URL-safe, base64 encoded version of the supplied string. | Parameters:
- $string: The string to convert to base64.
Returns (string)
File: includes/bootstrap.inc | function drupal_base64_encode($string) {
$data = base64_encode($string);
// Modify the output so it's safe to use in URLs.
return strtr($data, array('+' => '-', '/' => '_', '=' => ''));
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-0a1e5482f8 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21user%21user.module/function/user_register_submit/7.x | In Drupal 7, write the function `user_register_submit($form, &$form_state)` (file modules/user/user.module) so that it does the following: Submit handler for the user registration form. | This function is shared by the installation form and the normal registration form, which is why it can't be in the user.pages.inc file.
File: modules/user/user.module | function user_register_submit($form, &$form_state) {
$admin = $form_state['values']['administer_users'];
if (!variable_get('user_email_verification', TRUE) || $admin) {
$pass = $form_state['values']['pass'];
}
else {
$pass = user_password();
}
$notify = !empty($form_state['values']['notify']);
/... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-0a40e217b1 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21field%21field.attach.inc/function/_field_invoke_get_instances/7.x | I need the code for `_field_invoke_get_instances($entity_type, $bundle, $options)` in Drupal 7 (modules/field/field.attach.inc). It must do this: Helper for _field_invoke(): retrieves a list of instances to operate on. | Parameters:
- $entity_type: The entity type.
- $bundle: The bundle name.
- $options: An associative array of options, as provided to _field_invoke(). Only the following keys are considered : - deleted - field_name - field_id See _field_invoke() for details.
Returns: The array of selected instance definitions.
File: m... | function _field_invoke_get_instances($entity_type, $bundle, $options) {
if ($options['deleted']) {
// Deleted fields are not included in field_info_instances(), and need to
// be fetched from the database with field_read_instances().
$params = array('entity_type' => $entity_type, 'bundle' => $bundle);
... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-0a42f5a869 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_status_messages/7.x | In Drupal 7, write the function `theme_status_messages($variables)` (file includes/theme.inc) so that it does the following: Returns HTML for status and/or error messages, grouped by type. | An invisible heading identifies the messages for assistive technology. Sighted users see a colored box. See http://www.w3.org/TR/WCAG-TECHS/H69.html for info.
Parameters:
- $variables: An associative array containing: - display: (optional) Set to 'status' or 'error' to display only messages of that type.
File: includ... | function theme_status_messages($variables) {
$display = $variables['display'];
$output = '';
$status_heading = array(
'status' => t('Status message'),
'error' => t('Error message'),
'warning' => t('Warning message'),
);
foreach (drupal_get_messages($display) as $type => $messages) {
$output .... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-0a454da632 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21image.inc/function/image_get_info/7.x | In Drupal 7, write the function `image_get_info($filepath, $toolkit = FALSE)` (file includes/image.inc) so that it does the following: Gets details about an image. | Drupal supports GIF, JPG and PNG file formats when used with the GD toolkit, and may support others, depending on which toolkits are installed.
Parameters:
- $filepath: String specifying the path of the image file.
- $toolkit: An optional image toolkit name to override the default.
Returns: FALSE, if the file could n... | function image_get_info($filepath, $toolkit = FALSE) {
$details = FALSE;
if (!is_file($filepath) && !is_uploaded_file($filepath)) {
return $details;
}
if (!$toolkit) {
$toolkit = image_get_toolkit();
}
if ($toolkit) {
$image = new stdClass();
$image->source = $filepath;
$image->toolkit ... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-0a4c357fe6 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21simpletest%21simpletest.install/function/simpletest_schema/7.x | Implement `simpletest_schema()` in PHP for Drupal 7. Required behavior: Implements hook_schema(). | File: modules/simpletest/simpletest.install | function simpletest_schema() {
$schema['simpletest'] = array(
'description' => 'Stores simpletest messages',
'fields' => array(
'message_id' => array(
'type' => 'serial',
'not null' => TRUE,
'description' => 'Primary Key: Unique simpletest message ID.',
),
'test_id' ... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-0a5fa6e267 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21bootstrap.inc/function/_drupal_get_filename_fallback_trigger_error/7.x | In Drupal 7, write the function `_drupal_get_filename_fallback_trigger_error($type, $name, $error_type)` (file includes/bootstrap.inc) so that it does the following: Triggers a user-level warning for missing or unexpectedly moved files. | Parameters:
- $type: The type of the item (theme, theme_engine, module, profile).
- $name: The name of the item for which the filename is requested.
- $error_type: The type of the error ('missing' or 'moved').
File: includes/bootstrap.inc | function _drupal_get_filename_fallback_trigger_error($type, $name, $error_type) {
// Hide messages due to known bugs that will appear on a lot of sites.
// @todo Remove this in https://www.drupal.org/node/2383823
if (empty($name)) {
return;
}
// Make sure we only show any missing or moved file errors onl... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-0a6954bdc5 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21aggregator%21aggregator.module/function/aggregator_block_view/7.x | In Drupal 7, write the function `aggregator_block_view($delta = '')` (file modules/aggregator/aggregator.module) so that it does the following: Implements hook_block_view(). | Generates blocks for the latest news items in each category and feed.
File: modules/aggregator/aggregator.module | function aggregator_block_view($delta = '') {
if (user_access('access news feeds')) {
$block = array();
list($type, $id) = explode('-', $delta);
$result = FALSE;
switch ($type) {
case 'feed':
if ($feed = db_query('SELECT fid, title, block FROM {aggregator_feed} WHERE block <> 0 AND fid =... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-0a98959f1a | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21path%21path.admin.inc/function/path_admin_overview/7.x | Implement `path_admin_overview()` in PHP for Drupal 7. Required behavior: Returns a listing of all defined URL aliases. | When filter key passed, perform a standard search on the given key, and return the list of matching URL aliases.
File: modules/path/path.admin.inc | function path_admin_overview() {
// Get search keys.
$args = func_get_args();
$keys = implode('/', $args);
// Add the filter form above the overview table.
$build['path_admin_filter_form'] = drupal_get_form('path_admin_filter_form', $keys);
// Enable language column if locale is enabled or if we have any a... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-0aa03662a0 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21book%21book.module/function/_book_toc_recurse/7.x | I need the code for `_book_toc_recurse($tree, $indent, &$toc, $exclude, $depth_limit)` in Drupal 7 (modules/book/book.module). It must do this: Recursively processes and formats menu items for book_toc(). | This helper function recursively modifies the table of contents array for each item in the menu tree, ignoring items in the exclude array or at a depth greater than the limit. Truncates titles over thirty characters and appends an indentation string incremented by depth.
Parameters:
- $tree: The data structure of the ... | function _book_toc_recurse($tree, $indent, &$toc, $exclude, $depth_limit) {
foreach ($tree as $data) {
if ($data['link']['depth'] > $depth_limit) {
// Don't iterate through any links on this level.
break;
}
if (!in_array($data['link']['mlid'], $exclude)) {
$toc[$data['link']['mlid']] = ... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-0aa5097955 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21simpletest%21simpletest.install/function/simpletest_uninstall/7.x | In Drupal 7, write the function `simpletest_uninstall()` (file modules/simpletest/simpletest.install) so that it does the following: Implements hook_uninstall(). | File: modules/simpletest/simpletest.install | function simpletest_uninstall() {
drupal_load('module', 'simpletest');
simpletest_clean_database();
// Remove settings variables.
variable_del('simpletest_httpauth_method');
variable_del('simpletest_httpauth_username');
variable_del('simpletest_httpauth_password');
variable_del('simpletest_clear_results'... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-0ac2c3d6cf | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21locale.inc/function/_locale_import_tokenize_formula/7.x | Implement `_locale_import_tokenize_formula($formula)` in PHP for Drupal 7. Required behavior: Backward compatible implementation of token_get_all() for formula parsing | Parameters:
- $string: A string containing the arithmetic formula.
Returns: The PHP version of the formula.
File: includes/locale.inc | function _locale_import_tokenize_formula($formula) {
$formula = str_replace(" ", "", $formula);
$tokens = array();
for ($i = 0; $i < strlen($formula); $i++) {
if (is_numeric($formula[$i])) {
$num = $formula[$i];
$j = $i + 1;
while ($j < strlen($formula) && is_numeric($formula[$j])) {
... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-0ae6bdec78 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21ajax.inc/function/ajax_command_data/7.x | Implement `ajax_command_data($selector, $name, $value)` in PHP for Drupal 7. Required behavior: Creates a Drupal Ajax 'data' command. | The 'data' command instructs the client to attach the name=value pair of data to the selector via jQuery's data cache.
This command is implemented by Drupal.ajax.prototype.commands.data() defined in misc/ajax.js.
Parameters:
- $selector: A jQuery selector string. If the command is a response to a request from an #aja... | function ajax_command_data($selector, $name, $value) {
return array(
'command' => 'data',
'selector' => $selector,
'name' => $name,
'value' => $value,
);
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-0b0e2663a8 | 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_delete_field/7.x | I need the code for `field_sql_storage_field_storage_delete_field($field)` in Drupal 7 (modules/field/modules/field_sql_storage/field_sql_storage.module). It must do this: Implements hook_field_storage_delete_field(). | File: modules/field/modules/field_sql_storage/field_sql_storage.module | function field_sql_storage_field_storage_delete_field($field) {
// Mark all data associated with the field for deletion.
$field['deleted'] = 0;
$table = _field_sql_storage_tablename($field);
$revision_table = _field_sql_storage_revision_tablename($field);
db_update($table)
->fields(array('deleted' => 1))
... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-0b17eb30e9 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21theme.inc/function/_theme_table_cell/7.x | I need the code for `_theme_table_cell($cell, $header = FALSE)` in Drupal 7 (includes/theme.inc). It must do this: Returns HTML output for a single table cell for theme_table(). | Parameters:
- $cell: Array of cell information, or string to display in cell.
- $header (bool): TRUE if this cell is a table header cell, FALSE if it is an ordinary table cell. If $cell is an array with element 'header' set to TRUE, that will override the $header parameter.
Returns: HTML for the cell.
File: includes/... | function _theme_table_cell($cell, $header = FALSE) {
$attributes = '';
if (is_array($cell)) {
$data = isset($cell['data']) ? $cell['data'] : '';
// Cell's data property can be a string or a renderable array.
if (is_array($data)) {
$data = drupal_render($data);
}
$header |= isset($cell['he... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-0b1cfbbe70 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21filter%21filter.module/function/filter_fallback_format_title/7.x | Implement `filter_fallback_format_title()` in PHP for Drupal 7. Required behavior: Returns the title of the fallback text format. | Returns (string): The title of the fallback text format.
File: modules/filter/filter.module | function filter_fallback_format_title() {
$fallback_format = filter_format_load(filter_fallback_format());
return filter_admin_format_title($fallback_format);
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-0b30545b16 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21profile%21profile.install/function/profile_update_7002/7.x | I need the code for `profile_update_7002()` in Drupal 7 (modules/profile/profile.install). It must do this: Change the weight column to normal int. | File: modules/profile/profile.install | function profile_update_7002() {
db_change_field('profile_field', 'weight', 'weight', array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'description' => 'Weight of field in relation to other profile fields.',
));
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-0b435c3e05 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21taxonomy%21taxonomy.admin.inc/function/taxonomy_form_term/7.x | Implement `taxonomy_form_term($form, &$form_state, $edit = array(), $vocabulary = NULL)` in PHP for Drupal 7. Required behavior: Form function for the term edit form. | File: modules/taxonomy/taxonomy.admin.inc | function taxonomy_form_term($form, &$form_state, $edit = array(), $vocabulary = NULL) {
// During initial form build, add the term entity to the form state for use
// during form building and processing. During a rebuild, use what is in the
// form state.
if (!isset($form_state['term'])) {
$term = is_object... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-0b561c063f | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21theme.inc/function/template_preprocess_region/7.x | In Drupal 7, write the function `template_preprocess_region(&$variables)` (file includes/theme.inc) so that it does the following: Preprocess variables for region.tpl.php | Prepares the values passed to the theme_region function to be passed into a pluggable template engine. Uses the region name to generate a template file suggestions. If none are found, the default region.tpl.php is used.
File: includes/theme.inc | function template_preprocess_region(&$variables) {
// Create the $content variable that templates expect.
$variables['content'] = $variables['elements']['#children'];
$variables['region'] = $variables['elements']['#region'];
$variables['classes_array'][] = drupal_region_class($variables['region']);
$variable... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-0b83e09608 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21user%21user.admin.inc/function/user_filter_form_submit/7.x | In Drupal 7, write the function `user_filter_form_submit($form, &$form_state)` (file modules/user/user.admin.inc) so that it does the following: Process result from user administration filter form. | File: modules/user/user.admin.inc | function user_filter_form_submit($form, &$form_state) {
$op = $form_state['values']['op'];
$filters = user_filters();
switch ($op) {
case t('Filter'):
case t('Refine'):
// Apply every filter that has a choice selected other than 'any'.
foreach ($filters as $filter => $options) {
if (is... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-0b922481ee | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21user%21user.module/function/user_block_user_action/7.x | I need the code for `user_block_user_action(&$entity, $context = array())` in Drupal 7 (modules/user/user.module). It must do this: Blocks a specific user or the current user, if one is not specified. | Parameters:
- $entity: (optional) An entity object; if it is provided and it has a uid property, the user with that ID is blocked.
- $context: (optional) An associative array; if no user ID is found in $entity, the 'uid' element of this array determines the user to block.
File: modules/user/user.module | function user_block_user_action(&$entity, $context = array()) {
// First priority: If there is a $entity->uid, block that user.
// This is most likely a user object or the author if a node or comment.
if (isset($entity->uid)) {
$uid = $entity->uid;
}
elseif (isset($context['uid'])) {
$uid = $context['... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-0bc845967d | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21node%21node.module/function/node_revision_delete/7.x | I need the code for `node_revision_delete($revision_id)` in Drupal 7 (modules/node/node.module). It must do this: Deletes a node revision. | Parameters:
- $revision_id: The revision ID to delete.
File: modules/node/node.module | function node_revision_delete($revision_id) {
if ($revision = node_load(NULL, $revision_id)) {
// Prevent deleting the current revision.
$node = node_load($revision->nid);
if ($revision_id == $node->vid) {
return FALSE;
}
db_delete('node_revision')
->condition('nid', $revision->nid)
... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-0bd4022d51 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21blog%21blog.module/function/blog_node_info/7.x | Implement `blog_node_info()` in PHP for Drupal 7. Required behavior: Implements hook_node_info(). | File: modules/blog/blog.module | function blog_node_info() {
return array(
'blog' => array(
'name' => t('Blog entry'),
'base' => 'blog',
'description' => t('Use for multi-user blogs. Every user gets a personal blog.'),
)
);
} | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-0bd7eafef4 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21path.inc/function/drupal_path_alias_whitelist_rebuild/7.x | Implement `drupal_path_alias_whitelist_rebuild($source = NULL)` in PHP for Drupal 7. Required behavior: Rebuild the path alias white list. | Parameters:
- $source: An optional system path for which an alias is being inserted.
Returns: An array containing a white list of path aliases.
File: includes/path.inc | function drupal_path_alias_whitelist_rebuild($source = NULL) {
// When paths are inserted, only rebuild the whitelist if the system path
// has a top level component which is not already in the whitelist.
if (!empty($source)) {
$whitelist = variable_get('path_alias_whitelist', NULL);
if (isset($whitelist[... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-0bd97df219 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21language.api.php/function/hook_language_init/7.x | Give me the example code for `hook_language_init()` in Drupal 7. Hook description: Allows modules to act after language initialization has been performed. | This is primarily needed to provide translation for configuration variables in the proper bootstrap phase. Variables are user-defined strings and therefore should not be translated via t(), since the source string can change without notice and any previous translation would be lost. Moreover, since variables can be use... | function hook_language_init() {
global $language, $conf;
switch ($language->language) {
case 'it':
$conf['site_name'] = 'Il mio sito Drupal';
break;
case 'fr':
$conf['site_name'] = 'Mon site Drupal';
break;
}
} | [
"code-task",
"hook-definition"
] | 2026-09-30T00:00:00 |
api-drupal7-0bf75dd641 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21image%21image.admin.inc/function/image_effect_color_validate/7.x | In Drupal 7, write the function `image_effect_color_validate($element, &$form_state)` (file modules/image/image.admin.inc) so that it does the following: Element validate handler to ensure a hexadecimal color value. | File: modules/image/image.admin.inc | function image_effect_color_validate($element, &$form_state) {
if ($element['#value'] != '') {
$hex_value = preg_replace('/^#/', '', $element['#value']);
if (!preg_match('/^#[0-9A-F]{3}([0-9A-F]{3})?$/', $element['#value'])) {
form_error($element, t('!name must be a hexadecimal color value.', array('!na... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-0c00570557 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21taxonomy%21taxonomy.admin.inc/function/taxonomy_term_confirm_delete_submit/7.x | In Drupal 7, write the function `taxonomy_term_confirm_delete_submit($form, &$form_state)` (file modules/taxonomy/taxonomy.admin.inc) so that it does the following: Submit handler to delete a term after confirmation. | File: modules/taxonomy/taxonomy.admin.inc | function taxonomy_term_confirm_delete_submit($form, &$form_state) {
taxonomy_term_delete($form_state['values']['tid']);
taxonomy_check_vocabulary_hierarchy($form['#vocabulary'], $form_state['values']);
drupal_set_message(t('Deleted term %name.', array('%name' => $form_state['values']['name'])));
watchdog('taxon... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-0c04067d5d | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21theme.inc/function/_theme_load_registry/7.x | In Drupal 7, write the function `_theme_load_registry($theme, $base_theme = NULL, $theme_engine = NULL, $complete = TRUE)` (file includes/theme.inc) so that it does the following: Gets the theme_registry cache; if it doesn't exist, builds it. | Parameters:
- $theme: The loaded $theme object as returned by list_themes().
- $base_theme: An array of loaded $theme objects representing the ancestor themes in oldest first order.
- $theme_engine: The name of the theme engine.
- $complete: Whether to load the complete theme registry or an instance of the ThemeRegistr... | function _theme_load_registry($theme, $base_theme = NULL, $theme_engine = NULL, $complete = TRUE) {
if ($complete) {
// Check the theme registry cache; if it exists, use it.
$cached = cache_get("theme_registry:$theme->name");
if (isset($cached->data)) {
$registry = $cached->data;
}
else {
... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-0c28972553 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21overlay%21overlay.module/function/overlay_store_rendered_content/7.x | Implement `overlay_store_rendered_content($id = NULL, $content = NULL)` in PHP for Drupal 7. Required behavior: Stores strings representing rendered HTML content. | This function is used to keep a static cache of rendered content that can be referred to later in the page request.
Parameters:
- $id: (Optional) An identifier for the content which is being stored, which will be used as an array key in the returned array. If omitted, no change will be made to the current stored data.... | function overlay_store_rendered_content($id = NULL, $content = NULL) {
$rendered_content = &drupal_static(__FUNCTION__, array());
if (isset($id)) {
$rendered_content[$id] = $content;
}
return $rendered_content;
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-0c41ef0e1a | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21block%21block.module/function/_block_load_blocks/7.x | I need the code for `_block_load_blocks()` in Drupal 7 (modules/block/block.module). It must do this: Loads blocks' information from the database. | Returns: An array of blocks grouped by region.
File: modules/block/block.module | function _block_load_blocks() {
global $theme_key;
$query = db_select('block', 'b');
$result = $query
->fields('b')
->condition('b.theme', $theme_key)
->condition('b.status', 1)
->orderBy('b.region')
->orderBy('b.weight')
->orderBy('b.module')
->addTag('block_load')
->addTag('tran... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-0c43efbbf7 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21comment%21comment.module/function/comment_unpublish_by_keyword_action_form/7.x | In Drupal 7, write the function `comment_unpublish_by_keyword_action_form($context)` (file modules/comment/comment.module) so that it does the following: Form builder; Prepare a form for blacklisted keywords. | File: modules/comment/comment.module | function comment_unpublish_by_keyword_action_form($context) {
$form['keywords'] = array(
'#title' => t('Keywords'),
'#type' => 'textarea',
'#description' => t('The comment will be unpublished if it contains any of the phrases above. Use a case-sensitive, comma-separated list of phrases. Example: funny, bu... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-0c44e582de | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21bootstrap.inc/function/drupal_hash_base64/7.x | I need the code for `drupal_hash_base64($data)` in Drupal 7 (includes/bootstrap.inc). It must do this: Calculates a base-64 encoded, URL-safe sha-256 hash. | Parameters:
- $data: String to be hashed.
Returns: A base-64 encoded sha-256 hash, with + replaced with -, / with _ and any = padding characters removed.
File: includes/bootstrap.inc | function drupal_hash_base64($data) {
$hash = base64_encode(hash('sha256', $data, TRUE));
// Modify the hash so it's safe to use in URLs.
return strtr($hash, array('+' => '-', '/' => '_', '=' => ''));
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-0c51f5c354 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21comment%21comment.module/function/comment_block_view/7.x | In Drupal 7, write the function `comment_block_view($delta = '')` (file modules/comment/comment.module) so that it does the following: Implements hook_block_view(). | Generates a block with the most recent comments.
File: modules/comment/comment.module | function comment_block_view($delta = '') {
if (user_access('access comments')) {
$block['subject'] = t('Recent comments');
$block['content'] = theme('comment_block');
return $block;
}
} | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-0c5798df7f | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21search%21search.api.php/function/hook_search_execute/7.x | Give me the example code for `hook_search_execute($keys = NULL, $conditions = NULL)` in Drupal 7. Hook description: Execute a search for a set of key words. | Use database API with the 'PagerDefault' query extension to perform your search.
If your module uses hook_update_index() and search_index() to index its items, use table 'search_index' aliased to 'i' as the main table in your query, with the 'SearchQuery' extension. You can join to your module's table using the 'i.sid... | function hook_search_execute($keys = NULL, $conditions = NULL) {
// Build matching conditions
$query = db_select('search_index', 'i', array('target' => 'slave'))->extend('SearchQuery')->extend('PagerDefault');
$query->join('node', 'n', 'n.nid = i.sid');
$query
->condition('n.status', 1)
->addTag('node_a... | [
"code-task",
"hook-definition"
] | 2026-09-30T00:00:00 |
api-drupal7-0c6097b262 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21search%21search.module/function/search_expression_extract/7.x | I need the code for `search_expression_extract($expression, $option)` in Drupal 7 (modules/search/search.module). It must do this: Extracts a module-specific search option from a search expression. | Search options are added using search_expression_insert(), and retrieved using search_expression_extract(). They take the form option:value, and are added to the ordinary keywords in the search expression.
Parameters:
- $expression: The search expression to extract from.
- $option: The name of the option to retrieve f... | function search_expression_extract($expression, $option) {
if (preg_match('/(^| )' . $option . ':([^ ]*)( |$)/i', $expression, $matches)) {
return $matches[2];
}
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-0c74d4edfc | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21xmlrpc.inc/function/xmlrpc_message_tag_open/7.x | Implement `xmlrpc_message_tag_open($parser, $tag, $attr)` in PHP for Drupal 7. Required behavior: Handles opening tags for XML parsing in xmlrpc_message_parse(). | File: includes/xmlrpc.inc | function xmlrpc_message_tag_open($parser, $tag, $attr) {
$xmlrpc_message = xmlrpc_message_get();
$xmlrpc_message->current_tag_contents = '';
$xmlrpc_message->last_open = $tag;
switch ($tag) {
case 'methodCall':
case 'methodResponse':
case 'fault':
$xmlrpc_message->messagetype = $tag;
bre... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-0cac16c077 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21pager.inc/function/pager_get_query_parameters/7.x | Implement `pager_get_query_parameters()` in PHP for Drupal 7. Required behavior: Compose a URL query parameter array for pager links. | Returns: A URL query parameter array that consists of all components of the current page request except for those pertaining to paging.
File: includes/pager.inc | function pager_get_query_parameters() {
$query = &drupal_static(__FUNCTION__);
if (!isset($query)) {
$query = drupal_get_query_parameters($_GET, array('q', 'page'));
}
return $query;
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-0cd333c4e9 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21form.inc/function/_form_options_flatten/7.x | I need the code for `_form_options_flatten($array)` in Drupal 7 (includes/form.inc). It must do this: Iterates over an array and returns a flat array with duplicate keys removed. | This function also handles cases where objects are passed as array values.
File: includes/form.inc | function _form_options_flatten($array) {
$return = &drupal_static(__FUNCTION__);
foreach ($array as $key => $value) {
if (is_object($value)) {
_form_options_flatten($value->option);
}
elseif (is_array($value)) {
_form_options_flatten($value);
}
else {
$return[$key] = 1;
}
... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-0ceef0f655 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21filter%21filter.module/function/_filter_url_escape_comments/7.x | I need the code for `_filter_url_escape_comments($match, $escape = NULL)` in Drupal 7 (modules/filter/filter.module). It must do this: Escapes the contents of HTML comments. | Callback for preg_replace_callback() within _filter_url().
Parameters:
- $match: An array containing matches to replace from preg_replace_callback(), whereas $match[1] is expected to contain the content to be filtered.
- $escape: (optional) A Boolean indicating whether to escape (TRUE) or unescape comments (FALSE). De... | function _filter_url_escape_comments($match, $escape = NULL) {
static $mode, $comments = array();
if (isset($escape)) {
$mode = $escape;
if ($escape){
$comments = array();
}
return;
}
// Replace all HTML coments with a '<!-- [hash] -->' placeholder.
if ($mode) {
$content = $match[1... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-0d009924a0 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21system.api.php/function/hook_hook_info/7.x | In Drupal 7, show an example implementation for `hook_hook_info()` (modules/system/system.api.php): Defines one or more hooks that are exposed by a module. | Normally hooks do not need to be explicitly defined. However, by declaring a hook explicitly, a module may define a "group" for it. Modules that implement a hook may then place their implementation in either $module.module or in $module.$group.inc. If the hook is located in $module.$group.inc, then that file will be au... | function hook_hook_info() {
$hooks['token_info'] = array(
'group' => 'tokens',
);
$hooks['tokens'] = array(
'group' => 'tokens',
);
return $hooks;
} | [
"code-task",
"hook-definition"
] | 2026-09-30T00:00:00 |
api-drupal7-0d159cf85d | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21comment%21comment.module/function/comment_node_delete/7.x | In Drupal 7, write the function `comment_node_delete($node)` (file modules/comment/comment.module) so that it does the following: Implements hook_node_delete(). | File: modules/comment/comment.module | function comment_node_delete($node) {
$cids = db_query('SELECT cid FROM {comment} WHERE nid = :nid', array(':nid' => $node->nid))->fetchCol();
comment_delete_multiple($cids);
db_delete('node_comment_statistics')
->condition('nid', $node->nid)
->execute();
} | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-0d19b0847d | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21aggregator%21aggregator.parser.inc/function/aggregator_parse_feed/7.x | I need the code for `aggregator_parse_feed(&$data, $feed)` in Drupal 7 (modules/aggregator/aggregator.parser.inc). It must do this: Parses a feed and stores its items. | Parameters:
- $data: The feed data.
- $feed: An object describing the feed to be parsed.
Returns: FALSE on error, TRUE otherwise.
File: modules/aggregator/aggregator.parser.inc | function aggregator_parse_feed(&$data, $feed) {
global $items, $image, $channel;
// Unset the global variables before we use them.
unset($GLOBALS['element'], $GLOBALS['item'], $GLOBALS['tag']);
$items = array();
$image = array();
$channel = array();
// Parse the data.
$xml_parser = drupal_xml_parser_c... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-0d495f2491 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21menu.inc/function/menu_primary_local_tasks/7.x | In Drupal 7, write the function `menu_primary_local_tasks()` (file includes/menu.inc) so that it does the following: Returns the rendered local tasks at the top level. | File: includes/menu.inc | function menu_primary_local_tasks() {
$links = menu_local_tasks(0);
// Do not display single tabs.
return ($links['tabs']['count'] > 1 ? $links['tabs']['output'] : '');
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-0d5072e447 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21update%21update.module/function/_update_no_data/7.x | In Drupal 7, write the function `_update_no_data()` (file modules/update/update.module) so that it does the following: Returns a warning message when there is no data about available updates. | File: modules/update/update.module | function _update_no_data() {
$destination = drupal_get_destination();
$cron_token = array('token' => drupal_get_token('run-cron'));
return t('No update information available. <a href="@run_cron">Run cron</a> or <a href="@check_manually">check manually</a>.', array(
'@run_cron' => url('admin/reports/status/run... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-0d5dcb0d4a | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21install.core.inc/function/install_run_task/7.x | In Drupal 7, write the function `install_run_task($task, &$install_state)` (file includes/install.core.inc) so that it does the following: Runs an individual installation task. | Parameters:
- $task: An array of information about the task to be run as returned by hook_install_tasks().
- $install_state: An array of information about the current installation state. This is passed in by reference so that it can be modified by the task.
Returns: The output of the task function, if there is any.
F... | function install_run_task($task, &$install_state) {
$function = $task['function'];
if ($task['type'] == 'form') {
require_once DRUPAL_ROOT . '/includes/form.inc';
if ($install_state['interactive']) {
// For interactive forms, build the form and ensure that it will not
// redirect, since the ins... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-0d74a5f484 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21color%21color.module/function/_color_gd/7.x | Implement `_color_gd($img, $hex)` in PHP for Drupal 7. Required behavior: Converts a hex triplet into a GD color. | File: modules/color/color.module | function _color_gd($img, $hex) {
$c = array_merge(array($img), _color_unpack($hex));
return call_user_func_array('imagecolorallocate', $c);
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-0d7d856e74 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21locale%21locale.admin.inc/function/theme_locale_date_format_form/7.x | Implement `theme_locale_date_format_form($variables)` in PHP for Drupal 7. Required behavior: Returns HTML for a locale date format form. | Parameters:
- $variables: An associative array containing: - form: A render element representing the form.
File: modules/locale/locale.admin.inc | function theme_locale_date_format_form($variables) {
$form = $variables['form'];
$header = array(
t('Date type'),
t('Format'),
);
foreach (element_children($form['date_formats']) as $key) {
$row = array();
$row[] = $form['date_formats'][$key]['#title'];
unset($form['date_formats'][$key]['#t... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-0d81aed0f7 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21update%21update.module/function/update_flush_caches/7.x | Implement `update_flush_caches()` in PHP for Drupal 7. Required behavior: Implements hook_flush_caches(). | Called from update.php (among others) to flush the caches. Since we're running update.php, we are likely to install a new version of something, in which case, we want to check for available update data again. However, because we have our own caching system, we need to directly clear the database table ourselves at this... | function update_flush_caches() {
if (defined('MAINTENANCE_MODE') && MAINTENANCE_MODE == 'update') {
_update_cache_clear();
}
return array();
} | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-0d93db6b2a | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21filter%21filter.module/function/filter_format_allowcache/7.x | In Drupal 7, write the function `filter_format_allowcache($format_id)` (file modules/filter/filter.module) so that it does the following: Checks if the text in a certain text format is allowed to be cached. | This function can be used to check whether the result of the filtering process can be cached. A text format may allow caching depending on the filters enabled.
Parameters:
- $format_id: The text format ID to check.
Returns: TRUE if the given text format allows caching, FALSE otherwise.
File: modules/filter/filter.mo... | function filter_format_allowcache($format_id) {
$format = filter_format_load($format_id);
return !empty($format->cache);
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-0d945d8bb0 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21field_ui%21field_ui.admin.inc/function/field_ui_display_overview_multistep_submit/7.x | Implement `field_ui_display_overview_multistep_submit($form, &$form_state)` in PHP for Drupal 7. Required behavior: Form submission handler for buttons in field_ui_display_overview_form(). | File: modules/field_ui/field_ui.admin.inc | function field_ui_display_overview_multistep_submit($form, &$form_state) {
$trigger = $form_state['triggering_element'];
$op = $trigger['#op'];
switch ($op) {
case 'edit':
// Store the field whose settings are currently being edited.
$field_name = $trigger['#field_name'];
$form_state['forma... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-0d98dcea29 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21trigger%21trigger.admin.inc/function/theme_trigger_display/7.x | Implement `theme_trigger_display($variables)` in PHP for Drupal 7. Required behavior: Returns HTML for the form showing actions assigned to a trigger. | Parameters:
- $variables: An associative array containing: - element: The fieldset including all assigned actions.
File: modules/trigger/trigger.admin.inc | function theme_trigger_display($variables) {
$element = $variables['element'];
$header = array();
$rows = array();
if (isset($element['assigned']) && count($element['assigned']['#value'])) {
$header = array(array('data' => t('Name')), array('data' => t('Operation')));
$rows = array();
foreach ($ele... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-0db33e3973 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21field%21modules%21list%21list.module/function/_list_values_in_use/7.x | I need the code for `_list_values_in_use($field, $values)` in Drupal 7 (modules/field/modules/list/list.module). It must do this: Checks if a list of values are being used in actual field values. | File: modules/field/modules/list/list.module | function _list_values_in_use($field, $values) {
if ($values) {
$query = new EntityFieldQuery();
$found = $query
->fieldCondition($field['field_name'], 'value', $values)
->range(0, 1)
->execute();
return !empty($found);
}
return FALSE;
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-0db38c8379 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21filter%21filter.api.php/function/hook_filter_info_alter/7.x | In Drupal 7, show an example implementation for `hook_filter_info_alter(&$info)` (modules/filter/filter.api.php): Perform alterations on filter definitions. | Parameters:
- $info: Array of information on filters exposed by hook_filter_info() implementations.
File: modules/filter/filter.api.php | function hook_filter_info_alter(&$info) {
// Replace the PHP evaluator process callback with an improved
// PHP evaluator provided by a module.
$info['php_code']['process callback'] = 'my_module_php_evaluator';
// Alter the default settings of the URL filter provided by core.
$info['filter_url']['default set... | [
"code-task",
"hook-definition"
] | 2026-09-30T00:00:00 |
api-drupal7-0dbe5a6e1e | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21file%21file.field.inc/function/file_field_presave/7.x | In Drupal 7, write the function `file_field_presave($entity_type, $entity, $field, $instance, $langcode, &$items)` (file modules/file/file.field.inc) so that it does the following: Implements hook_field_presave(). | File: modules/file/file.field.inc | function file_field_presave($entity_type, $entity, $field, $instance, $langcode, &$items) {
// Make sure that each file which will be saved with this object has a
// permanent status, so that it will not be removed when temporary files are
// cleaned up.
foreach ($items as $delta => $item) {
if (empty($item... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-0dbeb71455 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21dashboard%21dashboard.install/function/dashboard_disable/7.x | I need the code for `dashboard_disable()` in Drupal 7 (modules/dashboard/dashboard.install). It must do this: Implements hook_disable(). | Stash a list of blocks enabled on the dashboard, so they can be re-enabled if the dashboard is re-enabled. Then disable those blocks, since the dashboard regions will no longer be defined.
File: modules/dashboard/dashboard.install | function dashboard_disable() {
// Stash a list of currently enabled blocks.
$stashed_blocks = array();
$result = db_select('block', 'b')
->fields('b', array('module', 'delta', 'region'))
->condition('b.region', dashboard_regions(), 'IN')
->execute();
foreach ($result as $block) {
$stashed_bloc... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-0dc2d31c33 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21aggregator%21aggregator.module/function/aggregator_save_feed/7.x | Implement `aggregator_save_feed($edit)` in PHP for Drupal 7. Required behavior: Add/edit/delete an aggregator feed. | Parameters:
- $edit: An associative array describing the feed to be added/edited/deleted.
File: modules/aggregator/aggregator.module | function aggregator_save_feed($edit) {
if (!empty($edit['fid'])) {
// An existing feed is being modified, delete the category listings.
db_delete('aggregator_category_feed')
->condition('fid', $edit['fid'])
->execute();
}
if (!empty($edit['fid']) && !empty($edit['title'])) {
db_update('agg... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-0dde58af8d | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21simpletest%21simpletest.pages.inc/function/theme_simpletest_result_summary/7.x | Implement `theme_simpletest_result_summary($variables)` in PHP for Drupal 7. Required behavior: Returns HTML for the summary status of a simpletest result. | Parameters:
- $variables: An associative array containing: - form: A render element representing the form.
File: modules/simpletest/simpletest.pages.inc | function theme_simpletest_result_summary($variables) {
$form = $variables['form'];
return '<div class="simpletest-' . ($form['#ok'] ? 'pass' : 'fail') . '">' . _simpletest_format_summary_line($form) . '</div>';
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-0dea79f354 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21comment%21comment.module/function/comment_build_content/7.x | Implement `comment_build_content($comment, $node, $view_mode = 'full', $langcode = NULL)` in PHP for Drupal 7. Required behavior: Builds a structured array representing the comment's content. | The content built for the comment (field values, comments, file attachments or other comment components) will vary depending on the $view_mode parameter.
Parameters:
- $comment: A comment object.
- $node: The node the comment is attached to.
- $view_mode: View mode, e.g. 'full', 'teaser'...
- $langcode: (optional) A l... | function comment_build_content($comment, $node, $view_mode = 'full', $langcode = NULL) {
if (!isset($langcode)) {
$langcode = $GLOBALS['language_content']->language;
}
// Remove previously built content, if exists.
$comment->content = array();
// Allow modules to change the view mode.
$view_mode = key... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-0dffece9ef | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21poll%21poll.module/function/poll_more_choices_submit/7.x | I need the code for `poll_more_choices_submit($form, &$form_state)` in Drupal 7 (modules/poll/poll.module). It must do this: Submit handler to add more choices to a poll form. | This handler is run regardless of whether JS is enabled or not. It makes changes to the form state. If the button was clicked with JS disabled, then the page is reloaded with the complete rebuilt form. If the button was clicked with JS enabled, then ajax_form_callback() calls poll_choice_js() to return just the changed... | function poll_more_choices_submit($form, &$form_state) {
// If this is a Ajax POST, add 1, otherwise add 5 more choices to the form.
if ($form_state['values']['poll_more']) {
$n = $_GET['q'] == 'system/ajax' ? 1 : 5;
$form_state['choice_count'] = count($form_state['values']['choice']) + $n;
}
// Renumbe... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-0e2295091c | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21xmlrpcs.inc/function/xmlrpc_server/7.x | I need the code for `xmlrpc_server($callbacks)` in Drupal 7 (includes/xmlrpcs.inc). It must do this: Invokes XML-RPC methods on this server. | Parameters:
- $callbacks (array): Either an associative array of external XML-RPC method names as keys with the callbacks they map to as values, or a more complex structure describing XML-RPC callbacks as returned from hook_xmlrpc().
File: includes/xmlrpcs.inc | function xmlrpc_server($callbacks) {
$xmlrpc_server = new stdClass();
// Define built-in XML-RPC method names
$defaults = array(
'system.multicall' => 'xmlrpc_server_multicall',
array(
'system.methodSignature',
'xmlrpc_server_method_signature',
array('array', 'string'),
'Returns an... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-0e53f750be | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21system.api.php/function/hook_modules_installed/7.x | Give me the example code for `hook_modules_installed($modules)` in Drupal 7. Hook description: Perform necessary actions after modules are installed. | This function differs from hook_install() in that it gives all other modules a chance to perform actions when a module is installed, whereas hook_install() is only called on the module actually being installed. See module_enable() for a detailed description of the order in which install and enable hooks are invoked.
T... | function hook_modules_installed($modules) {
if (in_array('lousy_module', $modules)) {
variable_set('lousy_module_conflicting_variable', FALSE);
}
} | [
"code-task",
"hook-definition"
] | 2026-09-30T00:00:00 |
api-drupal7-0e784f5690 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21unicode.inc/function/drupal_strlen/7.x | I need the code for `drupal_strlen($text)` in Drupal 7 (includes/unicode.inc). It must do this: Counts the number of characters in a UTF-8 string. | This is less than or equal to the byte count.
Parameters:
- $text: The string to run the operation on.
Returns (integer): The length of the string.
File: includes/unicode.inc | function drupal_strlen($text) {
global $multibyte;
if (is_null($text)) {
return 0;
}
if ($multibyte == UNICODE_MULTIBYTE) {
return mb_strlen($text);
}
else {
// Do not count UTF-8 continuation bytes.
return strlen(preg_replace("/[\x80-\xBF]/", '', $text));
}
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-0e7b21be62 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21system.api.php/function/hook_theme_registry_alter/7.x | Give me the example code for `hook_theme_registry_alter(&$theme_registry)` in Drupal 7. Hook description: Alter the theme registry information returned from hook_theme(). | The theme registry stores information about all available theme hooks, including which callback functions those hooks will call when triggered, what template files are exposed by these hooks, and so on.
Note that this hook is only executed as the theme cache is re-built. Changes here will not be visible until the next... | function hook_theme_registry_alter(&$theme_registry) {
// Kill the next/previous forum topic navigation links.
foreach ($theme_registry['forum_topic_navigation']['preprocess functions'] as $key => $value) {
if ($value == 'template_preprocess_forum_topic_navigation') {
unset($theme_registry['forum_topic_na... | [
"code-task",
"hook-definition"
] | 2026-09-30T00:00:00 |
api-drupal7-0e85f5fd93 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21taxonomy%21taxonomy.module/function/taxonomy_select_nodes/7.x | I need the code for `taxonomy_select_nodes($tid, $pager = TRUE, $limit = FALSE, $order = array('t.sticky' => 'DESC', 't.created' => 'DESC'))` in Drupal 7 (modules/taxonomy/taxonomy.module). It must do this: Return nodes attached to a term across all field instances. | This function requires taxonomy module to be maintaining its own tables, and will return an empty array if it is not. If using other field storage methods alternatives methods for listing terms will need to be used.
Parameters:
- $tid: The term ID.
- $pager: Boolean to indicate whether a pager should be used.
- $limit... | function taxonomy_select_nodes($tid, $pager = TRUE, $limit = FALSE, $order = array('t.sticky' => 'DESC', 't.created' => 'DESC')) {
if (!variable_get('taxonomy_maintain_index_table', TRUE)) {
return array();
}
$query = db_select('taxonomy_index', 't');
$query->addTag('node_access');
$query->condition('t.ti... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-0e89bcdfaa | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21lock.inc/function/lock_initialize/7.x | In Drupal 7, write the function `lock_initialize()` (file includes/lock.inc) so that it does the following: Initialize the locking system. | File: includes/lock.inc | function lock_initialize() {
global $locks;
$locks = array();
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-0ea0940bf0 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21locale%21locale.module/function/locale_field_language_fallback/7.x | Implement `locale_field_language_fallback(&$display_language, $entity, $langcode)` in PHP for Drupal 7. Required behavior: Applies language fallback rules to the fields attached to the given entity. | Core language fallback rules simply check if fields have a field translation for the requested language code. If so the requested language is returned, otherwise all the fallback candidates are inspected to see if there is a field translation available in another language. By default this is called by locale_field_lang... | function locale_field_language_fallback(&$display_language, $entity, $langcode) {
// Lazily init fallback candidates to avoid unnecessary calls.
$fallback_candidates = NULL;
$field_languages = array();
foreach ($display_language as $field_name => $field_language) {
// If the requested language is defined f... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-0ea5c2be7f | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21bootstrap.inc/function/_drupal_get_cookie_domain/7.x | Implement `_drupal_get_cookie_domain($host)` in PHP for Drupal 7. Required behavior: Derive the cookie domain to use for session cookies. | Parameters:
- $host: The value of the HTTP host name.
Returns: The string to use as a cookie domain.
File: includes/bootstrap.inc | function _drupal_get_cookie_domain($host) {
$cookie_domain = $host;
// Strip leading periods and port numbers from cookie domain.
$cookie_domain = ltrim($cookie_domain, '.');
$cookie_domain = explode(':', $cookie_domain);
$cookie_domain = '.' . $cookie_domain[0];
return $cookie_domain;
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-0ea876c8bf | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21trigger%21trigger.module/function/_trigger_tab_information/7.x | I need the code for `_trigger_tab_information()` in Drupal 7 (modules/trigger/trigger.module). It must do this: Gathers information about tabs on the triggers administration screen. | Returns (Array): of modules that have triggers, with the keys being the machine-readable name of the module, and the values being the human-readable name of the module.
File: modules/trigger/trigger.module | function _trigger_tab_information() {
// Gather information about all triggers and modules.
$trigger_info = _trigger_get_all_info();
$modules = system_get_info('module');
$modules = array_intersect_key($modules, $trigger_info);
$return_info = array();
foreach ($modules as $name => $info) {
$return_info... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-0eaa88ca1c | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21aggregator%21aggregator.module/function/aggregator_cron_queue_info/7.x | Implement `aggregator_cron_queue_info()` in PHP for Drupal 7. Required behavior: Implements hook_cron_queue_info(). | File: modules/aggregator/aggregator.module | function aggregator_cron_queue_info() {
$queues['aggregator_feeds'] = array(
'worker callback' => 'aggregator_refresh',
'time' => 60,
);
return $queues;
} | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-0eaf1bffa8 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21openid%21openid.inc/function/openid_extract_namespace/7.x | I need the code for `openid_extract_namespace($response, $extension_namespace, $fallback_prefix = NULL, $only_signed = FALSE)` in Drupal 7 (modules/openid/openid.inc). It must do this: Extract all the parameters belonging to an extension in a response message. | OpenID 2.0 defines a simple extension mechanism, based on a namespace prefix.
Each request or response can define a prefix using:
Parameters:
- $response: The response array.
- $extension_namespace: The namespace of the extension.
- $fallback_prefix: An optional prefix that will be used in case no prefix is found for... | function openid_extract_namespace($response, $extension_namespace, $fallback_prefix = NULL, $only_signed = FALSE) {
$signed_keys = explode(',', $response['openid.signed']);
// Find the namespace prefix.
$prefix = $fallback_prefix;
foreach ($response as $key => $value) {
if ($value == $extension_namespace &... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-0ed82f6e47 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21system.api.php/function/hook_token_info_alter/7.x | In Drupal 7, show an example implementation for `hook_token_info_alter(&$data)` (modules/system/system.api.php): Alter the metadata about available placeholder tokens and token types. | Parameters:
- $data: The associative array of token definitions from hook_token_info().
File: modules/system/system.api.php | function hook_token_info_alter(&$data) {
// Modify description of node tokens for our site.
$data['tokens']['node']['nid'] = array(
'name' => t("Node ID"),
'description' => t("The unique ID of the article."),
);
$data['tokens']['node']['title'] = array(
'name' => t("Title"),
'description' => t("... | [
"code-task",
"hook-definition"
] | 2026-09-30T00:00:00 |
api-drupal7-0ee859b5c8 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21system.admin.inc/function/system_themes_admin_form/7.x | Implement `system_themes_admin_form($form, &$form_state, $theme_options)` in PHP for Drupal 7. Required behavior: Form to select the administration theme. | File: modules/system/system.admin.inc | function system_themes_admin_form($form, &$form_state, $theme_options) {
// Administration theme settings.
$form['admin_theme'] = array(
'#type' => 'fieldset',
'#title' => t('Administration theme'),
);
$form['admin_theme']['admin_theme'] = array(
'#type' => 'select',
'#options' => array(0 => t('... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-0eeea69b5c | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21contact%21contact.install/function/contact_update_7000/7.x | In Drupal 7, write the function `contact_update_7000()` (file modules/contact/contact.install) so that it does the following: Rename the threshold limit variable. | File: modules/contact/contact.install | function contact_update_7000() {
variable_set('contact_threshold_limit', variable_get('contact_hourly_threshold', 5));
variable_del('contact_hourly_threshold');
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-0ef17c29ef | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21menu%21menu.admin.inc/function/menu_overview_page/7.x | I need the code for `menu_overview_page()` in Drupal 7 (modules/menu/menu.admin.inc). It must do this: Menu callback which shows an overview page of all the custom menus and their descriptions. | File: modules/menu/menu.admin.inc | function menu_overview_page() {
$result = db_query("SELECT * FROM {menu_custom} ORDER BY title", array(), array('fetch' => PDO::FETCH_ASSOC));
$header = array(t('Title'), array('data' => t('Operations'), 'colspan' => '3'));
$rows = array();
foreach ($result as $menu) {
$row = array(theme('menu_admin_overvie... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-0ef3cd28c9 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21update%21update.module/function/update_mail/7.x | I need the code for `update_mail($key, &$message, $params)` in Drupal 7 (modules/update/update.module). It must do this: Implements hook_mail(). | Constructs the e-mail notification message when the site is out of date.
Parameters:
- $key: Unique key to indicate what message to build, always 'status_notify'.
- $message: Reference to the message array being built.
- $params: Array of parameters to indicate what kind of text to include in the message body. This is... | function update_mail($key, &$message, $params) {
$language = $message['language'];
$langcode = $language->language;
$message['subject'] .= t('New release(s) available for !site_name', array('!site_name' => variable_get('site_name', 'Drupal')), array('langcode' => $langcode));
foreach ($params as $msg_type => $m... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-0ef688d65a | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21field%21modules%21list%21list.module/function/list_field_is_empty/7.x | In Drupal 7, write the function `list_field_is_empty($item, $field)` (file modules/field/modules/list/list.module) so that it does the following: Implements hook_field_is_empty(). | File: modules/field/modules/list/list.module | function list_field_is_empty($item, $field) {
if (empty($item['value']) && (string) $item['value'] !== '0') {
return TRUE;
}
return FALSE;
} | [
"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.