Download as pdf or txt
Download as pdf or txt
You are on page 1of 38

Drupal 7 API Components

Table of Contents
Drupal 7 API Components................................................................................................................1
Preface.............................................................................................................................................1
Module System (Hooks)...................................................................................................................1
Functions & methods...................................................................................................................2
Database Abstraction Layer.............................................................................................................9
SELECT.......................................................................................................................................9
INSERT, UPDATE and DELETE................................................................................................11
Transactions...............................................................................................................................11
Classes......................................................................................................................................12
Interfaces...................................................................................................................................14
Functions & methods.................................................................................................................14
Constants..................................................................................................................................14
Menu System.................................................................................................................................14
Functions & methods.................................................................................................................15
Constants..................................................................................................................................18
Groups.......................................................................................................................................19
Form Generation............................................................................................................................19
The $form_state keys are:.........................................................................................................20
Functions & methods.................................................................................................................21
File Management System...............................................................................................................24
Fields on the file object:.............................................................................................................24
Functions & methods.................................................................................................................24
Constants..................................................................................................................................26
Field API.........................................................................................................................................26
Classes......................................................................................................................................27
Functions & methods.................................................................................................................27
Constants..................................................................................................................................28
Search System...............................................................................................................................28
Functions & methods.................................................................................................................28
Node Access System.....................................................................................................................29
Functions & methods.................................................................................................................29
Theme System...............................................................................................................................30
See also.....................................................................................................................................31
Functions & methods.................................................................................................................31
Constants.......................................................................................................................................36
Global variables..............................................................................................................................37

Preface
The following technical document is compiled from the official Drupal API information published at
http://api.drupal.org/api/drupal/7
It is intended for use by developers aiming to master Drupal 7.

Module System (Hooks)


Allow modules to interact with the Drupal core.

Drupal's module system is based on the concept of "hooks". A hook is a PHP function that is
named foo_bar(), where "foo" is the name of the module (whose filename is thus foo.module) and
"bar" is the name of the hook. Each hook has a defined set of parameters and a specified result
type.

To extend Drupal, a module need simply implement a hook. When Drupal wishes to allow
intervention from modules, it determines which modules implement a hook and calls that hook in
all enabled modules that implement it.

The available hooks to implement are explained here in the Hooks section of the developer
documentation. The string "hook" is used as a placeholder for the module name in the hook
definitions. For example, if the module file is called example.module, then hook_help() as
implemented by that module would be defined as example_help().

The example functions included are not part of the Drupal core, they are just models that you can
modify. Only the hooks implemented within modules are executed when running Drupal.

See also the themeable group page.

Functions & methods


