common.inc

Version 1.1291 (checked in on 2011/02/19 at 13:19:26 by dries)

Common functions that many Drupal modules will need to reference.

The functions that are critical and need to be available even when serving a cached page are instead located in bootstrap.inc.

Functions & methods

NameDescription
archiver_get_archiverCreate the appropriate archiver for the specified file.
archiver_get_extensionsReturns a string of supported archive extensions.
archiver_get_infoRetrieves a list of all available archivers.
base_pathReturn the base URL path (i.e., directory) of the Drupal installation.
check_urlStrips dangerous protocols (e.g. 'javascript:') from a URI and encodes it for output to an HTML attribute value.
date_iso8601Returns an ISO8601 formatted date based on the given date.
debugDebug function used for outputting debug information.
drupal_access_deniedDeliver a "access denied" error to the browser.
drupal_add_cssAdds a cascading stylesheet to the stylesheet queue.
drupal_add_feedAdd a feed URL for the current page.
drupal_add_html_headAdd output to the head tag of the HTML page.
drupal_add_html_head_linkAdd a LINK tag with a distinct 'rel' attribute to the page's HEAD.
drupal_add_jsAdds a JavaScript file, setting, or inline code to the page.
drupal_add_libraryAdds multiple JavaScript or CSS files at the same time.
drupal_add_region_contentAdd content to a specified region.
drupal_add_tabledragAssist in adding the tableDrag JavaScript behavior to a themed table.
drupal_aggregate_cssDefault callback to aggregate CSS files and inline content.
drupal_array_get_nested_valueRetrieves a value from a nested array with variable depth.
drupal_array_nested_key_existsDetermines whether a nested array with variable depth contains all of the requested keys.
drupal_array_set_nested_valueSets a value in a nested array with variable depth.
drupal_attributesConverts an associative array to an attribute string for use in XML/HTML tags.
drupal_build_css_cacheAggregates and optimizes CSS files into a cache file in the files directory.
drupal_build_js_cacheAggregates JavaScript files into a cache file in the files directory.
drupal_check_incompatibilityCheck whether a version is compatible with a given dependency.
drupal_clean_css_identifierPrepare a string for use as a valid CSS identifier (element, class or ID name).
drupal_clear_css_cacheDeletes old cached CSS files.
drupal_clear_js_cacheDeletes old cached JavaScript files and variables.
drupal_common_themeProvide theme registration for themes across .inc files.
drupal_cron_cleanupShutdown function for cron cleanup.
drupal_cron_runExecutes a cron run when called.
drupal_delete_file_if_staleCallback to delete files modified more than a set time ago.
drupal_deliver_html_pagePackage and send the result of a page callback to the browser as HTML.
drupal_deliver_pageDelivers a page callback result to the browser in the appropriate format.
drupal_encode_pathEncodes a Drupal path for use in a URL.
drupal_exitPerform end-of-request tasks.
drupal_explode_tagsExplode a string of given tags into an array.
drupal_flush_all_cachesFlush all cached data on the site.
drupal_get_breadcrumbGet the breadcrumb trail for the current page.
drupal_get_cssReturns a themed representation of all stylesheets that should be attached to the page.
drupal_get_destinationPrepare a 'destination' URL query parameter for use in combination with drupal_goto().
drupal_get_feedsGet the feed URLs for the current page.
drupal_get_filetransfer_infoDrupal FileTransfer registry.
drupal_get_hash_saltGet a salt useful for hardening against SQL injection.
drupal_get_html_headRetrieve output to be displayed in the HEAD tag of the HTML page.
drupal_get_jsReturns a themed presentation of all JavaScript code for the current page.
drupal_get_libraryRetrieves information for a JavaScript/CSS library.
drupal_get_pathReturns the path to a system item (module, theme, etc.).
drupal_get_private_keyEnsure the private key variable used to generate tokens is set.
drupal_get_profileGet the name of the currently active install profile.
drupal_get_query_arraySplit an URL-encoded query string into an array.
drupal_get_query_parametersProcess a URL query parameter array to remove unwanted elements.
drupal_get_rdf_namespacesReturns a string containing RDF namespace declarations for use in XML and XHTML output.
drupal_get_region_contentGet assigned content for a given region.
drupal_get_schema_unprocessedReturns the unprocessed and unaltered version of a module's schema.
drupal_get_tokenGenerate a token based on $value, the current user session and private key.
drupal_get_updatersDrupal Updater registry.
drupal_gotoSend the user to a different Drupal page.
drupal_group_cssDefault callback to group CSS items.
drupal_html_classPrepare a string for use as a valid class name.
drupal_html_idPrepare a string for use as a valid HTML ID and guarantee uniqueness.
drupal_http_build_queryParse an array into a valid, rawurlencoded query string.
drupal_http_header_attributesFormat an attribute string for a HTTP header.
drupal_http_requestPerform an HTTP request.
drupal_implode_tagsImplode an array of tags into a string.
drupal_install_schemaCreates all tables in a module's hook_schema() implementation.
drupal_json_decodeConverts an HTML-safe JSON string into its PHP equivalent.
drupal_json_encodeConverts a PHP variable into its JavaScript equivalent.
drupal_json_outputReturn data in JSON format.
drupal_js_defaultsConstructs an array of the defaults that are used for JavaScript items.
drupal_load_stylesheetLoads the stylesheet and resolves all @import commands.
drupal_load_stylesheet_contentProcess the contents of a stylesheet for aggregation.
drupal_map_assocForm an associative array from a linear array.
drupal_not_foundDeliver a "page not found" error to the browser.
drupal_page_footerPerform end-of-request tasks.
drupal_page_set_cacheStore the current page in the cache.
drupal_parse_dependencyParse a dependency for comparison by drupal_check_incompatibility().
drupal_parse_info_fileParses Drupal module and theme .info files.
drupal_parse_info_formatParse data in Drupal's .info format.
drupal_parse_urlWrapper around parse_url() to parse a system URL string into an associative array, suitable for url().
drupal_pre_render_conditional_comments#pre_render callback to render #browsers into #prefix and #suffix.
drupal_pre_render_link#pre_render callback to render a link into #markup.
drupal_pre_render_links#pre_render callback that collects child links into a single array.
drupal_pre_render_markup#pre_render callback to append contents in #markup to #children.
drupal_pre_render_styles#pre_render callback to add the elements needed for CSS tags to be rendered.
drupal_process_attachedAdds attachments to a render() structure.
drupal_process_statesAdds JavaScript to change the state of an element based on another element.
drupal_region_classProvides a standard HTML class name that identifies a page region.
drupal_renderRenders HTML given a structured array tree.
drupal_render_cache_by_queryPrepare an element for caching based on a query. This smart caching strategy saves Drupal from querying and rendering to HTML when the underlying query is unchanged.
drupal_render_cache_getGet the rendered output of a renderable element from cache.
drupal_render_cache_setCache the rendered output of a renderable element.
drupal_render_childrenRender children of an element and concatenate them.
drupal_render_cid_createCreate the cache ID for a renderable element.
drupal_render_cid_partsHelper function for building cache ids.
drupal_render_collect_attachedCollect #attached for an element and all child elements into a single array.
drupal_render_pageRenders the page, including all theming.
drupal_schema_fields_sqlRetrieve a list of fields from a table schema. The list is suitable for use in a SQL query.
drupal_set_breadcrumbSet the breadcrumb trail for the current page.
drupal_set_page_contentSet the main page content value for later use.
drupal_set_time_limitAttempts to set the PHP maximum execution time.
drupal_site_offlineDeliver a "site is under maintenance" message to the browser.
drupal_sort_css_jsFunction used by uasort to sort the array structures returned by drupal_add_css() and drupal_add_js().
drupal_sort_titleArray sorting callback; sorts elements by 'title' key.
drupal_sort_weightFunction used by uasort to sort structured arrays by weight, without the property weight prefix.
drupal_strip_dangerous_protocolsStrips dangerous protocols (e.g. 'javascript:') from a URI.
drupal_system_listingReturns information about system object files (modules, themes, etc.).
drupal_uninstall_schemaRemove all tables that a module defines in its hook_schema().
drupal_valid_tokenValidate a token based on $value, the current user session and private key.
drupal_write_recordSaves (inserts or updates) a record to the database based upon the schema.
element_childCheck if the key is a child.
element_childrenReturn the children of an element, optionally sorted by weight.
element_get_visible_childrenReturn the visibile children of an element.
element_infoRetrieve the default properties for the defined element type.
element_info_propertyRetrieve a single property for the defined element type.
element_propertiesGet properties of a structured array element. Properties begin with '#'.
element_propertyCheck if the key is a property.
element_set_attributesSets HTML attributes based on element properties.
element_sortFunction used by uasort to sort structured arrays by weight.
element_sort_by_titleArray sorting callback; sorts elements by title.
entity_create_stub_entityHelper function to assemble an object structure with initial ids.
entity_extract_idsHelper function to extract id, vid, and bundle name from an entity.
entity_form_field_validateHelper function for attaching field API validation to entity forms.
entity_form_submit_build_entityHelper function for copying submitted values to entity properties for simple entity forms.
entity_get_controllerGet the entity controller class for an entity type.
entity_get_infoGet the entity info array of an entity type.
entity_info_cache_clearResets the cached information about entity types.
entity_labelReturns the label of an entity.
entity_loadLoad entities from the database.
entity_load_unchangedLoads the unchanged, i.e. not modified, entity from the database.
entity_prepare_viewInvoke hook_entity_prepare_view().
entity_uriReturns the uri elements of an entity.
filter_xssFilters an HTML string to prevent cross-site-scripting (XSS) vulnerabilities.
filter_xss_adminVery permissive XSS/HTML filter for admin-only use.
filter_xss_bad_protocolProcesses an HTML attribute value and ensures it does not contain an URL with a disallowed protocol (e.g. javascript:).
fix_gpc_magicFix double-escaping problems caused by "magic quotes" in some PHP installations.
flood_clear_eventMake the flood control mechanism forget about an event for the current visitor.
flood_is_allowedChecks whether user is allowed to proceed with the specified event.
flood_register_eventRegister an event for the current visitor to the flood control mechanism.
format_dateFormats a date, using a date type or a custom date format string.
format_intervalFormat a time interval with the requested granularity.
format_pluralFormat a string containing a count of items.
format_rss_channelFormats an RSS channel.
format_rss_itemFormat a single RSS item.
format_sizeGenerate a string representation for the given byte count.
format_usernameFormat a username.
format_xml_elementsFormat XML elements.
hideHide an element from later rendering.
lFormats an internal or external URL link as an HTML anchor tag.
parse_sizeParse a given byte count.
renderRender an element.
showShow a hidden element for later rendering.
urlGenerates an internal or external URL.
url_is_externalReturn TRUE if a path is external to Drupal (e.g. http://example.com).
valid_email_addressVerify the syntax of the given e-mail address.
valid_urlVerify the syntax of the given URL.
watchdog_severity_levelsSeverity levels, as defined in RFC 3164: http://www.ietf.org/rfc/rfc3164.txt.
xmlrpcPerforms one or more XML-RPC request(s).
_drupal_bootstrap_full
_drupal_build_css_pathHelper function for drupal_build_css_cache().
_drupal_default_html_headReturns elements that are always displayed in the HEAD tag of the HTML page.
_drupal_flush_css_jsHelper function to change query-strings on css/js files.
_drupal_load_stylesheetLoads stylesheets recursively and returns contents with corrected paths.
_drupal_schema_initializeFill in required default values for table definitions returned by hook_schema().
_filter_xss_attributesProcesses a string of HTML attributes.
_filter_xss_splitProcesses an HTML tag.
_fix_gpc_magic
_fix_gpc_magic_filesHelper function to strip slashes from $_FILES skipping over the tmp_name keys since PHP generates single backslashes for file paths on Windows systems.
_format_date_callbackCallback function for preg_replace_callback().

Constants

NameDescription
CSS_DEFAULTThe default group for module CSS files added to the page.
CSS_SYSTEMThe default group for system CSS files added to the page.
CSS_THEMEThe default group for theme CSS files added to the page.
DRUPAL_CACHE_CUSTOMThe block is handling its own caching in its hook_block_view(). From the perspective of the block cache system, this is equivalent to DRUPAL_NO_CACHE. Useful when time based expiration is needed or a site uses a node access which invalidates standard…
DRUPAL_CACHE_GLOBALThe block or element is the same for every user on every page where it is visible.
DRUPAL_CACHE_PER_PAGEThe block or element can change depending on the page being viewed.
DRUPAL_CACHE_PER_ROLEThe block or element can change depending on the roles the user viewing the page belongs to. This is the default setting for blocks, used when the block does not specify anything.
DRUPAL_CACHE_PER_USERThe block or element can change depending on the user viewing the page. This setting can be resource-consuming for sites with large number of users, and thus should only be used when DRUPAL_CACHE_PER_ROLE is not sufficient.
DRUPAL_NO_CACHEThe block should not get cached. This setting should be used:
HTTP_REQUEST_TIMEOUTError code indicating that the request made by drupal_http_request() exceeded the specified timeout.
JS_DEFAULTThe default group for module JavaScript code added to the page.
JS_LIBRARYThe default group for JavaScript libraries, settings or jQuery plugins added to the page.
JS_THEMEThe default group for theme JavaScript code added to the page.
SAVED_DELETEDReturn status for saving which deleted an existing item.
SAVED_NEWReturn status for saving which involved creating a new item.
SAVED_UPDATEDReturn status for saving which involved an update to an existing item.