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-a11ee801a0 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21aggregator%21aggregator.module/function/aggregator_permission/7.x | I need the code for `aggregator_permission()` in Drupal 7 (modules/aggregator/aggregator.module). It must do this: Implements hook_permission(). | File: modules/aggregator/aggregator.module | function aggregator_permission() {
return array(
'administer news feeds' => array(
'title' => t('Administer news feeds'),
),
'access news feeds' => array(
'title' => t('View news feeds'),
),
);
} | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-a11ef89358 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21module.inc/function/module_load_all_includes/7.x | In Drupal 7, write the function `module_load_all_includes($type, $name = NULL)` (file includes/module.inc) so that it does the following: Loads an include file for each module enabled in the {system} table. | File: includes/module.inc | function module_load_all_includes($type, $name = NULL) {
$modules = module_list();
foreach ($modules as $module) {
module_load_include($type, $module, $name);
}
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-a131bd642f | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21file.inc/function/drupal_unlink/7.x | Implement `drupal_unlink($uri, $context = NULL)` in PHP for Drupal 7. Required behavior: Deletes a file. | PHP's unlink() is broken on Windows, as it can fail to remove a file when it has a read-only flag set.
Parameters:
- $uri: A URI or pathname.
- $context: Refer to http://php.net/manual/ref.stream.php
Returns (Boolean): TRUE on success, or FALSE on failure.
File: includes/file.inc | function drupal_unlink($uri, $context = NULL) {
$scheme = file_uri_scheme($uri);
if ((!$scheme || !file_stream_wrapper_valid_scheme($scheme)) && (substr(PHP_OS, 0, 3) == 'WIN')) {
chmod($uri, 0600);
}
if ($context) {
return unlink($uri, $context);
}
else {
return unlink($uri);
}
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-a134dcea17 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21system.api.php/function/hook_entity_info_alter/7.x | Give me the example code for `hook_entity_info_alter(&$entity_info)` in Drupal 7. Hook description: Alter the entity info. | Modules may implement this hook to alter the information that defines an entity. All properties that are available in hook_entity_info() can be altered here.
Parameters:
- $entity_info: The entity info array, keyed by entity name.
File: modules/system/system.api.php | function hook_entity_info_alter(&$entity_info) {
// Set the controller class for nodes to an alternate implementation of the
// DrupalEntityController interface.
$entity_info['node']['controller class'] = 'MyCustomNodeController';
} | [
"code-task",
"hook-definition"
] | 2026-09-30T00:00:00 |
api-drupal7-a151690146 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21image%21image.module/function/image_default_style_revert/7.x | In Drupal 7, write the function `image_default_style_revert($style)` (file modules/image/image.module) so that it does the following: Reverts the changes made by users to a default image style. | Returns (Boolean): TRUE if the operation succeeded.
File: modules/image/image.module | function image_default_style_revert($style) {
image_style_flush($style);
db_delete('image_effects')->condition('isid', $style['isid'])->execute();
db_delete('image_styles')->condition('isid', $style['isid'])->execute();
return TRUE;
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-a1547178be | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21install.core.inc/function/install_tasks_to_display/7.x | In Drupal 7, write the function `install_tasks_to_display($install_state)` (file includes/install.core.inc) so that it does the following: Returns a list of tasks that should be displayed to the end user. | The output of this function is a list suitable for sending to theme_task_list().
Parameters:
- $install_state: An array of information about the current installation state.
Returns: A list of tasks, with keys equal to the machine-readable task name and values equal to the name that should be displayed.
File: include... | function install_tasks_to_display($install_state) {
$displayed_tasks = array();
foreach (install_tasks($install_state) as $name => $task) {
if ($task['display']) {
$displayed_tasks[$name] = $task['display_name'];
}
}
return $displayed_tasks;
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-a157498485 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21comment%21comment.module/function/comment_node_update_index/7.x | Implement `comment_node_update_index($node)` in PHP for Drupal 7. Required behavior: Implements hook_node_update_index(). | File: modules/comment/comment.module | function comment_node_update_index($node) {
$index_comments = &drupal_static(__FUNCTION__);
if ($index_comments === NULL) {
// Find and save roles that can 'access comments' or 'search content'.
$perms = array('access comments' => array(), 'search content' => array());
$result = db_query("SELECT rid, p... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-a171d8a318 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21field_ui%21field_ui.admin.inc/function/field_ui_field_overview_form_validate/7.x | In Drupal 7, write the function `field_ui_field_overview_form_validate($form, &$form_state)` (file modules/field_ui/field_ui.admin.inc) so that it does the following: Form validation handler for field_ui_field_overview_form(). | File: modules/field_ui/field_ui.admin.inc | function field_ui_field_overview_form_validate($form, &$form_state) {
_field_ui_field_overview_form_validate_add_new($form, $form_state);
_field_ui_field_overview_form_validate_add_existing($form, $form_state);
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-a187add1d0 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21poll%21poll.module/function/poll_node_form_submit/7.x | In Drupal 7, write the function `poll_node_form_submit(&$form, &$form_state)` (file modules/poll/poll.module) so that it does the following: Form submit handler for node_form(). | Upon preview and final submission, we need to renumber poll choices and create a teaser output.
File: modules/poll/poll.module | function poll_node_form_submit(&$form, &$form_state) {
// Renumber choices.
$form_state['values']['choice'] = array_values($form_state['values']['choice']);
$form_state['values']['teaser'] = poll_teaser((object) $form_state['values']);
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-a1b768e1fa | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21database%21database.inc/function/db_update/7.x | Implement `db_update($table, array $options = array())` in PHP for Drupal 7. Required behavior: Returns a new UpdateQuery object for the active database. | Parameters:
- $table: The table to update.
- $options: An array of options to control how the query operates.
Returns: UpdateQuery A new UpdateQuery object for this connection.
File: includes/database/database.inc | function db_update($table, array $options = array()) {
if (empty($options['target']) || $options['target'] == 'slave') {
$options['target'] = 'default';
}
return Database::getConnection($options['target'])->update($table, $options);
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-a1bd6d5934 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21field_ui%21field_ui.admin.inc/function/field_ui_widget_type_form/7.x | Implement `field_ui_widget_type_form($form, &$form_state, $instance)` in PHP for Drupal 7. Required behavior: Form constructor for the widget selection form. | Path: BUNDLE_ADMIN_PATH/fields/%field/widget-type, where BUNDLE_ADMIN_PATH is the path stored in the ['admin']['info'] property in the return value of hook_entity_info().
File: modules/field_ui/field_ui.admin.inc | function field_ui_widget_type_form($form, &$form_state, $instance) {
drupal_set_title($instance['label']);
$bundle = $instance['bundle'];
$entity_type = $instance['entity_type'];
$field_name = $instance['field_name'];
$field = field_info_field($field_name);
$field_type = field_info_field_types($field['typ... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-a1e4d9770e | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21openid%21openid.module/function/openid_openid_normalization_method_info/7.x | Implement `openid_openid_normalization_method_info()` in PHP for Drupal 7. Required behavior: Implements hook_openid_normalization_method_info(). | Define standard normalization methods.
File: modules/openid/openid.module | function openid_openid_normalization_method_info() {
// OpenID Authentication 2.0, section 7.2:
// If the User-supplied Identifier looks like an XRI, treat it as such;
// otherwise treat it as an HTTP URL.
return array(
'xri' => '_openid_xri_normalize',
'url' => '_openid_url_normalize',
);
} | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-a20acc34ca | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21contact%21contact.install/function/contact_update_dependencies/7.x | Implement `contact_update_dependencies()` in PHP for Drupal 7. Required behavior: Implements hook_update_dependencies(). | File: modules/contact/contact.install | function contact_update_dependencies() {
// contact_update_7001() relies on the {role_permission} table being updated
// to the new format and filled with data.
$dependencies['contact'][7001] = array(
'system' => 7007,
);
// contact_update_7002() relies on the {role_permission} table having the
// modu... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-a20cb3cf46 | 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: Determines if a theme is available to use. | Parameters:
- $theme: Either the name of a theme or a full theme object.
Returns (Boolean): TRUE if the theme is enabled or is the site administration theme; FALSE otherwise.
File: includes/theme.inc | function drupal_theme_access($theme) {
if (is_object($theme)) {
return _drupal_theme_access($theme);
}
else {
$themes = list_themes();
return isset($themes[$theme]) && _drupal_theme_access($themes[$theme]);
}
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-a20d6999cc | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21file%21file.field.inc/function/file_field_widget_process/7.x | Implement `file_field_widget_process($element, &$form_state, $form)` in PHP for Drupal 7. Required behavior: An element #process callback for the file_generic field type. | Expands the file_generic type to include the description and display fields.
File: modules/file/file.field.inc | function file_field_widget_process($element, &$form_state, $form) {
$item = $element['#value'];
$item['fid'] = $element['fid']['#value'];
$field = field_widget_field($element, $form_state);
$instance = field_widget_instance($element, $form_state);
$settings = $instance['widget']['settings'];
$element['#th... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-a223a49fbb | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21update%21update.install/function/update_uninstall/7.x | Implement `update_uninstall()` in PHP for Drupal 7. Required behavior: Implements hook_uninstall(). | File: modules/update/update.install | function update_uninstall() {
// Clear any variables that might be in use
$variables = array(
'update_check_frequency',
'update_fetch_url',
'update_last_check',
'update_last_email_notification',
'update_notification_threshold',
'update_notify_emails',
'update_max_fetch_attempts',
'up... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-a25d7055d0 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21field%21modules%21list%21list.module/function/list_field_info/7.x | Implement `list_field_info()` in PHP for Drupal 7. Required behavior: Implements hook_field_info(). | File: modules/field/modules/list/list.module | function list_field_info() {
return array(
'list_integer' => array(
'label' => t('List (integer)'),
'description' => t("This field stores integer values from a list of allowed 'value => label' pairs, i.e. 'Lifetime in days': 1 => 1 day, 7 => 1 week, 31 => 1 month."),
'settings' => array('allowed... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-a27c479a2e | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21dblog%21dblog.admin.inc/function/dblog_filter_form/7.x | Implement `dblog_filter_form($form)` in PHP for Drupal 7. Required behavior: Form constructor for the database logging filter form. | File: modules/dblog/dblog.admin.inc | function dblog_filter_form($form) {
$filters = dblog_filters();
$form['filters'] = array(
'#type' => 'fieldset',
'#title' => t('Filter log messages'),
'#collapsible' => TRUE,
'#collapsed' => empty($_SESSION['dblog_overview_filter']),
);
foreach ($filters as $key => $filter) {
$form['filters... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-a2ce496acf | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21user%21user.api.php/function/hook_user_role_delete/7.x | In Drupal 7, show an example implementation for `hook_user_role_delete($role)` (modules/user/user.api.php): Respond to user role deletion. | This hook allows you act when a user role has been deleted. If your module stores references to roles, it's recommended that you implement this hook and delete existing instances of the deleted role in your module database tables.
Parameters:
- $role: The $role object being deleted.
File: modules/user/user.api.php | function hook_user_role_delete($role) {
// Delete existing instances of the deleted role.
db_delete('my_module_table')
->condition('rid', $role->rid)
->execute();
} | [
"code-task",
"hook-definition"
] | 2026-09-30T00:00:00 |
api-drupal7-a2d15e38b8 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21install.core.inc/function/_install_select_profile/7.x | In Drupal 7, write the function `_install_select_profile($profiles)` (file includes/install.core.inc) so that it does the following: Selects an installation profile. | A profile will be selected if:
- Only one profile is available,
- A profile was submitted through $_POST,
- Exactly one of the profiles is marked as "exclusive".
If multiple profiles are marked as "exclusive" then no profile will be
selected.
Parameters:
- $profiles (array): An associative array of profiles with the m... | function _install_select_profile($profiles) {
if (sizeof($profiles) == 0) {
throw new Exception(install_no_profile_error());
}
// Don't need to choose profile if only one available.
if (sizeof($profiles) == 1) {
$profile = array_pop($profiles);
// TODO: is this right?
require_once DRUPAL_ROOT . ... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-a2d78c5efb | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21field_ui%21field_ui.api.php/function/hook_field_widget_settings_form/7.x | In Drupal 7, show an example implementation for `hook_field_widget_settings_form($field, $instance)` (modules/field_ui/field_ui.api.php): Add settings to a widget settings form. | Invoked from field_ui_field_edit_form() to allow the module defining the widget to add settings for a widget instance.
Parameters:
- $field: The field structure being configured.
- $instance: The instance structure being configured.
Returns: The form definition for the widget settings.
File: modules/field_ui/field_u... | function hook_field_widget_settings_form($field, $instance) {
$widget = $instance['widget'];
$settings = $widget['settings'];
if ($widget['type'] == 'text_textfield') {
$form['size'] = array(
'#type' => 'textfield',
'#title' => t('Size of textfield'),
'#default_value' => $settings['size'],
... | [
"code-task",
"hook-definition"
] | 2026-09-30T00:00:00 |
api-drupal7-a2f5443c6b | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21openid%21openid.module/function/openid_discovery/7.x | I need the code for `openid_discovery($claimed_id)` in Drupal 7 (modules/openid/openid.module). It must do this: Perform discovery on a claimed ID to determine the OpenID provider endpoint. | Discovery methods are provided by the hook_openid_discovery_method_info and could be further altered using the hook_openid_discovery_method_info_alter.
Parameters:
- $claimed_id: The OpenID URL to perform discovery on.
Returns: The resulting discovery array from the first successful discovery method, which must conta... | function openid_discovery($claimed_id) {
module_load_include('inc', 'openid');
$methods = module_invoke_all('openid_discovery_method_info');
drupal_alter('openid_discovery_method_info', $methods);
// Execute each method in turn and return first successful discovery.
foreach ($methods as $method) {
$disc... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-a306cb7bf2 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21file.inc/function/file_get_mimetype/7.x | Implement `file_get_mimetype($uri, $mapping = NULL)` in PHP for Drupal 7. Required behavior: Determines an Internet Media Type or MIME type from a filename. | Parameters:
- $uri: A string containing the URI, path, or filename.
- $mapping: An optional map of extensions to their mimetypes, in the form: - 'mimetypes': a list of mimetypes, keyed by an identifier, - 'extensions': the mapping itself, an associative array in which the key is the extension (lowercase) and the value ... | function file_get_mimetype($uri, $mapping = NULL) {
if ($wrapper = file_stream_wrapper_get_instance_by_uri($uri)) {
return $wrapper->getMimeType($uri, $mapping);
}
else {
// getMimeType() is not implementation specific, so we can directly
// call it without an instance.
return DrupalLocalStreamWra... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-a30b79e3da | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21install.inc/function/drupal_rewrite_settings/7.x | In Drupal 7, write the function `drupal_rewrite_settings($settings = array(), $prefix = '')` (file includes/install.inc) so that it does the following: Replaces values in settings.php with values in the submitted array. | Parameters:
- $settings: An array of settings that need to be updated.
File: includes/install.inc | function drupal_rewrite_settings($settings = array(), $prefix = '') {
$default_settings = 'sites/default/default.settings.php';
drupal_static_reset('conf_path');
$settings_file = conf_path(FALSE) . '/' . $prefix . 'settings.php';
// Build list of setting names and insert the values into the global namespace.
... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-a312fed274 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21field%21field.api.php/function/hook_field_presave/7.x | Give me the example code for `hook_field_presave($entity_type, $entity, $field, $instance, $langcode, &$items)` in Drupal 7. Hook description: Define custom presave behavior for this module's field types. | Make changes or additions to field values by altering the $items parameter by reference. There is no return value.
Parameters:
- $entity_type: The type of $entity.
- $entity: The entity for the operation.
- $field: The field structure for the operation.
- $instance: The instance structure for $field on $entity's bundl... | function hook_field_presave($entity_type, $entity, $field, $instance, $langcode, &$items) {
if ($field['type'] == 'number_decimal') {
// Let PHP round the value to ensure consistent behavior across storage
// backends.
foreach ($items as $delta => $item) {
if (isset($item['value'])) {
$items... | [
"code-task",
"hook-definition"
] | 2026-09-30T00:00:00 |
api-drupal7-a3186ceb91 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21contact%21contact.install/function/contact_schema/7.x | Implement `contact_schema()` in PHP for Drupal 7. Required behavior: Implements hook_schema(). | File: modules/contact/contact.install | function contact_schema() {
$schema['contact'] = array(
'description' => 'Contact form category settings.',
'fields' => array(
'cid' => array(
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
'description' => 'Primary Key: Unique category ID.',
),
'... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-a31917d4dc | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21node%21node.module/function/node_hook/7.x | I need the code for `node_hook($node, $hook)` in Drupal 7 (modules/node/node.module). It must do this: Determines whether a node hook exists. | Parameters:
- $node: A node object or a string containing the node type.
- $hook: A string containing the name of the hook.
Returns: TRUE if the $hook exists in the node type of $node.
File: modules/node/node.module | function node_hook($node, $hook) {
$base = node_type_get_base($node);
return module_hook($base, $hook);
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-a33ef0b8ef | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21overlay%21overlay.module/function/overlay_init/7.x | I need the code for `overlay_init()` in Drupal 7 (modules/overlay/overlay.module). It must do this: Implements hook_init(). | Determine whether the current page request is destined to appear in the parent window or in the overlay window, and format the page accordingly.
File: modules/overlay/overlay.module | function overlay_init() {
global $user;
$mode = overlay_get_mode();
// Only act if the user has access to the overlay and a mode was not already
// set. Other modules can also enable the overlay directly for other uses.
$use_overlay = !isset($user->data['overlay']) || $user->data['overlay'];
if (empty($mo... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-a352b49a68 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21simpletest%21simpletest.module/function/simpletest_clean_results_table/7.x | In Drupal 7, write the function `simpletest_clean_results_table($test_id = NULL)` (file modules/simpletest/simpletest.module) so that it does the following: Clear the test result tables. | Parameters:
- $test_id: Test ID to remove results for, or NULL to remove all results.
Returns: The number of results removed.
File: modules/simpletest/simpletest.module | function simpletest_clean_results_table($test_id = NULL) {
if (variable_get('simpletest_clear_results', TRUE)) {
if ($test_id) {
$count = db_query('SELECT COUNT(test_id) FROM {simpletest_test_id} WHERE test_id = :test_id', array(':test_id' => $test_id))->fetchField();
db_delete('simpletest')
... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-a35c31abea | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21system.admin.inc/function/system_batch_page/7.x | In Drupal 7, write the function `system_batch_page()` (file modules/system/system.admin.inc) so that it does the following: Default page callback for batches. | File: modules/system/system.admin.inc | function system_batch_page() {
require_once DRUPAL_ROOT . '/includes/batch.inc';
$output = _batch_page();
if ($output === FALSE) {
drupal_access_denied();
drupal_exit();
}
elseif (isset($output)) {
// Force a page without blocks or messages to
// display a list of collected messages later.
... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-a3b08e1513 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21menu.inc/function/menu_local_tabs/7.x | I need the code for `menu_local_tabs()` in Drupal 7 (includes/menu.inc). It must do this: Returns a renderable element for the primary and secondary tabs. | File: includes/menu.inc | function menu_local_tabs() {
return array(
'#theme' => 'menu_local_tasks',
'#primary' => menu_primary_local_tasks(),
'#secondary' => menu_secondary_local_tasks(),
);
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-a3b6702a42 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21locale.inc/function/_locale_import_parse_arithmetic/7.x | I need the code for `_locale_import_parse_arithmetic($string)` in Drupal 7 (includes/locale.inc). It must do this: Parses and sanitizes an arithmetic formula into a PHP expression | While parsing, we ensure, that the operators have the right precedence and associativity.
Parameters:
- $string: A string containing the arithmetic formula.
Returns: The PHP version of the formula.
File: includes/locale.inc | function _locale_import_parse_arithmetic($string) {
// Operator precedence table
$precedence = array("(" => -1, ")" => -1, "?" => 1, ":" => 1, "||" => 3, "&&" => 4, "==" => 5, "!=" => 5, "<" => 6, ">" => 6, "<=" => 6, ">=" => 6, "+" => 7, "-" => 7, "*" => 8, "/" => 8, "%" => 8);
// Right associativity
$right_as... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-a3b80ed8d4 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21user%21user.module/function/user_view_access/7.x | In Drupal 7, write the function `user_view_access($account)` (file modules/user/user.module) so that it does the following: User view access callback. | Parameters:
- $account: Can either be a full user object or a $uid.
File: modules/user/user.module | function user_view_access($account) {
$uid = is_object($account) ? $account->uid : (int) $account;
// Never allow access to view the anonymous user account.
if ($uid) {
// Admins can view all, users can view own profiles at all times.
if ($GLOBALS['user']->uid == $uid || user_access('administer users')) ... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-a3d39c74ad | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21taxonomy%21taxonomy.module/function/taxonomy_term_is_page/7.x | Implement `taxonomy_term_is_page($term)` in PHP for Drupal 7. Required behavior: Returns whether the current page is the page of the passed-in term. | Parameters:
- $term: A term object.
File: modules/taxonomy/taxonomy.module | function taxonomy_term_is_page($term) {
$page_term = menu_get_object('taxonomy_term', 2);
return (!empty($page_term) ? $page_term->tid == $term->tid : FALSE);
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-a41050ce7d | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21system.admin.inc/function/theme_admin_block_content/7.x | In Drupal 7, write the function `theme_admin_block_content($variables)` (file modules/system/system.admin.inc) so that it does the following: Returns HTML for the content of an administrative block. | Parameters:
- $variables: An associative array containing: - content: An array containing information about the block. Each element of the array represents an administrative menu item, and must at least contain the keys 'title', 'href', and 'localized_options', which are passed to l(). A 'description' key may also be p... | function theme_admin_block_content($variables) {
$content = $variables['content'];
$output = '';
if (!empty($content)) {
$class = 'admin-list';
if ($compact = system_admin_compact_mode()) {
$class .= ' compact';
}
$output .= '<dl class="' . $class . '">';
foreach ($content as $item) {
... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-a415aa6397 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21common.inc/function/entity_language/7.x | In Drupal 7, write the function `entity_language($entity_type, $entity)` (file includes/common.inc) so that it does the following: Returns the language of an entity. | Parameters:
- $entity_type: The entity type; e.g., 'node' or 'user'.
- $entity: The entity for which to get the language.
Returns: A valid language code or NULL if the entity has no language support.
File: includes/common.inc | function entity_language($entity_type, $entity) {
$info = entity_get_info($entity_type);
// Invoke the callback to get the language. If there is no callback, try to
// get it from a property of the entity, otherwise NULL.
if (isset($info['language callback']) && function_exists($info['language callback'])) {
... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-a4412f4594 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21xmlrpcs.inc/function/xmlrpc_server_error/7.x | I need the code for `xmlrpc_server_error($error, $message = FALSE)` in Drupal 7 (includes/xmlrpcs.inc). It must do this: Throws an XML-RPC error. | Parameters:
- $error: An error object or integer error code.
- $message: (optional) The description of the error. Used only if an integer error code was passed in.
File: includes/xmlrpcs.inc | function xmlrpc_server_error($error, $message = FALSE) {
if ($message && !is_object($error)) {
$error = xmlrpc_error($error, $message);
}
xmlrpc_server_output(xmlrpc_error_get_xml($error));
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-a4439ff482 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21block%21block.module/function/block_load/7.x | Implement `block_load($module, $delta)` in PHP for Drupal 7. Required behavior: Loads a block object from the database. | This function returns the first block matching the module and delta parameters, so it should not be used for theme-specific functionality.
Parameters:
- $module: Name of the module that implements the block to load.
- $delta: Unique ID of the block within the context of $module. Pass NULL to return an empty block obje... | function block_load($module, $delta) {
if (isset($delta)) {
$block = db_query('SELECT * FROM {block} WHERE module = :module AND delta = :delta', array(':module' => $module, ':delta' => $delta))->fetchObject();
}
// If the block does not exist in the database yet return a stub block
// object.
if (empty($... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-a475a53611 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21system.api.php/function/hook_xmlrpc_alter/7.x | In Drupal 7, show an example implementation for `hook_xmlrpc_alter(&$methods)` (modules/system/system.api.php): Alters the definition of XML-RPC methods before they are called. | This hook allows modules to modify the callback definition of declared XML-RPC methods, right before they are invoked by a client. Methods may be added, or existing methods may be altered.
Note that hook_xmlrpc() supports two distinct and incompatible formats to define a callback, so care must be taken when altering o... | function hook_xmlrpc_alter(&$methods) {
// Directly change a simple method.
$methods['drupal.login'] = 'mymodule_login';
// Alter complex definitions.
foreach ($methods as $key => &$method) {
// Skip simple method definitions.
if (!is_int($key)) {
continue;
}
// Perform the wanted manipul... | [
"code-task",
"hook-definition"
] | 2026-09-30T00:00:00 |
api-drupal7-a483acea30 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21menu%21menu.admin.inc/function/menu_reset_item_confirm/7.x | I need the code for `menu_reset_item_confirm($form, &$form_state, $item)` in Drupal 7 (modules/menu/menu.admin.inc). It must do this: Menu callback; reset a single modified menu link. | File: modules/menu/menu.admin.inc | function menu_reset_item_confirm($form, &$form_state, $item) {
$form['item'] = array('#type' => 'value', '#value' => $item);
return confirm_form($form, t('Are you sure you want to reset the link %item to its default values?', array('%item' => $item['link_title'])), 'admin/structure/menu/manage/' . $item['menu_name'... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-a49329d2be | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21taxonomy%21taxonomy.install/function/taxonomy_update_7009/7.x | Implement `taxonomy_update_7009()` in PHP for Drupal 7. Required behavior: Change {taxonomy_term_data}.format into varchar. | File: modules/taxonomy/taxonomy.install | function taxonomy_update_7009() {
db_change_field('taxonomy_term_data', 'format', 'format', array(
'type' => 'varchar',
'length' => 255,
'not null' => FALSE,
'description' => 'The {filter_format}.format of the description.',
));
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-a4b5a9e122 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21aggregator%21aggregator.module/function/aggregator_save_category/7.x | I need the code for `aggregator_save_category($edit)` in Drupal 7 (modules/aggregator/aggregator.module). It must do this: Adds/edits/deletes aggregator categories. | Parameters:
- $edit: An associative array describing the category to be added/edited/deleted.
File: modules/aggregator/aggregator.module | function aggregator_save_category($edit) {
$link_path = 'aggregator/categories/';
if (!empty($edit['cid'])) {
$link_path .= $edit['cid'];
if (!empty($edit['title'])) {
db_merge('aggregator_category')
->key(array('cid' => $edit['cid']))
->fields(array(
'title' => $edit['title'... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-a4bd520e58 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21node%21node.module/function/node_get_recent/7.x | In Drupal 7, write the function `node_get_recent($number = 10)` (file modules/node/node.module) so that it does the following: Finds the most recently changed nodes that are available to the current user. | Parameters:
- $number: (optional) The maximum number of nodes to find. Defaults to 10.
Returns: An array of node entities or an empty array if there are no recent nodes visible to the current user.
File: modules/node/node.module | function node_get_recent($number = 10) {
$query = db_select('node', 'n');
if (!user_access('bypass node access')) {
// If the user is able to view their own unpublished nodes, allow them to
// see these in addition to published nodes. Check that they actually have
// some unpublished nodes to view befo... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-a4c31f5232 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21system.admin.inc/function/system_ip_blocking/7.x | In Drupal 7, write the function `system_ip_blocking($default_ip = '')` (file modules/system/system.admin.inc) so that it does the following: Menu callback. Display blocked IP addresses. | Parameters:
- $default_ip: Optional IP address to be passed on to drupal_get_form() for use as the default value of the IP address form field.
File: modules/system/system.admin.inc | function system_ip_blocking($default_ip = '') {
$rows = array();
$header = array(t('Blocked IP addresses'), t('Operations'));
$result = db_query('SELECT * FROM {blocked_ips}');
foreach ($result as $ip) {
$rows[] = array(
$ip->ip,
l(t('delete'), "admin/config/people/ip-blocking/delete/$ip->iid"),... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-a4c457db02 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21comment%21comment.admin.inc/function/comment_confirm_delete_page/7.x | Implement `comment_confirm_delete_page($cid)` in PHP for Drupal 7. Required behavior: Page callback for comment deletions. | File: modules/comment/comment.admin.inc | function comment_confirm_delete_page($cid) {
if ($comment = comment_load($cid)) {
return drupal_get_form('comment_confirm_delete', $comment);
}
return MENU_NOT_FOUND;
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-a4f7b528cb | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21field%21field.api.php/function/hook_field_purge_field/7.x | Give me the example code for `hook_field_purge_field($field)` in Drupal 7. Hook description: Acts when a field record is being purged. | In field_purge_field(), after the field configuration has been removed from the database, the field storage module has had a chance to run its hook_field_storage_purge_field(), and the field info cache has been cleared, this hook is invoked on all modules to allow them to respond to the field being purged.
Parameters:... | function hook_field_purge_field($field) {
db_delete('my_module_field_info')
->condition('id', $field['id'])
->execute();
} | [
"code-task",
"hook-definition"
] | 2026-09-30T00:00:00 |
api-drupal7-a53a2eea29 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21shortcut%21shortcut.module/function/shortcut_help/7.x | Implement `shortcut_help($path, $arg)` in PHP for Drupal 7. Required behavior: Implements hook_help(). | File: modules/shortcut/shortcut.module | function shortcut_help($path, $arg) {
global $user;
switch ($path) {
case 'admin/help#shortcut':
$output = '<h3>' . t('About') . '</h3>';
$output .= '<p>' . t('The Shortcut module allows users to create sets of <em>shortcut</em> links to commonly-visited pages of the site. Shortcuts are contained w... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-a548640059 | 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_purge_field/7.x | I need the code for `field_sql_storage_field_storage_purge_field($field)` in Drupal 7 (modules/field/modules/field_sql_storage/field_sql_storage.module). It must do this: Implements hook_field_storage_purge_field(). | All field data items and instances have already been purged, so all that is left is to delete the table.
File: modules/field/modules/field_sql_storage/field_sql_storage.module | function field_sql_storage_field_storage_purge_field($field) {
$table_name = _field_sql_storage_tablename($field);
$revision_name = _field_sql_storage_revision_tablename($field);
db_drop_table($table_name);
db_drop_table($revision_name);
} | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-a5558b6bd3 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21user%21user.pages.inc/function/template_preprocess_user_profile_item/7.x | Implement `template_preprocess_user_profile_item(&$variables)` in PHP for Drupal 7. Required behavior: Process variables for user-profile-item.tpl.php. | The $variables array contains the following arguments:
- $element
File: modules/user/user.pages.inc | function template_preprocess_user_profile_item(&$variables) {
$variables['title'] = $variables['element']['#title'];
$variables['value'] = $variables['element']['#markup'];
$variables['attributes'] = '';
if (isset($variables['element']['#attributes'])) {
$variables['attributes'] = drupal_attributes($variabl... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-a5568cf2b9 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21dashboard%21dashboard.module/function/dashboard_page_build/7.x | In Drupal 7, write the function `dashboard_page_build(&$page)` (file modules/dashboard/dashboard.module) so that it does the following: Implements hook_page_build(). | Display dashboard blocks in the main content region.
File: modules/dashboard/dashboard.module | function dashboard_page_build(&$page) {
global $theme_key;
if (dashboard_is_visible()) {
$block_info = array();
// Create a wrapper for the dashboard itself, then insert each dashboard
// region into it.
$page['content']['dashboard'] = array('#theme_wrappers' => array('dashboard'));
foreach (d... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-a56553561d | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21book%21book.module/function/book_entity_info_alter/7.x | I need the code for `book_entity_info_alter(&$info)` in Drupal 7 (modules/book/book.module). It must do this: Implements hook_entity_info_alter(). | File: modules/book/book.module | function book_entity_info_alter(&$info) {
// Add the 'Print' view mode for nodes.
$info['node']['view modes'] += array(
'print' => array(
'label' => t('Print'),
'custom settings' => FALSE,
),
);
} | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-a572d05921 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21openid%21openid.module/function/openid_verify_assertion_nonce/7.x | In Drupal 7, write the function `openid_verify_assertion_nonce($service, $response)` (file modules/openid/openid.module) so that it does the following: Verify that the nonce has not been used in earlier assertions from the same OpenID provider. | Parameters:
- $service: Array describing the OpenID provider.
- $response: Array of response values from the provider.
Returns: TRUE if the nonce has not expired and has not been used earlier.
File: modules/openid/openid.module | function openid_verify_assertion_nonce($service, $response) {
if ($service['version'] != 2) {
return TRUE;
}
if (preg_match('/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})Z/', $response['openid.response_nonce'], $matches)) {
list(, $year, $month, $day, $hour, $minutes, $seconds) = $matches;
$nonce... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-a5783ca059 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21module.inc/function/module_implements/7.x | In Drupal 7, write the function `module_implements($hook, $sort = FALSE, $reset = FALSE)` (file includes/module.inc) so that it does the following: Determines which modules are implementing a hook. | Lazy-loaded include files specified with "group" via hook_hook_info() or hook_module_implements_alter() will be automatically included by this function when necessary.
Parameters:
- $hook (string): The name of the hook (e.g. "help" or "menu").
- $sort (bool): By default, modules are ordered by weight and filename, set... | function module_implements($hook, $sort = FALSE, $reset = FALSE) {
// Use the advanced drupal_static() pattern, since this is called very often.
static $drupal_static_fast;
if (!isset($drupal_static_fast)) {
$drupal_static_fast['implementations'] = &drupal_static(__FUNCTION__);
$drupal_static_fast['verifi... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-a57c08c132 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21book%21book.module/function/book_children/7.x | In Drupal 7, write the function `book_children($book_link)` (file modules/book/book.module) so that it does the following: Formats the menu links for the child pages of the current page. | Parameters:
- $book_link: A fully loaded menu link that is part of the book hierarchy.
Returns: HTML for the links to the child pages of the current page.
File: modules/book/book.module | function book_children($book_link) {
$flat = book_get_flat_menu($book_link);
$children = array();
if ($book_link['has_children']) {
// Walk through the array until we find the current page.
do {
$link = array_shift($flat);
}
while ($link && ($link['mlid'] != $book_link['mlid']));
// Co... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-a58c068946 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21xmlrpc.inc/function/xmlrpc_value_calculate_type/7.x | Implement `xmlrpc_value_calculate_type($xmlrpc_value)` in PHP for Drupal 7. Required behavior: Maps a PHP type to an XML-RPC type. | Parameters:
- $xmlrpc_value: Variable whose type should be mapped.
Returns (string): The corresponding XML-RPC type.
File: includes/xmlrpc.inc | function xmlrpc_value_calculate_type($xmlrpc_value) {
// http://www.php.net/gettype: Never use gettype() to test for a certain type
// [...] Instead, use the is_* functions.
if (is_bool($xmlrpc_value->data)) {
return 'boolean';
}
if (is_double($xmlrpc_value->data)) {
return 'double';
}
if (is_int(... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-a5973c44ad | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21color%21color.module/function/_color_rewrite_stylesheet/7.x | In Drupal 7, write the function `_color_rewrite_stylesheet($theme, &$info, &$paths, $palette, $style)` (file modules/color/color.module) so that it does the following: Rewrites the stylesheet to match the colors in the palette. | File: modules/color/color.module | function _color_rewrite_stylesheet($theme, &$info, &$paths, $palette, $style) {
$themes = list_themes();
// Prepare color conversion table.
$conversion = $palette;
foreach ($conversion as $k => $v) {
$conversion[$k] = drupal_strtolower($v);
}
$default = color_get_palette($theme, TRUE);
// Split off t... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-a5c2c0809f | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21taxonomy%21taxonomy.module/function/taxonomy_vocabulary_machine_name_load/7.x | I need the code for `taxonomy_vocabulary_machine_name_load($name)` in Drupal 7 (modules/taxonomy/taxonomy.module). It must do this: Return the vocabulary object matching a vocabulary machine name. | Parameters:
- $name: The vocabulary's machine name.
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_machine_name_load($name) {
$vocabularies = taxonomy_vocabulary_load_multiple(NULL, array('machine_name' => $name));
return reset($vocabularies);
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-a5c47b8412 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21search%21search.module/function/search_is_active/7.x | I need the code for `search_is_active()` in Drupal 7 (modules/search/search.module). It must do this: Determines access for the ?q=search path. | File: modules/search/search.module | function search_is_active() {
// This path cannot be accessed if there are no active modules.
return user_access('search content') && search_get_info();
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-a5d21c9c80 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21errors.inc/function/_drupal_decode_exception/7.x | I need the code for `_drupal_decode_exception($exception)` in Drupal 7 (includes/errors.inc). It must do this: Decodes an exception and retrieves the correct caller. | Parameters:
- $exception: The exception object that was thrown.
Returns: An error in the format expected by _drupal_log_error().
File: includes/errors.inc | function _drupal_decode_exception($exception) {
$message = $exception->getMessage();
$backtrace = $exception->getTrace();
// Add the line throwing the exception to the backtrace.
array_unshift($backtrace, array('line' => $exception->getLine(), 'file' => $exception->getFile()));
// For PDOException errors, w... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-a5dc00800e | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21errors.inc/function/_drupal_strip_error_file_path/7.x | Implement `_drupal_strip_error_file_path($error)` in PHP for Drupal 7. Required behavior: Strip full path information from error details. | Parameters:
- $error: An array with the following keys: %type, !message, %function, %file, %line and severity_level.
Returns: An array with the same keys as the $error param but with full paths stripped from the %file element
File: includes/errors.inc | function _drupal_strip_error_file_path($error) {
if (!empty($error['%file'])) {
if (($drupal_root_position = strpos($error['%file'], DRUPAL_ROOT)) === 0) {
$root_length = strlen(DRUPAL_ROOT);
$error['%file'] = substr($error['%file'], $root_length + 1);
}
elseif ($drupal_root_position !== FALSE... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-a5eeaf23e6 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21profile%21profile.pages.inc/function/profile_autocomplete/7.x | In Drupal 7, write the function `profile_autocomplete($field, $string)` (file modules/profile/profile.pages.inc) so that it does the following: Callback to allow autocomplete of profile text fields. | File: modules/profile/profile.pages.inc | function profile_autocomplete($field, $string) {
$matches = array();
$autocomplete_field = (bool) db_query_range("SELECT 1 FROM {profile_field} WHERE fid = :fid AND autocomplete = 1", 0, 1, array(':fid' => $field))->fetchField();
if ($autocomplete_field) {
$values = db_select('profile_value')
->fields('... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-a5fe338c85 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21taxonomy%21taxonomy.admin.inc/function/taxonomy_form_term_submit_build_taxonomy_term/7.x | In Drupal 7, write the function `taxonomy_form_term_submit_build_taxonomy_term($form, &$form_state)` (file modules/taxonomy/taxonomy.admin.inc) so that it does the following: Updates the form state's term entity by processing this submission's values. | File: modules/taxonomy/taxonomy.admin.inc | function taxonomy_form_term_submit_build_taxonomy_term($form, &$form_state) {
$term = $form_state['term'];
entity_form_submit_build_entity('taxonomy_term', $term, $form, $form_state);
// Convert text_format field into values expected by taxonomy_term_save().
$description = $form_state['values']['description'];... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-a604a362eb | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21search%21search.module/function/search_form/7.x | Implement `search_form($form, &$form_state, $action = '', $keys = '', $module = NULL, $prompt = NULL)` in PHP for Drupal 7. Required behavior: Builds a search form. | Parameters:
- $action: Form action. Defaults to "search/$path", where $path is the search path associated with the module in its hook_search_info(). This will be run through url().
- $keys: The search string entered by the user, containing keywords for the search.
- $module: The search module to render the form for: a ... | function search_form($form, &$form_state, $action = '', $keys = '', $module = NULL, $prompt = NULL) {
$module_info = FALSE;
if (!$module) {
$module_info = search_get_default_module_info();
}
else {
$info = search_get_info();
$module_info = isset($info[$module]) ? $info[$module] : FALSE;
}
// Sa... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-a61eaa8395 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21taxonomy%21taxonomy.module/function/taxonomy_field_presave/7.x | Implement `taxonomy_field_presave($entity_type, $entity, $field, $instance, $langcode, &$items)` in PHP for Drupal 7. Required behavior: Implements hook_field_presave(). | Create any new terms defined in a freetagging vocabulary.
File: modules/taxonomy/taxonomy.module | function taxonomy_field_presave($entity_type, $entity, $field, $instance, $langcode, &$items) {
foreach ($items as $delta => $item) {
if ($item['tid'] === 'autocreate') {
$term = (object) $item;
unset($term->tid);
taxonomy_term_save($term);
$items[$delta]['tid'] = $term->tid;
}
}
} | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-a638e43d8d | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21file.inc/function/file_uri_target/7.x | I need the code for `file_uri_target($uri)` in Drupal 7 (includes/file.inc). It must do this: Returns the part of a URI after the schema. | Parameters:
- $uri: A stream, referenced as "scheme://target".
Returns: A string containing the target (path), or FALSE if none. For example, the URI "public://sample/test.txt" would return "sample/test.txt".
File: includes/file.inc | function file_uri_target($uri) {
$data = explode('://', $uri, 2);
// Remove erroneous leading or trailing, forward-slashes and backslashes.
return count($data) == 2 ? trim($data[1], '\/') : FALSE;
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-a63ecf4870 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21common.inc/function/format_date/7.x | I need the code for `format_date($timestamp, $type = 'medium', $format = '', $timezone = NULL, $langcode = NULL)` in Drupal 7 (includes/common.inc). It must do this: Formats a date, using a date type or a custom date format string. | Parameters:
- $timestamp: A UNIX timestamp to format.
- $type: (optional) The format to use, one of: - 'short', 'medium', or 'long' (the corresponding built-in date formats). - The name of a date type defined by a module in hook_date_format_types(), if it's been assigned a format. - The machine name of an administrator... | function format_date($timestamp, $type = 'medium', $format = '', $timezone = NULL, $langcode = NULL) {
// Use the advanced drupal_static() pattern, since this is called very often.
static $drupal_static_fast;
if (!isset($drupal_static_fast)) {
$drupal_static_fast['timezones'] = &drupal_static(__FUNCTION__);
... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-a648202423 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21poll%21poll.module/function/poll_validate/7.x | In Drupal 7, write the function `poll_validate($node, $form)` (file modules/poll/poll.module) so that it does the following: Implements hook_validate(). | File: modules/poll/poll.module | function poll_validate($node, $form) {
if (isset($node->title)) {
// Check for at least two options and validate amount of votes.
$realchoices = 0;
foreach ($node->choice as $i => $choice) {
if ($choice['chtext'] != '') {
$realchoices++;
}
if (isset($choice['chvotes']) && $choice... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-a651adaa43 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21update.inc/function/update_fix_compatibility/7.x | I need the code for `update_fix_compatibility()` in Drupal 7 (includes/update.inc). It must do this: Disable any items in the {system} table that are not core compatible. | File: includes/update.inc | function update_fix_compatibility() {
$incompatible = array();
$result = db_query("SELECT name, type, status FROM {system} WHERE status = 1 AND type IN ('module','theme')");
foreach ($result as $row) {
if (update_check_incompatibility($row->name, $row->type)) {
$incompatible[] = $row->name;
}
}
... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-a66bf86e2c | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21image%21image.module/function/image_system_file_system_settings_submit/7.x | Implement `image_system_file_system_settings_submit($form, &$form_state)` in PHP for Drupal 7. Required behavior: Form submission handler for system_file_system_settings(). | Adds a menu rebuild after the public file path has been changed, so that the menu router item depending on that file path will be regenerated.
File: modules/image/image.module | function image_system_file_system_settings_submit($form, &$form_state) {
if ($form['file_public_path']['#default_value'] !== $form_state['values']['file_public_path']) {
variable_set('menu_rebuild_needed', TRUE);
}
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-a670514b20 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21simpletest%21simpletest.module/function/simpletest_js_alter/7.x | Implement `simpletest_js_alter(&$javascript)` in PHP for Drupal 7. Required behavior: Implements hook_js_alter(). | File: modules/simpletest/simpletest.module | function simpletest_js_alter(&$javascript) {
// Since SimpleTest is a special use case for the table select, stick the
// SimpleTest JavaScript above the table select.
$simpletest = drupal_get_path('module', 'simpletest') . '/simpletest.js';
if (array_key_exists($simpletest, $javascript) && array_key_exists('mi... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-a694e1dca7 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_username/7.x | I need the code for `theme_username($variables)` in Drupal 7 (includes/theme.inc). It must do this: Returns HTML for a username, potentially linked to the user's page. | Parameters:
- $variables: An associative array containing: - account: The user object to format. - name: The user's name, sanitized. - extra: Additional text to append to the user's name, sanitized. - link_path: The path or URL of the user's profile page, home page, or other desired page to link to for more information... | function theme_username($variables) {
if (isset($variables['link_path'])) {
// We have a link path, so we should generate a link using l().
// Additional classes may be added as array elements like
// $variables['link_options']['attributes']['class'][] = 'myclass';
$output = l($variables['name'] . $va... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-a69f1f6a06 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21trigger%21trigger.module/function/_trigger_normalize_comment_context/7.x | Implement `_trigger_normalize_comment_context($type, $comment)` in PHP for Drupal 7. Required behavior: Loads associated objects for comment triggers. | When an action is called in a context that does not match its type, the object that the action expects must be retrieved. For example, when an action that works on nodes is called during the comment hook, the node object is not available since the comment hook doesn't pass it. So here we load the object the action expe... | function _trigger_normalize_comment_context($type, $comment) {
switch ($type) {
// An action that works with nodes is being called in a comment context.
case 'node':
return node_load(is_array($comment) ? $comment['nid'] : $comment->nid);
// An action that works on users is being called in a comment... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-a6bda98be5 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21common.inc/function/drupal_add_library/7.x | Implement `drupal_add_library($module, $name, $every_page = NULL)` in PHP for Drupal 7. Required behavior: Adds multiple JavaScript or CSS files at the same time. | A library defines a set of JavaScript and/or CSS files, optionally using settings, and optionally requiring another library. For example, a library can be a jQuery plugin, a JavaScript framework, or a CSS framework. This function allows modules to load a library defined/shipped by itself or a depending module, without ... | function drupal_add_library($module, $name, $every_page = NULL) {
$added = &drupal_static(__FUNCTION__, array());
// Only process the library if it exists and it was not added already.
if (!isset($added[$module][$name])) {
if ($library = drupal_get_library($module, $name)) {
// Add all components withi... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-a6e4efa1ca | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21system.api.php/function/hook_url_outbound_alter/7.x | Give me the example code for `hook_url_outbound_alter(&$path, &$options, $original_path)` in Drupal 7. Hook description: Alters outbound URLs. | Parameters:
- $path: The outbound path to alter, not adjusted for path aliases yet. It won't be adjusted for path aliases until all modules are finished altering it, thus being consistent with hook_url_inbound_alter(), which adjusts for all path aliases before allowing modules to alter it. This may have been altered by... | function hook_url_outbound_alter(&$path, &$options, $original_path) {
// Use an external RSS feed rather than the Drupal one.
if ($path == 'rss.xml') {
$path = 'http://example.com/rss.xml';
$options['external'] = TRUE;
}
// Instead of pointing to user/[uid]/edit, point to user/me/edit.
if (preg_match... | [
"code-task",
"hook-definition"
] | 2026-09-30T00:00:00 |
api-drupal7-a71129d501 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21image%21image.admin.inc/function/image_scale_form/7.x | I need the code for `image_scale_form($data)` in Drupal 7 (modules/image/image.admin.inc). It must do this: Form structure for the image scale form. | Note that this is not a complete form, it only contains the portion of the form for configuring the scale options. Therefore it does not not need to include metadata about the effect, nor a submit button.
Parameters:
- $data: The current configuration for this scale effect.
File: modules/image/image.admin.inc | function image_scale_form($data) {
$form = image_resize_form($data);
$form['#element_validate'] = array('image_effect_scale_validate');
$form['width']['#required'] = FALSE;
$form['height']['#required'] = FALSE;
$form['upscale'] = array(
'#type' => 'checkbox',
'#default_value' => (isset($data['upscale'... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-a7258b6703 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21file%21file.module/function/theme_file_managed_file/7.x | Implement `theme_file_managed_file($variables)` in PHP for Drupal 7. Required behavior: Returns HTML for a managed file element. | Parameters:
- $variables: An associative array containing: - element: A render element representing the file.
File: modules/file/file.module | function theme_file_managed_file($variables) {
$element = $variables['element'];
$attributes = array();
if (isset($element['#id'])) {
$attributes['id'] = $element['#id'];
}
if (!empty($element['#attributes']['class'])) {
$attributes['class'] = (array) $element['#attributes']['class'];
}
$attribut... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-a72ea6a7c8 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21locale%21locale.admin.inc/function/locale_language_providers_session_form/7.x | Implement `locale_language_providers_session_form($form, &$form_state)` in PHP for Drupal 7. Required behavior: The URL language provider configuration form. | File: modules/locale/locale.admin.inc | function locale_language_providers_session_form($form, &$form_state) {
$form['locale_language_negotiation_session_param'] = array(
'#title' => t('Request/session parameter'),
'#type' => 'textfield',
'#default_value' => variable_get('locale_language_negotiation_session_param', 'language'),
'#descriptio... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-a74294cb58 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21book%21book.module/function/book_menu/7.x | I need the code for `book_menu()` in Drupal 7 (modules/book/book.module). It must do this: Implements hook_menu(). | File: modules/book/book.module | function book_menu() {
$items['admin/content/book'] = array(
'title' => 'Books',
'description' => "Manage your site's book outlines.",
'page callback' => 'book_admin_overview',
'access arguments' => array('administer book outlines'),
'type' => MENU_LOCAL_TASK,
'file' => 'book.admin.inc',
);
... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-a7506da272 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21system.module/function/system_action_info/7.x | Implement `system_action_info()` in PHP for Drupal 7. Required behavior: Implements hook_action_info(). | File: modules/system/system.module | function system_action_info() {
return array(
'system_message_action' => array(
'type' => 'system',
'label' => t('Display a message to the user'),
'configurable' => TRUE,
'triggers' => array('any'),
),
'system_send_email_action' => array(
'type' => 'system',
'label' => ... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-a75edd5e5b | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21bootstrap.inc/function/drupal_page_is_cacheable/7.x | Implement `drupal_page_is_cacheable($allow_caching = NULL)` in PHP for Drupal 7. Required behavior: Determines the cacheability of the current page. | Parameters:
- $allow_caching: Set to FALSE if you want to prevent this page from being cached.
Returns: TRUE if the current page can be cached, FALSE otherwise.
File: includes/bootstrap.inc | function drupal_page_is_cacheable($allow_caching = NULL) {
$allow_caching_static = &drupal_static(__FUNCTION__, TRUE);
if (isset($allow_caching)) {
$allow_caching_static = $allow_caching;
}
return $allow_caching_static && ($_SERVER['REQUEST_METHOD'] == 'GET' || $_SERVER['REQUEST_METHOD'] == 'HEAD')
&& ... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-a76050eb5a | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21rdf%21rdf.module/function/rdf_entity_info_alter/7.x | In Drupal 7, write the function `rdf_entity_info_alter(&$entity_info)` (file modules/rdf/rdf.module) so that it does the following: Implements hook_entity_info_alter(). | Adds the proper RDF mapping to each entity type/bundle pair.
File: modules/rdf/rdf.module | function rdf_entity_info_alter(&$entity_info) {
// Loop through each entity type and its bundles.
foreach ($entity_info as $entity_type => $entity_type_info) {
if (!empty($entity_type_info['bundles'])) {
$bundles = array_keys($entity_type_info['bundles']);
$mappings = _rdf_mapping_load_multiple($ent... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-a760f323e9 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21common.inc/function/render/7.x | In Drupal 7, write the function `render(&$element)` (file includes/common.inc) so that it does the following: Renders an element. | This function renders an element using drupal_render(). The top level element is shown with show() before rendering, so it will always be rendered even if hide() had been previously used on it.
Parameters:
- $element: The element to be rendered.
Returns: The rendered element.
File: includes/common.inc | function render(&$element) {
if (is_array($element)) {
show($element);
return drupal_render($element);
}
else {
// Safe-guard for inappropriate use of render() on flat variables: return
// the variable as-is.
return $element;
}
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-a7909b9e79 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21field%21field.install/function/_update_7000_field_read_fields/7.x | In Drupal 7, write the function `_update_7000_field_read_fields(array $conditions = array(), $key = 'id')` (file modules/field/field.install) so that it does the following: Utility function: fetch all the field definitions from the database. | Warning: unlike the field_read_fields() API function, this function returns all fields by default, including deleted and inactive fields, unless specified otherwise in the $conditions parameter.
Parameters:
- $conditions: An array of conditions to limit the select query to.
- $key: The name of the field property the r... | function _update_7000_field_read_fields(array $conditions = array(), $key = 'id') {
$fields = array();
$query = db_select('field_config', 'fc', array('fetch' => PDO::FETCH_ASSOC))
->fields('fc');
foreach ($conditions as $column => $value) {
$query->condition($column, $value);
}
foreach ($query->execut... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-a7914599db | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21filter%21filter.module/function/_filter_url_parse_full_links/7.x | I need the code for `_filter_url_parse_full_links($match)` in Drupal 7 (modules/filter/filter.module). It must do this: Makes links out of absolute URLs. | Callback for preg_replace_callback() within _filter_url().
File: modules/filter/filter.module | function _filter_url_parse_full_links($match) {
// The $i:th parenthesis in the regexp contains the URL.
$i = 1;
$match[$i] = decode_entities($match[$i]);
$caption = check_plain(_filter_url_trim($match[$i]));
$match[$i] = check_plain($match[$i]);
return '<a href="' . $match[$i] . '">' . $caption . '</a>' .... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-a79513f169 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21taxonomy%21taxonomy.api.php/function/hook_taxonomy_vocabulary_update/7.x | In Drupal 7, show an example implementation for `hook_taxonomy_vocabulary_update($vocabulary)` (modules/taxonomy/taxonomy.api.php): Act on taxonomy vocabularies when updated. | Modules implementing this hook can act on the vocabulary object when updated.
Parameters:
- $vocabulary: A taxonomy vocabulary object.
File: modules/taxonomy/taxonomy.api.php | function hook_taxonomy_vocabulary_update($vocabulary) {
db_update('mytable')
->fields(array('foo' => $vocabulary->foo))
->condition('vid', $vocabulary->vid)
->execute();
} | [
"code-task",
"hook-definition"
] | 2026-09-30T00:00:00 |
api-drupal7-a7a1271404 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21image.gd.inc/function/image_gd_settings/7.x | In Drupal 7, write the function `image_gd_settings()` (file modules/system/image.gd.inc) so that it does the following: Retrieve settings for the GD2 toolkit. | File: modules/system/image.gd.inc | function image_gd_settings() {
if (image_gd_check_settings()) {
$form['status'] = array(
'#markup' => t('The GD toolkit is installed and working properly.')
);
$form['image_jpeg_quality'] = array(
'#type' => 'textfield',
'#title' => t('JPEG quality'),
'#description' => t('Define t... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-a7a3672bfd | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21blog%21blog.pages.inc/function/blog_feed_last/7.x | Implement `blog_feed_last()` in PHP for Drupal 7. Required behavior: Menu callback; displays an RSS feed containing recent blog entries of all users. | File: modules/blog/blog.pages.inc | function blog_feed_last() {
$nids = db_select('node', 'n')
->fields('n', array('nid', 'created'))
->condition('type', 'blog')
->condition('status', 1)
->orderBy('created', 'DESC')
->range(0, variable_get('feed_default_items', 10))
->addTag('node_access')
->execute()
->fetchCol();
$c... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-a7a42a8ecf | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21node%21node.pages.inc/function/node_form_delete_submit/7.x | Implement `node_form_delete_submit($form, &$form_state)` in PHP for Drupal 7. Required behavior: Form submission handler for node_form(). | Handles the 'Delete' button on the node form.
File: modules/node/node.pages.inc | function node_form_delete_submit($form, &$form_state) {
$destination = array();
if (isset($_GET['destination'])) {
$destination = drupal_get_destination();
unset($_GET['destination']);
}
$node = $form['#node'];
$form_state['redirect'] = array('node/' . $node->nid . '/delete', array('query' => $destina... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-a7accf0201 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21system.module/function/system_authorized_get_url/7.x | I need the code for `system_authorized_get_url(array $options = array())` in Drupal 7 (modules/system/system.module). It must do this: Return the URL for the authorize.php script. | Parameters:
- $options (array): Optional array of options to pass to url().
Returns: The full URL to authorize.php, using HTTPS if available.
File: modules/system/system.module | function system_authorized_get_url(array $options = array()) {
global $base_url;
// Force HTTPS if available, regardless of what the caller specifies.
$options['https'] = TRUE;
// We prefix with $base_url so we get a full path even if clean URLs are
// disabled.
return url($base_url . '/authorize.php', $opt... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-a7d5743f0e | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21locale%21locale.module/function/locale_language_negotiation_info/7.x | In Drupal 7, write the function `locale_language_negotiation_info()` (file modules/locale/locale.module) so that it does the following: Implements hook_language_negotiation_info(). | File: modules/locale/locale.module | function locale_language_negotiation_info() {
require_once DRUPAL_ROOT . '/includes/locale.inc';
$file = 'includes/locale.inc';
$providers = array();
$providers[LOCALE_LANGUAGE_NEGOTIATION_URL] = array(
'types' => array(LANGUAGE_TYPE_CONTENT, LANGUAGE_TYPE_INTERFACE, LANGUAGE_TYPE_URL),
'callbacks' => ... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-a7da62db17 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21forum%21forum.module/function/template_preprocess_forum_list/7.x | Implement `template_preprocess_forum_list(&$variables)` in PHP for Drupal 7. Required behavior: Preprocesses variables for forum-list.tpl.php. | Parameters:
- $variables: An array containing the following elements: - forums: An array of all forum objects to display for the given taxonomy term ID. If tid = 0 then all the top-level forums are displayed. - parents: An array of taxonomy term objects that are ancestors of the current term ID. - tid: Taxonomy term ID... | function template_preprocess_forum_list(&$variables) {
global $user;
$row = 0;
// Sanitize each forum so that the template can safely print the data.
foreach ($variables['forums'] as $id => $forum) {
$variables['forums'][$id]->description = !empty($forum->description) ? filter_xss_admin($forum->description)... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-a7ebf44374 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21node%21node.module/function/node_content_form/7.x | In Drupal 7, write the function `node_content_form($node, $form_state)` (file modules/node/node.module) so that it does the following: Implements hook_form(). | File: modules/node/node.module | function node_content_form($node, $form_state) {
// It is impossible to define a content type without implementing hook_form()
// @todo: remove this requirement.
$form = array();
$type = node_type_get_type($node);
if ($type->has_title) {
$form['title'] = array(
'#type' => 'textfield',
'#title... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-a7f57051f5 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21search%21search.install/function/search_schema/7.x | I need the code for `search_schema()` in Drupal 7 (modules/search/search.install). It must do this: Implements hook_schema(). | File: modules/search/search.install | function search_schema() {
$schema['search_dataset'] = array(
'description' => 'Stores items that will be searched.',
'fields' => array(
'sid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
'description' => 'Search item ID, e.g.... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-a7fb9f4c30 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21common.inc/function/drupal_get_path/7.x | In Drupal 7, write the function `drupal_get_path($type, $name)` (file includes/common.inc) so that it does the following: Returns the path to a system item (module, theme, etc.). | Parameters:
- $type: The type of the item (i.e. theme, theme_engine, module, profile).
- $name: The name of the item for which the path is requested.
Returns: The path to the requested item or an empty string if the item is not found.
File: includes/common.inc | function drupal_get_path($type, $name) {
if ($filename = drupal_get_filename($type, $name)) {
return dirname($filename);
}
return "";
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-a7ffab65a1 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21field%21field.api.php/function/hook_field_purge_instance/7.x | In Drupal 7, show an example implementation for `hook_field_purge_instance($instance)` (modules/field/field.api.php): Acts when a field instance is being purged. | In field_purge_instance(), after the field instance has been removed from the database, the field storage module has had a chance to run its hook_field_storage_purge_instance(), and the field info cache has been cleared, this hook is invoked on all modules to allow them to respond to the field instance being purged.
P... | function hook_field_purge_instance($instance) {
db_delete('my_module_field_instance_info')
->condition('id', $instance['id'])
->execute();
} | [
"code-task",
"hook-definition"
] | 2026-09-30T00:00:00 |
api-drupal7-a802212498 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21file%21file.module/function/file_ajax_progress/7.x | I need the code for `file_ajax_progress($key)` in Drupal 7 (modules/file/file.module). It must do this: Menu callback for upload progress. | Parameters:
- $key: The unique key for this upload process.
File: modules/file/file.module | function file_ajax_progress($key) {
$progress = array(
'message' => t('Starting upload...'),
'percentage' => -1,
);
$implementation = file_progress_implementation();
if ($implementation == 'uploadprogress') {
$status = uploadprogress_get_info($key);
if (isset($status['bytes_uploaded']) && !empt... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-a8168b562c | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21menu%21menu.admin.inc/function/_menu_overview_tree_form/7.x | I need the code for `_menu_overview_tree_form($tree, $delta = 50)` in Drupal 7 (modules/menu/menu.admin.inc). It must do this: Recursive helper function for menu_overview_form(). | Parameters:
- $tree: The menu_tree retrieved by menu_tree_data.
- $delta: The number of items to use in the menu weight selector. Defaults to 50.
File: modules/menu/menu.admin.inc | function _menu_overview_tree_form($tree, $delta = 50) {
$form = &drupal_static(__FUNCTION__, array('#tree' => TRUE));
foreach ($tree as $data) {
$title = '';
$item = $data['link'];
// Don't show callbacks; these have $item['hidden'] < 0.
if ($item && $item['hidden'] >= 0) {
$mlid = 'mlid:' . $... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-a87f1bdcfc | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21user%21user.module/function/user_user_operations_unblock/7.x | In Drupal 7, write the function `user_user_operations_unblock($accounts)` (file modules/user/user.module) so that it does the following: Callback function for admin mass unblocking users. | File: modules/user/user.module | function user_user_operations_unblock($accounts) {
$accounts = user_load_multiple($accounts);
foreach ($accounts as $account) {
// Skip unblocking user if they are already unblocked.
if ($account !== FALSE && $account->status == 0) {
user_save($account, array('status' => 1));
}
}
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-a895746bf9 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21search%21search.module/function/search_invoke_preprocess/7.x | I need the code for `search_invoke_preprocess(&$text)` in Drupal 7 (modules/search/search.module). It must do this: Invokes hook_search_preprocess() in modules. | File: modules/search/search.module | function search_invoke_preprocess(&$text) {
foreach (module_implements('search_preprocess') as $module) {
$text = module_invoke($module, 'search_preprocess', $text);
}
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-a8991aa2b8 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21utility.inc/function/drupal_var_export/7.x | Implement `drupal_var_export($var, $prefix = '')` in PHP for Drupal 7. Required behavior: Drupal-friendly var_export(). | Parameters:
- $var: The variable to export.
- $prefix: A prefix that will be added at the beginning of every lines of the output.
Returns: The variable exported in a way compatible to Drupal's coding standards.
File: includes/utility.inc | function drupal_var_export($var, $prefix = '') {
if (is_array($var)) {
if (empty($var)) {
$output = 'array()';
}
else {
$output = "array(\n";
// Don't export keys if the array is non associative.
$export_keys = array_values($var) != $var;
foreach ($var as $key => $value) {
... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.