Name Description
hook_actions_delete Executes code after an action is deleted.
hook_action_info Declares information about actions.
hook_action_info_alter Alters the actions declared by another module.
hook_admin_paths Define administrative paths.
Redefine administrative paths defined by other
hook_admin_paths_alter
modules.
Implement this hook to create an alternative
hook_aggregator_fetch
fetcher for aggregator module.
Implement this hook to expose the title and a
hook_aggregator_fetch_info
short description of your fetcher.
Implement this hook to create an alternative
hook_aggregator_parse
parser for aggregator module.
Implement this hook to expose the title and a
hook_aggregator_parse_info
short description of your parser.
Implement this hook to create a processor for
hook_aggregator_process
aggregator module.
Implement this hook to expose the title and a
hook_aggregator_process_info
short description of your processor.
Implement this hook to remove stored data if a
hook_aggregator_remove feed is being deleted or a feed's items are being
removed.
Alter the commands that are sent to the user
hook_ajax_render_alter
through the AJAX framework.
hook_archiver_info Declare archivers to the system.
Alter archiver information declared by other
hook_archiver_info_alter
modules.
Alter batch information before a batch is
hook_batch_alter
processed.
hook_block_configure Define a configuration form for a block.
hook_block_info Define all blocks provided by the module.
Change block definition before saving to the
hook_block_info_alter
database.
hook_block_list_alter Act on blocks prior to rendering.
Save the configuration options
hook_block_save
fromhook_block_configure().
Name Description
hook_block_view Return a rendered or renderable view of a block.
hook_block_view_alter Perform alterations to the content of a block.
hook_block_view_MODULE_DELTA_alter Perform alterations to a specific block.
hook_boot Perform setup tasks. See also, hook_init.
hook_comment_delete The comment is being deleted by the moderator.
hook_comment_insert The comment is being inserted.
hook_comment_load Comments are being loaded from the database.
The comment passed validation and is about to
hook_comment_presave
be saved.
The comment is being published by the
hook_comment_publish
moderator.
The comment is being unpublished by the
hook_comment_unpublish
moderator.
hook_comment_update The comment is being updated.
The comment is being viewed. This hook can be
hook_comment_view used to add additional data to the comment
before theming.
The comment was built; the module may modify
hook_comment_view_alter
the structured content.
Alter a contextual links element before it is
hook_contextual_links_view_alter
rendered.
hook_countries_alter Alter the default country list.
hook_cron Perform periodic actions.
Declare queues holding items that need to be run
hook_cron_queue_info
periodically.
hook_cron_queue_info_alter Alter cron queue information before cron runs.
Alter CSS files before they are output on the
hook_css_alter
page.
Return the machine-readable name of the theme
hook_custom_theme
to use for the current page.
hook_dashboard_regions Adds regions to the dashboard.
hook_dashboard_regions_alter Alter dashboard regions provided by modules.
hook_date_formats Defines additional date formats.
Alters date types and formats declared by
hook_date_formats_alter
another module.
hook_date_format_types Defines additional date types.
hook_date_format_types_alter Modify existing date format types.
hook_delete Respond to node deletion.
Perform necessary actions before module is
hook_disable
disabled.
Change the page the user is sent to
hook_drupal_goto_alter
bydrupal_goto().
Allows modules to declare their own Forms API
hook_element_info
element types and specify their default values.
Alter the element type information returned from
hook_element_info_alter
modules.
Perform necessary actions after module is
hook_enable
enabled.
hook_entity_delete Act on entities when deleted.
Inform the base system and the Field API about
hook_entity_info
one or more entity types.
hook_entity_info_alter Alter the entity info.
hook_entity_insert Act on entities when inserted.
Name Description
hook_entity_load Act on entities when loaded.
Act on entities as they are being prepared for
hook_entity_prepare_view
view.
hook_entity_query_alter Alter or execute an EntityFieldQuery.
hook_entity_update Act on entities when updated.
hook_entity_view Act on entities being assembled before rendering.
hook_entity_view_alter Alter the results of ENTITY_view().
hook_exit Perform cleanup tasks.
Provide information on available file transfer
hook_filetransfer_backends
backends.
hook_file_copy Respond to a file that has been copied.
hook_file_delete Respond to a file being deleted.
Control access to private file downloads and
hook_file_download
specify HTTP headers.
hook_file_insert Respond to a file being added.
hook_file_load Load additional information into file objects.
Alter MIME type mappings used to determine
hook_file_mimetype_mapping_alter
MIME type from a file extension.
hook_file_move Respond to a file that has been moved.
hook_file_update Respond to a file being updated.
hook_file_url_alter Alter the URL to a file.
hook_file_validate Check that files meet a given criteria.
Perform actions when a text format has been
hook_filter_format_disable
disabled.
Perform actions when a new text format has been
hook_filter_format_insert
created.
Perform actions when a text format has been
hook_filter_format_update
updated.
hook_filter_info Define content filters.
hook_filter_info_alter Perform alterations on filter definitions.
hook_flush_caches Add a list of cache tables to be cleared.
hook_form Display a node editing form.
hook_forms Map form_ids to form builder functions.
hook_form_alter Perform alterations before a form is rendered.
Provide a form-specific alteration for shared
hook_form_BASE_FORM_ID_alter
forms.
Provide a form-specific alteration instead of the
hook_form_FORM_ID_alter
global hook_form_alter().
hook_help Provide online user help.
Defines one or more hooks that are exposed by a
hook_hook_info
module.
hook_hook_info_alter Alter information from hook_hook_info().
Alter XHTML HEAD tags before they are rendered
hook_html_head_alter
by drupal_get_html_head().
Provide module-based image styles for reuse
hook_image_default_styles
throughout Drupal.
Define information about image effects provided
hook_image_effect_info
by a module.
Alter the information provided
hook_image_effect_info_alter
inhook_image_effect_info().
Modify any image styles provided by other
hook_image_styles_alter
modules or the user.
hook_image_style_delete Respond to image style deletion.
Name Description
hook_image_style_flush Respond to image style flushing.
hook_image_style_save Respond to image style updating.
hook_image_toolkits Define image toolkits provided by this module.
hook_init Perform setup tasks. See also, hook_boot.
hook_insert Respond to creation of a new node.
hook_install Perform setup tasks when the module is installed.
Return an array of tasks to be performed by an
hook_install_tasks
installation profile.
hook_install_tasks_alter Alter the full list of installation tasks.
Perform necessary alterations to the JavaScript
hook_js_alter
before it is presented on the page.
Perform alterations on the language fallback
hook_language_fallback_candidates_alter
candidates.
Allows modules to act after language initialization
hook_language_init
has been performed.
Allow modules to define their own language
hook_language_negotiation_info
providers.
hook_language_negotiation_info_alter Perform alterations on language providers.
hook_language_switch_links_alter Perform alterations on language switcher links.
Allow modules to define their own language
hook_language_types_info
types.
hook_language_types_info_alter Perform alterations on language types.
Registers JavaScript/CSS libraries associated with
hook_library
a module.
hook_library_alter Alters the JavaScript/CSS library registry.
hook_load Act on nodes being loaded from the database.
Allows modules to define their own text groups
hook_locale
that can be translated.
Prepare a message based on parameters; called
hook_mail
from drupal_mail().
Alter an email message created with
hook_mail_alter
thedrupal_mail() function.
hook_menu Define menu items and page callbacks.
Alter the data being saved to the {menu_router}
hook_menu_alter
table after hook_menu is invoked.
Alter links in the active trail before it is rendered
hook_menu_breadcrumb_alter
as the breadcrumb.
hook_menu_contextual_links_alter Alter contextual links before they are rendered.
Informs modules that a custom menu was
hook_menu_delete
deleted.
Informs modules that a custom menu was
hook_menu_insert
created.
Alter the data being saved to the {menu_links}
hook_menu_link_alter
table by menu_link_save().
Inform modules that a menu link has been
hook_menu_link_delete
deleted.
Inform modules that a menu link has been
hook_menu_link_insert
created.
Inform modules that a menu link has been
hook_menu_link_update
updated.
Alter tabs and actions displayed on the page
hook_menu_local_tasks_alter
before they are rendered.
hook_menu_site_status_alter Control site status before menu dispatching.
hook_menu_update Informs modules that a custom menu was
Name Description
updated.
Perform necessary actions after modules are
hook_modules_disabled
disabled.
Perform necessary actions after modules are
hook_modules_enabled
enabled.
Perform necessary actions after modules are
hook_modules_installed
installed.
Perform necessary actions after modules are
hook_modules_uninstalled
uninstalled.
Alter the registry of modules implementing a
hook_module_implements_alter
hook.
Allow modules to react to language settings
hook_multilingual_settings_changed
changes.
hook_node_access Control access to a node.
Set permissions for a node to be written to the
hook_node_access_records
database.
Alter permissions for a node before it is written to
hook_node_access_records_alter
the database.
hook_node_delete Respond to node deletion.
Inform the node access system what permissions
hook_node_grants
the user has.
Alter user access rules when trying to view, edit
hook_node_grants_alter
or delete a node.
hook_node_info Define module-provided node types.
hook_node_insert Respond to creation of a new node.
hook_node_load Act on nodes being loaded from the database.
hook_node_operations Add mass node operations.
Act on a node object about to be shown on the
hook_node_prepare
add/edit form.
hook_node_presave Act on a node being inserted or updated.
hook_node_revision_delete Respond to deletion of a node revision.
hook_node_search_result Act on a node being displayed as a search result.
Act on a node after validated form values have
hook_node_submit
been copied to it.
hook_node_type_delete Respond to node type deletion.
hook_node_type_insert Respond to node type creation.
hook_node_type_update Respond to node type updates.
hook_node_update Respond to updates to a node.
hook_node_update_index Act on a node being indexed for searching.
Perform node validation before a node is created
hook_node_validate
or updated.
Act on a node that is being assembled before
hook_node_view
rendering.
hook_node_view_alter Alter the results of node_view().
Allow modules to modify the OpenID request
hook_openid
parameters.
Allow modules to declare OpenID discovery
hook_openid_discovery_method_info
methods.
hook_openid_discovery_method_info_alter Allow modules to alter discovery methods.
Allow modules to declare OpenID normalization
hook_openid_normalization_method_info
methods.
hook_openid_normalization_method_info_alter Allow modules to alter normalization methods.
Allow modules to act upon a successful OpenID
hook_openid_response
login.
Name Description
Allow modules to act when an overlay child
hook_overlay_child_initialize
window is initialized.
Allow modules to act when an overlay parent
hook_overlay_parent_initialize
window is initialized.
hook_page_alter Perform alterations before a page is rendered.
hook_page_build Add elements to a page before it is rendered.
Alters the delivery callback used to send the
hook_page_delivery_callback_alter
result of the page callback to the browser.
hook_path_delete The path has been deleted.
hook_path_insert The path has been inserted.
hook_path_update The path has been updated.
hook_permission Define user permissions.
Act on a node object about to be shown on the
hook_prepare
add/edit form.
hook_query_alter Perform alterations to a structured query.
Perform alterations to a structured query for a
hook_query_TAG_alter
given tag.
Provide additional methods of scoring for core
hook_ranking
search results for nodes.
Allow modules to define RDF mappings for field
hook_rdf_mapping
bundles.
Allow modules to define namespaces for RDF
hook_rdf_namespaces
mappings.
Perform necessary alterations to the list of files
hook_registry_files_alter
parsed by the registry.
Check installation requirements and do status
hook_requirements
reporting.
Define the current version of the database
hook_schema
schema.
hook_schema_alter Perform alterations to existing database schemas.
hook_search_access Define access to a custom search routine.
hook_search_admin Add elements to the search settings form.
hook_search_execute Execute a search for a set of key words.
hook_search_info Define a custom search type.
hook_search_page Override the rendering of search results.
hook_search_preprocess Preprocess text for search.
Take action when the search index is going to be
hook_search_reset
rebuilt.
hook_search_status Report the status of indexing.
Return the name of a default shortcut set for the
hook_shortcut_default_set
provided user account.
hook_simpletest_alter Alter the list of tests.
Registers PHP stream wrapper implementations
hook_stream_wrappers
associated with a module.
Alters the list of PHP stream wrapper
hook_stream_wrappers_alter
implementations.
Alter the information parsed from module and
hook_system_info_alter
theme .info files
hook_system_themes_page_alter Alters theme operation links.
hook_taxonomy_term_delete Respond to the deletion of taxonomy terms.
hook_taxonomy_term_insert Act on taxonomy terms when inserted.
hook_taxonomy_term_load Act on taxonomy terms when loaded.
hook_taxonomy_term_presave Act on taxonomy terms before they are saved.
Name Description
hook_taxonomy_term_update Act on taxonomy terms when updated.
hook_taxonomy_term_view_alter Alter the results of taxonomy_term_view().
Respond to the deletion of taxonomy
hook_taxonomy_vocabulary_delete
vocabularies.
hook_taxonomy_vocabulary_insert Act on taxonomy vocabularies when inserted.
hook_taxonomy_vocabulary_load Act on taxonomy vocabularies when loaded.
Act on taxonomy vocabularies before they are
hook_taxonomy_vocabulary_presave
saved.
hook_taxonomy_vocabulary_update Act on taxonomy vocabularies when updated.
hook_test_finished An individual test has finished.
hook_test_group_finished A test group has finished.
hook_test_group_started A test group has started.
Register a module (or theme's) theme
hook_theme
implementations.
Alter the theme registry information returned
hook_theme_registry_alter
from hook_theme().
Provide replacement values for placeholder
hook_tokens
tokens.
hook_tokens_alter Alter replacement values for placeholder tokens.
Provide information about available placeholder
hook_token_info
tokens and token types.
Alter the metadata about available placeholder
hook_token_info_alter
tokens and token types.
Alter a menu link after it has been translated and
hook_translated_menu_link_alter
before it is rendered.
Declare triggers (events) for users to assign
hook_trigger_info
actions to.
hook_trigger_info_alter Alter triggers declared by hook_trigger_info().
hook_uninstall Remove any information that the module sets.
hook_update Respond to updates to a node.
Provide information on Updaters (classes that can
hook_updater_info
update Drupal).
hook_updater_info_alter Alter the Updater information array.
Return an array of information about module
hook_update_dependencies
update dependencies.
hook_update_index Update the search index for this module.
Return a number which is no longer available
hook_update_last_removed
as hook_update_N().
hook_update_N Perform a single update.
Alter the list of projects before fetching data and
hook_update_projects_alter
comparing versions.
Alter the information about available updates for
hook_update_status_alter
projects.
hook_url_inbound_alter Alters inbound URL requests.
hook_url_outbound_alter Alters outbound URLs.
hook_username_alter Alter the username that is displayed for a user.
hook_user_cancel Act on user account cancellations.
hook_user_cancel_methods_alter Modify account cancellation methods.
Retrieve a list of user setting or profile
hook_user_categories
information categories.
hook_user_delete Respond to user deletion.
hook_user_insert A user account was created.
hook_user_load Act on user objects when loaded from the
Name Description
database.
hook_user_login The user just logged in.
hook_user_logout The user just logged out.
hook_user_operations Add mass user operations.
hook_user_presave A user account is about to be created or updated.
Inform other modules that a user role has been
hook_user_role_delete
deleted.
Inform other modules that a user role has been
hook_user_role_insert
added.
Inform other modules that a user role has been
hook_user_role_update
updated.
hook_user_update A user account was updated.
hook_user_view The user's account information is being displayed.
The user was built; the module may modify the
hook_user_view_alter
structured content.
Perform node validation before a node is created
hook_validate
or updated.
Verify an archive after it has been downloaded
hook_verify_update_archive
and extracted.
hook_view Display a node.
hook_watchdog Log an event message
hook_xmlrpc Register XML-RPC callbacks.
Alters the definition of XML-RPC methods before
hook_xmlrpc_alter
they are called.
module_hook Determine whether a module implements a hook.
Retrieve a list of what hooks are explicitly
module_hook_info
declared.
Determine which modules are implementing a
module_implements
hook.
module_implements_write_cache Writes the hook implementation cache.
module_invoke Invoke a hook in a particular module.
Invoke a hook in all enabled modules that
module_invoke_all
implement it.
An example conditions callback function for
sample_search_conditions_callback
search.
includes/module.inc, line 532

Database Abstraction Layer


Allow the use of different database servers using the same code base.

Drupal provides a database abstraction layer to provide developers with the ability to support
multiple database servers easily. The intent of this layer is to preserve the syntax and power of
SQL as much as possible, but also allow developers a way to leverage more complex functionality
in a unified way. It also provides a structured interface for dynamically constructing queries when
appropriate, and enforcing security checks and similar good practices.

The system is built atop PHP's PDO (PHP Data Objects) database API and inherits much of its
syntax and semantics.

SELECT
Most Drupal database SELECT queries are performed by a call to db_query() or
db_query_range(). Module authors should also consider using the PagerDefault Extender for
queries that return results that need to be presented on multiple pages, and the Tablesort Extender
for generating appropriate queries for sortable tables.

For example, one might wish to return a list of the most recent 10 nodes authored by a given user.
Instead of directly issuing the SQL query

<?php
SELECT n.nid, n.title, n.created FROM node n WHERE n.uid = $uid LIMIT 0, 10;
?>

one would instead call the Drupal functions:

<?php
$result = db_query_range('SELECT n.nid, n.title, n.created
FROM {node} n WHERE n.uid = :uid', 0, 10, array(':uid' => $uid));
foreach ($result as $record) {
// Perform operations on $node->title, etc. here.
}
?>

Curly braces are used around "node" to provide table prefixing via
DatabaseConnection::prefixTables(). The explicit use of a user ID is pulled out into an argument
passed to db_query() so that SQL injection attacks from user input can be caught and nullified. The
LIMIT syntax varies between database servers, so that is abstracted into db_query_range()
arguments. Finally, note the PDO-based ability to iterate over the result set using foreach ().

All queries are passed as a prepared statement string. A prepared statement is a "template" of a
query that omits literal or variable values in favor of placeholders. The values to place into those
placeholders are passed separately, and the database driver handles inserting the values into the
query in a secure fashion. That means you should never quote or string-escape a value to be
inserted into the query.

There are two formats for placeholders: named and unnamed. Named placeholders are strongly
preferred in all cases as they are more flexible and self-documenting. Named placeholders should
start with a colon ":" and can be followed by one or more letters, numbers or underscores.

Named placeholders begin with a colon followed by a unique string. Example:

<?php
SELECT nid, title FROM {node} WHERE uid=:uid;
?>

":uid" is a placeholder that will be replaced with a literal value when the query is executed. A given
placeholder label cannot be repeated in a given query, even if the value should be the same. When
using named placeholders, the array of arguments to the query must be an associative array
where keys are a placeholder label (e.g., :uid) and the value is the corresponding value to use. The
array may be in any order.

Unnamed placeholders are simply a question mark. Example:

<?php
SELECT nid, title FROM {node} WHERE uid=?;
?>

In this case, the array of arguments must be an indexed array of values to use in the exact same
order as the placeholders in the query.
Note that placeholders should be a "complete" value. For example, when running a LIKE query the
SQL wildcard character, %, should be part of the value, not the query itself. Thus, the following is
incorrect:

<?php
SELECT nid, title FROM {node} WHERE title LIKE :title%;
?>

It should instead read:

<?php
SELECT nid, title FROM {node} WHERE title LIKE :title;
?>

and the value for :title should include a % as appropriate. Again, note the lack of quotation marks
around :title. Because the value is not inserted into the query as one big string but as an explicitly
separate value, the database server knows where the query ends and a value begins. That is
considerably more secure against SQL injection than trying to remember which values need
quotation marks and string escaping and which don't.

INSERT, UPDATE and DELETE


INSERT, UPDATE, and DELETE queries need special care in order to behave consistently across
all different databases. Therefore, they use a special object-oriented API for defining a query
structurally. For example, rather than:

<?php
INSERT INTO node (nid, title, body) VALUES (1, 'my title', 'my body');
?>

one would instead write:

<?php
$fields = array('nid' => 1, 'title' => 'my title', 'body' => 'my body');
db_insert('node')->fields($fields)->execute();
?>

This method allows databases that need special data type handling to do so, while also allowing
optimizations such as multi-insert queries. UPDATE and DELETE queries have a similar pattern.

Transactions
Drupal also supports transactions, including a transparent fallback for databases that do not
support transactions. To start a new transaction, simply call $txn = db_transaction(); in your own
code. The transaction will remain open for as long as the variable $txn remains in scope. When
$txn is destroyed, the transaction will be committed. If your transaction is nested inside of another
then Drupal will track each transaction and only commit the outer-most transaction when the last
transaction object goes out out of scope, that is, all relevant queries completed successfully.

Example:

<?php
function my_transaction_function() {
// The transaction opens here.
$txn = db_transaction();
try {
$id = db_insert('example')
->fields(array(
'field1' => 'mystring',
'field2' => 5,
))
->execute();

my_other_function($id);

return $id;
}
catch (Exception $e) {
// Something went wrong somewhere, so roll back now.
$txn->rollback();
// Log the exception to watchdog.
watchdog_exception('type', $e);
}

// $txn goes out of scope here. Unless the transaction was rolled back, it
// gets automatically commited here.
}

function my_other_function($id) {
// The transaction is still open here.

if ($id % 2 == 0) {
db_update('example')
->condition('id', $id)
->fields(array('field2' => 10))
->execute();
}
}
?>

@link http://drupal.org/developing/api/database

Classes
Name Description
Primary front-controller for the
Database
database system.
Generic class for a series of conditions
DatabaseCondition
in a query.
DatabaseConnection Base Database API class.
Exception thrown if an undefined
DatabaseConnectionNotDefinedException
database connection is requested.
DatabaseConnection_mysql
DatabaseConnection_pgsql
Specific SQLite implementation of
DatabaseConnection_sqlite
DatabaseConnection.
Exception thrown if no driver is
DatabaseDriverNotSpecifiedException
specified for a database connection.
Name Description
Default implementation of
DatabaseStatementBase
DatabaseStatementInterface.
Empty implementation of a database
DatabaseStatementEmpty
statement.
An implementation of
DatabaseStatementPrefetch DatabaseStatementInterface that
prefetches all data.
Specific SQLite implementation of
DatabaseStatement_sqlite
DatabaseConnection.
A wrapper class for creating and
DatabaseTransaction
managing database transactions.
Exception thrown when a commit()
DatabaseTransactionCommitFailedException
function fails.
Exception to deny attempts to
DatabaseTransactionExplicitCommitNotAllowedException
explicitly manage transactions.
Exception thrown when a savepoint or
DatabaseTransactionNameNonUniqueException
transaction name occurs twice.
Exception for when popTransaction() is
DatabaseTransactionNoActiveException
called with no active transaction.
General class for an abstracted DELETE
DeleteQuery
operation.
SQLite specific implementation of
DeleteQuery_sqlite
DeleteQuery.
Exception thrown if an insert query
FieldsOverlapException
specifies a field twice.
General class for an abstracted INSERT
InsertQuery
query.
InsertQuery_mysql
InsertQuery_pgsql
SQLite specific implementation of
InsertQuery_sqlite
InsertQuery.
Exception thrown for merge queries
InvalidMergeQueryException
that do not make semantic sense.
General class for an abstracted MERGE
MergeQuery
query operation.
Exception thrown if an insert query
NoFieldsException
doesn't specify insert or default fields.
Query Base class for query builders.
SelectQuery Query builder for SELECT statements.
The base extender class for Select
SelectQueryExtender
queries.
SelectQuery_pgsql
SQLite specific query builder for
SelectQuery_sqlite
SELECT statements.
General class for an abstracted
TruncateQuery
TRUNCATE operation.
TruncateQuery_mysql
SQLite specific implementation of
TruncateQuery_sqlite
TruncateQuery.
General class for an abstracted
UpdateQuery
UPDATE operation.
UpdateQuery_pgsql
SQLite specific implementation of
UpdateQuery_sqlite
UpdateQuery.
Interfaces
Name Description
DatabaseStatementInterface A prepared statement.
QueryAlterableInterface Interface for a query that can be manipulated via an alter hook.
QueryConditionInterface Interface for a conditional clause in a query.
QueryExtendableInterface Interface for extendable query objects.
QueryPlaceholderInterface Interface for a query that accepts placeholders.
SelectQueryInterface Interface definition for a Select Query object.

Functions & methods


Name Description
db_and Returns a new DatabaseCondition, set to "AND" all conditions together.
db_autoload Autoload callback for the database system.
db_close Closes the active database connection.
db_condition Returns a new DatabaseCondition, set to the specified conjunction.
db_delete Returns a new DeleteQuery object for the active database.
db_driver Retrieves the name of the currently active database driver.
db_escape_field Restricts a dynamic column or constraint name to safe characters.
db_escape_table Restricts a dynamic table name to safe characters.
db_insert Returns a new InsertQuery object for the active database.
db_like Escapes characters that work as wildcard characters in a LIKE pattern.
db_merge Returns a new MergeQuery object for the active database.
db_next_id Retrieves a unique id.
db_or Returns a new DatabaseCondition, set to "OR" all conditions together.
db_query Executes an arbitrary query string against the active database.
db_query_range Executes a query against the active database, restricted to a range.
db_query_temporary Executes a query string and saves the result set to a temporary table.
db_select Returns a new SelectQuery object for the active database.
db_set_active Sets a new active database.
db_transaction Returns a new transaction object for the active database.
db_truncate Returns a new TruncateQuery object for the active database.
db_update Returns a new UpdateQuery object for the active database.
Returns a new DatabaseCondition, set to "XOR" all conditions
db_xor
together.

Constants
Name Description
The name by which to obtain a lock for retrive the next insert
POSTGRESQL_NEXTID_LOCK
id.
includes/database/database.inc, line 13

Menu System
Define the navigation menus, and route page requests to code based on URLs.

The Drupal menu system drives both the navigation system from a user perspective and the
callback system that Drupal uses to respond to URLs passed from the browser. For this reason, a
good understanding of the menu system is fundamental to the creation of complex modules.

Drupal's menu system follows a simple hierarchy defined by paths. Implementations of


hook_menu() define menu items and assign them to paths (which should be unique). The menu
system aggregates these items and determines the menu hierarchy from the paths. For example, if
the paths defined were a, a/b, e, a/b/c/d, f/g, and a/b/h, the menu system would form the structure:

• a
• a/b
• a/b/c/d
• a/b/h
• e
• f/g

Note that the number of elements in the path does not necessarily determine the depth of the
menu item in the tree.

When responding to a page request, the menu system looks to see if the path requested by the
browser is registered as a menu item with a callback. If not, the system searches up the menu tree
for the most complete match with a callback it can find. If the path a/b/i is requested in the tree
above, the callback for a/b would be used.

The found callback function is called with any arguments specified in the "page arguments"
attribute of its menu item. The attribute must be an array. After these arguments, any remaining
components of the path are appended as further arguments. In this way, the callback for a/b above
could respond to a request for a/b/i differently than a request for a/b/j.

For an illustration of this process, see page_example.module.

Access to the callback functions is also protected by the menu system. The "access callback" with
an optional "access arguments" of each menu item is called before the page callback proceeds. If
this returns TRUE, then access is granted; if FALSE, then access is denied. Menu items may omit
this attribute to use the value provided by an ancestor item.

In the default Drupal interface, you will notice many links rendered as tabs. These are known in the
menu system as "local tasks", and they are rendered as tabs by default, though other
presentations are possible. Local tasks function just as other menu items in most respects. It is
convention that the names of these tasks should be short verbs if possible. In addition, a "default"
local task should be provided for each set. When visiting a local task's parent menu item, the
default local task will be rendered as if it is selected; this provides for a normal tab user experience.
This default task is special in that it links not to its provided path, but to its parent item's path
instead. The default task's path is only used to place it appropriately in the menu hierarchy.

Everything described so far is stored in the menu_router table. The menu_links table holds the
visible menu links. By default these are derived from the same hook_menu definitions, however
you are free to add more with menu_link_save().

Functions & methods

Name Description
Generates elements for the $arg array in the help
drupal_help_arg
hook.
menu_build_tree Build a menu tree, translate links, and check access.
Clears the cached cached data for a single named
menu_cache_clear
menu.
Clears all cached menu data. This should be called
menu_cache_clear_all any time broad changes might have been made to
the router items or menu links.
Retrieve contextual links for a system object based
menu_contextual_links
on registered local tasks.
Name Description
menu_delete_links Deletes all links for a menu.
Execute the page callback associated with the
menu_execute_active_handler
current path.
Get the breadcrumb for the current page, as
menu_get_active_breadcrumb
determined by the active trail.
Returns the help associated with the active menu
menu_get_active_help
item.
Get the active menu for the current page -
menu_get_active_menu_names
determines the active trail.
Get the title of the current page, as determined by
menu_get_active_title
the active trail.
Gets the active trail (path to root menu root) of the
menu_get_active_trail
current page.
Returns the ancestors (and relevant placeholders)
menu_get_ancestors
for any given path.
Gets the custom theme for the current page, if there
menu_get_custom_theme
is one.
menu_get_item Get a router item.
menu_get_names Build a list of named menus.
menu_get_object Get a loaded object from a router item.
menu_get_router Get the menu router.
menu_links_clone Clone an array of menu links.
Find the depth of an item's children relative to its
menu_link_children_relative_depth
depth.
menu_link_delete Delete one or several menu links.
Lookup the preferred menu link for a given system
menu_link_get_preferred
path.
Get a menu link by its mlid, access checked and link
menu_link_load
translated for rendering.
Insert, update or delete an uncustomized menu link
menu_link_maintain
related to a module.
menu_link_save Save a menu link.
Return an array containing the names of system-
menu_list_system_menus
defined (default) menus.
menu_load_links Returns an array containing all links for a menu.
Returns the rendered local actions at the current
menu_local_actions
level.
Collects the local tasks (tabs), action links, and the
menu_local_tasks
root path.
Return an array of links to be rendered as the Main
menu_main_menu
menu.
menu_navigation_links Return an array of links for a navigation menu.
menu_primary_local_tasks Returns the rendered local tasks at the top level.
(Re)populate the database tables used by various
menu_rebuild
menu functions.
menu_reset_static_cache Resets the menu system static cache.
menu_router_build Collect and alter the menu definitions.
menu_secondary_local_tasks Returns the rendered local tasks at the second level.
Return an array of links to be rendered as the
menu_secondary_menu
Secondary links.
Set the active path, which determines which page is
menu_set_active_item
loaded.
Set (or get) the active menu for the current page -
menu_set_active_menu_names
determines the active trail.
Name Description
Sets or gets the active trail (path to menu tree root)
menu_set_active_trail
of the current page.
Sets a custom theme for the current page, if there is
menu_set_custom_theme
one.
menu_set_item Replaces the statically cached item for a given path.
Returns the router path, or the path of the parent
menu_tab_root_path
tab of a default local task.
menu_tail_to_arg
menu_tree Renders a menu tree based on the current path.
Get the data structure representing a named menu
menu_tree_all_data
tree.
Check access and perform other dynamic
menu_tree_check_access
operations for each link in the tree.
menu_tree_collect_node_links Recursive helper function - collect node links.
menu_tree_data Build the data representing a menu tree.
menu_tree_output Returns a rendered menu tree.
Get the data structure representing a named menu
menu_tree_page_data
tree, based on the current page.
The menu system uses serialized arrays stored in
the database for arguments. However, often these
menu_unserialize need to change according to the current path. This
function unserializes such an array and does the
necessary change.
Preprocesses the rendered tree
template_preprocess_menu_tree
for theme_menu_tree().
theme_menu_link Returns HTML for a menu link and submenu.
theme_menu_local_action Returns HTML for a single local action link.
theme_menu_local_task Returns HTML for a single local task link.
theme_menu_local_tasks Returns renderable local tasks.
theme_menu_tree Returns HTML for a wrapper for a menu sub-tree.
_menu_build_tree Build a menu tree.
Check access to a menu item using the access
_menu_check_access
callback
Helper function to clear the page and block caches
_menu_clear_page_cache
at most twice per page load.
Helper function for menu_link_delete; deletes a
_menu_delete_item
single menu link.
_menu_find_router_path Find the router path which will serve this path.
Localize the router item title using t() or another
_menu_item_localize
callback.
_menu_link_build Builds a link from a router item.
This function translates the path elements in the
map using any to_arg helper function. These
_menu_link_map_translate functions take an argument and return an object.
Seehttp://drupal.org/node/109153 for more
information.
Update the children of a menu link that's being
_menu_link_move_children
moved.
Helper function that sets the p1..p9 values for a
_menu_link_parents_set
menu link being saved.
This function is similar to _menu_translate() but
_menu_link_translate does link-specific preparation such as always calling
to_arg functions
Loads objects into the map as defined in the
_menu_load_objects
$item['load_functions'].
Name Description
Helper function to build menu links for the items in
_menu_navigation_links_rebuild
the menu router.
Helper function to build the router table based on
_menu_router_build
the data from hook_menu.
Helper function to store the menu router if we have
_menu_router_cache
it in memory.
Helper function to save data
_menu_router_save
from menu_router_build() to the router table.
Helper function to update a list of menus with
_menu_set_expanded_menus
expanded items
_menu_site_is_offline Checks whether the site is in maintenance mode.
Handles dynamic path translation and menu access
_menu_translate
control.
Recursive helper function
_menu_tree_check_access
for menu_tree_check_access()
Recursive helper function to build the data
_menu_tree_data
representing a menu tree.
Check and update the has_children status for the
_menu_update_parental_status
parent of a link.

Constants
Name Description
Internal menu status code -- Menu item access is
MENU_ACCESS_DENIED
denied.
Menu type -- A hidden, internal callback, typically
MENU_CALLBACK
used for API calls.
Internal menu flag: Local task should be displayed
MENU_CONTEXT_INLINE
inline.
MENU_CONTEXT_NONE Internal menu flag: Invisible local task.
Internal menu flag: Local task should be displayed
MENU_CONTEXT_PAGE
in page context.
Internal menu flag -- menu item was created by
MENU_CREATED_BY_ADMIN
administrator.
Menu type -- The "default" local task, which is
MENU_DEFAULT_LOCAL_TASK
initially active.
MENU_FOUND Internal menu status code -- Menu item was found.
MENU_IS_LOCAL_ACTION Internal menu flag -- menu item is a local action.
MENU_IS_LOCAL_TASK Internal menu flag -- menu item is a local task.
Internal menu flag -- menu item is the root of the
MENU_IS_ROOT
menu tree.
Internal menu flag -- menu item links back to its
MENU_LINKS_TO_PARENT
parent.
Menu type -- An action specific to the parent,
MENU_LOCAL_ACTION
usually rendered as a link.
Menu type -- A task specific to the parent item,
MENU_LOCAL_TASK
usually rendered as a tab.
The maximum depth of a menu links tree - matches
MENU_MAX_DEPTH
the number of p columns.
The maximum number of path elements for a menu
MENU_MAX_PARTS
callback
Internal menu flag -- menu item can be modified by
MENU_MODIFIED_BY_ADMIN
administrator.
Menu type -- A "normal" menu item that's shown in
MENU_NORMAL_ITEM
menu and breadcrumbs.
Name Description
Internal menu status code -- Menu item was not
MENU_NOT_FOUND
found.
Internal menu status code -- Menu item inaccessible
MENU_SITE_OFFLINE
because site is offline.
Internal menu status code -- Everything is working
MENU_SITE_ONLINE
fine.
Menu type -- A normal menu item, hidden until
MENU_SUGGESTED_ITEM
enabled by an administrator.
Internal menu flag -- menu item is visible in the
MENU_VISIBLE_IN_BREADCRUMB
breadcrumb.
Internal menu flag -- menu item is visible in the
MENU_VISIBLE_IN_TREE
menu tree.

Groups
Name Description
Menu context
Flags for use in the "context" attribute of menu router items.
types
Menu flags Flags for use in the "type" attribute of menu items.
Menu item definitions provide one of these constants, which are shortcuts for
Menu item types
combinations of the above flags.
Menu status codes Status codes for menu callbacks.
Menu tree
Menu tree
parameters
includes/menu.inc, line 9

Form Generation
Functions to enable the processing and display of HTML forms.

Drupal uses these functions to achieve consistency in its form processing and presentation, while
simplifying code and reducing the amount of HTML that must be explicitly generated by modules.

The primary function used with forms is drupal_get_form(), which is used for forms presented
interactively to a user. Forms can also be built and submitted programmatically without any user
input using the drupal_form_submit() function.

drupal_get_form() handles retrieving, processing, and displaying a rendered HTML form for
modules automatically.

Here is an example of how to use drupal_get_form() and a form builder function:

<?php
$form = drupal_get_form('my_module_example_form');
...
function my_module_example_form($form, &$form_state) {
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Submit'),
);
return $form;
}
function my_module_example_form_validate($form, &$form_state) {
// Validation logic.
}
function my_module_example_form_submit($form, &$form_state) {
// Submission logic.
}
?>

Or with any number of additional arguments:

<?php
$extra = "extra";
$form = drupal_get_form('my_module_example_form', $extra);
...
function my_module_example_form($form, &$form_state, $extra) {
$form['submit'] = array(
'#type' => 'submit',
'#value' => $extra,
);
return $form;
}
?>

The $form argument to form-related functions is a structured array containing the elements and
properties of the form. For information on the array components and format, and more detailed
explanations of the Form API workflow, see the Form API reference and the Form API section of
the handbook. In addition, there is a set of Form API tutorials in the Form Example Tutorial which
provide basics all the way up through multistep forms.

In the form builder, validation, submission, and other form functions, $form_state is the primary
influence on the processing of the form and is passed by reference to most functions, so they use
it to communicate with the form system and each other.

The $form_state keys are:


• 'values': An associative array of values submitted to the form. The validation functions and
submit functions use this array for nearly all their decision making. (Note that #tree
determines whether the values are a flat array or an array whose structure parallels the
$form array.)
• 'rebuild': If the submit function sets $form_state['rebuild'] to TRUE, submission is not
completed and instead the form is rebuilt using any information that the submit function has
made available to the form builder function via $form_state. This is commonly used for
wizard-style multi-step forms, add-more buttons, and the like. For further information see
drupal_build_form().
• 'redirect': a URL that will be used to redirect the form on submission. See
drupal_redirect_form() for complete information.
• 'storage': $form_state['storage'] is not a special key, and no specific support is provided for
it in the Form API, but by tradition it was the location where application-specific data was
stored for communication between the submit, validation, and form builder functions,
especially in a multi-step-style form. Form implementations may use any key(s) within
$form_state (other than the keys listed here and other reserved ones used by Form API
internals) for this kind of storage. The recommended way to ensure that the chosen key
doesn't conflict with ones used by the Form API or other modules is to use the module
name as the key name or a prefix for the key name. For example, the Node module uses
$form_state['node'] in node editing forms to store information about the node being edited,
and this information stays available across successive clicks of the "Preview" button as well
as when the "Save" button is finally clicked.
• 'temporary': Since values for all non-reserved keys in $form_state persist throughout a
multistep form sequence, the Form API provides the 'temporary' key for modules to use for
communicating information across form-related functions during a single page request only.
There is no use-case for this functionality in core.
• 'triggering_element': (read-only) The form element that triggered submission. This is the
same as the deprecated $form_state['clicked_button']. It is the element that caused
submission, which may or may not be a button (in the case of AJAX forms.) This is often
used to distinguish between various buttons in a submit handler, and is also used in AJAX
handlers.
• 'cache': The typical form workflow involves two page requests. During the first page
request, a form is built and returned for the user to fill in. Then the user fills the form in and
submits it, triggering a second page request in which the form must be built and processed.
By default, $form and $form_state are built from scratch during each of these page
requests. In some special use-cases, it is necessary or desired to persist the $form and
$form_state variables from the initial page request to the one that processes the
submission. A form builder function can set 'cache' to TRUE to do this. One example where
this is needed is to handle AJAX submissions, so ajax_process_form() sets this for all forms
that include an element with a #ajax property. (In AJAX, the handler has no way to build the
form itself, so must rely on the cached version created on each page load, so it's a classic
example of this use case.) Note that the persistence of $form and $form_state across
successive submissions of a multi-step form happens automatically regardless of the value
for 'cache'.
• 'input': The array of values as they were submitted by the user. These are raw and
unvalidated, so should not be used without a thorough understanding of security
implications. In almost all cases, code should use the data in the 'values' array exclusively.
The most common use of this key is for multi-step forms that need to clear some of the user
input when setting 'rebuild'.

