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-6295b18f48 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21user%21user.api.php/function/hook_user_delete/7.x | Give me the example code for `hook_user_delete($account)` in Drupal 7. Hook description: Respond to user deletion. | This hook is invoked from user_delete_multiple() before field_attach_delete() is called and before users are actually removed from the database.
Modules should additionally implement hook_user_cancel() to process stored user data for other account cancellation methods.
Parameters:
- $account: The account that is bein... | function hook_user_delete($account) {
db_delete('mytable')
->condition('uid', $account->uid)
->execute();
} | [
"code-task",
"hook-definition"
] | 2026-09-30T00:00:00 |
api-drupal7-62a8188914 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21trigger%21trigger.module/function/trigger_menu/7.x | I need the code for `trigger_menu()` in Drupal 7 (modules/trigger/trigger.module). It must do this: Implements hook_menu(). | File: modules/trigger/trigger.module | function trigger_menu() {
$items['admin/structure/trigger'] = array(
'title' => 'Triggers',
'description' => 'Configure when to execute actions.',
'page callback' => 'trigger_assign',
'access arguments' => array('administer actions'),
'file' => 'trigger.admin.inc',
);
$trigger_info = _trigger... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-62b332269e | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21system.module/function/theme_system_compact_link/7.x | I need the code for `theme_system_compact_link()` in Drupal 7 (modules/system/system.module). It must do this: Returns HTML for a link to show or hide inline help descriptions. | File: modules/system/system.module | function theme_system_compact_link() {
$output = '<div class="compact-link">';
if (system_admin_compact_mode()) {
$output .= l(t('Show descriptions'), 'admin/compact/off', array('attributes' => array('title' => t('Expand layout to include descriptions.')), 'query' => drupal_get_destination()));
}
else {
... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-62bdd17663 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21locale.inc/function/_locale_import_one_string_db/7.x | I need the code for `_locale_import_one_string_db(&$report, $langcode, $context, $source, $translation, $textgroup, $location, $mode, $plid = 0, $plural = 0)` in Drupal 7 (includes/locale.inc). It must do this: Import one string into the database. | Parameters:
- $report: Report array summarizing the number of changes done in the form: array(additions, deletes, skips, updates).
- $langcode: Language code to import string into.
- $context: The context of this string.
- $source: Source string.
- $translation: Translation to language specified in $langcode.
- $textgr... | function _locale_import_one_string_db(&$report, $langcode, $context, $source, $translation, $textgroup, $location, $mode, $plid = 0, $plural = 0) {
$lid = db_query("SELECT lid FROM {locales_source} WHERE source = :source AND context = :context AND textgroup = :textgroup", array(':source' => $source, ':context' => $co... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-62daba9837 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21rdf%21rdf.module/function/rdf_entity_load/7.x | In Drupal 7, write the function `rdf_entity_load($entities, $type)` (file modules/rdf/rdf.module) so that it does the following: Implements hook_entity_load(). | File: modules/rdf/rdf.module | function rdf_entity_load($entities, $type) {
foreach ($entities as $entity) {
// Extracts the bundle of the entity being loaded.
list($id, $vid, $bundle) = entity_extract_ids($type, $entity);
$entity->rdf_mapping = rdf_mapping_load($type, $bundle);
}
} | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-630f7dc6ff | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21toolbar%21toolbar.module/function/theme_toolbar_toggle/7.x | In Drupal 7, write the function `theme_toolbar_toggle($variables)` (file modules/toolbar/toolbar.module) so that it does the following: Formats an element used to toggle the toolbar drawer's visibility. | Parameters:
- $variables: An associative array containing: - collapsed: A boolean value representing the toolbar drawer's visibility. - attributes: An associative array of HTML attributes.
Returns: An HTML string representing the element for toggling.
File: modules/toolbar/toolbar.module | function theme_toolbar_toggle($variables) {
if ($variables['collapsed']) {
$toggle_text = t('Show shortcuts');
}
else {
$toggle_text = t('Hide shortcuts');
$variables['attributes']['class'][] = 'toggle-active';
}
return l($toggle_text, 'toolbar/toggle', array('query' => drupal_get_destination(), '... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-632710ccc6 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21translation%21translation.module/function/translation_path_get_translations/7.x | Implement `translation_path_get_translations($path)` in PHP for Drupal 7. Required behavior: Returns the paths of all translations of a node, based on its Drupal path. | Parameters:
- $path: A Drupal path, for example node/432.
Returns: An array of paths of translations of the node accessible to the current user, keyed with language codes.
File: modules/translation/translation.module | function translation_path_get_translations($path) {
$paths = array();
// Check for a node related path, and for its translations.
if ((preg_match("!^node/(\d+)(/.+|)$!", $path, $matches)) && ($node = node_load((int) $matches[1])) && !empty($node->tnid)) {
foreach (translation_node_get_translations($node->tnid... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-6334ced1fa | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21system.module/function/system_form_user_profile_form_alter/7.x | I need the code for `system_form_user_profile_form_alter(&$form, &$form_state)` in Drupal 7 (modules/system/system.module). It must do this: Implements hook_form_FORM_ID_alter(). | File: modules/system/system.module | function system_form_user_profile_form_alter(&$form, &$form_state) {
if ($form['#user_category'] == 'account') {
if (variable_get('configurable_timezones', 1)) {
system_user_timezone($form, $form_state);
}
return $form;
}
} | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-6358c9c751 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21search%21search.module/function/search_node_update/7.x | I need the code for `search_node_update($node)` in Drupal 7 (modules/search/search.module). It must do this: Implements hook_node_update(). | File: modules/search/search.module | function search_node_update($node) {
// Reindex the node when it is updated. The node is automatically indexed
// when it is added, simply by being added to the node table.
search_touch_node($node->nid);
} | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-635fec5f2e | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21openid%21openid.module/function/openid_help/7.x | Implement `openid_help($path, $arg)` in PHP for Drupal 7. Required behavior: Implements hook_help(). | File: modules/openid/openid.module | function openid_help($path, $arg) {
switch ($path) {
case 'user/%/openid':
$output = '<p>' . t('This site supports <a href="@openid-net">OpenID</a>, a secure way to log in to many websites using a single username and password. OpenID can reduce the necessity of managing many usernames and passwords for many... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-636110a31c | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21aggregator%21aggregator.admin.inc/function/aggregator_form_feed/7.x | I need the code for `aggregator_form_feed($form, &$form_state, stdClass $feed = NULL)` in Drupal 7 (modules/aggregator/aggregator.admin.inc). It must do this: Form constructor for adding and editing feed sources. | Parameters:
- $feed: (optional) If editing a feed, the feed to edit as a PHP stdClass value; if adding a new feed, NULL. Defaults to NULL.
File: modules/aggregator/aggregator.admin.inc | function aggregator_form_feed($form, &$form_state, stdClass $feed = NULL) {
$period = drupal_map_assoc(array(900, 1800, 3600, 7200, 10800, 21600, 32400, 43200, 64800, 86400, 172800, 259200, 604800, 1209600, 2419200), 'format_interval');
$period[AGGREGATOR_CLEAR_NEVER] = t('Never');
$form['title'] = array('#type'... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-636b6f9d59 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21comment%21comment.module/function/comment_load/7.x | In Drupal 7, write the function `comment_load($cid, $reset = FALSE)` (file modules/comment/comment.module) so that it does the following: Load the entire comment by cid. | Parameters:
- $cid: The identifying comment id.
- $reset: Whether to reset the internal static entity cache. Note that the static cache is disabled in comment_entity_info() by default.
Returns: The comment object.
File: modules/comment/comment.module | function comment_load($cid, $reset = FALSE) {
$comment = comment_load_multiple(array($cid), array(), $reset);
return $comment ? $comment[$cid] : FALSE;
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-637af90c2e | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21overlay%21overlay.module/function/overlay_form_user_profile_form_alter/7.x | I need the code for `overlay_form_user_profile_form_alter(&$form, &$form_state)` in Drupal 7 (modules/overlay/overlay.module). It must do this: Implements hook_form_FORM_ID_alter(). | File: modules/overlay/overlay.module | function overlay_form_user_profile_form_alter(&$form, &$form_state) {
if ($form['#user_category'] == 'account') {
$account = $form['#user'];
if (user_access('access overlay', $account)) {
$form['overlay_control'] = array(
'#type' => 'fieldset',
'#title' => t('Administrative overlay'),
... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-63841ae1b2 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21user%21user.api.php/function/hook_user_update/7.x | Give me the example code for `hook_user_update(&$edit, $account, $category)` in Drupal 7. Hook description: A user account was updated. | Modules may use this hook to update their user data in a custom storage after a user account has been updated.
Parameters:
- $edit: The array of form values submitted by the user.
- $account: The user object on which the operation is performed.
- $category: The active category of user information being edited.
File: ... | function hook_user_update(&$edit, $account, $category) {
db_insert('user_changes')
->fields(array(
'uid' => $account->uid,
'changed' => time(),
))
->execute();
} | [
"code-task",
"hook-definition"
] | 2026-09-30T00:00:00 |
api-drupal7-6398455b15 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21system.module/function/system_system_info_alter/7.x | I need the code for `system_system_info_alter(&$info, $file, $type)` in Drupal 7 (modules/system/system.module). It must do this: Implements hook_system_info_alter(). | File: modules/system/system.module | function system_system_info_alter(&$info, $file, $type) {
// Remove page-top and page-bottom from the blocks UI since they are reserved for
// modules to populate from outside the blocks system.
if ($type == 'theme') {
$info['regions_hidden'][] = 'page_top';
$info['regions_hidden'][] = 'page_bottom';
}
... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-639bb61a40 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21color%21color.install/function/color_requirements/7.x | I need the code for `color_requirements($phase)` in Drupal 7 (modules/color/color.install). It must do this: Implements hook_requirements(). | File: modules/color/color.install | function color_requirements($phase) {
$requirements = array();
if ($phase == 'runtime') {
// Check for the PHP GD library.
if (function_exists('imagegd2')) {
$info = gd_info();
$requirements['color_gd'] = array(
'value' => $info['GD Version'],
);
// Check for PNG support.
... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-63be802b28 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21user%21user.install/function/user_update_7003/7.x | In Drupal 7, write the function `user_update_7003()` (file modules/user/user.install) so that it does the following: Update user settings for cancelling user accounts. | Prior to 7.x, users were not able to cancel their accounts. When administrators deleted an account, all contents were assigned to uid 0, which is the same as the 'user_cancel_reassign' method now.
File: modules/user/user.install | function user_update_7003() {
// Set the default account cancellation method.
variable_set('user_cancel_method', 'user_cancel_reassign');
// Re-assign notification setting.
if ($setting = variable_get('user_mail_status_deleted_notify', FALSE)) {
variable_set('user_mail_status_canceled_notify', $setting);
... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-63fc41326c | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21image%21image.effects.inc/function/image_resize_dimensions/7.x | I need the code for `image_resize_dimensions(array &$dimensions, array $data)` in Drupal 7 (modules/image/image.effects.inc). It must do this: Image dimensions callback; Resize. | Parameters:
- $dimensions: Dimensions to be modified - an array with components width and height, in pixels.
- $data: An array of attributes to use when performing the resize effect with the following items: - "width": An integer representing the desired width in pixels. - "height": An integer representing the desired ... | function image_resize_dimensions(array &$dimensions, array $data) {
// The new image will have the exact dimensions defined for the effect.
$dimensions['width'] = $data['width'];
$dimensions['height'] = $data['height'];
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-63ffdbc894 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21system.api.php/function/hook_filetransfer_info_alter/7.x | In Drupal 7, show an example implementation for `hook_filetransfer_info_alter(&$filetransfer_info)` (modules/system/system.api.php): Alter the FileTransfer class registry. | Parameters:
- $filetransfer_info (array): Reference to a nested array containing information about the FileTransfer class registry.
File: modules/system/system.api.php | function hook_filetransfer_info_alter(&$filetransfer_info) {
if (variable_get('paranoia', FALSE)) {
// Remove the FTP option entirely.
unset($filetransfer_info['ftp']);
// Make sure the SSH option is listed first.
$filetransfer_info['ssh']['weight'] = -10;
}
} | [
"code-task",
"hook-definition"
] | 2026-09-30T00:00:00 |
api-drupal7-6400186d45 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21common.inc/function/archiver_get_extensions/7.x | In Drupal 7, write the function `archiver_get_extensions()` (file includes/common.inc) so that it does the following: Returns a string of supported archive extensions. | Returns: A space-separated string of extensions suitable for use by the file validation system.
File: includes/common.inc | function archiver_get_extensions() {
$valid_extensions = array();
foreach (archiver_get_info() as $archive) {
foreach ($archive['extensions'] as $extension) {
foreach (explode('.', $extension) as $part) {
if (!in_array($part, $valid_extensions)) {
$valid_extensions[] = $part;
}
... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-641acd7200 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21xmlrpc.inc/function/xmlrpc_request/7.x | I need the code for `xmlrpc_request($method, $args)` in Drupal 7 (includes/xmlrpc.inc). It must do this: Constructs an object representing an XML-RPC request. | Parameters:
- $method: The name of the method to be called.
- $args: An array of parameters to send with the method.
Returns (object): An XML-RPC object representing the request.
File: includes/xmlrpc.inc | function xmlrpc_request($method, $args) {
$xmlrpc_request = new stdClass();
$xmlrpc_request->method = $method;
$xmlrpc_request->args = $args;
$xmlrpc_request->xml = <<<EOD
<?xml version="1.0"?>
<methodCall>
<methodName>{$xmlrpc_request->method}</methodName>
<params>
EOD;
foreach ($xmlrpc_request->args as $ar... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-64320481a0 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21file.inc/function/drupal_basename/7.x | Implement `drupal_basename($uri, $suffix = NULL)` in PHP for Drupal 7. Required behavior: Gets the filename from a given path. | PHP's basename() does not properly support streams or filenames beginning with a non-US-ASCII character.
File: includes/file.inc | function drupal_basename($uri, $suffix = NULL) {
$separators = '/';
if (DIRECTORY_SEPARATOR != '/') {
// For Windows OS add special separator.
$separators .= DIRECTORY_SEPARATOR;
}
// Remove right-most slashes when $uri points to directory.
$uri = rtrim($uri, $separators);
// Returns the trailing pa... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-6441a0b310 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21menu.inc/function/menu_tree/7.x | In Drupal 7, write the function `menu_tree($menu_name)` (file includes/menu.inc) so that it does the following: Renders a menu tree based on the current path. | The tree is expanded based on the current path and dynamic paths are also changed according to the defined to_arg functions (for example the 'My account' link is changed from user/% to a link with the current user's uid).
Parameters:
- $menu_name: The name of the menu.
Returns: A structured array representing the spe... | function menu_tree($menu_name) {
$menu_output = &drupal_static(__FUNCTION__, array());
if (!isset($menu_output[$menu_name])) {
$tree = menu_tree_page_data($menu_name);
$menu_output[$menu_name] = menu_tree_output($tree);
}
return $menu_output[$menu_name];
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-64438f1bf8 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21dblog%21dblog.admin.inc/function/theme_dblog_message/7.x | In Drupal 7, write the function `theme_dblog_message($variables)` (file modules/dblog/dblog.admin.inc) so that it does the following: Returns HTML for a log message. | Parameters:
- $variables (array): An associative array containing: - event: An object with at least the message and variables properties. - link: (optional) Format message as link, event->wid is required.
File: modules/dblog/dblog.admin.inc | function theme_dblog_message($variables) {
$output = '';
$event = $variables['event'];
// Check for required properties.
if (isset($event->message) && isset($event->variables)) {
$event_variables = @unserialize($event->variables);
// Messages without variables or user specified text.
if ($event_vari... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-647bf89fa6 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21form.inc/function/map_month/7.x | Implement `map_month($month)` in PHP for Drupal 7. Required behavior: Helper function for usage with drupal_map_assoc to display month names. | File: includes/form.inc | function map_month($month) {
$months = &drupal_static(__FUNCTION__, array(
1 => 'Jan',
2 => 'Feb',
3 => 'Mar',
4 => 'Apr',
5 => 'May',
6 => 'Jun',
7 => 'Jul',
8 => 'Aug',
9 => 'Sep',
10 => 'Oct',
11 => 'Nov',
12 => 'Dec',
));
return t($months[$month]);
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-647c0e5c12 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21node%21node.module/function/node_user_delete/7.x | Implement `node_user_delete($account)` in PHP for Drupal 7. Required behavior: Implements hook_user_delete(). | File: modules/node/node.module | function node_user_delete($account) {
// Delete nodes (current revisions).
// @todo Introduce node_mass_delete() or make node_mass_update() more flexible.
$nodes = db_select('node', 'n')
->fields('n', array('nid'))
->condition('uid', $account->uid)
->execute()
->fetchCol();
node_delete_multiple(... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-64936a1d65 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21book%21book.admin.inc/function/theme_book_admin_table/7.x | Implement `theme_book_admin_table($variables)` in PHP for Drupal 7. Required behavior: Returns HTML for a book administration form. | Parameters:
- $variables: An associative array containing: - form: A render element representing the form.
File: modules/book/book.admin.inc | function theme_book_admin_table($variables) {
$form = $variables['form'];
drupal_add_tabledrag('book-outline', 'match', 'parent', 'book-plid', 'book-plid', 'book-mlid', TRUE, MENU_MAX_DEPTH - 2);
drupal_add_tabledrag('book-outline', 'order', 'sibling', 'book-weight');
$header = array(t('Title'), t('Weight'), ... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-64945b460b | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21node%21node.module/function/node_block_list_alter/7.x | Implement `node_block_list_alter(&$blocks)` in PHP for Drupal 7. Required behavior: Implements hook_block_list_alter(). | Check the content type specific visibilty settings. Remove the block if the visibility conditions are not met.
File: modules/node/node.module | function node_block_list_alter(&$blocks) {
global $theme_key;
// Build an array of node types for each block.
$block_node_types = array();
$result = db_query('SELECT module, delta, type FROM {block_node_type}');
foreach ($result as $record) {
$block_node_types[$record->module][$record->delta][$record->ty... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-649a5d1e5a | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21common.inc/function/drupal_system_listing/7.x | Implement `drupal_system_listing($mask, $directory, $key = 'name', $min_depth = 1)` in PHP for Drupal 7. Required behavior: Returns information about system object files (modules, themes, etc.). | This function is used to find all or some system object files (module files, theme files, etc.) that exist on the site. It searches in several locations, depending on what type of object you are looking for. For instance, if you are looking for modules and call:
Parameters:
- $mask (string): The preg_match() regular e... | function drupal_system_listing($mask, $directory, $key = 'name', $min_depth = 1) {
$config = conf_path();
$searchdir = array($directory);
$files = array();
// The 'profiles' directory contains pristine collections of modules and
// themes as organized by a distribution. It is pristine in the same way
// t... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-64a358f3ab | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21form.inc/function/form_state_defaults/7.x | I need the code for `form_state_defaults()` in Drupal 7 (includes/form.inc). It must do this: Retrieves default values for the $form_state array. | File: includes/form.inc | function form_state_defaults() {
return array(
'rebuild' => FALSE,
'rebuild_info' => array(),
'redirect' => NULL,
// @todo 'args' is usually set, so no other default 'build_info' keys are
// appended via += form_state_defaults().
'build_info' => array(
'args' => array(),
'files' ... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-64b7c958a9 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21statistics%21statistics.module/function/statistics_node_view/7.x | I need the code for `statistics_node_view($node, $view_mode)` in Drupal 7 (modules/statistics/statistics.module). It must do this: Implements hook_node_view(). | File: modules/statistics/statistics.module | function statistics_node_view($node, $view_mode) {
// Attach Ajax node count statistics if configured.
if (variable_get('statistics_count_content_views', 0) && variable_get('statistics_count_content_views_ajax', 0)) {
if (!empty($node->nid) && $view_mode == 'full' && node_is_page($node) && empty($node->in_previ... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-64cdba8135 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21module.inc/function/system_list/7.x | I need the code for `system_list($type)` in Drupal 7 (includes/module.inc). It must do this: Builds a list of bootstrap modules and enabled modules and themes. | Parameters:
- $type: The type of list to return: - module_enabled: All enabled modules. - bootstrap: All enabled modules required for bootstrap. - theme: All themes.
Returns: An associative array of modules or themes, keyed by name. For $type 'bootstrap', the array values equal the keys. For $type 'module_enabled' or ... | function system_list($type) {
$lists = &drupal_static(__FUNCTION__);
// For bootstrap modules, attempt to fetch the list from cache if possible.
// if not fetch only the required information to fire bootstrap hooks
// in case we are going to serve the page from cache.
if ($type == 'bootstrap') {
if (isse... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-651e843a4c | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21bootstrap.inc/function/t/7.x | Implement `t($string, array $args = array(), array $options = array())` in PHP for Drupal 7. Required behavior: Translates a string to the current language or to a given language. | The t() function serves two purposes. First, at run-time it translates user-visible text into the appropriate language. Second, various mechanisms that figure out what text needs to be translated work off t() -- the text inside t() calls is added to the database of strings to be translated. These strings are expected t... | function t($string, array $args = array(), array $options = array()) {
global $language;
static $custom_strings;
// Merge in default.
if (empty($options['langcode'])) {
$options['langcode'] = isset($language->language) ? $language->language : 'en';
}
if (empty($options['context'])) {
$options['cont... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-653daa5446 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21openid%21openid.inc/function/_openid_math_mul/7.x | Implement `_openid_math_mul($x, $y)` in PHP for Drupal 7. Required behavior: Calls the mul function from the available math library for OpenID. | File: modules/openid/openid.inc | function _openid_math_mul($x, $y) {
$library = _openid_get_math_library();
switch ($library) {
case 'gmp':
return gmp_mul($x, $y);
case 'bcmath':
return bcmul($x, $y);
}
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-6544a4ef0e | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21locale.inc/function/_locale_import_one_string/7.x | Implement `_locale_import_one_string($op, $value = NULL, $mode = NULL, $lang = NULL, $file = NULL, $group = 'default')` in PHP for Drupal 7. Required behavior: Imports a string into the database | Parameters:
- $op: Operation to perform: 'db-store', 'db-report', 'mem-store' or 'mem-report'.
- $value: Details of the string stored.
- $mode: Should existing translations be replaced LOCALE_IMPORT_KEEP or LOCALE_IMPORT_OVERWRITE.
- $lang: Language to store the string in.
- $file: Object representation of file being i... | function _locale_import_one_string($op, $value = NULL, $mode = NULL, $lang = NULL, $file = NULL, $group = 'default') {
$report = &drupal_static(__FUNCTION__, array('additions' => 0, 'updates' => 0, 'deletes' => 0, 'skips' => 0));
$header_done = &drupal_static(__FUNCTION__ . ':header_done', FALSE);
$strings = &dru... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-654c75a07b | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21block%21block.module/function/template_preprocess_block/7.x | I need the code for `template_preprocess_block(&$variables)` in Drupal 7 (modules/block/block.module). It must do this: Processes variables for block.tpl.php. | Prepares the values passed to the theme_block function to be passed into a pluggable template engine. Uses block properties to generate a series of template file suggestions. If none are found, the default block.tpl.php is used.
Most themes utilize their own copy of block.tpl.php. The default is located inside "module... | function template_preprocess_block(&$variables) {
$block_counter = &drupal_static(__FUNCTION__, array());
$variables['block'] = $variables['elements']['#block'];
// All blocks get an independent counter for each region.
if (!isset($block_counter[$variables['block']->region])) {
$block_counter[$variables['bl... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-65682fb5af | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21image%21image.module/function/image_style_flush/7.x | In Drupal 7, write the function `image_style_flush($style)` (file modules/image/image.module) so that it does the following: Flushes cached media for a style. | Parameters:
- $style: An image style array.
File: modules/image/image.module | function image_style_flush($style) {
// Delete the style directory in each registered wrapper.
$wrappers = file_get_stream_wrappers(STREAM_WRAPPERS_WRITE_VISIBLE);
foreach ($wrappers as $wrapper => $wrapper_data) {
if (file_exists($directory = $wrapper . '://styles/' . $style['name'])) {
file_unmanaged_... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-65908766b0 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21block%21block.install/function/block_update_7000/7.x | I need the code for `block_update_7000()` in Drupal 7 (modules/block/block.install). It must do this: Set system.weight to a low value for block module. | Block should go first so that other modules can alter its output during hook_page_alter(). Almost everything on the page is a block, so before block module runs, there will not be much to alter.
File: modules/block/block.install | function block_update_7000() {
db_update('system')
->fields(array('weight' => '-5'))
->condition('name', 'block')
->execute();
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-6591ea4a2d | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21book%21book.module/function/book_admin_paths/7.x | I need the code for `book_admin_paths()` in Drupal 7 (modules/book/book.module). It must do this: Implements hook_admin_paths(). | File: modules/book/book.module | function book_admin_paths() {
if (variable_get('node_admin_theme')) {
$paths = array(
'node/*/outline' => TRUE,
'node/*/outline/remove' => TRUE,
);
return $paths;
}
} | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-6596b7e122 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_feed_icon/7.x | Implement `theme_feed_icon($variables)` in PHP for Drupal 7. Required behavior: Returns HTML for a feed icon. | Parameters:
- $variables: An associative array containing: - url: An internal system path or a fully qualified external URL of the feed. - title: A descriptive title of the feed.
File: includes/theme.inc | function theme_feed_icon($variables) {
$text = t('Subscribe to !feed-title', array('!feed-title' => $variables['title']));
if ($image = theme('image', array('path' => 'misc/feed.png', 'width' => 16, 'height' => 16, 'alt' => $text))) {
return l($image, $variables['url'], array('html' => TRUE, 'attributes' => arr... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-65a21ece69 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21locale%21locale.admin.inc/function/locale_date_format_form_submit/7.x | In Drupal 7, write the function `locale_date_format_form_submit($form, &$form_state)` (file modules/locale/locale.admin.inc) so that it does the following: Submit handler for configuring localized date formats on the locale_date_format_form. | File: modules/locale/locale.admin.inc | function locale_date_format_form_submit($form, &$form_state) {
include_once DRUPAL_ROOT . '/includes/locale.inc';
$langcode = $form_state['values']['langcode'];
// Get list of date format types.
$types = system_get_date_types();
foreach ($types as $type => $type_info) {
$format = $form_state['values']['d... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-65ba6794c4 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21statistics%21statistics.module/function/statistics_ranking/7.x | Implement `statistics_ranking()` in PHP for Drupal 7. Required behavior: Implements hook_ranking(). | File: modules/statistics/statistics.module | function statistics_ranking() {
if (variable_get('statistics_count_content_views', 0)) {
return array(
'views' => array(
'title' => t('Number of views'),
'join' => array(
'type' => 'LEFT',
'table' => 'node_counter',
'alias' => 'node_counter',
'on' => '... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-65cd7ce59b | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21field%21modules%21options%21options.module/function/theme_options_none/7.x | In Drupal 7, write the function `theme_options_none($variables)` (file modules/field/modules/options/options.module) so that it does the following: Returns HTML for the label for the empty value for options that are not required. | The default theme will display N/A for a radio list and '- None -' for a select.
Parameters:
- $variables: An associative array containing: - instance: An array representing the widget requesting the options.
File: modules/field/modules/options/options.module | function theme_options_none($variables) {
$instance = $variables['instance'];
$option = $variables['option'];
$output = '';
switch ($instance['widget']['type']) {
case 'options_buttons':
$output = t('N/A');
break;
case 'options_select':
$output = ($option == 'option_none' ? t('- None... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-65d4c99bad | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21aggregator%21aggregator.api.php/function/hook_aggregator_parse/7.x | Give me the example code for `hook_aggregator_parse($feed)` in Drupal 7. Hook description: Create an alternative parser for aggregator module. | A parser converts feed item data to a common format. The parser is called at the second of the three aggregation stages: first, data is downloaded by the active fetcher; second, it is converted to a common format by the active parser; and finally, it is passed to all active processors which manipulate or store the data... | function hook_aggregator_parse($feed) {
if ($items = mymodule_parse($feed->source_string)) {
$feed->items = $items;
return TRUE;
}
return FALSE;
} | [
"code-task",
"hook-definition"
] | 2026-09-30T00:00:00 |
api-drupal7-65df7ead59 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21book%21book.module/function/theme_book_title_link/7.x | In Drupal 7, write the function `theme_book_title_link($variables)` (file modules/book/book.module) so that it does the following: Returns HTML for a link to a book title when used as a block title. | Parameters:
- $variables: An associative array containing: - link: An array containing title, href and options for the link.
File: modules/book/book.module | function theme_book_title_link($variables) {
$link = $variables['link'];
$link['options']['attributes']['class'] = array('book-title');
return l($link['title'], $link['href'], $link['options']);
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-65fa9c7fb2 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21openid%21openid.inc/function/_openid_math_pow/7.x | In Drupal 7, write the function `_openid_math_pow($x, $y)` (file modules/openid/openid.inc) so that it does the following: Calls the pow function from the available math library for OpenID. | File: modules/openid/openid.inc | function _openid_math_pow($x, $y) {
$library = _openid_get_math_library();
switch ($library) {
case 'gmp':
return gmp_pow($x, $y);
case 'bcmath':
return bcpow($x, $y);
}
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-6602baf2bd | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21aggregator%21aggregator.install/function/aggregator_update_7002/7.x | In Drupal 7, write the function `aggregator_update_7002()` (file modules/aggregator/aggregator.install) so that it does the following: Add queued timestamp. | File: modules/aggregator/aggregator.install | function aggregator_update_7002() {
db_add_field('aggregator_feed', 'queued', array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'description' => 'Time when this feed was queued for refresh, 0 if not queued.',
));
db_add_index('aggregator_feed', 'queued', array('queued'));
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-661f7219a9 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21translation%21translation.module/function/translation_node_insert/7.x | I need the code for `translation_node_insert($node)` in Drupal 7 (modules/translation/translation.module). It must do this: Implements hook_node_insert(). | File: modules/translation/translation.module | function translation_node_insert($node) {
// Only act if we are dealing with a content type supporting translations.
if (translation_supported_type($node->type)) {
if (!empty($node->translation_source)) {
if ($node->translation_source->tnid) {
// Add node to existing translation set.
$tnid... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-6624851b20 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21dblog%21dblog.admin.inc/function/dblog_clear_log_form/7.x | In Drupal 7, write the function `dblog_clear_log_form($form)` (file modules/dblog/dblog.admin.inc) so that it does the following: Form constructor for the form that clears out the log. | File: modules/dblog/dblog.admin.inc | function dblog_clear_log_form($form) {
$form['dblog_clear'] = array(
'#type' => 'fieldset',
'#title' => t('Clear log messages'),
'#description' => t('This will permanently remove the log messages from the database.'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form['dblog_clear']['clear... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-663944236c | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21book%21book.module/function/template_preprocess_book_navigation/7.x | In Drupal 7, write the function `template_preprocess_book_navigation(&$variables)` (file modules/book/book.module) so that it does the following: Processes variables for book-navigation.tpl.php. | Parameters:
- $variables: An associative array containing the following key: - book_link
File: modules/book/book.module | function template_preprocess_book_navigation(&$variables) {
$book_link = $variables['book_link'];
// Provide extra variables for themers. Not needed by default.
$variables['book_id'] = $book_link['bid'];
$variables['book_title'] = check_plain($book_link['link_title']);
$variables['book_url'] = 'node/' . $boo... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-663f420b1f | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21taxonomy%21taxonomy.pages.inc/function/taxonomy_term_feed/7.x | I need the code for `taxonomy_term_feed($term)` in Drupal 7 (modules/taxonomy/taxonomy.pages.inc). It must do this: Generate the content feed for a taxonomy term. | Parameters:
- $term: The taxonomy term.
File: modules/taxonomy/taxonomy.pages.inc | function taxonomy_term_feed($term) {
$channel['link'] = url('taxonomy/term/' . $term->tid, array('absolute' => TRUE));
$channel['title'] = variable_get('site_name', 'Drupal') . ' - ' . $term->name;
// Only display the description if we have a single term, to avoid clutter and confusion.
// HTML will be removed ... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-66429a4f6e | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21image%21image.effects.inc/function/image_scale_effect/7.x | I need the code for `image_scale_effect(&$image, $data)` in Drupal 7 (modules/image/image.effects.inc). It must do this: Image effect callback; Scale an image resource. | Parameters:
- $image: An image object returned by image_load().
- $data: An array of attributes to use when performing the scale effect with the following items: - "width": An integer representing the desired width in pixels. - "height": An integer representing the desired height in pixels. - "upscale": A boolean indic... | function image_scale_effect(&$image, $data) {
// Set sane default values.
$data += array(
'width' => NULL,
'height' => NULL,
'upscale' => FALSE,
);
if (!image_scale($image, $data['width'], $data['height'], $data['upscale'])) {
watchdog('image', 'Image scale failed using the %toolkit toolkit on ... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-6648b9bb1f | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21overlay%21overlay.module/function/overlay_page_delivery_callback_alter/7.x | I need the code for `overlay_page_delivery_callback_alter(&$callback)` in Drupal 7 (modules/overlay/overlay.module). It must do this: Implements hook_page_delivery_callback_alter(). | File: modules/overlay/overlay.module | function overlay_page_delivery_callback_alter(&$callback) {
if (overlay_display_empty_page()) {
$callback = 'overlay_deliver_empty_page';
}
} | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-665ad5232b | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21file%21file.module/function/theme_file_icon/7.x | I need the code for `theme_file_icon($variables)` in Drupal 7 (modules/file/file.module). It must do this: Returns HTML for an image with an appropriate icon for the given file. | Parameters:
- $variables: An associative array containing: - file: A file object for which to make an icon. - icon_directory: (optional) A path to a directory of icons to be used for files. Defaults to the value of the "file_icon_directory" variable. - alt: (optional) The alternative text to represent the icon in text-... | function theme_file_icon($variables) {
$file = $variables['file'];
$alt = $variables['alt'];
$icon_directory = $variables['icon_directory'];
$mime = check_plain($file->filemime);
$icon_url = file_icon_url($file, $icon_directory);
return '<img class="file-icon" alt="' . check_plain($alt) . '" title="' . $mi... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-6665d5a62a | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21system.api.php/function/hook_entity_update/7.x | Give me the example code for `hook_entity_update($entity, $type)` in Drupal 7. Hook description: Act on entities when updated. | Parameters:
- $entity: The entity object.
- $type: The type of entity being updated (i.e. node, user, comment).
File: modules/system/system.api.php | function hook_entity_update($entity, $type) {
// Update the entity's entry in a fictional table of all entities.
$info = entity_get_info($type);
list($id) = entity_extract_ids($type, $entity);
db_update('example_entity')
->fields(array(
'updated' => REQUEST_TIME,
))
->condition('type', $type)
... | [
"code-task",
"hook-definition"
] | 2026-09-30T00:00:00 |
api-drupal7-6681a834e1 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21poll%21poll.install/function/poll_schema/7.x | Implement `poll_schema()` in PHP for Drupal 7. Required behavior: Implements hook_schema(). | File: modules/poll/poll.install | function poll_schema() {
$schema['poll'] = array(
'description' => 'Stores poll-specific information for poll nodes.',
'fields' => array(
'nid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
'description' => "The poll's {node}.n... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-66a5180429 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21password.inc/function/_password_enforce_log2_boundaries/7.x | In Drupal 7, write the function `_password_enforce_log2_boundaries($count_log2)` (file includes/password.inc) so that it does the following: Ensures that $count_log2 is within set bounds. | Parameters:
- $count_log2: Integer that determines the number of iterations used in the hashing process. A larger value is more secure, but takes more time to complete.
Returns (Integer): within set bounds that is closest to $count_log2.
File: includes/password.inc | function _password_enforce_log2_boundaries($count_log2) {
if ($count_log2 < DRUPAL_MIN_HASH_COUNT) {
return DRUPAL_MIN_HASH_COUNT;
}
elseif ($count_log2 > DRUPAL_MAX_HASH_COUNT) {
return DRUPAL_MAX_HASH_COUNT;
}
return (int) $count_log2;
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-66b4041d29 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21node%21node.api.php/function/hook_prepare/7.x | In Drupal 7, show an example implementation for `hook_prepare($node)` (modules/node/node.api.php): Act on a node object about to be shown on the add/edit form. | This is a node-type-specific hook, which is invoked only for the node type being affected. See
Parameters:
- $node: The node that is about to be shown on the add/edit form.
File: modules/node/node.api.php | function hook_prepare($node) {
if (!isset($node->mymodule_value)) {
$node->mymodule_value = 'foo';
}
} | [
"code-task",
"hook-definition"
] | 2026-09-30T00:00:00 |
api-drupal7-66b79d94ce | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21poll%21poll.install/function/poll_update_7001/7.x | I need the code for `poll_update_7001()` in Drupal 7 (modules/poll/poll.install). It must do this: Use the poll_choice primary key to record votes in poll_votes rather than the choice order. Rename chorder to weight. | Rename {poll_choices} table to {poll_choice} and {poll_votes} to {poll_vote}.
File: modules/poll/poll.install | function poll_update_7001() {
// Add chid column and convert existing votes.
db_add_field('poll_votes', 'chid', array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0));
db_add_index('poll_votes', 'chid', array('chid'));
db_update('poll_votes')
->expression('chid', Database::getConnec... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-66c594f2f8 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21image%21image.admin.inc/function/image_effect_form/7.x | I need the code for `image_effect_form($form, &$form_state, $style, $effect)` in Drupal 7 (modules/image/image.admin.inc). It must do this: Form builder; Form for adding and editing image effects. | This form is used universally for editing all image effects. Each effect adds its own custom section to the form by calling the form function specified in hook_image_effects().
Parameters:
- $form_state: An associative array containing the current state of the form.
- $style: An image style array.
- $effect: An image ... | function image_effect_form($form, &$form_state, $style, $effect) {
if (!empty($effect['data'])) {
$title = t('Edit %label effect', array('%label' => $effect['label']));
}
else{
$title = t('Add %label effect', array('%label' => $effect['label']));
}
drupal_set_title($title, PASS_THROUGH);
$form_stat... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-66cc0fe2d3 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21block%21block.module/function/block_themes_enabled/7.x | I need the code for `block_themes_enabled($theme_list)` in Drupal 7 (modules/block/block.module). It must do this: Initializes blocks for enabled themes. | Parameters:
- $theme_list: An array of theme names.
File: modules/block/block.module | function block_themes_enabled($theme_list) {
foreach ($theme_list as $theme) {
block_theme_initialize($theme);
}
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-66d5b8ba58 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21trigger%21trigger.module/function/_trigger_taxonomy/7.x | In Drupal 7, write the function `_trigger_taxonomy($hook, $array)` (file modules/trigger/trigger.module) so that it does the following: Calls action functions for taxonomy triggers. | Parameters:
- $hook: Hook to trigger actions for taxonomy_term_insert(), taxonomy_term_update(), and taxonomy_term_delete().
- $array: Item on which operation is being performed, either a term or form values.
File: modules/trigger/trigger.module | function _trigger_taxonomy($hook, $array) {
$aids = trigger_get_assigned_actions($hook);
$context = array(
'group' => 'taxonomy',
'hook' => $hook
);
actions_do(array_keys($aids), (object) $array, $context);
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-66eab1da9c | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21node%21node.admin.inc/function/node_filter_form_submit/7.x | I need the code for `node_filter_form_submit($form, &$form_state)` in Drupal 7 (modules/node/node.admin.inc). It must do this: Form submission handler for node_filter_form(). | File: modules/node/node.admin.inc | function node_filter_form_submit($form, &$form_state) {
$filters = node_filters();
switch ($form_state['values']['op']) {
case t('Filter'):
case t('Refine'):
// Apply every filter that has a choice selected other than 'any'.
foreach ($filters as $filter => $options) {
if (isset($form_sta... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-66f23b725c | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21shortcut%21shortcut.module/function/shortcut_default_set/7.x | Implement `shortcut_default_set($account = NULL)` in PHP for Drupal 7. Required behavior: Returns the default shortcut set for a given user account. | Parameters:
- $account (object): (optional) The user account whose default shortcut set will be returned. If not provided, the function will return the currently logged-in user's default shortcut set.
Returns: An object representing the default shortcut set.
File: modules/shortcut/shortcut.module | function shortcut_default_set($account = NULL) {
global $user;
if (!isset($account)) {
$account = $user;
}
// Allow modules to return a default shortcut set name. Since we can only
// have one, we allow the last module which returns a valid result to take
// precedence. If no module returns a valid set... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-67274d74a6 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21bootstrap.inc/function/drupal_language_initialize/7.x | In Drupal 7, write the function `drupal_language_initialize()` (file includes/bootstrap.inc) so that it does the following: Initializes all the defined language types. | File: includes/bootstrap.inc | function drupal_language_initialize() {
$types = language_types();
// Ensure the language is correctly returned, even without multilanguage
// support. Also make sure we have a $language fallback, in case a language
// negotiation callback needs to do a full bootstrap.
// Useful for eg. XML/HTML 'lang' attri... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-672f4e4fb8 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21field%21field.crud.inc/function/field_retrieve_schema/7.x | I need the code for `field_retrieve_schema($field)` in Drupal 7 (modules/field/field.crud.inc). It must do this: Retrieves the schema for a field. | Parameters:
- $field (array): The field array to get the schema definition against.
Returns (array): The field schema definition array.
File: modules/field/field.crud.inc | function field_retrieve_schema($field) {
// Make sure the installation API is available.
include_once DRUPAL_ROOT . '/includes/install.inc';
module_load_all_includes('install');
$schema = (array) module_invoke($field['module'], 'field_schema', $field);
$schema += array('columns' => array(), 'indexes' => array... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-6753e2d9fe | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21taxonomy%21taxonomy.module/function/template_preprocess_taxonomy_term/7.x | Implement `template_preprocess_taxonomy_term(&$variables)` in PHP for Drupal 7. Required behavior: Process variables for taxonomy-term.tpl.php. | File: modules/taxonomy/taxonomy.module | function template_preprocess_taxonomy_term(&$variables) {
$variables['view_mode'] = $variables['elements']['#view_mode'];
$variables['term'] = $variables['elements']['#term'];
$term = $variables['term'];
$uri = entity_uri('taxonomy_term', $term);
$variables['term_url'] = url($uri['path'], $uri['options']);
... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-675aea605e | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21install.inc/function/drupal_detect_baseurl/7.x | In Drupal 7, write the function `drupal_detect_baseurl($file = 'install.php')` (file includes/install.inc) so that it does the following: Detects the base URL using the PHP $_SERVER variables. | Parameters:
- $file: The name of the file calling this function so we can strip it out of the URI when generating the base_url.
Returns: The auto-detected $base_url that should be configured in settings.php
File: includes/install.inc | function drupal_detect_baseurl($file = 'install.php') {
$proto = $_SERVER['HTTPS'] ? 'https://' : 'http://';
$host = $_SERVER['SERVER_NAME'];
$port = ($_SERVER['SERVER_PORT'] == 80 ? '' : ':' . $_SERVER['SERVER_PORT']);
$uri = preg_replace("/\?.*/", '', $_SERVER['REQUEST_URI']);
$dir = str_replace("/$file", '... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-675f0a8ab9 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21install.inc/function/drupal_check_module/7.x | I need the code for `drupal_check_module($module)` in Drupal 7 (includes/install.inc). It must do this: Checks a module's requirements. | Parameters:
- $module: Machine name of module to check.
Returns: TRUE or FALSE, depending on whether the requirements are met.
File: includes/install.inc | function drupal_check_module($module) {
module_load_install($module);
if (module_hook($module, 'requirements')) {
// Check requirements
$requirements = module_invoke($module, 'requirements', 'install');
if (is_array($requirements) && drupal_requirements_severity($requirements) == REQUIREMENT_ERROR) {
... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-6761ee8790 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21token.inc/function/token_generate/7.x | In Drupal 7, write the function `token_generate($type, array $tokens, array $data = array(), array $options = array())` (file includes/token.inc) so that it does the following: Generates replacement values for a list of tokens. | Parameters:
- $type: The type of token being replaced. 'node', 'user', and 'date' are common.
- $tokens: An array of tokens to be replaced, keyed by the literal text of the token as it appeared in the source text.
- $data: (optional) An array of keyed objects. For simple replacement scenarios 'node', 'user', and others... | function token_generate($type, array $tokens, array $data = array(), array $options = array()) {
$options += array('sanitize' => TRUE);
$replacements = module_invoke_all('tokens', $type, $tokens, $data, $options);
// Allow other modules to alter the replacements.
$context = array(
'type' => $type,
'tok... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-676dae1bb4 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21blog%21blog.module/function/blog_block_info/7.x | In Drupal 7, write the function `blog_block_info()` (file modules/blog/blog.module) so that it does the following: Implements hook_block_info(). | File: modules/blog/blog.module | function blog_block_info() {
$block['recent']['info'] = t('Recent blog posts');
$block['recent']['properties']['administrative'] = TRUE;
return $block;
} | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-6777588d5e | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21user%21user.module/function/user_authenticate/7.x | Implement `user_authenticate($name, $password)` in PHP for Drupal 7. Required behavior: Try to validate the user's login credentials locally. | Parameters:
- $name: User name to authenticate.
- $password: A plain-text password, such as trimmed text from form values.
Returns: The user's uid on success, or FALSE on failure to authenticate.
File: modules/user/user.module | function user_authenticate($name, $password) {
$uid = FALSE;
if (!empty($name) && strlen(trim($password)) > 0) {
$account = user_load_by_name($name);
if ($account) {
// Allow alternate password hashing schemes.
require_once DRUPAL_ROOT . '/' . variable_get('password_inc', 'includes/password.inc'... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-679efe919f | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21form.inc/function/_form_element_triggered_scripted_submission/7.x | Implement `_form_element_triggered_scripted_submission($element, &$form_state)` in PHP for Drupal 7. Required behavior: Detects if an element triggered the form submission via Ajax. | This detects button or non-button controls that trigger a form submission via Ajax or some other scriptable environment. These environments can set the special input key '_triggering_element_name' to identify the triggering element. If the name alone doesn't identify the element uniquely, the input key '_triggering_ele... | function _form_element_triggered_scripted_submission($element, &$form_state) {
if (!empty($form_state['input']['_triggering_element_name']) && $element['#name'] == $form_state['input']['_triggering_element_name']) {
if (empty($form_state['input']['_triggering_element_value']) || $form_state['input']['_triggering_... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-67ac99e8c5 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21node%21node.admin.inc/function/node_admin_nodes_submit/7.x | I need the code for `node_admin_nodes_submit($form, &$form_state)` in Drupal 7 (modules/node/node.admin.inc). It must do this: Process node_admin_nodes form submissions. | Executes the chosen 'Update option' on the selected nodes.
File: modules/node/node.admin.inc | function node_admin_nodes_submit($form, &$form_state) {
$operations = module_invoke_all('node_operations');
$operation = $operations[$form_state['values']['operation']];
// Filter out unchecked nodes
$nodes = array_filter($form_state['values']['nodes']);
if ($function = $operation['callback']) {
// Add in... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-67af0f77b5 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21field_ui%21field_ui.admin.inc/function/field_ui_field_overview_row_region/7.x | In Drupal 7, write the function `field_ui_field_overview_row_region($row)` (file modules/field_ui/field_ui.admin.inc) so that it does the following: Returns the region to which a row in the 'Manage fields' screen belongs. | This function is used as a #region_callback in field_ui_field_overview_form(). It is called during field_ui_table_pre_render().
File: modules/field_ui/field_ui.admin.inc | function field_ui_field_overview_row_region($row) {
switch ($row['#row_type']) {
case 'field':
case 'extra_field':
return 'main';
case 'add_new_field':
// If no input in 'label', assume the row has not been dragged out of the
// 'add new' section.
return (!empty($row['label']['#val... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-67bb2966bc | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21aggregator%21aggregator.processor.inc/function/aggregator_aggregator_process_info/7.x | In Drupal 7, write the function `aggregator_aggregator_process_info()` (file modules/aggregator/aggregator.processor.inc) so that it does the following: Implements hook_aggregator_process_info(). | File: modules/aggregator/aggregator.processor.inc | function aggregator_aggregator_process_info() {
return array(
'title' => t('Default processor'),
'description' => t('Creates lightweight records from feed items.'),
);
} | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-67bc0488ca | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21common.inc/function/drupal_pre_render_links/7.x | In Drupal 7, write the function `drupal_pre_render_links($element)` (file includes/common.inc) so that it does the following: #pre_render callback that collects child links into a single array. | This function can be added as a pre_render callback for a renderable array, usually one which will be themed by theme_links(). It iterates through all unrendered children of the element, collects any #links properties it finds, merges them into the parent element's #links array, and prevents those children from being r... | function drupal_pre_render_links($element) {
$element += array('#links' => array());
foreach (element_children($element) as $key) {
$child = &$element[$key];
// If the child has links which have not been printed yet and the user has
// access to it, merge its links in to the parent.
if (isset($child... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-67e65abcef | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21block%21block.module/function/block_custom_block_save/7.x | In Drupal 7, write the function `block_custom_block_save($edit, $delta)` (file modules/block/block.module) so that it does the following: Saves a user-created block in the database. | Parameters:
- $edit: Associative array of fields to save. Array keys: - info: Block description. - body: Associative array of body value and format. Array keys: - value: Block contents. - format: Filter ID of the filter format for the body.
- $delta: Block ID of the block to save.
Returns: Always returns TRUE.
File: ... | function block_custom_block_save($edit, $delta) {
db_update('block_custom')
->fields(array(
'body' => $edit['body']['value'],
'info' => $edit['info'],
'format' => $edit['body']['format'],
))
->condition('bid', $delta)
->execute();
return TRUE;
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-68143ec294 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21announcements_feed%21announcements_feed.install/function/announcements_feed_uninstall/7.x | I need the code for `announcements_feed_uninstall()` in Drupal 7 (modules/announcements_feed/announcements_feed.install). It must do this: Implements hook_uninstall(). | File: modules/announcements_feed/announcements_feed.install | function announcements_feed_uninstall() {
// Delete the announcements_feed module variables.
variable_del('announcements_feed_limit');
variable_del('announcements_feed_cron_interval');
variable_del('announcements_feed_max_age');
variable_del('announcements_feed_json_url');
variable_del('announcements_feed_l... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-6816ec648a | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21search%21search.module/function/search_data/7.x | I need the code for `search_data($keys, $module, $conditions = NULL)` in Drupal 7 (modules/search/search.module). It must do this: Performs a search by calling hook_search_execute(). | Parameters:
- $keys: Keyword query to search on.
- $module: Search module to search.
- $conditions: Optional array of additional search conditions.
Returns: Renderable array of search results. No return value if $keys are not supplied or if the given search module is not active.
File: modules/search/search.module | function search_data($keys, $module, $conditions = NULL) {
if (module_hook($module, 'search_execute')) {
$results = module_invoke($module, 'search_execute', $keys, $conditions);
if (module_hook($module, 'search_page')) {
return module_invoke($module, 'search_page', $results);
}
else {
retu... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-68197bd358 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21comment%21comment.module/function/comment_node_type_load/7.x | I need the code for `comment_node_type_load($name)` in Drupal 7 (modules/comment/comment.module). It must do this: Menu loader callback for Field UI paths. | Return a comment bundle name from a node type in the URL.
File: modules/comment/comment.module | function comment_node_type_load($name) {
if ($type = node_type_get_type(strtr($name, array('-' => '_')))) {
return 'comment_node_' . $type->type;
}
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-681f94cf4a | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21form.inc/function/_batch_populate_queue/7.x | Implement `_batch_populate_queue(&$batch, $set_id)` in PHP for Drupal 7. Required behavior: Populates a job queue with the operations of a batch set. | Depending on whether the batch is progressive or not, the BatchQueue or BatchMemoryQueue handler classes will be used.
Parameters:
- $batch: The batch array.
- $set_id: The id of the set to process.
Returns: The name and class of the queue are added by reference to the batch set.
File: includes/form.inc | function _batch_populate_queue(&$batch, $set_id) {
$batch_set = &$batch['sets'][$set_id];
if (isset($batch_set['operations'])) {
$batch_set += array(
'queue' => array(
'name' => 'drupal_batch:' . $batch['id'] . ':' . $set_id,
'class' => $batch['progressive'] ? 'BatchQueue' : 'BatchMemoryQ... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-6825ff3d14 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21common.inc/function/format_interval/7.x | I need the code for `format_interval($interval, $granularity = 2, $langcode = NULL)` in Drupal 7 (includes/common.inc). It must do this: Formats a time interval with the requested granularity. | Parameters:
- $interval: The length of the interval in seconds.
- $granularity: How many different units to display in the string.
- $langcode: Optional language code to translate to a language other than what is used to display the page.
Returns: A translated string representation of the interval.
File: includes/com... | function format_interval($interval, $granularity = 2, $langcode = NULL) {
$units = array(
'1 year|@count years' => 31536000,
'1 month|@count months' => 2592000,
'1 week|@count weeks' => 604800,
'1 day|@count days' => 86400,
'1 hour|@count hours' => 3600,
'1 min|@count min' => 60,
'1 sec|@c... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-682706939f | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21system.install/function/system_update_7070/7.x | Implement `system_update_7070()` in PHP for Drupal 7. Required behavior: Remove the obsolete 'drupal_badge_color' and 'drupal_badge_size' variables. | File: modules/system/system.install | function system_update_7070() {
variable_del('drupal_badge_color');
variable_del('drupal_badge_size');
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-68878cdae7 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21image%21image.admin.inc/function/image_effect_form_submit/7.x | In Drupal 7, write the function `image_effect_form_submit($form, &$form_state)` (file modules/image/image.admin.inc) so that it does the following: Submit handler for updating an image effect. | File: modules/image/image.admin.inc | function image_effect_form_submit($form, &$form_state) {
$style = $form_state['image_style'];
$effect = array_merge($form_state['image_effect'], $form_state['values']);
$effect['isid'] = $style['isid'];
image_effect_save($effect);
drupal_set_message(t('The image effect was successfully applied.'));
$form_st... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-688eaf0a4c | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21blog%21blog.module/function/blog_menu/7.x | In Drupal 7, write the function `blog_menu()` (file modules/blog/blog.module) so that it does the following: Implements hook_menu(). | File: modules/blog/blog.module | function blog_menu() {
$items['blog'] = array(
'title' => 'Blogs',
'page callback' => 'blog_page_last',
'access arguments' => array('access content'),
'type' => MENU_SUGGESTED_ITEM,
'file' => 'blog.pages.inc',
);
$items['blog/%user_uid_optional'] = array(
'title' => 'My blog',
'page ca... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-689a0fea44 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21image%21image.admin.inc/function/theme_image_rotate_summary/7.x | In Drupal 7, write the function `theme_image_rotate_summary($variables)` (file modules/image/image.admin.inc) so that it does the following: Returns HTML for a summary of an image rotate effect. | Parameters:
- $variables: An associative array containing: - data: The current configuration for this rotate effect.
File: modules/image/image.admin.inc | function theme_image_rotate_summary($variables) {
$data = $variables['data'];
return ($data['random']) ? t('random between -@degrees° and @degrees°', array('@degrees' => str_replace('-', '', $data['degrees']))) : t('@degrees°', array('@degrees' => $data['degrees']));
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-68a7d227f2 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21filter%21filter.module/function/filter_get_formats_by_role/7.x | In Drupal 7, write the function `filter_get_formats_by_role($rid)` (file modules/filter/filter.module) so that it does the following: Retrieves a list of text formats that are allowed for a given role. | Parameters:
- $rid: The user role ID to retrieve text formats for.
Returns: An array of text format objects that are allowed for the role, keyed by the text format ID and ordered by weight.
File: modules/filter/filter.module | function filter_get_formats_by_role($rid) {
$formats = array();
foreach (filter_formats() as $format) {
$roles = filter_get_roles_by_format($format);
if (isset($roles[$rid])) {
$formats[$format->format] = $format;
}
}
return $formats;
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-68b772c5cb | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21field%21field.api.php/function/hook_field_attach_delete_bundle/7.x | In Drupal 7, show an example implementation for `hook_field_attach_delete_bundle($entity_type, $bundle, $instances)` (modules/field/field.api.php): Act on field_attach_delete_bundle. | This hook is invoked after the field module has performed the operation.
Parameters:
- $entity_type: The type of entity; for example, 'node' or 'user'.
- $bundle: The name of the bundle that was just deleted.
- $instances: An array of all instances that existed for the bundle before it was deleted.
File: modules/fiel... | function hook_field_attach_delete_bundle($entity_type, $bundle, $instances) {
// Remove the extra weights variable information for this bundle.
$extra_weights = variable_get('field_extra_weights', array());
if (isset($extra_weights[$entity_type][$bundle])) {
unset($extra_weights[$entity_type][$bundle]);
v... | [
"code-task",
"hook-definition"
] | 2026-09-30T00:00:00 |
api-drupal7-68e6cc5e2e | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21system.install/function/_system_check_db_utf8mb4_requirements/7.x | I need the code for `_system_check_db_utf8mb4_requirements($phase)` in Drupal 7 (modules/system/system.install). It must do this: Checks whether the requirements for multi-byte UTF-8 support are met. | Parameters:
- $phase (string): The hook_requirements() stage.
Returns (array): A requirements array with the result of the charset check.
File: modules/system/system.install | function _system_check_db_utf8mb4_requirements($phase) {
global $install_state;
// In the requirements check of the installer, skip the utf8mb4 check unless
// the database connection info has been preconfigured by hand with valid
// information before running the installer, as otherwise we cannot get a
// va... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-69039738f5 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21field%21field.multilingual.inc/function/field_language/7.x | I need the code for `field_language($entity_type, $entity, $field_name = NULL, $langcode = NULL)` in Drupal 7 (modules/field/field.multilingual.inc). It must do this: Returns the display language for the fields attached to the given entity. | The actual language for each given field is determined based on the requested language and the actual data available in the fields themselves. If there is no registered translation handler for the given entity type, the display language to be used is just LANGUAGE_NONE, as no other language code is allowed by field_ava... | function field_language($entity_type, $entity, $field_name = NULL, $langcode = NULL) {
$display_languages = &drupal_static(__FUNCTION__, array());
list($id, , $bundle) = entity_extract_ids($entity_type, $entity);
$langcode = field_valid_language($langcode, FALSE);
if (!isset($display_languages[$entity_type][$i... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-691c2c0c6f | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21locale%21locale.install/function/locale_schema/7.x | I need the code for `locale_schema()` in Drupal 7 (modules/locale/locale.install). It must do this: Implements hook_schema(). | File: modules/locale/locale.install | function locale_schema() {
$schema['languages'] = array(
'description' => 'List of all available languages in the system.',
'fields' => array(
'language' => array(
'type' => 'varchar',
'length' => 12,
'not null' => TRUE,
'default' => '',
'description' => "Language... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-692c9b9868 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21bootstrap.inc/function/language_list/7.x | In Drupal 7, write the function `language_list($field = 'language')` (file includes/bootstrap.inc) so that it does the following: Returns a list of installed languages, indexed by the specified key. | Parameters:
- $field: (optional) The field to index the list with.
Returns: An associative array, keyed on the values of $field. - If $field is 'weight' or 'enabled', the array is nested, with the outer array's values each being associative arrays with language codes as keys and language objects as values. - For all o... | function language_list($field = 'language') {
$languages = &drupal_static(__FUNCTION__);
// Init language list
if (!isset($languages)) {
if (drupal_multilingual() || module_exists('locale')) {
$languages['language'] = db_query('SELECT * FROM {languages} ORDER BY weight ASC, name ASC')->fetchAllAssoc('la... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-693decfc9a | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21locale.inc/function/locale_language_from_url/7.x | In Drupal 7, write the function `locale_language_from_url($languages)` (file includes/locale.inc) so that it does the following: Identify language via URL prefix or domain. | Parameters:
- $languages: An array of valid language objects.
Returns: A valid language code on success, FALSE otherwise.
File: includes/locale.inc | function locale_language_from_url($languages) {
$language_url = FALSE;
if (!language_negotiation_get_any(LOCALE_LANGUAGE_NEGOTIATION_URL)) {
return $language_url;
}
switch (variable_get('locale_language_negotiation_url_part', LOCALE_LANGUAGE_NEGOTIATION_URL_PREFIX)) {
case LOCALE_LANGUAGE_NEGOTIATION_... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-6953aad915 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21bootstrap.inc/function/bootstrap_invoke_all/7.x | Implement `bootstrap_invoke_all($hook)` in PHP for Drupal 7. Required behavior: Invokes a bootstrap hook in all bootstrap modules that implement it. | Parameters:
- $hook: The name of the bootstrap hook to invoke.
File: includes/bootstrap.inc | function bootstrap_invoke_all($hook) {
// Bootstrap modules should have been loaded when this function is called, so
// we don't need to tell module_list() to reset its internal list (and we
// therefore leave the first parameter at its default value of FALSE). We
// still pass in TRUE for the second parameter,... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-695c8bbbbd | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21field%21field.install/function/field_update_7001/7.x | I need the code for `field_update_7001()` in Drupal 7 (modules/field/field.install). It must do this: Fix fields definitions created during the d6 to d7 upgrade path. | File: modules/field/field.install | function field_update_7001() {
$fields = _update_7000_field_read_fields();
foreach ($fields as $field) {
// _update_7000_field_create_field() was broken in d7 RC2, and the fields
// created during a d6 to d7 upgrade do not correcly store the 'index'
// entry. See http://drupal.org/node/996160.
modu... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-696961e7b9 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21unicode.inc/function/truncate_utf8/7.x | Implement `truncate_utf8($string, $max_length, $wordsafe = FALSE, $add_ellipsis = FALSE, $min_wordsafe_length = 1)` in PHP for Drupal 7. Required behavior: Truncates a UTF-8-encoded string safely to a number of characters. | Parameters:
- $string: The string to truncate.
- $max_length: An upper limit on the returned string length, including trailing ellipsis if $add_ellipsis is TRUE.
- $wordsafe: If TRUE, attempt to truncate on a word boundary. Word boundaries are spaces, punctuation, and Unicode characters used as word boundaries in non-L... | function truncate_utf8($string, $max_length, $wordsafe = FALSE, $add_ellipsis = FALSE, $min_wordsafe_length = 1) {
$ellipsis = '';
$max_length = max($max_length, 0);
$min_wordsafe_length = max($min_wordsafe_length, 0);
if (drupal_strlen($string) <= $max_length) {
// No truncation needed, so don't add ellip... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-6978df684c | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21statistics%21statistics.tokens.inc/function/statistics_token_info/7.x | In Drupal 7, write the function `statistics_token_info()` (file modules/statistics/statistics.tokens.inc) so that it does the following: Implements hook_token_info(). | File: modules/statistics/statistics.tokens.inc | function statistics_token_info() {
$node['total-count'] = array(
'name' => t("Number of views"),
'description' => t("The number of visitors who have read the node."),
);
$node['day-count'] = array(
'name' => t("Views today"),
'description' => t("The number of visitors who have read the node today.... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-697b730419 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21path%21path.admin.inc/function/path_admin_form_submit/7.x | In Drupal 7, write the function `path_admin_form_submit($form, &$form_state)` (file modules/path/path.admin.inc) so that it does the following: Form submission handler for path_admin_form(). | File: modules/path/path.admin.inc | function path_admin_form_submit($form, &$form_state) {
// Remove unnecessary values.
form_state_values_clean($form_state);
path_save($form_state['values']);
drupal_set_message(t('The alias has been saved.'));
$form_state['redirect'] = 'admin/config/search/path';
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-698238fc82 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21dashboard%21dashboard.module/function/dashboard_admin/7.x | Implement `dashboard_admin($launch_customize = FALSE)` in PHP for Drupal 7. Required behavior: Page callback: Displays the dashboard. | Parameters:
- $launch_customize: Whether to launch in customization mode right away. TRUE or FALSE.
File: modules/dashboard/dashboard.module | function dashboard_admin($launch_customize = FALSE) {
$js_settings = array(
'dashboard' => array(
'drawer' => url('admin/dashboard/drawer'),
'blockContent' => url('admin/dashboard/block-content'),
'updatePath' => url('admin/dashboard/update'),
'formToken' => drupal_get_token('dashboard-upd... | [
"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.