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-1c5922a1b0 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21update%21update.module/function/_update_get_cache_multiple/7.x | In Drupal 7, write the function `_update_get_cache_multiple($cid_prefix)` (file modules/update/update.module) so that it does the following: Returns an array of cache items with a given cache ID prefix. | Parameters:
- $cid_prefix (string): The cache ID prefix.
Returns: Associative array of cache items, keyed by cache ID.
File: modules/update/update.module | function _update_get_cache_multiple($cid_prefix) {
$data = array();
$result = db_select('cache_update')
->fields('cache_update', array('cid', 'data', 'created', 'expire', 'serialized'))
->condition('cache_update.cid', $cid_prefix . '::%', 'LIKE')
->execute();
foreach ($result as $cache) {
if ($cac... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-1c74f80493 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21update%21update.settings.inc/function/update_settings/7.x | I need the code for `update_settings($form)` in Drupal 7 (modules/update/update.settings.inc). It must do this: Form constructor for the update settings form. | File: modules/update/update.settings.inc | function update_settings($form) {
$form['update_check_frequency'] = array(
'#type' => 'radios',
'#title' => t('Check for updates'),
'#default_value' => variable_get('update_check_frequency', 1),
'#options' => array(
'1' => t('Daily'),
'7' => t('Weekly'),
),
'#description' => t('Sel... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-1c906a6603 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21dashboard%21dashboard.api.php/function/hook_dashboard_regions_alter/7.x | In Drupal 7, show an example implementation for `hook_dashboard_regions_alter(&$regions)` (modules/dashboard/dashboard.api.php): Alter dashboard regions provided by modules. | Parameters:
- $regions: An array containing all dashboard regions, in the format provided by hook_dashboard_regions().
File: modules/dashboard/dashboard.api.php | function hook_dashboard_regions_alter(&$regions) {
// Remove the sidebar region defined by the core dashboard module.
unset($regions['dashboard_sidebar']);
} | [
"code-task",
"hook-definition"
] | 2026-09-30T00:00:00 |
api-drupal7-1ccbf9dff8 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21filter%21filter.module/function/_filter_format_is_cacheable/7.x | In Drupal 7, write the function `_filter_format_is_cacheable($format)` (file modules/filter/filter.module) so that it does the following: Helper function to determine whether the output of a given text format can be cached. | The output of a given text format can be cached when all enabled filters in the text format allow caching.
Parameters:
- $format: The text format object to check.
Returns: TRUE if all the filters enabled in the given text format allow caching, FALSE otherwise.
File: modules/filter/filter.module | function _filter_format_is_cacheable($format) {
if (empty($format->filters)) {
return TRUE;
}
$filter_info = filter_get_filters();
foreach ($format->filters as $name => $filter) {
// By default, 'cache' is TRUE for all filters unless specified otherwise.
if (!empty($filter['status']) && isset($filte... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-1cf71e2080 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21user%21user.module/function/theme_user_signature/7.x | Implement `theme_user_signature($variables)` in PHP for Drupal 7. Required behavior: Returns HTML for a user signature. | Parameters:
- $variables: An associative array containing: - signature: The user's signature.
File: modules/user/user.module | function theme_user_signature($variables) {
$signature = $variables['signature'];
$output = '';
if ($signature) {
$output .= '<div class="clear">';
$output .= '<div>—</div>';
$output .= $signature;
$output .= '</div>';
}
return $output;
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-1d083fa8c0 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21system.admin.inc/function/system_actions_remove_orphans/7.x | Implement `system_actions_remove_orphans()` in PHP for Drupal 7. Required behavior: Remove actions that are in the database but not supported by any enabled module. | File: modules/system/system.admin.inc | function system_actions_remove_orphans() {
actions_synchronize(TRUE);
drupal_goto('admin/config/system/actions/manage');
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-1d0cc9dbb6 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21theme.maintenance.inc/function/theme_update_page/7.x | Implement `theme_update_page($variables)` in PHP for Drupal 7. Required behavior: Returns HTML for the update page. | Note: this function is not themeable.
Parameters:
- $variables: An associative array containing: - content: The page content to show. - show_messages: Whether to output status and error messages. FALSE can be useful to postpone the messages to a subsequent page.
File: includes/theme.maintenance.inc | function theme_update_page($variables) {
drupal_add_http_header('Content-Type', 'text/html; charset=utf-8');
return theme('maintenance_page', $variables);
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-1d10151a44 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21menu.inc/function/_menu_delete_item/7.x | In Drupal 7, write the function `_menu_delete_item($item, $force = FALSE)` (file includes/menu.inc) so that it does the following: Deletes a single menu link. | Parameters:
- $item: Item to be deleted.
- $force: Forces deletion. Internal use only, setting to TRUE is discouraged.
File: includes/menu.inc | function _menu_delete_item($item, $force = FALSE) {
$item = is_object($item) ? get_object_vars($item) : $item;
if ($item && ($item['module'] != 'system' || $item['updated'] || $force)) {
// Children get re-attached to the item's parent.
if ($item['has_children']) {
$result = db_query("SELECT mlid FROM... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-1d13d43689 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21poll%21poll.module/function/poll_view_voting/7.x | Implement `poll_view_voting($form, &$form_state, $node, $block = FALSE)` in PHP for Drupal 7. Required behavior: Generates the voting form for a poll. | File: modules/poll/poll.module | function poll_view_voting($form, &$form_state, $node, $block = FALSE) {
if ($node->choice) {
$list = array();
foreach ($node->choice as $i => $choice) {
$list[$i] = check_plain($choice['chtext']);
}
$form['choice'] = array(
'#type' => 'radios',
'#title' => t('Choices'),
'#title... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-1d18e76de7 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21system.module/function/system_rebuild_theme_data/7.x | I need the code for `system_rebuild_theme_data()` in Drupal 7 (modules/system/system.module). It must do this: Rebuild, save, and return data about all currently available themes. | Returns (Array): of all available themes and their data.
File: modules/system/system.module | function system_rebuild_theme_data() {
$themes = _system_rebuild_theme_data();
ksort($themes);
system_get_files_database($themes, 'theme');
system_update_files_database($themes, 'theme');
return $themes;
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-1d1a4472e1 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21shortcut%21shortcut.admin.inc/function/shortcut_set_add_form_submit/7.x | Implement `shortcut_set_add_form_submit($form, &$form_state)` in PHP for Drupal 7. Required behavior: Submit handler for shortcut_set_add_form(). | File: modules/shortcut/shortcut.admin.inc | function shortcut_set_add_form_submit($form, &$form_state) {
// Save a new shortcut set with links copied from the user's default set.
$default_set = shortcut_default_set();
$set = (object) array(
'title' => $form_state['values']['new'],
'links' => menu_links_clone($default_set->links),
);
shortcut_se... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-1d1de282e0 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21translation%21translation.module/function/translation_form_node_type_form_alter/7.x | I need the code for `translation_form_node_type_form_alter(&$form, &$form_state)` in Drupal 7 (modules/translation/translation.module). It must do this: Implements hook_form_FORM_ID_alter() for node_type_form(). | File: modules/translation/translation.module | function translation_form_node_type_form_alter(&$form, &$form_state) {
// Add translation option to content type form.
$form['workflow']['language_content_type']['#options'][TRANSLATION_ENABLED] = t('Enabled, with translation');
// Description based on text from locale.module.
$form['workflow']['language_conten... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-1d24cb4b66 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21forum%21forum.install/function/forum_uninstall/7.x | In Drupal 7, write the function `forum_uninstall()` (file modules/forum/forum.install) so that it does the following: Implements hook_uninstall(). | File: modules/forum/forum.install | function forum_uninstall() {
// Load the dependent Taxonomy module, in case it has been disabled.
drupal_load('module', 'taxonomy');
variable_del('forum_containers');
variable_del('forum_hot_topic');
variable_del('forum_per_page');
variable_del('forum_order');
variable_del('forum_block_num_active');
va... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-1d46f719af | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21book%21book.module/function/book_get_books/7.x | I need the code for `book_get_books()` in Drupal 7 (modules/book/book.module). It must do this: Returns an array of all books. | This list may be used for generating a list of all the books, or for building the options for a form select.
Returns: An array of all books.
File: modules/book/book.module | function book_get_books() {
$all_books = &drupal_static(__FUNCTION__);
if (!isset($all_books)) {
$all_books = array();
$nids = db_query("SELECT DISTINCT(bid) FROM {book}")->fetchCol();
if ($nids) {
$query = db_select('book', 'b', array('fetch' => PDO::FETCH_ASSOC));
$query->join('node', 'n... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-1d4ae2b491 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21comment%21comment.module/function/comment_help/7.x | In Drupal 7, write the function `comment_help($path, $arg)` (file modules/comment/comment.module) so that it does the following: Implements hook_help(). | File: modules/comment/comment.module | function comment_help($path, $arg) {
switch ($path) {
case 'admin/help#comment':
$output = '<h3>' . t('About') . '</h3>';
$output .= '<p>' . t('The Comment module allows users to comment on site content, set commenting defaults and permissions, and moderate comments. For more information, see the onli... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-1d663423cd | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21file.inc/function/drupal_dirname/7.x | I need the code for `drupal_dirname($uri)` in Drupal 7 (includes/file.inc). It must do this: Gets the name of the directory from a given path. | PHP's dirname() does not properly pass streams, so this function fills that gap. It is backwards compatible with normal paths and will use PHP's dirname() as a fallback.
Compatibility: normal paths and stream wrappers.
Parameters:
- $uri: A URI or path.
Returns: A string containing the directory name.
File: include... | function drupal_dirname($uri) {
$scheme = file_uri_scheme($uri);
if ($scheme && file_stream_wrapper_valid_scheme($scheme)) {
return file_stream_wrapper_get_instance_by_scheme($scheme)->dirname($uri);
}
else {
return dirname($uri);
}
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-1d6ab21bc7 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21update%21update.module/function/update_themes_enabled/7.x | I need the code for `update_themes_enabled($themes)` in Drupal 7 (modules/update/update.module). It must do this: Implements hook_themes_enabled(). | If themes are enabled, we invalidate the cache of available updates.
File: modules/update/update.module | function update_themes_enabled($themes) {
// Clear all update module caches.
_update_cache_clear();
} | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-1d6e46b597 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21profile%21profile.module/function/profile_user_categories/7.x | I need the code for `profile_user_categories()` in Drupal 7 (modules/profile/profile.module). It must do this: Implements hook_user_categories(). | File: modules/profile/profile.module | function profile_user_categories() {
$result = db_query("SELECT DISTINCT(category) FROM {profile_field}");
$data = array();
foreach ($result as $category) {
$data[] = array(
'name' => $category->category,
'title' => $category->category,
'weight' => 3,
'access callback' => 'profile_cate... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-1d86402aab | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21menu.inc/function/menu_tree_check_access/7.x | Implement `menu_tree_check_access(&$tree, $node_links = array())` in PHP for Drupal 7. Required behavior: Checks access and performs dynamic operations for each link in the tree. | Parameters:
- $tree: The menu tree you wish to operate on.
- $node_links: A collection of node link references generated from $tree by menu_tree_collect_node_links().
File: includes/menu.inc | function menu_tree_check_access(&$tree, $node_links = array()) {
if ($node_links && (user_access('access content') || user_access('bypass node access'))) {
$nids = array_keys($node_links);
$select = db_select('node', 'n');
$select->addField('n', 'nid');
// When a menu administrator who we know has per... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-1d8e6c2302 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21user%21user.pages.inc/function/user_edit_cancel_submit/7.x | Implement `user_edit_cancel_submit($form, &$form_state)` in PHP for Drupal 7. Required behavior: Submit function for the 'Cancel account' button on the user edit form. | File: modules/user/user.pages.inc | function user_edit_cancel_submit($form, &$form_state) {
$destination = array();
if (isset($_GET['destination'])) {
$destination = drupal_get_destination();
unset($_GET['destination']);
}
// Note: We redirect from user/uid/edit to user/uid/cancel to make the tabs disappear.
$form_state['redirect'] = ar... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-1d9596ee99 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21system.module/function/system_admin_compact_page/7.x | Implement `system_admin_compact_page($mode = 'off')` in PHP for Drupal 7. Required behavior: Menu callback; Sets whether the admin menu is in compact mode or not. | Parameters:
- $mode: Valid values are 'on' and 'off'.
File: modules/system/system.module | function system_admin_compact_page($mode = 'off') {
user_cookie_save(array('admin_compact_mode' => ($mode == 'on')));
drupal_goto();
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-1da6de6851 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21system.module/function/_system_update_bootstrap_status/7.x | Implement `_system_update_bootstrap_status()` in PHP for Drupal 7. Required behavior: Refresh bootstrap column in the system table. | This is called internally by module_enable/disable() to flag modules that implement hooks used during bootstrap, such as hook_boot(). These modules are loaded earlier to invoke the hooks.
File: modules/system/system.module | function _system_update_bootstrap_status() {
$bootstrap_modules = array();
foreach (bootstrap_hooks() as $hook) {
foreach (module_implements($hook) as $module) {
$bootstrap_modules[] = $module;
}
}
$query = db_update('system')->fields(array('bootstrap' => 0));
if ($bootstrap_modules) {
db_up... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-1db2f1e3a7 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21book%21book.module/function/book_get_flat_menu/7.x | Implement `book_get_flat_menu($book_link)` in PHP for Drupal 7. Required behavior: Gets the book menu tree for a page and returns it as a linear array. | Parameters:
- $book_link: A fully loaded menu link that is part of the book hierarchy.
Returns: A linear array of menu links in the order that the links are shown in the menu, so the previous and next pages are the elements before and after the element corresponding to the current node. The children of the current nod... | function book_get_flat_menu($book_link) {
$flat = &drupal_static(__FUNCTION__, array());
if (!isset($flat[$book_link['mlid']])) {
// Call menu_tree_all_data() to take advantage of the menu system's caching.
$tree = menu_tree_all_data($book_link['menu_name'], $book_link, $book_link['depth'] + 1);
$flat[... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-1db77180ad | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21aggregator%21aggregator.module/function/aggregator_category_load/7.x | I need the code for `aggregator_category_load($cid)` in Drupal 7 (modules/aggregator/aggregator.module). It must do this: Loads an aggregator category. | Parameters:
- $cid: The category id.
Returns: An associative array describing the category.
File: modules/aggregator/aggregator.module | function aggregator_category_load($cid) {
$categories = &drupal_static(__FUNCTION__);
if (!isset($categories[$cid])) {
$categories[$cid] = db_query('SELECT * FROM {aggregator_category} WHERE cid = :cid', array(':cid' => $cid))->fetchAssoc();
}
return $categories[$cid];
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-1dbbf76664 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21system.api.php/function/hook_file_load/7.x | In Drupal 7, show an example implementation for `hook_file_load($files)` (modules/system/system.api.php): Load additional information into file objects. | file_load_multiple() calls this hook to allow modules to load additional information into each file.
Parameters:
- $files: An array of file objects, indexed by fid.
File: modules/system/system.api.php | function hook_file_load($files) {
// Add the upload specific data into the file object.
$result = db_query('SELECT * FROM {upload} u WHERE u.fid IN (:fids)', array(':fids' => array_keys($files)))->fetchAll(PDO::FETCH_ASSOC);
foreach ($result as $record) {
foreach ($record as $key => $value) {
$files[$re... | [
"code-task",
"hook-definition"
] | 2026-09-30T00:00:00 |
api-drupal7-1dc035ff9e | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21menu.inc/function/menu_tree_collect_node_links/7.x | In Drupal 7, write the function `menu_tree_collect_node_links(&$tree, &$node_links)` (file includes/menu.inc) so that it does the following: Collects node links from a given menu tree recursively. | Parameters:
- $tree: The menu tree you wish to collect node links from.
- $node_links: An array in which to store the collected node links.
File: includes/menu.inc | function menu_tree_collect_node_links(&$tree, &$node_links) {
foreach ($tree as $key => $v) {
if ($tree[$key]['link']['router_path'] == 'node/%') {
$nid = substr($tree[$key]['link']['link_path'], 5);
if (is_numeric($nid)) {
$node_links[$nid][$tree[$key]['link']['mlid']] = &$tree[$key]['link'];... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-1de8df3d97 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21ajax.inc/function/ajax_command_before/7.x | I need the code for `ajax_command_before($selector, $html, $settings = NULL)` in Drupal 7 (includes/ajax.inc). It must do this: Creates a Drupal Ajax 'insert/before' command. | The 'insert/before' command instructs the client to use jQuery's before() method to insert the given HTML content before each of elements matched by the given selector.
This command is implemented by Drupal.ajax.prototype.commands.insert() defined in misc/ajax.js.
Parameters:
- $selector: A jQuery selector string. If... | function ajax_command_before($selector, $html, $settings = NULL) {
return array(
'command' => 'insert',
'method' => 'before',
'selector' => $selector,
'data' => $html,
'settings' => $settings,
);
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-1dec973b0a | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21system.install/function/system_update_7055/7.x | Implement `system_update_7055()` in PHP for Drupal 7. Required behavior: Converts fields that store serialized variables from text to blob. | File: modules/system/system.install | function system_update_7055() {
$spec = array(
'description' => 'The value of the variable.',
'type' => 'blob',
'not null' => TRUE,
'size' => 'big',
'translatable' => TRUE,
);
db_change_field('variable', 'value', 'value', $spec);
$spec = array(
'description' => 'Parameters to be passed ... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-1df0c533ef | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21trigger%21trigger.module/function/trigger_trigger_info/7.x | In Drupal 7, write the function `trigger_trigger_info()` (file modules/trigger/trigger.module) so that it does the following: Implements hook_trigger_info(). | Defines all the triggers that this module implements triggers for.
File: modules/trigger/trigger.module | function trigger_trigger_info() {
return array(
'node' => array(
'node_presave' => array(
'label' => t('When either saving new content or updating existing content'),
),
'node_insert' => array(
'label' => t('After saving new content'),
),
'node_update' => arr... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-1e041cbba9 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21system.api.php/function/hook_date_formats/7.x | Give me the example code for `hook_date_formats()` in Drupal 7. Hook description: Define additional date formats. | This hook is used to define the PHP date format strings that can be assigned to date types in the administrative interface. A module can provide date format strings for the core-provided date types ('long', 'medium', and 'short'), or for date types defined in hook_date_format_types() by itself or another module.
Since... | function hook_date_formats() {
return array(
array(
'type' => 'mymodule_extra_long',
'format' => 'l jS F Y H:i:s e',
'locales' => array('en-ie'),
),
array(
'type' => 'mymodule_extra_long',
'format' => 'l jS F Y h:i:sa',
'locales' => array('en', 'en-us'),
),
arra... | [
"code-task",
"hook-definition"
] | 2026-09-30T00:00:00 |
api-drupal7-1e1964125e | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21system.module/function/system_authorized_init/7.x | Implement `system_authorized_init($callback, $file, $arguments = array(), $page_title = NULL)` in PHP for Drupal 7. Required behavior: Setup a given callback to run via authorize.php with elevated privileges. | To use authorize.php, certain variables must be stashed into $_SESSION. This function sets up all the necessary $_SESSION variables. The calling function should then redirect to authorize.php, using the full path returned by system_authorized_get_url(). That initiates the workflow that will eventually lead to the callb... | function system_authorized_init($callback, $file, $arguments = array(), $page_title = NULL) {
// First, figure out what file transfer backends the site supports, and put
// all of those in the SESSION so that authorize.php has access to all of
// them via the class autoloader, even without a full bootstrap.
$_S... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-1e263851d7 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21path.inc/function/drupal_get_normal_path/7.x | In Drupal 7, write the function `drupal_get_normal_path($path, $path_language = NULL)` (file includes/path.inc) so that it does the following: Given a path alias, return the internal path it represents. | Parameters:
- $path: A Drupal path alias.
- $path_language: An optional language code to look up the path in.
Returns: The internal path represented by the alias, or the original alias if no internal path was found.
File: includes/path.inc | function drupal_get_normal_path($path, $path_language = NULL) {
$original_path = $path;
// Lookup the path alias first.
if ($source = drupal_lookup_path('source', $path, $path_language)) {
$path = $source;
}
// Allow other modules to alter the inbound URL. We cannot use drupal_alter()
// here because ... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-1e32051ea7 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21bootstrap.inc/function/drupal_settings_initialize/7.x | Implement `drupal_settings_initialize()` in PHP for Drupal 7. Required behavior: Sets the base URL, cookie domain, and session name from configuration. | File: includes/bootstrap.inc | function drupal_settings_initialize() {
global $base_url, $base_path, $base_root;
// Export these settings.php variables to the global namespace.
global $databases, $cookie_domain, $conf, $installed_profile, $update_free_access, $db_url, $db_prefix, $drupal_hash_salt, $is_https, $base_secure_url, $base_insecure_... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-1e5ae50b13 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21field%21field.api.php/function/hook_field_widget_form/7.x | In Drupal 7, show an example implementation for `hook_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element)` (modules/field/field.api.php): Return the form for a single field widget. | Field widget form elements should be based on the passed-in $element, which contains the base form element properties derived from the field configuration.
Field API will set the weight, field name and delta values for each form element. If there are multiple values for this field, the Field API will invoke this hook ... | function hook_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {
$element += array(
'#type' => $instance['widget']['type'],
'#default_value' => isset($items[$delta]) ? $items[$delta] : '',
);
return array('value' => $element);
} | [
"code-task",
"hook-definition"
] | 2026-09-30T00:00:00 |
api-drupal7-1e6cda33ce | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21node%21content_types.inc/function/node_type_form/7.x | In Drupal 7, write the function `node_type_form($form, &$form_state, $type = NULL)` (file modules/node/content_types.inc) so that it does the following: Form constructor for the node type editing form. | Parameters:
- $type: (optional) An object representing the node type, when editing an existing node type.
File: modules/node/content_types.inc | function node_type_form($form, &$form_state, $type = NULL) {
if (!isset($type->type)) {
// This is a new type. Node module managed types are custom and unlocked.
$type = node_type_set_defaults(array('custom' => 1, 'locked' => 0));
}
// Make the type object available to implementations of hook_form_alter.... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-1e7d64aadc | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21aggregator%21aggregator.pages.inc/function/template_preprocess_aggregator_feed_source/7.x | In Drupal 7, write the function `template_preprocess_aggregator_feed_source(&$variables)` (file modules/aggregator/aggregator.pages.inc) so that it does the following: Processes variables for aggregator-feed-source.tpl.php. | File: modules/aggregator/aggregator.pages.inc | function template_preprocess_aggregator_feed_source(&$variables) {
$feed = $variables['feed'];
$variables['source_icon'] = theme('feed_icon', array('url' => $feed->url, 'title' => t('!title feed', array('!title' => $feed->title))));
if (!empty($feed->image) && !empty($feed->title) && !empty($feed->link)) {
... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-1e7e8766f4 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21node%21node.module/function/node_search_execute/7.x | I need the code for `node_search_execute($keys = NULL, $conditions = NULL)` in Drupal 7 (modules/node/node.module). It must do this: Implements hook_search_execute(). | File: modules/node/node.module | function node_search_execute($keys = NULL, $conditions = NULL) {
// Build matching conditions
$query = db_select('search_index', 'i', array('target' => 'slave'))->extend('SearchQuery')->extend('PagerDefault');
$query->join('node', 'n', 'n.nid = i.sid');
$query
->condition('n.status', 1)
->addTag('node_a... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-1e8842c279 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21php%21php.module/function/php_filter_info/7.x | In Drupal 7, write the function `php_filter_info()` (file modules/php/php.module) so that it does the following: Implements hook_filter_info(). | Provide PHP code filter. Use with care.
File: modules/php/php.module | function php_filter_info() {
$filters['php_code'] = array(
'title' => t('PHP evaluator'),
'description' => t('Executes a piece of PHP code. The usage of this filter should be restricted to administrators only!'),
'process callback' => 'php_eval',
'tips callback' => '_php_filter_tips',
'cache' => F... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-1ead6603c0 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21openid%21openid.inc/function/openid_redirect_http/7.x | In Drupal 7, write the function `openid_redirect_http($url, $message)` (file modules/openid/openid.inc) so that it does the following: Performs an HTTP 302 redirect (for the 1.x protocol). | File: modules/openid/openid.inc | function openid_redirect_http($url, $message) {
$query = array();
foreach ($message as $key => $val) {
$query[] = $key . '=' . urlencode($val);
}
$sep = (strpos($url, '?') === FALSE) ? '?' : '&';
header('Location: ' . $url . $sep . implode('&', $query), TRUE, 302);
drupal_exit();
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-1edeb8e327 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21image%21image.admin.inc/function/image_style_list/7.x | Implement `image_style_list()` in PHP for Drupal 7. Required behavior: Menu callback; Listing of all current image styles. | File: modules/image/image.admin.inc | function image_style_list() {
$page = array();
$styles = image_styles();
$page['image_style_list'] = array(
'#markup' => theme('image_style_list', array('styles' => $styles)),
'#attached' => array(
'css' => array(drupal_get_path('module', 'image') . '/image.admin.css' => array()),
),
);
re... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-1ef0b5e478 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21common.inc/function/entity_get_controller/7.x | Implement `entity_get_controller($entity_type)` in PHP for Drupal 7. Required behavior: Gets the entity controller for an entity type. | Returns: DrupalEntityControllerInterface The entity controller object for the specified entity type.
File: includes/common.inc | function entity_get_controller($entity_type) {
$controllers = &drupal_static(__FUNCTION__, array());
if (!isset($controllers[$entity_type])) {
$type_info = entity_get_info($entity_type);
// Explicitly fail for malformed entities missing a valid controller class.
if (!isset($type_info['controller class']... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-1f17bff3c0 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21node%21node.admin.inc/function/node_admin_content/7.x | Implement `node_admin_content($form, $form_state)` in PHP for Drupal 7. Required behavior: Page callback: Form constructor for the content administration form. | File: modules/node/node.admin.inc | function node_admin_content($form, $form_state) {
if (isset($form_state['values']['operation']) && $form_state['values']['operation'] == 'delete') {
return node_multiple_delete_confirm($form, $form_state, array_filter($form_state['values']['nodes']));
}
$form['filter'] = node_filter_form();
$form['#submit']... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-1f183c0a95 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21menu.inc/function/menu_cache_clear_all/7.x | I need the code for `menu_cache_clear_all()` in Drupal 7 (includes/menu.inc). It must do this: Clears all cached menu data. | This should be called any time broad changes might have been made to the router items or menu links.
File: includes/menu.inc | function menu_cache_clear_all() {
cache_clear_all('*', 'cache_menu', TRUE);
menu_reset_static_cache();
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-1f4c865681 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21bootstrap.inc/function/drupal_multilingual/7.x | In Drupal 7, write the function `drupal_multilingual()` (file includes/bootstrap.inc) so that it does the following: Returns TRUE if there is more than one language enabled. | Returns: TRUE if more than one language is enabled.
File: includes/bootstrap.inc | function drupal_multilingual() {
// The "language_count" variable stores the number of enabled languages to
// avoid unnecessarily querying the database when building the list of
// enabled languages on monolingual sites.
return variable_get('language_count', 1) > 1;
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-1f844d4a68 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21user%21user.module/function/user_form_field_ui_field_edit_form_submit/7.x | In Drupal 7, write the function `user_form_field_ui_field_edit_form_submit($form, &$form_state)` (file modules/user/user.module) so that it does the following: Additional submit handler for the 'Edit field instance' form. | Make sure the 'user_register_form' setting is set for required fields.
File: modules/user/user.module | function user_form_field_ui_field_edit_form_submit($form, &$form_state) {
$instance = $form_state['values']['instance'];
if (!empty($instance['required'])) {
form_set_value($form['instance']['settings']['user_register_form'], 1, $form_state);
}
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-1f988ee2aa | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21install.core.inc/function/install_settings_form_submit/7.x | In Drupal 7, write the function `install_settings_form_submit($form, &$form_state)` (file includes/install.core.inc) so that it does the following: Form submission handler for install_settings_form(). | File: includes/install.core.inc | function install_settings_form_submit($form, &$form_state) {
global $install_state;
// Update global settings array and save.
$settings['databases'] = array(
'value' => array('default' => array('default' => $form_state['storage']['database'])),
'required' => TRUE,
);
$settings['drupal_hash_salt'] ... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-1fae97e3d3 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21node%21node.admin.inc/function/node_multiple_delete_confirm/7.x | I need the code for `node_multiple_delete_confirm($form, &$form_state, $nodes)` in Drupal 7 (modules/node/node.admin.inc). It must do this: Multiple node deletion confirmation form for node_admin_content(). | File: modules/node/node.admin.inc | function node_multiple_delete_confirm($form, &$form_state, $nodes) {
$form['nodes'] = array('#prefix' => '<ul>', '#suffix' => '</ul>', '#tree' => TRUE);
// array_filter returns only elements with TRUE values
foreach ($nodes as $nid => $value) {
$title = db_query('SELECT title FROM {node} WHERE nid = :nid', ar... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-1faf9be98f | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21locale%21locale.admin.inc/function/locale_languages_edit_form/7.x | I need the code for `locale_languages_edit_form($form, &$form_state, $langcode)` in Drupal 7 (modules/locale/locale.admin.inc). It must do this: Editing screen for a particular language. | Parameters:
- $langcode: Language code of the language to edit.
File: modules/locale/locale.admin.inc | function locale_languages_edit_form($form, &$form_state, $langcode) {
if ($language = db_query("SELECT * FROM {languages} WHERE language = :language", array(':language' => $langcode))->fetchObject()) {
_locale_languages_common_controls($form, $language);
$form['actions'] = array('#type' => 'actions');
$fo... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-1fe399f35b | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21overlay%21overlay.module/function/template_preprocess_overlay/7.x | Implement `template_preprocess_overlay(&$variables)` in PHP for Drupal 7. Required behavior: Implements template_preprocess_HOOK() for overlay.tpl.php | If the current page request is inside the overlay, add appropriate classes to the <body> element, and simplify the page title.
File: modules/overlay/overlay.module | function template_preprocess_overlay(&$variables) {
$variables['tabs'] = menu_primary_local_tasks();
$variables['title'] = drupal_get_title();
$variables['disable_overlay'] = overlay_disable_message();
$variables['content_attributes_array']['class'][] = 'clearfix';
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-1fe5bea880 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21system.admin.inc/function/theme_system_date_time_settings/7.x | I need the code for `theme_system_date_time_settings($variables)` in Drupal 7 (modules/system/system.admin.inc). It must do this: Returns HTML for the date settings form. | Parameters:
- $variables: An associative array containing: - form: A render element representing the form.
File: modules/system/system.admin.inc | function theme_system_date_time_settings($variables) {
$form = $variables['form'];
$header = array(
t('Date type'),
t('Format'),
t('Operations'),
);
foreach (element_children($form['format']) as $key) {
$delete_key = $key . '_delete';
$row = array();
$row[] = $form['format'][$key]['#tit... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-1ff1ac976e | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21locale%21locale.admin.inc/function/locale_languages_configure_form/7.x | In Drupal 7, write the function `locale_languages_configure_form()` (file modules/locale/locale.admin.inc) so that it does the following: Setting for language negotiation options | File: modules/locale/locale.admin.inc | function locale_languages_configure_form() {
include_once DRUPAL_ROOT . '/includes/language.inc';
$form = array(
'#submit' => array('locale_languages_configure_form_submit'),
'#theme' => 'locale_languages_configure_form',
'#language_types' => language_types_configurable(FALSE),
'#language_types_inf... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-1ff3c8039b | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21system.module/function/_system_date_format_types_build/7.x | I need the code for `_system_date_format_types_build()` in Drupal 7 (modules/system/system.module). It must do this: Builds and returns information about available date types. | Returns: An associative array of date type information keyed by name. Each date type information array has the following elements: - type: The machine-readable name of the date type. - title: The human-readable name of the date type. - locked: A boolean indicating whether or not this date type should be configurable fr... | function _system_date_format_types_build() {
$types = array();
// Get list of modules that implement hook_date_format_types().
$modules = module_implements('date_format_types');
foreach ($modules as $module) {
$module_types = module_invoke($module, 'date_format_types');
foreach ($module_types as $modu... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-201f9f18c4 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21aggregator%21aggregator.module/function/aggregator_theme/7.x | Implement `aggregator_theme()` in PHP for Drupal 7. Required behavior: Implements hook_theme(). | File: modules/aggregator/aggregator.module | function aggregator_theme() {
return array(
'aggregator_wrapper' => array(
'variables' => array('content' => NULL),
'file' => 'aggregator.pages.inc',
'template' => 'aggregator-wrapper',
),
'aggregator_categorize_items' => array(
'render element' => 'form',
'file' => 'aggregat... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-203c93ced0 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21field%21field.info.inc/function/field_info_storage_settings/7.x | In Drupal 7, write the function `field_info_storage_settings($type)` (file modules/field/field.info.inc) so that it does the following: Returns a field storage type's default settings. | Parameters:
- $type: A field storage type name.
Returns: The storage type's default settings, as provided by hook_field_storage_info(), or an empty array if type or settings are undefined.
File: modules/field/field.info.inc | function field_info_storage_settings($type) {
$info = field_info_storage_types($type);
return isset($info['settings']) ? $info['settings'] : array();
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-203d869885 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21field%21field.api.php/function/hook_field_delete/7.x | In Drupal 7, show an example implementation for `hook_field_delete($entity_type, $entity, $field, $instance, $langcode, &$items)` (modules/field/field.api.php): Define custom delete behavior for this module's field data. | This hook is invoked from field_attach_delete() on the module that defines a field, during the process of deleting an entity object (node, taxonomy term, etc.). It is invoked just before the data for this field on the particular entity object is deleted from field storage. Only field modules that are storing or trackin... | function hook_field_delete($entity_type, $entity, $field, $instance, $langcode, &$items) {
list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);
foreach ($items as $delta => $item) {
// For hook_file_references(), remember that this is being deleted.
$item['file_field_name'] = $field['field_... | [
"code-task",
"hook-definition"
] | 2026-09-30T00:00:00 |
api-drupal7-20634b279c | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21poll%21poll.module/function/template_preprocess_poll_results/7.x | In Drupal 7, write the function `template_preprocess_poll_results(&$variables)` (file modules/poll/poll.module) so that it does the following: Preprocess the poll_results theme hook. | Inputs: $raw_title, $results, $votes, $raw_links, $block, $nid, $vote. The $raw_* inputs to this are naturally unsafe; often safe versions are made to simply overwrite the raw version, but in this case it seems likely that the title and the links may be overridden by the theme layer, so they are left in with a differen... | function template_preprocess_poll_results(&$variables) {
$variables['links'] = theme('links__poll_results', array('links' => $variables['raw_links']));
if (isset($variables['vote']) && $variables['vote'] > -1 && user_access('cancel own vote')) {
$elements = drupal_get_form('poll_cancel_form', $variables['nid'])... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-208a56bc62 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21field%21modules%21number%21number.module/function/number_help/7.x | Implement `number_help($path, $arg)` in PHP for Drupal 7. Required behavior: Implements hook_help(). | File: modules/field/modules/number/number.module | function number_help($path, $arg) {
switch ($path) {
case 'admin/help#number':
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
$output .= '<p>' . t('The Number module defines various numeric field types for the Field module. Numbers can be in integer, decimal, or floating-point form, and... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-209b66eecc | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21forum%21forum.admin.inc/function/forum_confirm_delete/7.x | Implement `forum_confirm_delete($form, &$form_state, $tid)` in PHP for Drupal 7. Required behavior: Form constructor for confirming deletion of a forum taxonomy term. | Parameters:
- $tid: ID of the term to be deleted.
File: modules/forum/forum.admin.inc | function forum_confirm_delete($form, &$form_state, $tid) {
$term = taxonomy_term_load($tid);
$form['tid'] = array('#type' => 'value', '#value' => $tid);
$form['name'] = array('#type' => 'value', '#value' => $term->name);
return confirm_form($form, t('Are you sure you want to delete the forum %name?', array('%... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-209ea162f2 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21forum%21forum.install/function/forum_update_7001/7.x | I need the code for `forum_update_7001()` in Drupal 7 (modules/forum/forum.install). It must do this: Create new {forum_index} table. | File: modules/forum/forum.install | function forum_update_7001() {
$forum_index = array(
'description' => 'Maintains denormalized information about node/term relationships.',
'fields' => array(
'nid' => array(
'description' => 'The {node}.nid this record tracks.',
'type' => 'int',
'unsigned' => TRUE,
'not n... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-210004b873 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21image%21image.module/function/image_style_transform_dimensions/7.x | I need the code for `image_style_transform_dimensions($style_name, array &$dimensions)` in Drupal 7 (modules/image/image.module). It must do this: Determines the dimensions of the styled image. | Applies all of an image style's effects to $dimensions.
Parameters:
- $style_name: The name of the style to be applied.
- $dimensions: Dimensions to be modified - an array with components width and height, in pixels.
File: modules/image/image.module | function image_style_transform_dimensions($style_name, array &$dimensions) {
module_load_include('inc', 'image', 'image.effects');
$style = image_style_load($style_name);
if (!is_array($style)) {
return;
}
foreach ($style['effects'] as $effect) {
if (isset($effect['dimensions passthrough'])) {
... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-211599db60 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21field%21field.api.php/function/hook_field_attach_create_bundle/7.x | Give me the example code for `hook_field_attach_create_bundle($entity_type, $bundle)` in Drupal 7. Hook description: Act on field_attach_create_bundle(). | This hook is invoked after the field module has performed the operation.
See field_attach_create_bundle() for details and arguments.
File: modules/field/field.api.php | function hook_field_attach_create_bundle($entity_type, $bundle) {
// When a new bundle is created, the menu needs to be rebuilt to add the
// Field UI menu item tabs.
variable_set('menu_rebuild_needed', TRUE);
} | [
"code-task",
"hook-definition"
] | 2026-09-30T00:00:00 |
api-drupal7-21166ab29b | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21bootstrap.inc/function/drupal_page_header/7.x | I need the code for `drupal_page_header()` in Drupal 7 (includes/bootstrap.inc). It must do this: Sets HTTP headers in preparation for a page response. | Authenticated users are always given a 'no-cache' header, and will fetch a fresh page on every request. This prevents authenticated users from seeing locally cached pages.
ETag and Last-Modified headers are not set per default for authenticated users so that browsers do not send If-Modified-Since headers from authenti... | function drupal_page_header() {
$headers_sent = &drupal_static(__FUNCTION__, FALSE);
if ($headers_sent) {
return TRUE;
}
$headers_sent = TRUE;
$default_headers = array(
'Expires' => 'Sun, 19 Nov 1978 05:00:00 GMT',
'Cache-Control' => 'no-cache, must-revalidate',
// Prevent browsers from sniff... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-213fb5f65b | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21path%21path.admin.inc/function/path_admin_form_delete_submit/7.x | I need the code for `path_admin_form_delete_submit($form, &$form_state)` in Drupal 7 (modules/path/path.admin.inc). It must do this: Form submission handler for the 'Delete' button on path_admin_form(). | File: modules/path/path.admin.inc | function path_admin_form_delete_submit($form, &$form_state) {
$destination = array();
if (isset($_GET['destination'])) {
$destination = drupal_get_destination();
unset($_GET['destination']);
}
$form_state['redirect'] = array('admin/config/search/path/delete/' . $form_state['values']['pid'], array('query... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-2160d10809 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21form.inc/function/batch_get/7.x | Implement `&batch_get()` in PHP for Drupal 7. Required behavior: Retrieves the current batch. | File: includes/form.inc | function &batch_get() {
// Not drupal_static(), because Batch API operates at a lower level than most
// use-cases for resetting static variables, and we specifically do not want a
// global drupal_static_reset() resetting the batch information. Functions
// that are part of the Batch API and need to reset the ... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-2168ef670d | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21file%21file.field.inc/function/file_field_widget_value/7.x | I need the code for `file_field_widget_value($element, $input = FALSE, $form_state = array())` in Drupal 7 (modules/file/file.field.inc). It must do this: The #value_callback for the file_generic field element. | File: modules/file/file.field.inc | function file_field_widget_value($element, $input = FALSE, $form_state = array()) {
if ($input) {
// Checkboxes lose their value when empty.
// If the display field is present make sure its unchecked value is saved.
$field = field_widget_field($element, $form_state);
if (empty($input['display'])) {
... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-218a34a835 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21locale%21locale.admin.inc/function/locale_languages_custom_form/7.x | Implement `locale_languages_custom_form($form)` in PHP for Drupal 7. Required behavior: Custom language addition form. | File: modules/locale/locale.admin.inc | function locale_languages_custom_form($form) {
$form['custom language'] = array('#type' => 'fieldset',
'#title' => t('Custom language'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
_locale_languages_common_controls($form['custom language']);
$form['custom language']['actions'] = array('#type' =... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-21a012a6a6 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21bootstrap.inc/function/drupal_get_complete_schema/7.x | In Drupal 7, write the function `drupal_get_complete_schema($rebuild = FALSE)` (file includes/bootstrap.inc) so that it does the following: Gets the whole database schema. | The returned schema will include any modifications made by any module that implements hook_schema_alter().
Parameters:
- $rebuild: If true, the schema will be rebuilt instead of retrieved from the cache.
File: includes/bootstrap.inc | function drupal_get_complete_schema($rebuild = FALSE) {
static $schema = array();
if (empty($schema) || $rebuild) {
// Try to load the schema from cache.
if (!$rebuild && $cached = cache_get('schema')) {
$schema = $cached->data;
}
// Otherwise, rebuild the schema cache.
else {
$sche... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-21a0c55848 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21system.api.php/function/hook_translated_menu_link_alter/7.x | In Drupal 7, show an example implementation for `hook_translated_menu_link_alter(&$item, $map)` (modules/system/system.api.php): Alter a menu link after it has been translated and before it is rendered. | This hook is invoked from _menu_link_translate() after a menu link has been translated; i.e., after dynamic path argument placeholders (%) have been replaced with actual values, the user access to the link's target page has been checked, and the link has been localized. It is only invoked if $item['options']['alter'] h... | function hook_translated_menu_link_alter(&$item, $map) {
if ($item['href'] == 'devel/cache/clear') {
$item['localized_options']['query'] = drupal_get_destination();
}
} | [
"code-task",
"hook-definition"
] | 2026-09-30T00:00:00 |
api-drupal7-21a19b217d | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21node%21node.module/function/node_save/7.x | In Drupal 7, write the function `node_save($node)` (file modules/node/node.module) so that it does the following: Saves changes to a node or adds a new node. | Parameters:
- $node: The $node object to be saved. If $node->nid is omitted (or $node->is_new is TRUE), a new node will be added.
File: modules/node/node.module | function node_save($node) {
$transaction = db_transaction();
try {
// Load the stored entity, if any.
if (!empty($node->nid) && !isset($node->original)) {
$node->original = entity_load_unchanged('node', $node->nid);
}
field_attach_presave('node', $node);
global $user;
// Determine i... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-21ac0762b1 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21user%21user.module/function/_user_mail_text/7.x | In Drupal 7, write the function `_user_mail_text($key, $language = NULL, $variables = array(), $replace = TRUE)` (file modules/user/user.module) so that it does the following: Returns a mail string for a variable name. | Used by user_mail() and the settings forms to retrieve strings.
File: modules/user/user.module | function _user_mail_text($key, $language = NULL, $variables = array(), $replace = TRUE) {
$langcode = isset($language) ? $language->language : NULL;
if ($admin_setting = variable_get('user_mail_' . $key, FALSE)) {
// An admin setting overrides the default string.
$text = $admin_setting;
}
else {
//... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-21b8213f4f | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21system.module/function/system_admin_menu_block/7.x | In Drupal 7, write the function `system_admin_menu_block($item)` (file modules/system/system.module) so that it does the following: Provide a single block on the administration overview page. | Parameters:
- $item: The menu item to be displayed.
File: modules/system/system.module | function system_admin_menu_block($item) {
$cache = &drupal_static(__FUNCTION__, array());
// If we are calling this function for a menu item that corresponds to a
// local task (for example, admin/tasks), then we want to retrieve the
// parent item's child links, not this item's (since this item won't have
//... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-21bae22e3d | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21locale%21locale.admin.inc/function/locale_languages_edit_form_validate/7.x | In Drupal 7, write the function `locale_languages_edit_form_validate($form, &$form_state)` (file modules/locale/locale.admin.inc) so that it does the following: Validate the language editing form. Reused for custom language addition too. | File: modules/locale/locale.admin.inc | function locale_languages_edit_form_validate($form, &$form_state) {
// Ensure sane field values for langcode, name, and native.
if (!isset($form['langcode_view']) && preg_match('@[^a-zA-Z_-]@', $form_state['values']['langcode'])) {
form_set_error('langcode', t('%field may only contain characters a-z, underscore... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-21bc3d3491 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21rdf%21rdf.module/function/rdf_rdf_namespaces/7.x | In Drupal 7, write the function `rdf_rdf_namespaces()` (file modules/rdf/rdf.module) so that it does the following: Implements hook_rdf_namespaces(). | File: modules/rdf/rdf.module | function rdf_rdf_namespaces() {
return array(
'content' => 'http://purl.org/rss/1.0/modules/content/',
'dc' => 'http://purl.org/dc/terms/',
'foaf' => 'http://xmlns.com/foaf/0.1/',
'og' => 'http://ogp.me/ns#',
'rdfs' => 'http://www.w3.org/2000/01/rdf-schema#',
'sioc' =>... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-21c3478472 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21image%21image.module/function/image_file_delete/7.x | I need the code for `image_file_delete($file)` in Drupal 7 (modules/image/image.module). It must do this: Implements hook_file_delete(). | File: modules/image/image.module | function image_file_delete($file) {
// Delete any image derivatives of this image.
image_path_flush($file->uri);
} | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-21c453658f | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21field%21field.attach.inc/function/_field_invoke/7.x | In Drupal 7, write the function `_field_invoke($op, $entity_type, $entity, &$a = NULL, &$b = NULL, $options = array())` (file modules/field/field.attach.inc) so that it does the following: Invoke a field hook. | Parameters:
- $op: Possible operations include: - form - validate - presave - insert - update - delete - delete revision - view - prepare translation
- $entity_type: The type of $entity; e.g. 'node' or 'user'.
- $entity: The fully formed $entity_type entity.
- $a: - The $form in the 'form' operation. - The value of $vi... | function _field_invoke($op, $entity_type, $entity, &$a = NULL, &$b = NULL, $options = array()) {
// Merge default options.
$default_options = array(
'default' => FALSE,
'deleted' => FALSE,
'language' => NULL,
);
$options += $default_options;
// Determine the list of instances to iterate on.
lis... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-21cd1c9337 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21system.api.php/function/hook_form_FORM_ID_alter/7.x | Give me the example code for `hook_form_FORM_ID_alter(&$form, &$form_state, $form_id)` in Drupal 7. Hook description: Provide a form-specific alteration instead of the global hook_form_alter(). | Modules can implement hook_form_FORM_ID_alter() to modify a specific form, rather than implementing hook_form_alter() and checking the form ID, or using long switch statements to alter multiple forms.
Form alter hooks are called in the following order: hook_form_alter(), hook_form_BASE_FORM_ID_alter(), hook_form_FORM_... | function hook_form_FORM_ID_alter(&$form, &$form_state, $form_id) {
// Modification for the form with the given form ID goes here. For example, if
// FORM_ID is "user_register_form" this code would run only on the user
// registration form.
// Add a checkbox to registration form about agreeing to terms of use.
... | [
"code-task",
"hook-definition"
] | 2026-09-30T00:00:00 |
api-drupal7-21cf117ef3 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21system.module/function/system_updater_info/7.x | I need the code for `system_updater_info()` in Drupal 7 (modules/system/system.module). It must do this: Implements hook_updater_info(). | File: modules/system/system.module | function system_updater_info() {
return array(
'module' => array(
'class' => 'ModuleUpdater',
'name' => t('Update modules'),
'weight' => 0,
),
'theme' => array(
'class' => 'ThemeUpdater',
'name' => t('Update themes'),
'weight' => 0,
),
);
} | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-21d74515dd | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21common.inc/function/drupal_parse_url/7.x | I need the code for `drupal_parse_url($url)` in Drupal 7 (includes/common.inc). It must do this: Parses a URL string into its path, query, and fragment components. | This function splits both internal paths like @code node?b=c#d @endcode and external URLs like @code https://example.com/a?b=c#d @endcode into their component parts. See
Parameters:
- $url (string): The internal path or external URL string to parse.
Returns (array): An associative array containing: - path: The path c... | function drupal_parse_url($url) {
$options = array(
'path' => NULL,
'query' => array(),
'fragment' => '',
);
// External URLs: not using parse_url() here, so we do not have to rebuild
// the scheme, host, and path without having any use for it.
if (strpos($url, '://') !== FALSE) {
// Split of... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-21dc197b86 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21file.inc/function/file_space_used/7.x | Implement `file_space_used($uid = NULL, $status = FILE_STATUS_PERMANENT)` in PHP for Drupal 7. Required behavior: Determines total disk space used by a single user or the whole filesystem. | Parameters:
- $uid: Optional. A user id, specifying NULL returns the total space used by all non-temporary files.
- $status: Optional. The file status to consider. The default is to only consider files in status FILE_STATUS_PERMANENT.
Returns: An integer containing the number of bytes used.
File: includes/file.inc | function file_space_used($uid = NULL, $status = FILE_STATUS_PERMANENT) {
$query = db_select('file_managed', 'f');
$query->condition('f.status', $status);
$query->addExpression('SUM(f.filesize)', 'filesize');
if (isset($uid)) {
$query->condition('f.uid', $uid);
}
return $query->execute()->fetchField();
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-21e6985413 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/themes%21seven%21template.php/function/seven_tablesort_indicator/7.x | Implement `seven_tablesort_indicator($variables)` in PHP for Drupal 7. Required behavior: Override of theme_tablesort_indicator(). | Use our own image versions, so they show up as black and not gray on gray.
File: themes/seven/template.php | function seven_tablesort_indicator($variables) {
$style = $variables['style'];
$theme_path = drupal_get_path('theme', 'seven');
if ($style == 'asc') {
return theme('image', array('path' => $theme_path . '/images/arrow-asc.png', 'alt' => t('sort ascending'), 'width' => 13, 'height' => 13, 'title' => t('sort as... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-21e70549ce | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21field%21field.api.php/function/hook_field_update_forbid/7.x | Give me the example code for `hook_field_update_forbid($field, $prior_field, $has_data)` in Drupal 7. Hook description: Forbid a field update from occurring. | Any module may forbid any update for any reason. For example, the field's storage module might forbid an update if it would change the storage schema while data for the field exists. A field type module might forbid an update if it would change existing data's semantics, or if there are external dependencies on field s... | function hook_field_update_forbid($field, $prior_field, $has_data) {
// A 'list' field stores integer keys mapped to display values. If
// the new field will have fewer values, and any data exists for the
// abandoned keys, the field will have no way to display them. So,
// forbid such an update.
if ($has_dat... | [
"code-task",
"hook-definition"
] | 2026-09-30T00:00:00 |
api-drupal7-21e7128c8a | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21color%21color.module/function/_color_rgb2hsl/7.x | In Drupal 7, write the function `_color_rgb2hsl($rgb)` (file modules/color/color.module) so that it does the following: Converts an RGB triplet to HSL. | File: modules/color/color.module | function _color_rgb2hsl($rgb) {
$r = $rgb[0];
$g = $rgb[1];
$b = $rgb[2];
$min = min($r, min($g, $b));
$max = max($r, max($g, $b));
$delta = $max - $min;
$l = ($min + $max) / 2;
$s = 0;
if ($l > 0 && $l < 1) {
$s = $delta / ($l < 0.5 ? (2 * $l) : (2 - 2 * $l));
}
$h = 0;
if ($delta > 0) {
... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-21e96707af | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21comment%21comment.module/function/comment_view/7.x | Implement `comment_view($comment, $node, $view_mode = 'full', $langcode = NULL)` in PHP for Drupal 7. Required behavior: Generate an array for rendering the given comment. | Parameters:
- $comment: A comment object.
- $node: The node the comment is attached to.
- $view_mode: View mode, e.g. 'full', 'teaser'...
- $langcode: (optional) A language code to use for rendering. Defaults to the global content language of the current request.
Returns: An array as expected by drupal_render().
File... | function comment_view($comment, $node, $view_mode = 'full', $langcode = NULL) {
if (!isset($langcode)) {
$langcode = $GLOBALS['language_content']->language;
}
// Populate $comment->content with a render() array.
comment_build_content($comment, $node, $view_mode, $langcode);
$build = $comment->content;
... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-21edcc60b5 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21search%21search.module/function/search_index_split/7.x | Implement `search_index_split($text)` in PHP for Drupal 7. Required behavior: Simplifies and splits a string into tokens for indexing. | File: modules/search/search.module | function search_index_split($text) {
$last = &drupal_static(__FUNCTION__);
$lastsplit = &drupal_static(__FUNCTION__ . ':lastsplit');
if ($last == $text) {
return $lastsplit;
}
// Process words
$text = search_simplify($text);
$words = explode(' ', $text);
// Save last keyword result
$last = $text... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-21fb4e93c3 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21common.inc/function/archiver_get_info/7.x | In Drupal 7, write the function `archiver_get_info()` (file includes/common.inc) so that it does the following: Retrieves a list of all available archivers. | File: includes/common.inc | function archiver_get_info() {
$archiver_info = &drupal_static(__FUNCTION__, array());
if (empty($archiver_info)) {
$cache = cache_get('archiver_info');
if ($cache === FALSE) {
// Rebuild the cache and save it.
$archiver_info = module_invoke_all('archiver_info');
drupal_alter('archiver_in... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-220d16d6a5 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21menu%21menu.admin.inc/function/menu_edit_item/7.x | In Drupal 7, write the function `menu_edit_item($form, &$form_state, $type, $item, $menu)` (file modules/menu/menu.admin.inc) so that it does the following: Menu callback; Build the menu link editing form. | File: modules/menu/menu.admin.inc | function menu_edit_item($form, &$form_state, $type, $item, $menu) {
if ($type == 'add' || empty($item)) {
// This is an add form, initialize the menu link.
$item = array('link_title' => '', 'mlid' => 0, 'plid' => 0, 'menu_name' => $menu['menu_name'], 'weight' => 0, 'link_path' => '', 'options' => array(), 'mo... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-221372dfd5 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21update%21update.fetch.inc/function/update_manual_status/7.x | Implement `update_manual_status()` in PHP for Drupal 7. Required behavior: Page callback: Checks for updates and displays the update status report. | Manually checks the update status without the use of cron.
File: modules/update/update.fetch.inc | function update_manual_status() {
_update_refresh();
$batch = array(
'operations' => array(
array('update_fetch_data_batch', array()),
),
'finished' => 'update_fetch_data_finished',
'title' => t('Checking available update data'),
'progress_message' => t('Trying to check available update da... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-2215969b43 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21locale%21locale.module/function/locale_form_node_type_form_alter/7.x | I need the code for `locale_form_node_type_form_alter(&$form, &$form_state)` in Drupal 7 (modules/locale/locale.module). It must do this: Implements hook_form_FORM_ID_alter(). | File: modules/locale/locale.module | function locale_form_node_type_form_alter(&$form, &$form_state) {
if (isset($form['type'])) {
$form['workflow']['language_content_type'] = array(
'#type' => 'radios',
'#title' => t('Multilingual support'),
'#default_value' => variable_get('language_content_type_' . $form['#node_type']->type, 0),... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-221735feca | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21file%21file.field.inc/function/file_field_delete_revision/7.x | Implement `file_field_delete_revision($entity_type, $entity, $field, $instance, $langcode, &$items)` in PHP for Drupal 7. Required behavior: Implements hook_field_delete_revision(). | File: modules/file/file.field.inc | function file_field_delete_revision($entity_type, $entity, $field, $instance, $langcode, &$items) {
list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);
foreach ($items as $delta => $item) {
// Decrement the file usage count by 1 and delete the file if possible.
if (file_field_delete_file($... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-2221257087 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21unicode.inc/function/drupal_ucfirst/7.x | I need the code for `drupal_ucfirst($text)` in Drupal 7 (includes/unicode.inc). It must do this: Capitalizes the first letter of a UTF-8 string. | Parameters:
- $text: The string to convert.
Returns: The string with the first letter as uppercase.
File: includes/unicode.inc | function drupal_ucfirst($text) {
// Note: no mbstring equivalent!
return drupal_strtoupper(drupal_substr($text, 0, 1)) . drupal_substr($text, 1);
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-222cca40ed | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21field%21field.attach.inc/function/field_attach_create_bundle/7.x | I need the code for `field_attach_create_bundle($entity_type, $bundle)` in Drupal 7 (modules/field/field.attach.inc). It must do this: Notify field.module that a new bundle was created. | The default SQL-based storage doesn't need to do anything about it, but others might.
Parameters:
- $entity_type: The entity type to which the bundle is bound.
- $bundle: The name of the newly created bundle.
File: modules/field/field.attach.inc | function field_attach_create_bundle($entity_type, $bundle) {
// Clear the cache.
field_cache_clear();
// Let other modules act on creating the bundle.
module_invoke_all('field_attach_create_bundle', $entity_type, $bundle);
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-2232eadc63 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21node%21node.pages.inc/function/node_revision_delete_confirm/7.x | I need the code for `node_revision_delete_confirm($form, $form_state, $node_revision)` in Drupal 7 (modules/node/node.pages.inc). It must do this: Form constructor for the revision deletion confirmation form. | This form prevents against CSRF attacks.
Parameters:
- $node_revision: The node revision ID.
Returns: An array as expected by drupal_render().
File: modules/node/node.pages.inc | function node_revision_delete_confirm($form, $form_state, $node_revision) {
$form['#node_revision'] = $node_revision;
return confirm_form($form, t('Are you sure you want to delete the revision from %revision-date?', array('%revision-date' => format_date($node_revision->revision_timestamp))), 'node/' . $node_revisio... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-226de1df7a | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21locale%21locale.admin.inc/function/locale_languages_configure_form_submit/7.x | I need the code for `locale_languages_configure_form_submit($form, &$form_state)` in Drupal 7 (modules/locale/locale.admin.inc). It must do this: Submit handler for language negotiation settings. | File: modules/locale/locale.admin.inc | function locale_languages_configure_form_submit($form, &$form_state) {
$configurable_types = $form['#language_types'];
foreach ($configurable_types as $type) {
$negotiation = array();
$enabled_providers = $form_state['values'][$type]['enabled'];
$enabled_providers[LANGUAGE_NEGOTIATION_DEFAULT] = TRUE;
... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-2276f35af4 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_enable/7.x | I need the code for `theme_enable($theme_list)` in Drupal 7 (includes/theme.inc). It must do this: Enables a given list of themes. | Parameters:
- $theme_list: An array of theme names.
File: includes/theme.inc | function theme_enable($theme_list) {
drupal_clear_css_cache();
foreach ($theme_list as $key) {
db_update('system')
->fields(array('status' => 1))
->condition('type', 'theme')
->condition('name', $key)
->execute();
}
list_themes(TRUE);
menu_rebuild();
drupal_theme_rebuild();
... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-22c29ebc8f | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21openid%21openid.inc/function/_openid_url_normalize/7.x | I need the code for `_openid_url_normalize($url)` in Drupal 7 (modules/openid/openid.inc). It must do this: OpenID normalization method: normalize URL identifiers. | File: modules/openid/openid.inc | function _openid_url_normalize($url) {
$normalized_url = $url;
if (stristr($url, '://') === FALSE) {
$normalized_url = 'http://' . $url;
}
// Strip the fragment and fragment delimiter if present.
$normalized_url = strtok($normalized_url, '#');
if (substr_count($normalized_url, '/') < 3) {
$normal... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-22ceed1488 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21comment%21comment.module/function/comment_form_node_form_alter/7.x | I need the code for `comment_form_node_form_alter(&$form, $form_state)` in Drupal 7 (modules/comment/comment.module). It must do this: Implements hook_form_BASE_FORM_ID_alter(). | File: modules/comment/comment.module | function comment_form_node_form_alter(&$form, $form_state) {
$node = $form['#node'];
$form['comment_settings'] = array(
'#type' => 'fieldset',
'#access' => user_access('administer comments'),
'#title' => t('Comment settings'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#group' => 'additi... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-22ea88cd24 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21system.admin.inc/function/system_sort_themes/7.x | I need the code for `system_sort_themes($a, $b)` in Drupal 7 (modules/system/system.admin.inc). It must do this: Sorts themes by their names, with the default theme listed first. | Callback for uasort() within system_themes_page().
File: modules/system/system.admin.inc | function system_sort_themes($a, $b) {
if ($a->is_default) {
return -1;
}
if ($b->is_default) {
return 1;
}
return strcasecmp($a->info['name'], $b->info['name']);
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-22ffbbb8c7 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21file%21file.field.inc/function/file_field_widget_settings_form/7.x | In Drupal 7, write the function `file_field_widget_settings_form($field, $instance)` (file modules/file/file.field.inc) so that it does the following: Implements hook_field_widget_settings_form(). | File: modules/file/file.field.inc | function file_field_widget_settings_form($field, $instance) {
$widget = $instance['widget'];
$settings = $widget['settings'];
$form['progress_indicator'] = array(
'#type' => 'radios',
'#title' => t('Progress indicator'),
'#options' => array(
'throbber' => t('Throbber'),
'bar' => t('Bar wi... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-2312df52bb | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21system.api.php/function/hook_entity_insert/7.x | Give me the example code for `hook_entity_insert($entity, $type)` in Drupal 7. Hook description: Act on entities when inserted. | Parameters:
- $entity: The entity object.
- $type: The type of entity being inserted (i.e. node, user, comment).
File: modules/system/system.api.php | function hook_entity_insert($entity, $type) {
// Insert the new entity into a fictional table of all entities.
$info = entity_get_info($type);
list($id) = entity_extract_ids($type, $entity);
db_insert('example_entity')
->fields(array(
'type' => $type,
'id' => $id,
'created' => REQUEST_TIME... | [
"code-task",
"hook-definition"
] | 2026-09-30T00:00:00 |
api-drupal7-233c02d38b | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21common.inc/function/entity_form_submit_build_entity/7.x | Implement `entity_form_submit_build_entity($entity_type, $entity, $form, &$form_state)` in PHP for Drupal 7. Required behavior: Copies submitted values to entity properties for simple entity forms. | During the submission handling of an entity form's "Save", "Preview", and possibly other buttons, the form state's entity needs to be updated with the submitted form values. Each entity form implements its own builder function for doing this, appropriate for the particular entity and form, whereas modules may specify a... | function entity_form_submit_build_entity($entity_type, $entity, $form, &$form_state) {
$info = entity_get_info($entity_type);
list(, , $bundle) = entity_extract_ids($entity_type, $entity);
// Copy top-level form values that are not for fields to entity properties,
// without changing existing entity properties... | [
"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.