Functions & methods


Name Description
Validates the date type to stop dates like February
date_validate
30, 2006.
drupal_build_form Build and process a form based on a form id.
drupal_form_submit Retrieves, populates, and processes a form.
Wrapper for drupal_build_form() for use when
drupal_get_form
$form_state is not needed.
Prepares a structured form array by adding
required elements, executing any hook_form_alter
drupal_prepare_form
functions, and optionally inserting a validation
token to prevent tampering.
drupal_process_form Processes a form submission.
Constructs a new $form from the information in
drupal_rebuild_form
$form_state.
Redirects the user to a URL after a form has been
drupal_redirect_form
processed.
Retrieves the structured array that defines a given
drupal_retrieve_form
form.
Validates user-submitted form data from the
drupal_validate_form $form_state using the validate functions defined
in a structured form array.
Walk through the structured form array, adding
any required properties to each element and
form_builder mapping the incoming input data to the proper
elements. Also, execute any #process handlers
attached to a specific element.
Name Description
Clear all errors against all form elements made
form_clear_error
by form_set_error().
form_error Flag an element as having an error.
A helper function used to execute custom
validation and submission handlers for a given
form_execute_handlers form. Button-specific handlers are checked first. If
none exist, the function falls back to form-level
handlers.
form_get_cache Fetch a form from cache.
Returns the error message filed against the given
form_get_error
form element.
form_get_errors Return an associative array of all errors.
Traverses a select element's #option array looking
form_get_options for any values that hold the given key. Returns an
array of indexes that match.
Allows PHP array processing of multiple select
form_options_flatten
options with the same value.
Add form_element theming to an element if title
form_pre_render_conditional_form_element
or description is set.
Adds members of this group as actual elements
form_pre_render_fieldset
for rendering.
form_process_actions Processes a form actions container element.
Sets the #checked property of a checkbox
form_process_checkbox
element.
form_process_checkboxes
form_process_container Processes a container element.
form_process_date Roll out a single date element.
Adds fieldsets to the specified group or adds
form_process_fieldset
group members to this fieldset.
Processes a machine-readable name form
form_process_machine_name
element.
Expand a password_confirm field into two text
form_process_password_confirm
boxes.
Roll out a single radios element to a list of radios,
form_process_radios
using the options array as index.
form_process_select Processes a select list form element.
Create the correct amount of checkbox or radio
form_process_tableselect
elements to populate the table.
form_process_vertical_tabs Creates a group formatted as vertical tabs.
form_process_weight Expand weight elements into selects.
Converts a select form element's options array
form_select_options
into an HTML.
form_set_cache Store a form in the cache.
form_set_error Files an error against a form element.
Change submitted form values during form
form_set_value
validation.
form_state_defaults Retrieve default values for the $form_state array.
Returns an array of $form_state keys that
form_state_keys_no_cache
shouldn't be cached.
Removes internal Form API elements and buttons
form_state_values_clean
from submitted form values.
Helper function to determine the value for a
form_type_checkboxes_value
checkboxes form element.
Helper function to determine the value for a
form_type_checkbox_value
checkbox form element.
Name Description
Helper function to determine the value for an
form_type_image_button_value
image button form element.
Helper function to determine the value for a
form_type_password_confirm_value
password_confirm form element.
Helper function to determine the value for a select
form_type_select_value
form element.
Helper function to determine the value for a
form_type_tableselect_value
tableselect form element.
Helper function to determine the value for a
form_type_textfield_value
textfield form element.
Helper function to determine the value for form's
form_type_token_value
token value.
Form element validation handler for #type
form_validate_machine_name
'machine_name'.
Helper function for usage with drupal_map_assoc
map_month
to display month names.
password_confirm_validate Validate password_confirm element.
theme_button Returns HTML for a button form element.
theme_checkbox Returns HTML for a checkbox form element.
Returns HTML for a set of checkbox form
theme_checkboxes
elements.
Returns HTML for a container for grouped form
theme_container
items.
theme_date Returns HTML for a date selection form element.
Returns HTML for a fieldset form element and its
theme_fieldset
children.
theme_file Returns HTML for a file upload form element.
theme_form Returns HTML for a form.
theme_form_element Returns HTML for a form element.
Returns HTML for a form element label and
theme_form_element_label
required marker.
Returns HTML for a marker for required form
theme_form_required_marker
elements.
theme_hidden Returns HTML for a hidden form element.
theme_image_button Returns HTML for an image button form element.
theme_password Returns HTML for a password form element.
theme_radio Returns HTML for a radio button form element.
Returns HTML for a set of radio button form
theme_radios
elements.
theme_select Returns HTML for a select form element.
theme_submit Returns HTML for a submit button form element.
Returns HTML for a table with radio buttons or
theme_tableselect
checkboxes.
theme_textarea Returns HTML for a textarea form element.
theme_textfield Returns HTML for a textfield form element.
Returns HTML for an element's children fieldsets
theme_vertical_tabs
as vertical tabs.
If no default value is set for weight select boxes,
weight_value
use 0.
Populate the #value and #name properties of
_form_builder_handle_input_element input elements so they can be processed and
rendered.
Helper function to handle the convoluted logic of
_form_button_was_clicked
button click detection.
Name Description
Helper function to handle the convoluted logic of
_form_element_triggered_scripted_submission
button click detection.
_form_options_flatten Helper function for form_options_flatten().
_form_set_class Sets a form element's class attribute.
Performs validation on form elements. First
ensures required fields are completed,
_form_validate #maxlength is not exceeded, and selected
options were in the list of options given to the
user. Then calls user-defined validators.

