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-7e2c872d07 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21taxonomy%21taxonomy.module/function/taxonomy_term_delete/7.x | Implement `taxonomy_term_delete($tid)` in PHP for Drupal 7. Required behavior: Delete a term. | Parameters:
- $tid: The term ID.
Returns: Status constant indicating deletion.
File: modules/taxonomy/taxonomy.module | function taxonomy_term_delete($tid) {
$transaction = db_transaction();
try {
$tids = array($tid);
while ($tids) {
$children_tids = $orphans = array();
foreach ($tids as $tid) {
// See if any of the term's children are about to be become orphans:
if ($children = taxonomy_get_child... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-7e4d6c2782 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21openid%21openid.inc/function/_openid_create_message/7.x | Implement `_openid_create_message($data)` in PHP for Drupal 7. Required behavior: Create a serialized message packet as per spec: $key:$value\n . | File: modules/openid/openid.inc | function _openid_create_message($data) {
$serialized = '';
foreach ($data as $key => $value) {
if ((strpos($key, ':') !== FALSE) || (strpos($key, "\n") !== FALSE) || (strpos($value, "\n") !== FALSE)) {
return NULL;
}
$serialized .= "$key:$value\n";
}
return $serialized;
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-7e5224d323 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21module.inc/function/system_list_reset/7.x | Implement `system_list_reset()` in PHP for Drupal 7. Required behavior: Resets all system_list() caches. | File: includes/module.inc | function system_list_reset() {
drupal_static_reset('system_list');
drupal_static_reset('system_rebuild_module_data');
drupal_static_reset('list_themes');
cache_clear_all('bootstrap_modules', 'cache_bootstrap');
cache_clear_all('system_list', 'cache_bootstrap');
// Clean up the bootstrap file scan cache.
... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-7e527c6de2 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21field_ui%21field_ui.admin.inc/function/field_ui_display_overview_row_region/7.x | In Drupal 7, write the function `field_ui_display_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 display' screen belongs. | This function is used as a #region_callback in field_ui_field_overview_form(), and is called during field_ui_table_pre_render().
File: modules/field_ui/field_ui.admin.inc | function field_ui_display_overview_row_region($row) {
switch ($row['#row_type']) {
case 'field':
case 'extra_field':
return ($row['format']['type']['#value'] == 'hidden' ? 'hidden' : 'visible');
}
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-7e6bb45ca7 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21node%21node.module/function/node_access/7.x | Implement `node_access($op, $node, $account = NULL)` in PHP for Drupal 7. Required behavior: Determines whether the current user may perform the operation on the node. | Parameters:
- $op: The operation to be performed on the node. Possible values are: - "view" - "update" - "delete" - "create"
- $node: The node object on which the operation is to be performed, or node type (e.g. 'forum') for "create" operation.
- $account: Optional, a user object representing the user for whom the oper... | function node_access($op, $node, $account = NULL) {
$rights = &drupal_static(__FUNCTION__, array());
if (!$node || !in_array($op, array('view', 'update', 'delete', 'create'), TRUE)) {
// If there was no node to check against, or the $op was not one of the
// supported ones, we return access denied.
ret... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-7e9b4c7a1a | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21simpletest%21simpletest.api.php/function/hook_simpletest_alter/7.x | Give me the example code for `hook_simpletest_alter(&$groups)` in Drupal 7. Hook description: Alter the list of tests. | Parameters:
- $groups: A two dimension array, the first key is the test group (as defined in getInfo) the second is the name of the class and the value is the return value of the getInfo method.
File: modules/simpletest/simpletest.api.php | function hook_simpletest_alter(&$groups) {
// An alternative session handler module would not want to run the original
// Session HTTPS handling test because it checks the sessions table in the
// database.
unset($groups['Session']['testHttpsSession']);
} | [
"code-task",
"hook-definition"
] | 2026-09-30T00:00:00 |
api-drupal7-7ea56b8377 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21filter%21filter.module/function/filter_process_format/7.x | I need the code for `filter_process_format($element)` in Drupal 7 (modules/filter/filter.module). It must do this: Expands an element into a base element with text format selector attached. | The form element will be expanded into two separate form elements, one
holding the original element, and the other holding the text format selector:
- value: Holds the original element, having its #type changed to the value of
#base_type or 'textarea' by default.
- format: Holds the text format fieldset and the text ... | function filter_process_format($element) {
global $user;
// Ensure that children appear as subkeys of this element.
$element['#tree'] = TRUE;
$blacklist = array(
// Make form_builder() regenerate child properties.
'#parents',
'#id',
'#name',
// Do not copy this #process function to prevent ... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-7ebaeb3933 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21node%21node.module/function/node_requirements/7.x | I need the code for `node_requirements($phase)` in Drupal 7 (modules/node/node.module). It must do this: Implements hook_requirements(). | File: modules/node/node.module | function node_requirements($phase) {
$requirements = array();
if ($phase === 'runtime') {
// Only show rebuild button if there are either 0, or 2 or more, rows
// in the {node_access} table, or if there are modules that
// implement hook_node_grants().
$grant_count = db_query('SELECT COUNT(*) FROM {... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-7ec6b15bd8 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21taxonomy%21taxonomy.api.php/function/hook_taxonomy_vocabulary_insert/7.x | Give me the example code for `hook_taxonomy_vocabulary_insert($vocabulary)` in Drupal 7. Hook description: Act on taxonomy vocabularies when inserted. | Modules implementing this hook can act on the vocabulary object when saved to the database.
Parameters:
- $vocabulary: A taxonomy vocabulary object.
File: modules/taxonomy/taxonomy.api.php | function hook_taxonomy_vocabulary_insert($vocabulary) {
if ($vocabulary->machine_name == 'my_vocabulary') {
$vocabulary->weight = 100;
}
} | [
"code-task",
"hook-definition"
] | 2026-09-30T00:00:00 |
api-drupal7-7ed2352b5c | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21file.inc/function/file_save/7.x | Implement `file_save(stdClass $file)` in PHP for Drupal 7. Required behavior: Saves a file object to the database. | If the $file->fid is not set a new record will be added.
Parameters:
- $file: A file object returned by file_load().
Returns: The updated file object.
File: includes/file.inc | function file_save(stdClass $file) {
$file->timestamp = REQUEST_TIME;
$file->filesize = filesize($file->uri);
// Load the stored entity, if any.
if (!empty($file->fid) && !isset($file->original)) {
$file->original = entity_load_unchanged('file', $file->fid);
}
module_invoke_all('file_presave', $file);... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-7ee7292d39 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21form.inc/function/batch_set/7.x | I need the code for `batch_set($batch_definition)` in Drupal 7 (includes/form.inc). It must do this: Adds a new batch. | Batch operations are added as new batch sets. Batch sets are used to spread processing (primarily, but not exclusively, forms processing) over several page requests. This helps to ensure that the processing is not interrupted due to PHP timeouts, while users are still able to receive feedback on the progress of the ong... | function batch_set($batch_definition) {
if ($batch_definition) {
$batch =& batch_get();
// Initialize the batch if needed.
if (empty($batch)) {
$batch = array(
'sets' => array(),
'has_form_submits' => FALSE,
);
}
// Base and default properties for the batch set.
/... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-7ef59d2709 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21image%21image.module/function/image_help/7.x | I need the code for `image_help($path, $arg)` in Drupal 7 (modules/image/image.module). It must do this: Implements hook_help(). | File: modules/image/image.module | function image_help($path, $arg) {
switch ($path) {
case 'admin/help#image':
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
$output .= '<p>' . t('The Image module allows you to manipulate images on your website. It exposes a setting for using the <em>Image toolkit</em>, allows you to co... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-7efef3d716 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21filter%21filter.module/function/filter_format_save/7.x | I need the code for `filter_format_save($format)` in Drupal 7 (modules/filter/filter.module). It must do this: Saves a text format object to the database. | Parameters:
- $format: A format object having the properties: - format: A machine-readable name representing the ID of the text format to save. If this corresponds to an existing text format, that format will be updated; otherwise, a new format will be created. - name: The title of the text format. - status: (optional)... | function filter_format_save($format) {
$format->name = trim($format->name);
$format->cache = _filter_format_is_cacheable($format);
if (!isset($format->status)) {
$format->status = 1;
}
if (!isset($format->weight)) {
$format->weight = 0;
}
// Insert or update the text format.
$return = db_merge(... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-7f02a1a434 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21user%21user.module/function/user_is_blocked/7.x | I need the code for `user_is_blocked($name)` in Drupal 7 (modules/user/user.module). It must do this: Checks for usernames blocked by user administration. | Parameters:
- $name: A string containing a name of the user.
Returns (Object): with property 'name' (the user name), if the user is blocked; FALSE if the user is not blocked.
File: modules/user/user.module | function user_is_blocked($name) {
return db_select('users')
->fields('users', array('name'))
->condition('name', db_like($name), 'LIKE')
->condition('status', 0)
->execute()->fetchObject();
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-7f0d5ac452 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21node%21content_types.inc/function/node_type_reset/7.x | In Drupal 7, write the function `node_type_reset($type)` (file modules/node/content_types.inc) so that it does the following: Resets relevant fields of a module-defined node type to their default values. | Parameters:
- $type: The node type to reset. The node type is passed back by reference with its resetted values. If there is no module-defined info for this node type, then nothing happens.
File: modules/node/content_types.inc | function node_type_reset($type) {
$info_array = module_invoke_all('node_info');
if (isset($info_array[$type->orig_type])) {
$info_array[$type->orig_type]['type'] = $type->orig_type;
$info = node_type_set_defaults($info_array[$type->orig_type]);
foreach ($info as $field => $value) {
$type->$field ... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-7f2b3c2c66 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21file.inc/function/file_scan_directory/7.x | I need the code for `file_scan_directory($dir, $mask, $options = array(), $depth = 0)` in Drupal 7 (includes/file.inc). It must do this: Finds all files that match a given mask in a given directory. | Directories and files beginning with a period are excluded; this prevents hidden files and directories (such as SVN working directories) from being scanned.
Parameters:
- $dir: The base directory or URI to scan, without trailing slash.
- $mask: The preg_match() regular expression of the files to find.
- $options: An a... | function file_scan_directory($dir, $mask, $options = array(), $depth = 0) {
// Default nomask option.
$nomask = '/(\.\.?|CVS)$/';
// Overrides the $nomask variable accordingly if $options['nomask'] is set.
//
// Allow directories specified in settings.php to be ignored. You can use this
// to not check for... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-7f618aa573 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/themes%21bartik%21template.php/function/bartik_preprocess_html/7.x | I need the code for `bartik_preprocess_html(&$variables)` in Drupal 7 (themes/bartik/template.php). It must do this: Add body classes if certain regions have content. | File: themes/bartik/template.php | function bartik_preprocess_html(&$variables) {
if (!empty($variables['page']['featured'])) {
$variables['classes_array'][] = 'featured';
}
if (!empty($variables['page']['triptych_first'])
|| !empty($variables['page']['triptych_middle'])
|| !empty($variables['page']['triptych_last'])) {
$variables... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-7f6a574449 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21filter%21filter.api.php/function/callback_filter_settings/7.x | In Drupal 7, show an example implementation for `callback_filter_settings($form, &$form_state, $filter, $format, $defaults, $filters)` (modules/filter/filter.api.php): Provide a settings form for filter settings. | Callback for hook_filter_info().
This callback function is used to provide a settings form for filter settings, for filters that need settings on a per-text-format basis. This function should return the form elements for the settings; the filter module will take care of saving the settings in the database.
If the fil... | function callback_filter_settings($form, &$form_state, $filter, $format, $defaults, $filters) {
$filter->settings += $defaults;
$elements = array();
$elements['nofollow'] = array(
'#type' => 'checkbox',
'#title' => t('Add rel="nofollow" to all links'),
'#default_value' => $filter->settings['nofollow'... | [
"code-task",
"hook-definition"
] | 2026-09-30T00:00:00 |
api-drupal7-7f6b920a62 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21contextual%21contextual.module/function/contextual_pre_render_links/7.x | Implement `contextual_pre_render_links($element)` in PHP for Drupal 7. Required behavior: Build a renderable array for contextual links. | Parameters:
- $element: A renderable array containing a #contextual_links property, which is a keyed array. Each key is the name of the implementing module, and each value is an array that forms the function arguments for menu_contextual_links(). For example: @code array('#contextual_links' => array( 'block' => array('... | function contextual_pre_render_links($element) {
// Retrieve contextual menu links.
$items = array();
foreach ($element['#contextual_links'] as $module => $args) {
$items += menu_contextual_links($module, $args[0], $args[1]);
}
// Transform contextual links into parameters suitable for theme_link().
$l... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-7f70a16467 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21common.inc/function/drupal_get_feeds/7.x | In Drupal 7, write the function `drupal_get_feeds($delimiter = "\n")` (file includes/common.inc) so that it does the following: Gets the feed URLs for the current page. | Parameters:
- $delimiter: A delimiter to split feeds by.
File: includes/common.inc | function drupal_get_feeds($delimiter = "\n") {
$feeds = drupal_add_feed();
return implode($delimiter, $feeds);
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-7f7b6f80e9 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21menu.inc/function/menu_tail_load/7.x | In Drupal 7, write the function `menu_tail_load($arg, &$map, $index)` (file includes/menu.inc) so that it does the following: Loads the path as one string relative to the current index. | To use this load function, you must specify the load arguments in the router item as:
File: includes/menu.inc | function menu_tail_load($arg, &$map, $index) {
$arg = implode('/', array_slice($map, $index));
$map = array_slice($map, 0, $index);
return $arg;
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-7f9f812ba6 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21field_ui%21field_ui.module/function/field_ui_element_info/7.x | Implement `field_ui_element_info()` in PHP for Drupal 7. Required behavior: Implements hook_element_info(). | File: modules/field_ui/field_ui.module | function field_ui_element_info() {
return array(
'field_ui_table' => array(
'#theme' => 'field_ui_table',
'#pre_render' => array('field_ui_table_pre_render'),
'#regions' => array('' => array()),
),
);
} | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-7fbaee04b0 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21rdf%21rdf.module/function/rdf_mapping_load/7.x | I need the code for `rdf_mapping_load($type, $bundle = RDF_DEFAULT_BUNDLE)` in Drupal 7 (modules/rdf/rdf.module). It must do this: Returns the mapping for attributes of a given entity type/bundle pair. | Parameters:
- $type: An entity type.
- $bundle: (optional) A bundle name.
Returns: The mapping corresponding to the requested entity type/bundle pair or an empty array.
File: modules/rdf/rdf.module | function rdf_mapping_load($type, $bundle = RDF_DEFAULT_BUNDLE) {
// Retrieves the bundle-specific mapping from the entity info.
$entity_info = entity_get_info($type);
if (!empty($entity_info['bundles'][$bundle]['rdf_mapping'])) {
return $entity_info['bundles'][$bundle]['rdf_mapping'];
}
// If there is no ... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-7fcfc59e4c | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21bootstrap.inc/function/drupal_register_shutdown_function/7.x | Implement `&drupal_register_shutdown_function($callback = NULL)` in PHP for Drupal 7. Required behavior: Registers a function for execution on shutdown. | Wrapper for register_shutdown_function() that catches thrown exceptions to avoid "Exception thrown without a stack frame in Unknown".
Parameters:
- $callback: The shutdown function to register.
Returns (Array): of shutdown functions to be executed.
File: includes/bootstrap.inc | function &drupal_register_shutdown_function($callback = NULL) {
// We cannot use drupal_static() here because the static cache is reset during
// batch processing, which breaks batch handling.
static $callbacks = array();
if (isset($callback)) {
// Only register the internal shutdown function once.
if ... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-7fd5729725 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21taxonomy%21taxonomy.module/function/taxonomy_get_children/7.x | In Drupal 7, write the function `taxonomy_get_children($tid, $vid = 0)` (file modules/taxonomy/taxonomy.module) so that it does the following: Finds all children of a term ID. | Parameters:
- $tid: A taxonomy term ID.
- $vid: An optional vocabulary ID to restrict the child search.
Returns: An array of term objects that are the children of the term $tid, or an empty array when no children exist.
File: modules/taxonomy/taxonomy.module | function taxonomy_get_children($tid, $vid = 0) {
$children = &drupal_static(__FUNCTION__, array());
if ($tid && !isset($children[$tid])) {
$query = db_select('taxonomy_term_data', 't');
$query->join('taxonomy_term_hierarchy', 'h', 'h.tid = t.tid');
$query->addField('t', 'tid');
$query->condition('h... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-7fd860e749 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21xmlrpcs.inc/function/xmlrpc_server_method_signature/7.x | Implement `xmlrpc_server_method_signature($methodname)` in PHP for Drupal 7. Required behavior: Returns one method signature for a function. | This is the function mapped to the XML-RPC method system.methodSignature.
A method signature is an array of the input and output types of a method. For instance, the method signature of this function is array('array', 'string'), because it takes an array and returns a string.
Parameters:
- $methodname (string): Name ... | function xmlrpc_server_method_signature($methodname) {
$xmlrpc_server = xmlrpc_server_get();
if (!isset($xmlrpc_server->callbacks[$methodname])) {
return xmlrpc_error(-32601, t('Server error. Requested method @methodname not specified.', array("@methodname" => $methodname)));
}
if (!is_array($xmlrpc_server-... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-7fd8ef9c1a | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21translation%21translation.pages.inc/function/translation_node_overview/7.x | In Drupal 7, write the function `translation_node_overview($node)` (file modules/translation/translation.pages.inc) so that it does the following: Page callback: Displays a list of a node's translations. | Parameters:
- $node: A node object.
Returns: A render array for a page containing a list of content.
File: modules/translation/translation.pages.inc | function translation_node_overview($node) {
include_once DRUPAL_ROOT . '/includes/language.inc';
if ($node->tnid) {
// Already part of a set, grab that set.
$tnid = $node->tnid;
$translations = translation_node_get_translations($node->tnid);
}
else {
// We have no translation source nid, this c... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-8000a7bc47 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21batch.inc/function/_batch_progress_page/7.x | I need the code for `_batch_progress_page()` in Drupal 7 (includes/batch.inc). It must do this: Outputs a batch processing page. | File: includes/batch.inc | function _batch_progress_page() {
$batch = &batch_get();
$current_set = _batch_current_set();
drupal_set_title($current_set['title'], PASS_THROUGH);
$new_op = 'do_nojs';
if (!isset($batch['running'])) {
// This is the first page so we return some output immediately.
$percentage = 0;
$mess... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-80785f596b | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21filter%21filter.module/function/_filter_disable_format_access/7.x | Implement `_filter_disable_format_access($format)` in PHP for Drupal 7. Required behavior: Access callback: Checks access for disabling text formats. | Parameters:
- $format: A text format object.
Returns: TRUE if the text format can be disabled by the current user, FALSE otherwise.
File: modules/filter/filter.module | function _filter_disable_format_access($format) {
// The fallback format can never be disabled.
return user_access('administer filters') && ($format->format != filter_fallback_format());
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-809c98aeb5 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21system.module/function/system_form_user_register_form_alter/7.x | In Drupal 7, write the function `system_form_user_register_form_alter(&$form, &$form_state)` (file modules/system/system.module) so that it does the following: Implements hook_form_FORM_ID_alter(). | File: modules/system/system.module | function system_form_user_register_form_alter(&$form, &$form_state) {
if (variable_get('configurable_timezones', 1)) {
if (variable_get('user_default_timezone', DRUPAL_USER_TIMEZONE_DEFAULT) == DRUPAL_USER_TIMEZONE_SELECT) {
system_user_timezone($form, $form_state);
}
else {
$form['account']['... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-80a45a19d3 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21overlay%21overlay.module/function/overlay_help/7.x | Implement `overlay_help($path, $arg)` in PHP for Drupal 7. Required behavior: Implements hook_help(). | File: modules/overlay/overlay.module | function overlay_help($path, $arg) {
switch ($path) {
case 'admin/help#overlay':
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
$output .= '<p>' . t('The Overlay module makes the administration pages on your site display in a JavaScript overlay of the page you were viewing when you clic... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-80b9ccb537 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21shortcut%21shortcut.admin.inc/function/shortcut_set_customize_submit/7.x | I need the code for `shortcut_set_customize_submit($form, &$form_state)` in Drupal 7 (modules/shortcut/shortcut.admin.inc). It must do this: Submit handler for shortcut_set_customize(). | File: modules/shortcut/shortcut.admin.inc | function shortcut_set_customize_submit($form, &$form_state) {
foreach ($form_state['values']['shortcuts'] as $group => $links) {
foreach ($links as $mlid => $data) {
$link = menu_link_load($mlid);
$link['hidden'] = $data['status'] == 'enabled' ? 0 : 1;
$link['weight'] = $data['weight'];
me... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-80c19da077 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21contact%21contact.pages.inc/function/contact_site_form_validate/7.x | In Drupal 7, write the function `contact_site_form_validate($form, &$form_state)` (file modules/contact/contact.pages.inc) so that it does the following: Form validation handler for contact_site_form(). | File: modules/contact/contact.pages.inc | function contact_site_form_validate($form, &$form_state) {
if (!$form_state['values']['cid']) {
form_set_error('cid', t('You must select a valid category.'));
}
if (!valid_email_address($form_state['values']['mail'])) {
form_set_error('mail', t('You must enter a valid e-mail address.'));
}
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-80c4d2ecf9 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21theme.inc/function/_theme_render_template_debug/7.x | Implement `_theme_render_template_debug($template_function, $template_file, $variables, $extension)` in PHP for Drupal 7. Required behavior: Renders a template for any engine. | Includes the possibility to get debug output by setting the theme_debug variable to TRUE.
Parameters:
- $template_function (string): The function to call for rendering the template.
- $template_file (string): The filename of the template to render.
- $variables (array): A keyed array of variables that will appear in t... | function _theme_render_template_debug($template_function, $template_file, $variables, $extension) {
$output = array(
'debug_prefix' => '',
'debug_info' => '',
'rendered_markup' => call_user_func($template_function, $template_file, $variables),
'debug_suffix' => '',
);
$output['debug_prefix'] .= "\... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-80d649c67d | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21aggregator%21aggregator.pages.inc/function/aggregator_page_categories/7.x | In Drupal 7, write the function `aggregator_page_categories()` (file modules/aggregator/aggregator.pages.inc) so that it does the following: Page callback: Displays all the categories used by the Aggregator module. | Returns (string): An HTML formatted string.
File: modules/aggregator/aggregator.pages.inc | function aggregator_page_categories() {
$result = db_query('SELECT c.cid, c.title, c.description FROM {aggregator_category} c LEFT JOIN {aggregator_category_item} ci ON c.cid = ci.cid LEFT JOIN {aggregator_item} i ON ci.iid = i.iid GROUP BY c.cid, c.title, c.description');
$output = '';
foreach ($result as $cate... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-80e703806d | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21image%21image.module/function/image_style_create_derivative/7.x | Implement `image_style_create_derivative($style, $source, $destination)` in PHP for Drupal 7. Required behavior: Creates a new image derivative based on an image style. | Generates an image derivative by creating the destination folder (if it does not already exist), applying all image effects defined in $style['effects'], and saving a cached version of the resulting image.
Parameters:
- $style: An image style array.
- $source: Path of the source file.
- $destination: Path or URI of th... | function image_style_create_derivative($style, $source, $destination) {
// If the source file doesn't exist, return FALSE without creating folders.
if (!$image = image_load($source)) {
return FALSE;
}
// Get the folder for the final location of this style.
$directory = drupal_dirname($destination);
//... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-80ef740f9a | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21path%21path.module/function/path_taxonomy_term_insert/7.x | Implement `path_taxonomy_term_insert($term)` in PHP for Drupal 7. Required behavior: Implements hook_taxonomy_term_insert(). | File: modules/path/path.module | function path_taxonomy_term_insert($term) {
if (isset($term->path)) {
$path = $term->path;
$path['alias'] = trim($path['alias']);
// Only save a non-empty alias.
if (!empty($path['alias'])) {
// Ensure fields for programmatic executions.
$path['source'] = 'taxonomy/term/' . $term->tid;
... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-80fa966cb8 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21taxonomy%21taxonomy.module/function/taxonomy_allowed_values/7.x | I need the code for `taxonomy_allowed_values($field)` in Drupal 7 (modules/taxonomy/taxonomy.module). It must do this: Returns the set of valid terms for a taxonomy field. | Parameters:
- $field: The field definition.
Returns: The array of valid terms for this field, keyed by term id.
File: modules/taxonomy/taxonomy.module | function taxonomy_allowed_values($field) {
$options = array();
foreach ($field['settings']['allowed_values'] as $tree) {
if ($vocabulary = taxonomy_vocabulary_machine_name_load($tree['vocabulary'])) {
if ($terms = taxonomy_get_tree($vocabulary->vid, $tree['parent'])) {
foreach ($terms as $term) {
... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-8102d4bdc2 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21translation%21translation.module/function/translation_language_switch_links_alter/7.x | I need the code for `translation_language_switch_links_alter(array &$links, $type, $path)` in Drupal 7 (modules/translation/translation.module). It must do this: Implements hook_language_switch_links_alter(). | Replaces links with pointers to translated versions of the content.
File: modules/translation/translation.module | function translation_language_switch_links_alter(array &$links, $type, $path) {
$language_type = variable_get('translation_language_type', LANGUAGE_TYPE_INTERFACE);
if ($type == $language_type && preg_match("!^node/(\d+)(/.+|)!", $path, $matches)) {
$node = node_load((int) $matches[1]);
if (empty($node->t... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-810de4dbfd | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21system.admin.inc/function/system_logging_settings/7.x | Implement `system_logging_settings()` in PHP for Drupal 7. Required behavior: Form builder; Configure error reporting settings. | File: modules/system/system.admin.inc | function system_logging_settings() {
$form['error_level'] = array(
'#type' => 'radios',
'#title' => t('Error messages to display'),
'#default_value' => variable_get('error_level', ERROR_REPORTING_DISPLAY_ALL),
'#options' => array(
ERROR_REPORTING_HIDE => t('None'),
ERROR_REPORTING_DISPLAY_... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-8114fc93bb | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21common.inc/function/drupal_clean_css_identifier/7.x | In Drupal 7, write the function `drupal_clean_css_identifier($identifier, $filter = array(' ' => '-', '_' => '-', '/' => '-', '[' => '-', ']' => ''))` (file includes/common.inc) so that it does the following: Prepares a string for use as a CSS identifier (element, class, or ID name). | http://www.w3.org/TR/CSS21/syndata.html#characters shows the syntax for valid CSS identifiers (including element names, classes, and IDs in selectors.)
Parameters:
- $identifier: The identifier to clean.
- $filter: An array of string replacements to use on the identifier.
Returns: The cleaned identifier.
File: inclu... | function drupal_clean_css_identifier($identifier, $filter = array(' ' => '-', '_' => '-', '/' => '-', '[' => '-', ']' => '')) {
// Use the advanced drupal_static() pattern, since this is called very often.
static $drupal_static_fast;
if (!isset($drupal_static_fast)) {
$drupal_static_fast['allow_css_double_und... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-8157a6ae92 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21locale%21locale.admin.inc/function/_locale_languages_configure_form_language_table/7.x | I need the code for `_locale_languages_configure_form_language_table(&$form, $type)` in Drupal 7 (modules/locale/locale.admin.inc). It must do this: Helper function to build a language provider table. | File: modules/locale/locale.admin.inc | function _locale_languages_configure_form_language_table(&$form, $type) {
$info = $form['#language_types_info'][$type];
$table_form = array(
'#title' => t('@type language detection', array('@type' => $info['name'])),
'#tree' => TRUE,
'#description' => $info['description'],
'#language_providers' => ... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-815831f45e | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21system.admin.inc/function/theme_admin_page/7.x | I need the code for `theme_admin_page($variables)` in Drupal 7 (modules/system/system.admin.inc). It must do this: Returns HTML for an administrative page. | Parameters:
- $variables: An associative array containing: - blocks: An array of blocks to display. Each array should include a 'title', a 'description', a formatted 'content' and a 'position' which will control which container it will be in. This is usually 'left' or 'right'.
File: modules/system/system.admin.inc | function theme_admin_page($variables) {
$blocks = $variables['blocks'];
$stripe = 0;
$container = array();
foreach ($blocks as $block) {
if ($block_output = theme('admin_block', array('block' => $block))) {
if (empty($block['position'])) {
// perform automatic striping.
$block['posit... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-81674cabb8 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21forum%21forum.module/function/template_preprocess_forum_topic_list/7.x | In Drupal 7, write the function `template_preprocess_forum_topic_list(&$variables)` (file modules/forum/forum.module) so that it does the following: Preprocesses variables for forum-topic-list.tpl.php. | Parameters:
- $variables: An array containing the following elements: - tid: Taxonomy term ID of the current forum. - topics: An array of all the topics in the current forum. - forum_per_page: The maximum number of topics to display per page.
File: modules/forum/forum.module | function template_preprocess_forum_topic_list(&$variables) {
global $forum_topic_list_header;
// Create the tablesorting header.
$ts = tablesort_init($forum_topic_list_header);
$header = '';
foreach ($forum_topic_list_header as $cell) {
$cell = tablesort_header($cell, $forum_topic_list_header, $ts);
... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-816d07faf7 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21user%21user.admin.inc/function/user_admin/7.x | Implement `user_admin($callback_arg = '')` in PHP for Drupal 7. Required behavior: Page callback: Generates the appropriate user administration form. | This function generates the user registration, multiple user cancellation, or filtered user list admin form, depending on the argument and the POST form values.
Parameters:
- $callback_arg (string): (optional) Indicates which form to build. Defaults to '', which will trigger the user filter form. If the POST value 'op... | function user_admin($callback_arg = '') {
$op = isset($_POST['op']) ? $_POST['op'] : $callback_arg;
switch ($op) {
case t('Create new account'):
case 'create':
$build['user_register'] = drupal_get_form('user_register_form');
break;
default:
if (!empty($_POST['accounts']) && isset($_PO... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-816e9ec1ca | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21node%21node.pages.inc/function/node_form_validate/7.x | Implement `node_form_validate($form, &$form_state)` in PHP for Drupal 7. Required behavior: Form validation handler for node_form(). | File: modules/node/node.pages.inc | function node_form_validate($form, &$form_state) {
// $form_state['node'] contains the actual entity being edited, but we must
// not update it with form values that have not yet been validated, so we
// create a pseudo-entity to use during validation.
$node = (object) $form_state['values'];
node_validate($no... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-8190d0413d | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21unicode.inc/function/drupal_truncate_bytes/7.x | Implement `drupal_truncate_bytes($string, $len)` in PHP for Drupal 7. Required behavior: Truncates a UTF-8-encoded string safely to a number of bytes. | If the end position is in the middle of a UTF-8 sequence, it scans backwards until the beginning of the byte sequence.
Use this function whenever you want to chop off a string at an unsure location. On the other hand, if you're sure that you're splitting on a character boundary (e.g. after using strpos() or similar), ... | function drupal_truncate_bytes($string, $len) {
if (strlen($string) <= $len) {
return $string;
}
if ((ord($string[$len]) < 0x80) || (ord($string[$len]) >= 0xC0)) {
return substr($string, 0, $len);
}
// Scan backwards to beginning of the byte sequence.
while (--$len >= 0 && ord($string[$len]) >= 0x80... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-81b3980c24 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21shortcut%21shortcut.module/function/shortcut_set_unassign_user/7.x | In Drupal 7, write the function `shortcut_set_unassign_user($account)` (file modules/shortcut/shortcut.module) so that it does the following: Unassigns a user from any shortcut set they may have been assigned to. | The user will go back to using whatever default set applies.
Parameters:
- $account: A user account that will be removed from the shortcut set assignment.
Returns: TRUE if the user was previously assigned to a shortcut set and has been successfully removed from it. FALSE if the user was already not assigned to any se... | function shortcut_set_unassign_user($account) {
$deleted = db_delete('shortcut_set_users')
->condition('uid', $account->uid)
->execute();
return (bool) $deleted;
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-81d5dd7d87 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21search%21search.module/function/search_comment_unpublish/7.x | Implement `search_comment_unpublish($comment)` in PHP for Drupal 7. Required behavior: Implements hook_comment_unpublish(). | File: modules/search/search.module | function search_comment_unpublish($comment) {
// Reindex the node when comments are unpublished.
search_touch_node($comment->nid);
} | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-81d7712208 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21comment%21comment.module/function/comment_node_load/7.x | In Drupal 7, write the function `comment_node_load($nodes, $types)` (file modules/comment/comment.module) so that it does the following: Implements hook_node_load(). | File: modules/comment/comment.module | function comment_node_load($nodes, $types) {
$comments_enabled = array();
// Check if comments are enabled for each node. If comments are disabled,
// assign values without hitting the database.
foreach ($nodes as $node) {
// Store whether comments are enabled for this node.
if ($node->comment != COMME... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-81d910e2ef | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21field%21modules%21list%21list.install/function/list_update_7002/7.x | In Drupal 7, write the function `list_update_7002()` (file modules/field/modules/list/list.install) so that it does the following: Re-apply list_update_7001() for deleted fields. | File: modules/field/modules/list/list.install | function list_update_7002() {
// See http://drupal.org/node/1022924: list_update_7001() intitally
// overlooked deleted fields, which then caused fatal errors when the fields
// were being purged.
// list_update_7001() has the required checks to ensure it is reentrant, so
// it can simply be executed once mor... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-81d9dc65c5 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21book%21book.pages.inc/function/book_outline_form/7.x | I need the code for `book_outline_form($form, &$form_state, $node)` in Drupal 7 (modules/book/book.pages.inc). It must do this: Form constructor for the book outline form. | Allows handling of all book outline operations via the outline tab.
Parameters:
- $node: The book node for which to show the outline.
File: modules/book/book.pages.inc | function book_outline_form($form, &$form_state, $node) {
if (!isset($node->book)) {
// The node is not part of any book yet - set default options.
$node->book = _book_link_defaults($node->nid);
}
else {
$node->book['original_bid'] = $node->book['bid'];
}
// Find the depth limit for the parent sel... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-81e77aa628 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21image%21image.admin.inc/function/image_style_form/7.x | Implement `image_style_form($form, &$form_state, $style)` in PHP for Drupal 7. Required behavior: Form builder; Edit an image style name and effects order. | Parameters:
- $form_state: An associative array containing the current state of the form.
- $style: An image style array.
File: modules/image/image.admin.inc | function image_style_form($form, &$form_state, $style) {
$title = t('Edit %name style', array('%name' => $style['label']));
drupal_set_title($title, PASS_THROUGH);
// Adjust this form for styles that must be overridden to edit.
$editable = (bool) ($style['storage'] & IMAGE_STORAGE_EDITABLE);
if (!$editable ... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-81f952a387 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21update.inc/function/update_check_incompatibility/7.x | I need the code for `update_check_incompatibility($name, $type = 'module')` in Drupal 7 (includes/update.inc). It must do this: Tests the compatibility of a module or theme. | File: includes/update.inc | function update_check_incompatibility($name, $type = 'module') {
static $themes, $modules;
// Store values of expensive functions for future use.
if (empty($themes) || empty($modules)) {
// We need to do a full rebuild here to make sure the database reflects any
// code changes that were made in the file... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-82102d933b | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21path.inc/function/path_load/7.x | I need the code for `path_load($conditions)` in Drupal 7 (includes/path.inc). It must do this: Fetches a specific URL alias from the database. | Parameters:
- $conditions: A string representing the source, a number representing the pid, or an array of query conditions.
Returns: FALSE if no alias was found or an associative array containing the following keys: - source: The internal system path. - alias: The URL alias. - pid: Unique path alias identifier. - lan... | function path_load($conditions) {
if (is_numeric($conditions)) {
$conditions = array('pid' => $conditions);
}
elseif (is_string($conditions)) {
$conditions = array('source' => $conditions);
}
elseif (!is_array($conditions)) {
return FALSE;
}
$select = db_select('url_alias');
foreach ($condit... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-82106bd8c3 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21user%21user.module/function/_user_categories/7.x | Implement `_user_categories()` in PHP for Drupal 7. Required behavior: Retrieve a list of all user setting/information categories and sort them by weight. | File: modules/user/user.module | function _user_categories() {
$categories = module_invoke_all('user_categories');
usort($categories, '_user_sort');
return $categories;
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-8224e602d6 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21user%21user.module/function/user_role_edit_access/7.x | I need the code for `user_role_edit_access($role)` in Drupal 7 (modules/user/user.module). It must do this: Menu access callback for user role editing. | File: modules/user/user.module | function user_role_edit_access($role) {
// Prevent the system-defined roles from being altered or removed.
if ($role->rid == DRUPAL_ANONYMOUS_RID || $role->rid == DRUPAL_AUTHENTICATED_RID) {
return FALSE;
}
return user_access('administer permissions');
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-822cb3d9b9 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21form.inc/function/form_process_checkbox/7.x | In Drupal 7, write the function `form_process_checkbox($element, $form_state)` (file includes/form.inc) so that it does the following: Sets the #checked property of a checkbox element. | File: includes/form.inc | function form_process_checkbox($element, $form_state) {
$value = $element['#value'];
$return_value = $element['#return_value'];
// On form submission, the #value of an available and enabled checked
// checkbox is #return_value, and the #value of an available and enabled
// unchecked checkbox is integer 0. On ... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-82369a8ef3 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21node%21node.module/function/node_add_body_field/7.x | I need the code for `node_add_body_field($type, $label = 'Body')` in Drupal 7 (modules/node/node.module). It must do this: Adds default body field to a node type. | Parameters:
- $type: A node type object.
- $label: The label for the body instance.
Returns: Body field instance.
File: modules/node/node.module | function node_add_body_field($type, $label = 'Body') {
// Add or remove the body field, as needed.
$field = field_info_field('body');
$instance = field_info_instance('node', 'body', $type->type);
if (empty($field)) {
$field = array(
'field_name' => 'body',
'type' => 'text_with_summary',
'... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-8236a2d7ef | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21comment%21comment.admin.inc/function/comment_admin/7.x | I need the code for `comment_admin($type = 'new')` in Drupal 7 (modules/comment/comment.admin.inc). It must do this: Menu callback; present an administrative comment listing. | File: modules/comment/comment.admin.inc | function comment_admin($type = 'new') {
$edit = $_POST;
if (isset($edit['operation']) && ($edit['operation'] == 'delete') && isset($edit['comments']) && $edit['comments']) {
return drupal_get_form('comment_multiple_delete_confirm');
}
else {
return drupal_get_form('comment_admin_overview', $type);
}
... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-8240e64f95 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21field_ui%21field_ui.admin.inc/function/field_ui_widget_type_form_submit/7.x | In Drupal 7, write the function `field_ui_widget_type_form_submit($form, &$form_state)` (file modules/field_ui/field_ui.admin.inc) so that it does the following: Form submission handler for field_ui_widget_type_form(). | File: modules/field_ui/field_ui.admin.inc | function field_ui_widget_type_form_submit($form, &$form_state) {
$form_values = $form_state['values'];
$bundle = $form['#bundle'];
$entity_type = $form['#entity_type'];
$field_name = $form['#field_name'];
// Retrieve the stored instance settings to merge with the incoming values.
$instance = field_read_ins... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-82453c8760 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21file%21file.module/function/theme_file_link/7.x | Implement `theme_file_link($variables)` in PHP for Drupal 7. Required behavior: Returns HTML for a link to a file. | Parameters:
- $variables: An associative array containing: - file: A file object to which the link will be created. - 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.
File: modules/file/file.module | function theme_file_link($variables) {
$file = $variables['file'];
$icon_directory = $variables['icon_directory'];
$url = file_create_url($file->uri);
// Human-readable names, for use as text-alternatives to icons.
$mime_name = array(
'application/msword' => t('Microsoft Office document icon'),
'app... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-8249920212 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21image%21image.module/function/image_effect_definitions/7.x | I need the code for `image_effect_definitions()` in Drupal 7 (modules/image/image.module). It must do this: Returns a set of image effects. | These image effects are exposed by modules implementing hook_image_effect_info().
Returns: An array of image effects to be used when transforming images.
File: modules/image/image.module | function image_effect_definitions() {
global $language;
// hook_image_effect_info() includes translated strings, so each language is
// cached separately.
$langcode = $language->language;
$effects = &drupal_static(__FUNCTION__);
if (!isset($effects)) {
if ($cache = cache_get("image_effects:$langcode"... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-82589bce6c | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21taxonomy%21taxonomy.module/function/taxonomy_field_widget_form/7.x | I need the code for `taxonomy_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element)` in Drupal 7 (modules/taxonomy/taxonomy.module). It must do this: Implements hook_field_widget_form(). | File: modules/taxonomy/taxonomy.module | function taxonomy_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {
$tags = array();
foreach ($items as $item) {
$tags[$item['tid']] = isset($item['taxonomy_term']) ? $item['taxonomy_term'] : taxonomy_term_load($item['tid']);
}
$element += array(
'#type' ... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-8259acdd96 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21menu%21menu.admin.inc/function/menu_item_delete_page/7.x | In Drupal 7, write the function `menu_item_delete_page($item)` (file modules/menu/menu.admin.inc) so that it does the following: Menu callback; Check access and present a confirm form for deleting a menu link. | File: modules/menu/menu.admin.inc | function menu_item_delete_page($item) {
// Links defined via hook_menu may not be deleted. Updated items are an
// exception, as they can be broken.
if ($item['module'] == 'system' && !$item['updated']) {
return MENU_ACCESS_DENIED;
}
return drupal_get_form('menu_item_delete_form', $item);
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-82824f952e | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21block%21block.module/function/block_user_role_delete/7.x | I need the code for `block_user_role_delete($role)` in Drupal 7 (modules/block/block.module). It must do this: Implements hook_user_role_delete(). | Removes deleted role from blocks that use it.
File: modules/block/block.module | function block_user_role_delete($role) {
db_delete('block_role')
->condition('rid', $role->rid)
->execute();
} | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-8290df033e | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21menu%21menu.module/function/menu_enable/7.x | Implement `menu_enable()` in PHP for Drupal 7. Required behavior: Implements hook_enable(). | Add a link for each custom menu.
File: modules/menu/menu.module | function menu_enable() {
menu_rebuild();
$base_link = db_query("SELECT mlid AS plid, menu_name FROM {menu_links} WHERE link_path = 'admin/structure/menu' AND module = 'system'")->fetchAssoc();
$base_link['router_path'] = 'admin/structure/menu/manage/%';
$base_link['module'] = 'menu';
$result = db_query("SELEC... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-82cbd968b4 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21system.admin.inc/function/system_actions_manage_form_submit/7.x | I need the code for `system_actions_manage_form_submit($form, &$form_state)` in Drupal 7 (modules/system/system.admin.inc). It must do this: Process system_actions_manage form submissions. | File: modules/system/system.admin.inc | function system_actions_manage_form_submit($form, &$form_state) {
if ($form_state['values']['action']) {
$form_state['redirect'] = 'admin/config/system/actions/configure/' . $form_state['values']['action'];
}
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-82e75fab2a | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21node%21node.module/function/node_type_delete/7.x | Implement `node_type_delete($type)` in PHP for Drupal 7. Required behavior: Deletes a node type from the database. | Parameters:
- $type: The machine-readable name of the node type to be deleted.
File: modules/node/node.module | function node_type_delete($type) {
$info = node_type_get_type($type);
db_delete('node_type')
->condition('type', $type)
->execute();
field_attach_delete_bundle('node', $type);
module_invoke_all('node_type_delete', $info);
// Clear the node type cache.
node_type_cache_reset();
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-8309a6fbcd | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21form.inc/function/theme_checkbox/7.x | Implement `theme_checkbox($variables)` in PHP for Drupal 7. Required behavior: Returns HTML for a checkbox form element. | Parameters:
- $variables: An associative array containing: - element: An associative array containing the properties of the element. Properties used: #id, #name, #attributes, #checked, #return_value.
File: includes/form.inc | function theme_checkbox($variables) {
$element = $variables['element'];
$element['#attributes']['type'] = 'checkbox';
element_set_attributes($element, array('id', 'name', '#return_value' => 'value'));
// Unchecked checkbox has #value of integer 0.
if (!empty($element['#checked'])) {
$element['#attributes... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-831282f1d2 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21common.inc/function/_fix_gpc_magic/7.x | Implement `_fix_gpc_magic(&$item)` in PHP for Drupal 7. Required behavior: Strips slashes from a string or array of strings. | Callback for array_walk() within fix_gpx_magic().
Parameters:
- $item: An individual string or array of strings from superglobals.
File: includes/common.inc | function _fix_gpc_magic(&$item) {
if (is_array($item)) {
array_walk($item, '_fix_gpc_magic');
}
else {
$item = stripslashes($item);
}
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-8329be9d1f | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21session.inc/function/drupal_session_started/7.x | In Drupal 7, write the function `drupal_session_started($set = NULL)` (file includes/session.inc) so that it does the following: Returns whether a session has been started. | File: includes/session.inc | function drupal_session_started($set = NULL) {
static $session_started = FALSE;
if (isset($set)) {
$session_started = $set;
}
return $session_started && session_id();
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-832ce6a977 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21book%21book.module/function/book_node_view/7.x | I need the code for `book_node_view($node, $view_mode)` in Drupal 7 (modules/book/book.module). It must do this: Implements hook_node_view(). | File: modules/book/book.module | function book_node_view($node, $view_mode) {
if ($view_mode == 'full') {
if (!empty($node->book['bid']) && empty($node->in_preview)) {
$node->content['book_navigation'] = array(
'#markup' => theme('book_navigation', array('book_link' => $node->book)),
'#weight' => 100,
);
}
}
... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-833735533e | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21node%21node.api.php/function/hook_validate/7.x | Give me the example code for `hook_validate($node, $form, &$form_state)` in Drupal 7. Hook description: Perform node validation before a node is created or updated. | This is a node-type-specific hook, which is invoked only for the node type being affected. See
Parameters:
- $node: The node being validated.
- $form: The form being used to edit the node.
- $form_state: The form state array.
File: modules/node/node.api.php | function hook_validate($node, $form, &$form_state) {
if (isset($node->end) && isset($node->start)) {
if ($node->start > $node->end) {
form_set_error('time', t('An event may not end before it starts.'));
}
}
} | [
"code-task",
"hook-definition"
] | 2026-09-30T00:00:00 |
api-drupal7-8337ebf070 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21image%21image.module/function/image_style_url/7.x | I need the code for `image_style_url($style_name, $path)` in Drupal 7 (modules/image/image.module). It must do this: Returns the URL for an image derivative given a style and image path. | Parameters:
- $style_name: The name of the style to be used with this image.
- $path: The path to the image.
Returns: The absolute URL where a style image can be downloaded, suitable for use in an <img> tag. Requesting the URL will cause the image to be created.
File: modules/image/image.module | function image_style_url($style_name, $path) {
$uri = image_style_path($style_name, $path);
$uri = file_uri_normalize_dot_segments($uri);
// The passed-in $path variable can be either a relative path or a full URI.
$original_uri = file_uri_scheme($path) ? file_stream_wrapper_uri_normalize($path) : file_build_u... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-835c01c5d1 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21menu%21menu.module/function/menu_get_menus/7.x | In Drupal 7, write the function `menu_get_menus($all = TRUE)` (file modules/menu/menu.module) so that it does the following: Return an associative array of the custom menus names. | Parameters:
- $all: If FALSE return only user-added menus, or if TRUE also include the menus defined by the system.
Returns: An array with the machine-readable names as the keys, and human-readable titles as the values.
File: modules/menu/menu.module | function menu_get_menus($all = TRUE) {
if ($custom_menus = menu_load_all()) {
if (!$all) {
$custom_menus = array_diff_key($custom_menus, menu_list_system_menus());
}
foreach ($custom_menus as $menu_name => $menu) {
$custom_menus[$menu_name] = t($menu['title']);
}
asort($custom_menus);
... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-83a55de994 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21book%21book.pages.inc/function/book_export/7.x | In Drupal 7, write the function `book_export($type, $nid)` (file modules/book/book.pages.inc) so that it does the following: Menu callback; Generates representations of a book page and its children. | The function delegates the generation of output to helper functions. The function name is derived by prepending 'book_export_' to the given output type. So, e.g., a type of 'html' results in a call to the function book_export_html().
Parameters:
- $type: A string encoding the type of output requested. The following ty... | function book_export($type, $nid) {
// Check that the node exists and that the current user has access to it.
$node = node_load($nid);
if (!$node) {
return MENU_NOT_FOUND;
}
if (!node_access('view', $node)) {
return MENU_ACCESS_DENIED;
}
$type = drupal_strtolower($type);
$export_function = 'bo... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-83b68c5f05 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21node%21node.module/function/node_form_block_custom_block_delete_submit/7.x | In Drupal 7, write the function `node_form_block_custom_block_delete_submit($form, &$form_state)` (file modules/node/node.module) so that it does the following: Form submission handler for node_form_block_custom_block_delete_alter(). | File: modules/node/node.module | function node_form_block_custom_block_delete_submit($form, &$form_state) {
db_delete('block_node_type')
->condition('module', 'block')
->condition('delta', $form_state['values']['bid'])
->execute();
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-83b7dc574a | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21user%21user.api.php/function/hook_user_logout/7.x | In Drupal 7, show an example implementation for `hook_user_logout($account)` (modules/user/user.api.php): The user just logged out. | Note that when this hook is invoked, the changes have not yet been written to the database, because a database transaction is still in progress. The transaction is not finalized until the save operation is entirely completed and user_save() goes out of scope. You should not rely on data in the database at this time as ... | function hook_user_logout($account) {
db_insert('logouts')
->fields(array(
'uid' => $account->uid,
'time' => time(),
))
->execute();
} | [
"code-task",
"hook-definition"
] | 2026-09-30T00:00:00 |
api-drupal7-83f806f34f | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21locale.inc/function/_locale_import_message/7.x | I need the code for `_locale_import_message($message, $file, $lineno = NULL)` in Drupal 7 (includes/locale.inc). It must do this: Sets an error message occurred during locale file parsing. | Parameters:
- $message: The message to be translated.
- $file: Drupal file object corresponding to the PO file to import.
- $lineno: An optional line number argument.
File: includes/locale.inc | function _locale_import_message($message, $file, $lineno = NULL) {
$vars = array('%filename' => $file->filename);
if (isset($lineno)) {
$vars['%line'] = $lineno;
}
$t = get_t();
drupal_set_message($t($message, $vars), 'error');
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-8418b14615 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21image%21image.module/function/image_effect_definition_load/7.x | I need the code for `image_effect_definition_load($effect, $style_name = NULL)` in Drupal 7 (modules/image/image.module). It must do this: Loads the definition for an image effect. | The effect definition is a set of core properties for an image effect, not containing any user-settings. The definition defines various functions to call when configuring or executing an image effect. This loader is mostly for internal use within image.module. Use image_effect_load() or image_style_load() to get image ... | function image_effect_definition_load($effect, $style_name = NULL) {
$definitions = image_effect_definitions();
// If a style is specified, do not allow loading of default style
// effects.
if (isset($style_name)) {
$style = image_style_load($style_name, NULL);
if ($style['storage'] == IMAGE_STORAGE_DE... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-84290fb825 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21menu%21menu.admin.inc/function/menu_edit_item_submit/7.x | Implement `menu_edit_item_submit($form, &$form_state)` in PHP for Drupal 7. Required behavior: Process menu and menu item add/edit form submissions. | File: modules/menu/menu.admin.inc | function menu_edit_item_submit($form, &$form_state) {
$item = &$form_state['values'];
// The value of "hidden" is the opposite of the value
// supplied by the "enabled" checkbox.
$item['hidden'] = (int) !$item['enabled'];
unset($item['enabled']);
$item['options']['attributes']['title'] = $item['descriptio... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-8435fe9568 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21comment%21comment.module/function/comment_forms/7.x | I need the code for `comment_forms()` in Drupal 7 (modules/comment/comment.module). It must do this: Implements hook_forms(). | File: modules/comment/comment.module | function comment_forms() {
$forms = array();
foreach (node_type_get_types() as $type) {
$forms["comment_node_{$type->type}_form"]['callback'] = 'comment_form';
}
return $forms;
} | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-8444275962 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21system.install/function/system_update_7032/7.x | Implement `system_update_7032()` in PHP for Drupal 7. Required behavior: Alter field hostname to identifier in the {flood} table. | File: modules/system/system.install | function system_update_7032() {
db_drop_index('flood', 'allow');
db_change_field('flood', 'hostname', 'identifier', array('type' => 'varchar', 'length' => 128, 'not null' => TRUE, 'default' => ''));
db_add_index('flood', 'allow', array('event', 'identifier', 'timestamp'));
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-8446d9f04a | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21menu.inc/function/theme_menu_local_task/7.x | In Drupal 7, write the function `theme_menu_local_task($variables)` (file includes/menu.inc) so that it does the following: Returns HTML for a single local task link. | Parameters:
- $variables: An associative array containing: - element: A render element containing: - #link: A menu link array with 'title', 'href', and 'localized_options' keys. - #active: A boolean indicating whether the local task is active.
File: includes/menu.inc | function theme_menu_local_task($variables) {
$link = $variables['element']['#link'];
$link_text = $link['title'];
if (!empty($variables['element']['#active'])) {
// Add text to indicate active tab for non-visual users.
$active = '<span class="element-invisible">' . t('(active tab)') . '</span>';
// ... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-845ac75517 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21node%21node.module/function/node_access_grants/7.x | I need the code for `node_access_grants($op, $account = NULL)` in Drupal 7 (modules/node/node.module). It must do this: Fetches an array of permission IDs granted to the given user ID. | The implementation here provides only the universal "all" grant. A node access module should implement hook_node_grants() to provide a grant list for the user.
After the default grants have been loaded, we allow modules to alter the grants array by reference. This hook allows for complex business logic to be applied w... | function node_access_grants($op, $account = NULL) {
if (!isset($account)) {
$account = $GLOBALS['user'];
}
// Fetch node access grants from other modules.
$grants = module_invoke_all('node_grants', $account, $op);
// Allow modules to alter the assigned grants.
drupal_alter('node_grants', $grants, $acc... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-84796628d6 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21common.inc/function/drupal_load_stylesheet/7.x | I need the code for `drupal_load_stylesheet($file, $optimize = NULL, $reset_basepath = TRUE)` in Drupal 7 (includes/common.inc). It must do this: Loads the stylesheet and resolves all @import commands. | Loads a stylesheet and replaces @import commands with the contents of the imported file. Use this instead of file_get_contents when processing stylesheets.
The returned contents are compressed removing white space and comments only when CSS aggregation is enabled. This optimization will not apply for color.module enab... | function drupal_load_stylesheet($file, $optimize = NULL, $reset_basepath = TRUE) {
// These statics are not cache variables, so we don't use drupal_static().
static $_optimize, $basepath;
if ($reset_basepath) {
$basepath = '';
}
// Store the value of $optimize for preg_replace_callback with nested
// @i... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-8494c9b810 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21comment%21comment.module/function/comment_publish_action/7.x | In Drupal 7, write the function `comment_publish_action($comment, $context = array())` (file modules/comment/comment.module) so that it does the following: Publishes a comment. | Parameters:
- $comment: An optional comment object.
- $context (array): Array with components: - 'cid': Comment ID. Required if $comment is not given.
File: modules/comment/comment.module | function comment_publish_action($comment, $context = array()) {
if (isset($comment->subject)) {
$subject = $comment->subject;
$comment->status = COMMENT_PUBLISHED;
}
else {
$cid = $context['cid'];
$subject = db_query('SELECT subject FROM {comment} WHERE cid = :cid', array(':cid' => $cid))->fetchFi... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-84b2c66271 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21common.inc/function/drupal_render_cache_set/7.x | I need the code for `drupal_render_cache_set(&$markup, $elements)` in Drupal 7 (includes/common.inc). It must do this: Caches the rendered output of a renderable element. | This is called by drupal_render() if the #cache property is set on an element.
Parameters:
- $markup: The rendered output string of $elements.
- $elements: A renderable array.
File: includes/common.inc | function drupal_render_cache_set(&$markup, $elements) {
// Create the cache ID for the element.
if (!in_array($_SERVER['REQUEST_METHOD'], array('GET', 'HEAD')) || !$cid = drupal_render_cid_create($elements)) {
return FALSE;
}
// Cache implementations are allowed to modify the markup, to support
// replac... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-84bd583d86 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21toolbar%21toolbar.module/function/toolbar_menu_navigation_links/7.x | Implement `toolbar_menu_navigation_links($tree)` in PHP for Drupal 7. Required behavior: Generates a links array from a menu tree array. | Based on menu_navigation_links(). Adds path based IDs and icon placeholders to the links.
Returns: An array of links as defined above.
File: modules/toolbar/toolbar.module | function toolbar_menu_navigation_links($tree) {
$links = array();
foreach ($tree as $item) {
if (!$item['link']['hidden'] && $item['link']['access']) {
// Make sure we have a path specific ID in place, so we can attach icons
// and behaviors to the items.
$id = str_replace(array('/', '<', '>')... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-84be194539 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21field%21modules%21text%21text.module/function/text_field_validate/7.x | I need the code for `text_field_validate($entity_type, $entity, $field, $instance, $langcode, $items, &$errors)` in Drupal 7 (modules/field/modules/text/text.module). It must do this: Implements hook_field_validate(). | Possible error codes:
- 'text_value_max_length': The value exceeds the maximum length.
- 'text_summary_max_length': The summary exceeds the maximum length.
File: modules/field/modules/text/text.module | function text_field_validate($entity_type, $entity, $field, $instance, $langcode, $items, &$errors) {
foreach ($items as $delta => $item) {
// @todo Length is counted separately for summary and value, so the maximum
// length can be exceeded very easily.
foreach (array('value', 'summary') as $column) {
... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-84c11e68f6 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21taxonomy%21taxonomy.admin.inc/function/taxonomy_form_vocabulary_submit/7.x | Implement `taxonomy_form_vocabulary_submit($form, &$form_state)` in PHP for Drupal 7. Required behavior: Form submission handler for taxonomy_form_vocabulary(). | File: modules/taxonomy/taxonomy.admin.inc | function taxonomy_form_vocabulary_submit($form, &$form_state) {
if ($form_state['triggering_element']['#value'] == t('Delete')) {
// Rebuild the form to confirm vocabulary deletion.
$form_state['rebuild'] = TRUE;
$form_state['confirm_delete'] = TRUE;
return;
}
$vocabulary = $form_state['vocabular... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-84f0088844 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21bootstrap.inc/function/timer_start/7.x | In Drupal 7, write the function `timer_start($name)` (file includes/bootstrap.inc) so that it does the following: Starts the timer with the specified name. | If you start and stop the same timer multiple times, the measured intervals will be accumulated.
Parameters:
- $name: The name of the timer.
File: includes/bootstrap.inc | function timer_start($name) {
global $timers;
$timers[$name]['start'] = microtime(TRUE);
$timers[$name]['count'] = isset($timers[$name]['count']) ? ++$timers[$name]['count'] : 1;
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-8517cd092b | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21update%21update.install/function/_update_requirement_check/7.x | In Drupal 7, write the function `_update_requirement_check($project, $type)` (file modules/update/update.install) so that it does the following: Fills in the requirements array. | This is shared for both core and contrib to generate the right elements in the array for hook_requirements().
Parameters:
- $project: Array of information about the project we're testing as returned by update_calculate_project_data().
- $type: What kind of project this is ('core' or 'contrib').
Returns: An array to b... | function _update_requirement_check($project, $type) {
$requirement = array();
if ($type == 'core') {
$requirement['title'] = t('Drupal core update status');
}
else {
$requirement['title'] = t('Module and theme update status');
}
$status = $project['status'];
if ($status != UPDATE_CURRENT) {
$r... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-854de921e4 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21user%21user.admin.inc/function/user_admin_account_validate/7.x | I need the code for `user_admin_account_validate($form, &$form_state)` in Drupal 7 (modules/user/user.admin.inc). It must do this: Form validation handler for the user_admin_account() form. | File: modules/user/user.admin.inc | function user_admin_account_validate($form, &$form_state) {
$form_state['values']['accounts'] = array_filter($form_state['values']['accounts']);
if (count($form_state['values']['accounts']) == 0) {
form_set_error('', t('No users selected.'));
}
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-855b0c243e | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21system.api.php/function/hook_tokens_alter/7.x | Give me the example code for `hook_tokens_alter(array &$replacements, array $context)` in Drupal 7. Hook description: Alter replacement values for placeholder tokens. | Parameters:
- $replacements: An associative array of replacements returned by hook_tokens().
- $context: The context in which hook_tokens() was called. An associative array with the following keys, which have the same meaning as the corresponding parameters of hook_tokens(): - 'type' - 'tokens' - 'data' - 'options'
Fi... | function hook_tokens_alter(array &$replacements, array $context) {
$options = $context['options'];
if (isset($options['language'])) {
$url_options['language'] = $options['language'];
$language_code = $options['language']->language;
}
else {
$language_code = NULL;
}
$sanitize = !empty($options['... | [
"code-task",
"hook-definition"
] | 2026-09-30T00:00:00 |
api-drupal7-85aa40f576 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21search%21search.admin.inc/function/search_admin_settings_validate/7.x | Implement `search_admin_settings_validate($form, &$form_state)` in PHP for Drupal 7. Required behavior: Form validation handler for search_admin_settings(). | File: modules/search/search.admin.inc | function search_admin_settings_validate($form, &$form_state) {
// Check whether we selected a valid default.
if ($form_state['triggering_element']['#value'] != t('Reset to defaults')) {
$new_modules = array_filter($form_state['values']['search_active_modules']);
$default = $form_state['values']['search_defa... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-85b4d4e621 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21image%21image.effects.inc/function/image_image_effect_info/7.x | Implement `image_image_effect_info()` in PHP for Drupal 7. Required behavior: Implements hook_image_effect_info(). | File: modules/image/image.effects.inc | function image_image_effect_info() {
$effects = array(
'image_resize' => array(
'label' => t('Resize'),
'help' => t('Resizing will make images an exact set of dimensions. This may cause images to be stretched or shrunk disproportionately.'),
'effect callback' => 'image_resize_effect',
'dim... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-85b7d99e77 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21image%21image.admin.inc/function/image_crop_form/7.x | In Drupal 7, write the function `image_crop_form($data)` (file modules/image/image.admin.inc) so that it does the following: Form structure for the image crop form. | Note that this is not a complete form, it only contains the portion of the form for configuring the crop options. Therefore it does not not need to include metadata about the effect, nor a submit button.
Parameters:
- $data: The current configuration for this crop effect.
File: modules/image/image.admin.inc | function image_crop_form($data) {
$data += array(
'width' => '',
'height' => '',
'anchor' => 'center-center',
);
$form = image_resize_form($data);
$form['anchor'] = array(
'#type' => 'radios',
'#title' => t('Anchor'),
'#options' => array(
'left-top' => t('Top left'),
'c... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-85bb2f25a8 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21common.inc/function/drupal_flush_all_caches/7.x | I need the code for `drupal_flush_all_caches()` in Drupal 7 (includes/common.inc). It must do this: Flushes all cached data on the site. | Empties cache tables, rebuilds the menu cache and theme registries, and invokes a hook so that other modules' cache data can be cleared as well.
File: includes/common.inc | function drupal_flush_all_caches() {
// Change query-strings on css/js files to enforce reload for all users.
_drupal_flush_css_js();
registry_rebuild();
drupal_clear_css_cache();
drupal_clear_js_cache();
// Rebuild the theme data. Note that the module data is rebuilt above, as
// part of registry_rebui... | [
"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.