includes/form.inc, line 23

File Management System


Common file handling functions.

Fields on the file object:

• fid: File ID
• uid: The {users}.uid of the user who is associated with the file.
• filename: Name of the file with no path components. This may differ from the basename of
the filepath if the file is renamed to avoid overwriting an existing file.
• uri: URI of the file.
• filemime: The file's MIME type.
• filesize: The size of the file in bytes.
• status: A bitmapped field indicating the status of the file. The first 8 bits are reserved for
Drupal core. The least significant bit indicates temporary (0) or permanent (1). Temporary
files older than DRUPAL_MAXIMUM_TEMP_FILE_AGE will be removed during cron runs.
• timestamp: UNIX timestamp for the date the file was added to the database.

Functions & methods


Name Description
drupal_chmod Set the permissions on a file or directory.
Gets the name of the directory from a given
drupal_dirname
path.
drupal_mkdir Creates a directory using Drupal's default mode.
drupal_realpath Returns the absolute path of a file or directory
drupal_rmdir Remove a directory.
Creates a file with a unique filename in the
drupal_tempnam
specified directory.
drupal_unlink Deletes a file.
Given a relative path, construct a URI into
file_build_uri
Drupal's default files location.
Copies a file to a new location and adds a file
file_copy
record to the database.
Create a full file path from a directory and
file_create_filename
filename.
file_create_htaccess Creates an .htaccess file in the given directory.
Creates a web-accessible URL for a stream to an
file_create_url
external or local file.
file_default_scheme Get the default file stream implementation.
file_delete Delete a file and its database record.
Name Description
Determines the destination path for a file
file_destination depending on how replacement of existing files
should be handled.
Get the path of system-appropriate temporary
file_directory_temp
directory.
file_download Menu handler for private file transfers.
If missing, create a .htaccess file in each Drupal
file_ensure_htaccess
files directory.
Examines a file object and returns appropriate
file_get_content_headers
content headers for download.
Determine an Internet Media Type, or MIME type
file_get_mimetype
from a filename.
file_get_stream_wrappers Drupal stream wrapper registry.
file_load Load a file object from the database.
file_load_multiple Loads file objects from the database.
Move a file to a new location and update the
file_move
file's database entry.
Modify a filename as needed for security
file_munge_filename
purposes.
file_prepare_directory Check that the directory exists and is writable.
file_save Save a file object to the database.
Save a string to the specified destination and
file_save_data
create a database file entry.
file_save_upload Saves a file upload to a new location.
Finds all files that match a given mask in a given
file_scan_directory
directory.
Determine total disk space used by a single user
file_space_used
or the whole filesystem.
Returns the stream wrapper class name for a
file_stream_wrapper_get_class
given scheme.
Returns a reference to the stream wrapper class
file_stream_wrapper_get_instance_by_scheme
responsible for a given scheme.
Returns a reference to the stream wrapper class
file_stream_wrapper_get_instance_by_uri
responsible for a given URI.
Normalizes a URI by making it syntactically
file_stream_wrapper_uri_normalize
correct.
file_stream_wrapper_valid_scheme Check that the scheme of a stream URI is valid.
file_transfer Transfer file using HTTP to client.
Copies a file to a new location without invoking
file_unmanaged_copy
the file API.
Delete a file without calling any hooks or making
file_unmanaged_delete
any changes to the database.
Recursively delete all files and directories in the
file_unmanaged_delete_recursive
specified filepath.
Move a file to a new location without calling any
file_unmanaged_move
hooks or making any changes to the database.
Save a string to the specified destination without
file_unmanaged_save_data
invoking file API.
file_unmunge_filename Undo the effect of upload_munge_filename().
Determine the maximum file upload size by
file_upload_max_size
querying the PHP settings.
file_uri_scheme Returns the scheme of a URI (e.g. a stream).
file_uri_target Returns the part of an URI after the schema.
file_usage_add Records that a module is using a file.
Name Description
Removes a record to indicate that a module is no
file_usage_delete
longer using a file.
file_usage_list Determines where a file is used.
Check that a file meets the criteria specified by
file_validate
the validators.
Check that the filename ends with an allowed
file_validate_extensions
extension.
Verify that image dimensions are within the
file_validate_image_resolution
specified maximum and minimum.
Check that the file is recognized
file_validate_is_image
byimage_get_info() as an image.
Check for files with names longer than we can
file_validate_name_length
store in the database.
file_validate_size Check that the file's size is below certain limits.
Determine whether the URI has a valid scheme
file_valid_uri
for file API operations.

Constants
Name Description
FILE_CREATE_DIRECTORY Flag used by file_prepare_directory() -- create directory if not present.
FILE_EXISTS_ERROR Flag for dealing with existing files: Do nothing and return FALSE.
Flag for dealing with existing files: Appends number until name is
FILE_EXISTS_RENAME
unique.
FILE_EXISTS_REPLACE Flag for dealing with existing files: Replace the existing file.
FILE_MODIFY_PERMISSION Flag used by file_prepare_directory() -- file permissions may be
S changed.
FILE_STATUS_PERMANENT Indicates that the file is permanent and should not be deleted.

includes/file.inc, line 18

Field API
Attach custom data fields to Drupal entities.
The Field API allows custom data fields to be attached to Drupal entities and takes care of storing,
loading, editing, and rendering field data. Any entity type (node, user, etc.) can use the Field API to
make itself "fieldable" and thus allow fields to be attached to it. Other modules can provide a user
interface for managing custom fields via a web browser as well as a wide and flexible variety of
data type, form element, and display format capabilities.
• Data structures: Field, Instance, Bundle.
• Field Types API. Defines field types, widget types, and display formatters. Field modules
use this API to provide field types like Text and Node Reference along with the associated
form elements and display formatters.
• Field CRUD API. Create, updates, and deletes fields, bundles (a.k.a. "content types"), and
instances. Modules use this API, often in hook_install(), to create custom data structures.
• Field Attach API. Connects entity types to the Field API. Field Attach API functions load,
store, generate Form API structures, display, and perform a variety of other functions for
field data connected to individual entities. Fieldable entity types like node and user use this
API to make themselves fieldable.
• Field Info API. Exposes information about all fields, instances, widgets, and related
information defined by or with the Field API.
• Field Storage API. Provides a pluggable back-end storage system for actual field data. The
default implementation, field_sql_storage.module, stores field data in the local SQL
database.
• Field API bulk data deletion. Cleans up after bulk deletion operations such
asfield_delete_field() and field_delete_instance().
• Field language API. Provides native multilingual support for the Field API.

Classes
Name Description
FieldUpdateForbiddenException Exception class thrown by hook_field_update_forbid().

Functions & methods


Name Description
Determine whether the user has access to a given
field_access
field.
Allows a module to update the database for fields
field_associate_fields
and columns it controls.
Gets or sets administratively defined bundle
field_bundle_settings
settings.
field_cache_clear Clear the field info and field data caches.
field_cron Implements hook_cron().
Helper function to extract the bundle name of
field_extract_bundle
from a bundle object.
Returns the display settings to use for pseudo-
field_extra_fields_get_display
fields in a given view mode.
Like filter_xss_admin(), but with a shorter list of
field_filter_xss
allowed tags.
field_flush_caches Implements hook_flush_caches().
Helper function to get the default value for a field
field_get_default_value
on an entity.
Returns the display settings to use for an instance
field_get_display
in a given view mode.
Returns the field items in the language they
field_get_items
currently would be displayed.
field_has_data Determine whether a field has any data.
field_help Implements hook_help().
field_modules_disabled Implements hook_modules_disabled().
field_modules_enabled Implements hook_modules_enabled().
field_modules_uninstalled Implements hook_modules_uninstalled().
field_theme Implements hook_theme().
Returns a renderable array for the value of a
field_view_field
single field in an entity.
field_view_mode_settings Returns view mode settings in a given bundle.
field_view_value Returns a renderable array for a single field value.
Theme preprocess function for theme_field()
template_preprocess_field
andfield.tpl.php.
Theme process function for theme_field()
template_process_field
andfield.tpl.php.
Pre-render callback to adjust weights and visibility
_field_extra_fields_pre_render
of non-field elements.
_field_filter_items Helper function to filter out empty field values.
_field_filter_xss_allowed_tags List of tags allowed by field_filter_xss().
_field_filter_xss_display_allowed_tags Human-readable list of allowed tags, for display in
Name Description
help texts.
Helper function to sort items in a field according
_field_sort_items
to user drag-n-drop reordering.
Sort function for items order. (copied
_field_sort_items_helper
formelement_sort(), which acts on #weight keys)
_field_sort_items_value_helper Same as above, using ['_weight']['#value']

Constants
Name Description
FIELD_BEHAVIOR_CUSTOM TODO
FIELD_BEHAVIOR_DEFAULT TODO
FIELD_BEHAVIOR_NONE TODO
Value for $field['cardinality'] property to indicate it can
FIELD_CARDINALITY_UNLIMITED
hold an unlimited number of values.
Age argument for loading the most recent version of an
FIELD_LOAD_CURRENT
entity's field data with field_attach_load().
Age argument for loading the version of an entity's field
FIELD_LOAD_REVISION
data specified in the entity with field_attach_load().
modules/field/field.module, line 28

Search System
The Drupal search interface manages a global search mechanism.
Modules may plug into this system to provide searches of different types of data. Most of the
system is handled by search.module, so this must be enabled for all of the search features to work.
There are three ways to interact with the search system:
Specifically for searching nodes, you can implement hook_node_update_index() and
hook_node_search_result(). However, note that the search system already indexes all visible
output of a node, i.e. everything displayed normally by hook_view() and hook_node_view(). This is
usually sufficient. You should only use this mechanism if you want additional, non-visible data to be
indexed.
Implement hook_search_info(). This will create a search tab for your module on the /search page
with a simple keyword search form. You will also need to implement hook_search_execute() to
perform the search.
Implement hook_update_index(). This allows your module to use Drupal's HTML indexing
mechanism for searching full text efficiently.
If your module needs to provide a more complicated search form, then you need to implement it
yourself without hook_search_info(). In that case, you should define it as a local task (tab) under
the /search page (e.g. /search/mymodule) so that users can easily find it.

Functions & methods


Name Description
hook_search_access Define access to a custom search routine.
hook_search_admin Add elements to the search settings form.
hook_search_execute Execute a search for a set of key words.
hook_search_info Define a custom search type.
hook_search_preprocess Preprocess text for search.
hook_search_reset Take action when the search index is going to be rebuilt.
Name Description
hook_search_status Report the status of indexing.
hook_update_index Update the search index for this module.
sample_search_conditions_c
An example conditions callback function for search.
allback
Form builder; Output a search form for the search block's search
search_box
box.
search_box_form_submit Process a block search form submission.
search_data Performs a search by callinghook_search_execute().
Returns snippets from a piece of text, with certain keywords
search_excerpt
highlighted. Used for formatting search results.
search_form Builds a search form.
search_index Update the full-text search index for a particular item.
template_preprocess_search
Process variables for search-block-form.tpl.php.
_block_form
modules/search/search.module, line 897

Node Access System


The node access system determines who can do what to which nodes.
In determining access rights for a node, node_access() first checks whether the user has the
"bypass node access" permission. Such users have unrestricted access to all nodes. user 1 will
always pass this check.
Next, all implementations of hook_node_access() will be called. Each implementation may
explicitly allow, explicitly deny, or ignore the access request. If at least one module says to deny
the request, it will be rejected. If no modules deny the request and at least one says to allow it, the
request will be permitted.
If all modules ignore the access request, then the node_access table is used to determine access.
All node access modules are queried using hook_node_grants() to assemble a list of "grant IDs"
for the user. This list is compared against the table. If any row contains the node ID in question (or
0, which stands for "all nodes"), one of the grant IDs returned, and a value of TRUE for the
operation in question, then access is granted. Note that this table is a list of grants; any matching
row is sufficient to grant access to the node.
In node listings, the process above is followed except that hook_node_access() is not called on
each node for performance reasons and for proper functioning of the pager system. When adding
a node listing to your module, be sure to use a dynamic query created by db_select() and add a
tag of "node_access" to ensure that only nodes to which the user has access are retrieved.
Note: Even a single module returning NODE_ACCESS_DENY from hook_node_access() will block
access to the node. Therefore, implementers should take care to not deny access unless they
really intend to. Unless a module wishes to actively deny access it should return
NODE_ACCESS_IGNORE (or simply return nothing) to allow other modules or the node_access
table to control access.
To see how to write a node access module of your own, see node_access_example.module.

Functions & methods


Name Description
hook_node_access Control access to a node.
Set permissions for a node to be written to the
hook_node_access_records
database.
Alter permissions for a node before it is written to
hook_node_access_records_alter
the database.
Name Description
Inform the node access system what permissions
hook_node_grants
the user has.
Alter user access rules when trying to view, edit or
hook_node_grants_alter
delete a node.
Determine whether the current user may perform
node_access
the given operation on the specified node.
Gets the list of node access grants and writes them
node_access_acquire_grants
to the database.
Fetch an array of permission IDs granted to the
node_access_grants
given user ID.
Flag / unflag the node access grants for rebuilding,
node_access_needs_rebuild
or read the current value of the flag.
Rebuild the node access database. This is
node_access_rebuild occasionally needed by modules that make
system-wide changes to access levels.
Determines whether the user has a global viewing
node_access_view_all_nodes
grant for all nodes.
Writes a list of grants to the database, deleting any
node_access_write_grants
previously saved ones.
Helper function to generate standard node
node_list_permissions
permission list for a given type.
node_node_access Implements hook_node_access().
Returns an array of node types that should be
node_permissions_get_configured_types
managed by permissions.
node_query_entity_field_access_alter Implements hook_query_TAG_alter().
node_query_node_access_alter Implements hook_query_TAG_alter().
_node_access_rebuild_batch_finished Post-processing for node_access_rebuild_batch.
_node_access_rebuild_batch_operation Batch operation for node_access_rebuild_batch.
_node_query_node_access_alter Helper for node access functions.
modules/node/node.module, line 2726

Theme System
Functions and templates that present output to the user, and can be implemented by themes.
Drupal's presentation layer is a pluggable system known as the theme layer. Each theme can take
control over most of Drupal's output, and has complete control over the CSS.
Inside Drupal, the theme layer is utilized by the use of the theme() function, which is passed the
name of a component (the theme hook) and an array of variables. For example, theme('table',
array('header' => $header, 'rows' => $rows)); Additionally, the theme() function can take an array of
theme hooks, which can be used to provide 'fallback' implementations to allow for more specific
control of output. For example, the function: theme(array('table__foo', 'table'), $variables) would
look to see if 'table__foo' is registered anywhere; if it is not, it would 'fall back' to the generic 'table'
implementation. This can be used to attach specific theme functions to named objects, allowing the
themer more control over specific types of output.
As of Drupal 6, every theme hook is required to be registered by the module that owns it, so that
Drupal can tell what to do with it and to make it simple for themes to identify and override the
behavior for these calls.
The theme hooks are registered via hook_theme(), which returns an array of arrays with
information about the hook. It describes the arguments the function or template will need, and
provides defaults for the template in case they are not filled in. If the default implementation is a
function, by convention it is named theme_HOOK().
Each module should provide a default implementation for theme_hooks that it registers. This
implementation may be either a function or a template; if it is a function it must be specified via
hook_theme(). By convention, default implementations of theme hooks are named theme_HOOK.
Default template implementations are stored in the module directory.
Drupal's default template renderer is a simple PHP parsing engine that includes the template and
stores the output. Drupal's theme engines can provide alternate template engines, such as
XTemplate, Smarty and PHPTal. The most common template engine is PHPTemplate (included
with Drupal and implemented in phptemplate.engine, which uses Drupal's default template
renderer.
In order to create theme-specific implementations of these hooks, themes can implement their own
version of theme hooks, either as functions or templates. These implementations will be used
instead of the default implementation. If using a pure .theme without an engine, the .theme is
required to implement its own version of hook_theme() to tell Drupal what it is implementing;
themes utilizing an engine will have their well-named theming functions automatically registered for
them. While this can vary based upon the theme engine, the standard set by phptemplate is that
theme functions should be named THEMENAME_HOOK. For example, for Drupal's default theme
(Bartik) to implement the 'table' hook, the phptemplate.engine would find bartik_table().
The theme system is described and defined in theme.inc.
End of "defgroup themeable".

See also
theme()
hook_theme()

Functions & methods


Name Description
Returns HTML for an administrative block for
theme_admin_block
display.
Returns HTML for the content of an
theme_admin_block_content
administrative block.
theme_admin_page Returns HTML for an administrative page.
Returns HTML for an individual feed item for
theme_aggregator_block_item
display in the block.
Returns HTML for the aggregator page list form
theme_aggregator_categorize_items
for assigning categories.
Implemented using the aggregator-feed-
theme_aggregator_feed_source
source.tpl.php template.
Implemented using the aggregator-
theme_aggregator_item
item.tpl.phptemplate.
theme_aggregator_page_opml Prints the OPML page for a feed.
theme_aggregator_page_rss Prints the RSS page for a feed.
Implemented using the aggregator-summary-
theme_aggregator_summary_item
item.tpl.php template.
Implemented using the aggregator-summary-
theme_aggregator_summary_items
items.tpl.php template.
Implemented using the aggregator-
theme_aggregator_wrapper
wrapper.tpl.phptemplate.
Returns HTML for a single log message from
theme_authorize_message
theauthorize.php batch operation.
Returns HTML for a report of the results from an
theme_authorize_report
operation run via authorize.php.
theme_block Implemented using the block.tpl.php template.
theme_block_admin_display_form Implemented using the block-admin-display-
Name Description
form.tpl.php template.
theme_book_admin_table Returns HTML for a book administration form.
Implemented using the book-all-books-
theme_book_all_books_block
block.tpl.phptemplate.
Implemented using the book-export-
theme_book_export_html
html.tpl.phptemplate.
Implemented using the book-
theme_book_navigation
navigation.tpl.phptemplate.
Implemented using the book-node-export-
theme_book_node_export_html
html.tpl.php template.
Returns HTML for a link to a book title when used
theme_book_title_link
as a block title.
theme_breadcrumb Returns HTML for a breadcrumb trail.
theme_button Returns HTML for a button form element.
theme_checkbox Returns HTML for a checkbox form element.
Returns HTML for a set of checkbox form
theme_checkboxes
elements.
theme_color_scheme_form Returns HTML for a theme's color form.
Implemented using
theme_comment
the comment.tpl.php template.
Returns HTML for a list of recent comments to be
theme_comment_block
displayed in the comment block.
Returns HTML for a "you can't post comments"
theme_comment_post_forbidden
notice.
Implemented using the comment-
theme_comment_wrapper
wrapper.tpl.phptemplate.
theme_confirm_form Returns HTML for a confirmation form.
Returns HTML for a container for grouped form
theme_container
items.
theme_dashboard Returns HTML for the entire dashboard.
Returns HTML for the non-customizable part of
theme_dashboard_admin
the dashboard page.
Returns HTML for a disabled block, for display in
theme_dashboard_disabled_block
dashboard customization mode.
Returns HTML for a set of disabled blocks, for
theme_dashboard_disabled_blocks
display in dashboard customization mode.
theme_dashboard_region Returns HTML for a generic dashboard region.
theme_date Returns HTML for a date selection form element.
theme_dblog_message Returns HTML for a log message.
theme_exposed_filters Returns HTML for an exposed filter form.
theme_feed_icon Returns HTML for a feed icon.
theme_field Returns HTML for a field.
Returns HTML for a fieldset form element and its
theme_fieldset
children.
theme_field_multiple_value_form Returns HTML for an individual form element.
Implemented using the field_ui-display-overview-
theme_field_ui_display_overview_table
table.tpl.php template.
Implemented using the field_ui-field-overview-
theme_field_ui_field_overview_form
form.tpl.php template.
theme_field_ui_table Returns HTML for Field UI overview tables.
theme_file Returns HTML for a file upload form element.
theme_file_formatter_table Returns HTML for a file attachments table.
Returns HTML for an image with an appropriate
theme_file_icon
icon for the given file.
Name Description
theme_file_link Returns HTML for a link to a file.
theme_file_managed_file Returns HTML for a managed file element.
Returns HTML for help text based on file upload
theme_file_upload_help
validators.
theme_file_widget Returns HTML for an individual file upload widget.
theme_file_widget_multiple Returns HTML for a group of file upload widgets.
theme_filter_admin_format_filter_order Returns HTML for a text format's filter order form.
Returns HTML for the text format administration
theme_filter_admin_overview
overview form.
theme_filter_guidelines Returns HTML for guidelines for a text format.
theme_filter_tips Returns HTML for a set of filter tips.
Returns HTML for a link to the more extensive
theme_filter_tips_more_info
filter tips.
theme_form Returns HTML for a form.
theme_form_element Returns HTML for a form element.
Returns HTML for a form element label and
theme_form_element_label
required marker.
Returns HTML for a marker for required form
theme_form_required_marker
elements.
theme_forums Implemented using the forums.tpl.php template.
theme_forum_form Returns HTML for a forum form.
Implemented using the forum-
theme_forum_icon
icon.tpl.phptemplate.
Implemented using the forum-
theme_forum_list
list.tpl.php template.
Implemented using the forum-
theme_forum_submitted
submitted.tpl.phptemplate.
Implemented using the forum-topic-
theme_forum_topic_list
list.tpl.phptemplate.
theme_hidden Returns HTML for a hidden form element.
theme_html Implemented using the html.tpl.php template.
Returns HTML for a generic HTML tag with
theme_html_tag
attributes.
theme_image Returns HTML for an image.
Returns HTML for a 3x3 grid of checkboxes for
theme_image_anchor
image anchors.
theme_image_button Returns HTML for an image button form element.
Returns HTML for a summary of an image crop
theme_image_crop_summary
effect.
theme_image_formatter Returns HTML for an image field formatter.
Returns HTML for a summary of an image resize
theme_image_resize_summary
effect.
Returns HTML for a summary of an image rotate
theme_image_rotate_summary
effect.
Returns HTML for a summary of an image scale
theme_image_scale_summary
effect.
Returns HTML for an image using a specific
theme_image_style
image style.
Returns HTML for a listing of the effects within a
theme_image_style_effects
specific image style.
Returns HTML for the page containing the list of
theme_image_style_list
image styles.
theme_image_style_preview Returns HTML for a preview of an image style.
theme_image_widget Returns HTML for an image field widget.
Name Description
Returns HTML for an indentation div; used for
theme_indentation
drag and drop tables.
theme_item_list Returns HTML for a list or nested list of items.
theme_link Returns HTML for a link.
theme_links Returns HTML for a set of links.
theme_locale_date_format_form Returns HTML for a locale date format form.
theme_locale_languages_configure_form Returns HTML for a language configuration form.
theme_locale_languages_overview_form Returns HTML for the language overview form.
Implemented using the maintenance-
theme_maintenance_page
page.tpl.phptemplate.
Returns HTML for a marker for new or updated
theme_mark
content.
Returns HTML for a menu title and description for
theme_menu_admin_overview
the menu overview page.
theme_menu_link Returns HTML for a menu link and submenu.
theme_menu_local_action Returns HTML for a single local action link.
theme_menu_local_task Returns HTML for a single local task link.
theme_menu_local_tasks Returns renderable local tasks.
Returns HTML for the menu overview form into a
theme_menu_overview_form
table.
theme_menu_tree Returns HTML for a wrapper for a menu sub-tree.
theme_more_help_link Returns HTML for a "more help" link.
Returns HTML for a "more" link, like those used in
theme_more_link
blocks.
theme_node Implemented using the node.tpl.php template.
Returns HTML for a list of available node types
theme_node_add_list
for node creation.
Returns HTML for a node type description for the
theme_node_admin_overview
content type admin overview page.
Returns HTML for a node preview for display
theme_node_preview
during node creation and editing.
theme_node_recent_block Returns HTML for a list of recent content.
Returns HTML for a recent node to be displayed
theme_node_recent_content
in the recent content block.
Returns HTML for the content ranking part of the
theme_node_search_admin
search settings admin page.
Returns HTML for the label for the empty value
theme_options_none
for options that are not required.
theme_page Implemented using the page.tpl.php template.
theme_pager Returns HTML for a query pager.
Returns HTML for the "first page" link in a query
theme_pager_first
pager.
Returns HTML for the "last page" link in query
theme_pager_last
pager.
Returns HTML for a link to a specific query result
theme_pager_link
page.
Returns HTML for the "next page" link in a query
theme_pager_next
pager.
Returns HTML for the "previous page" link in a
theme_pager_previous
query pager.
theme_password Returns HTML for a password form element.
theme_poll_bar Implemented using the poll-bar.tpl.php template.
Implemented using the poll-bar--
theme_poll_bar__block
block.tpl.phptemplate.
Name Description
theme_poll_choices Returns HTML for an admin poll form for choices.
Implemented using the poll-
theme_poll_results
results.tpl.phptemplate.
Implemented using the poll-results--
theme_poll_results__block
block.tpl.phptemplate.
Implemented using the poll-
theme_poll_vote
vote.tpl.php template.
Returns HTML for the profile field overview form
theme_profile_admin_overview
into a drag and drop enabled table.
Implemented using the profile-
theme_profile_block
block.tpl.phptemplate.
Implemented using the profile-
theme_profile_listing
listing.tpl.phptemplate.
Implemented using the profile-
theme_profile_wrapper
wrapper.tpl.phptemplate.
theme_progress_bar Returns HTML for a progress bar.
theme_radio Returns HTML for a radio button form element.
Returns HTML for a set of radio button form
theme_radios
elements.
Returns HTML for a series of empty spans for
theme_rdf_metadata
exporting RDF metadata in RDFa.
Returns HTML for a template variable wrapped in
theme_rdf_template_variable_wrapper
an HTML element with the RDF attributes.
theme_region Implemented using the region.tpl.php template.
Implemented using the search-block-
theme_search_block_form
form.tpl.phptemplate.
Implemented using the search-
theme_search_result
result.tpl.phptemplate.
Implemented using the search-
theme_search_results
results.tpl.phptemplate.
theme_select Returns HTML for a select form element.
Returns HTML for a shortcut set customization
theme_shortcut_set_customize
form.
Returns HTML for the summary status of a
theme_simpletest_result_summary
simpletest result.
Returns HTML for a test list generated
theme_simpletest_test_table
bysimpletest_test_form() into a table.
Returns HTML for status and/or error messages,
theme_status_messages
grouped by type.
theme_status_report Returns HTML for the status report.
theme_submit Returns HTML for a submit button form element.
Returns HTML for the output of the dashboard
theme_system_admin_index
page.
Returns HTML for a link to show or hide inline
theme_system_compact_link
help descriptions.
theme_system_date_time_settings Returns HTML for the date settings form.
theme_system_modules_fieldset Returns HTML for the modules form.
Returns HTML for a message about incompatible
theme_system_modules_incompatible
modules.
Returns HTML for a table of currently disabled
theme_system_modules_uninstall
modules.
theme_system_powered_by Returns HTML for the Powered by Drupal text.
theme_system_settings_form Returns HTML for a system settings form.
theme_system_themes_page Returns HTML for the Appearance page.
Name Description
theme_table Returns HTML for a table.
Returns HTML for a table with radio buttons or
theme_tableselect
checkboxes.
theme_tablesort_indicator Returns HTML for a sort icon.
Returns HTML for a list of maintenance tasks to
theme_task_list
perform.
Returns HTML for a terms overview form as a
theme_taxonomy_overview_terms
sortable list of terms.
Returns HTML for the vocabulary overview form
theme_taxonomy_overview_vocabularies
as a sortable list of vocabularies.
Implemented using the taxonomy-
theme_taxonomy_term
term.tpl.phptemplate.
theme_textarea Returns HTML for a textarea form element.
theme_textfield Returns HTML for a textfield form element.
Returns HTML for a text format-enabled form
theme_text_format_wrapper
element.
theme_toolbar Implemented using the toolbar.tpl.php template.
Returns HTML for the form showing actions
theme_trigger_display
assigned to a trigger.
Returns HTML for the last time we checked for
theme_update_last_check
update data.
Returns HTML for the first page in the update
theme_update_manager_update_form
manager wizard to select projects.
theme_update_report Returns HTML for the project status report.
theme_update_version Returns HTML for the version display of a project.
Returns HTML for a username, potentially linked
theme_username
to the user's page.
Returns HTML for the administer permissions
theme_user_admin_permissions
page.
Returns HTML for the role order and new role
theme_user_admin_roles
form.
theme_user_list Returns HTML for a list of users.
Returns HTML for an individual permission
theme_user_permission_description
description.
Implemented using the user-
theme_user_picture
picture.tpl.phptemplate.
Implemented using the user-
theme_user_profile
profile.tpl.phptemplate.
Implemented using the user-profile-
theme_user_profile_category
category.tpl.phptemplate.
Implemented using the user-profile-
theme_user_profile_item
item.tpl.phptemplate.
theme_user_signature Returns HTML for a user signature.
Returns HTML for an element's children
theme_vertical_tabs
fieldsets as vertical tabs.
modules/system/theme.api.php, line 4

Constants
See http://api.drupal.org/api/drupal/constants/7
Global variables
Name Location Description
The base path of the Drupal
$base_path developer/globals.php
installation.
The root URL of the host, excluding the
$base_root developer/globals.php
path.
An array of objects that represent the
$base_theme_info developer/globals.php
base theme.
The base URL of the Drupal
$base_url developer/globals.php
installation.
An associative array containing title,
$channel developer/globals.php
link, description and other keys.
Array of persistent variables stored in
$conf developer/globals.php
'variable' table.
The domain to be used for session
$cookie_domain developer/globals.php
cookies.
Name of custom theme to override
$custom_theme developer/globals.php
default theme.
$databases developer/globals.php Array of database connections.
modules/simpletest/drupal_ Global variable that holds information
$drupal_test_info
web_test_case.php about the tests being run.
Structured array describing the data to
$element developer/globals.php
be rendered.
An array of forum topic header
$forum_topic_list_header developer/globals.php
information.
Current image tag used by aggregator
$image developer/globals.php
parsing.
The name of the profile that has just
$installed_profile developer/globals.php
been installed.
$item developer/globals.php General string or array.
$items developer/globals.php Array of items used by aggregator.
An object containing the information
$language developer/globals.php
for the active interface language.
An object containing the information
$language_content developer/globals.php
for the active content language.
An object containing the information
$language_url developer/globals.php
for the active URL language.
Boolean indicating that a menu
$menu_admin developer/globals.php administrator is running a menu access
check.
$multibyte developer/globals.php The current multibyte mode.
Array of the number of items per page
$pager_limits developer/globals.php
for each pager.
Array of current page numbers for each
$pager_page_array developer/globals.php
pager.
Array of the total number of pages for
$pager_total developer/globals.php
each pager.
Array of the total number of items for
$pager_total_items developer/globals.php
each pager.
$tag developer/globals.php Active tag name.
$theme developer/globals.php Name of the active theme.
The theme engine related to the active
$theme_engine developer/globals.php
theme.
$theme_info developer/globals.php Active theme object.
Name Location Description
$theme_key developer/globals.php Name of the active theme.
$theme_path developer/globals.php The path to the active theme.
Timers that have been created
$timers developer/globals.php
bytimer_start().
Allows the update.php script to be run
$update_free_access developer/globals.php
when not logged in as administrator.
An object representing the currently
$user developer/globals.php
logged-in user.

2010-11-10
THE END! ( or is it, the beginning? )

You might also like