[ Index ]

PHP Cross Reference of Drupal 6 (yi-drupal)

title

Body

[close]

/includes/ -> common.inc (summary)

(no description)

File Size: 3837 lines (133 kb)
Included or required: 5 times
Referenced: 3 times
Includes or requires: 11 files
 includes/image.inc
 includes/tablesort.inc
 includes/xmlrpc.inc
 includes/form.inc
 includes/actions.inc
 includes/mail.inc
 includes/menu.inc
 includes/pager.inc
 includes/file.inc
 includes/unicode.inc
 includes/theme.inc

Defines 94 functions

  drupal_set_content()
  drupal_get_content()
  drupal_set_breadcrumb()
  drupal_get_breadcrumb()
  drupal_set_html_head()
  drupal_get_html_head()
  drupal_clear_path_cache()
  drupal_set_header()
  drupal_get_headers()
  drupal_final_markup()
  drupal_add_feed()
  drupal_get_feeds()
  drupal_query_string_encode()
  drupal_get_destination()
  drupal_goto()
  drupal_site_offline()
  drupal_not_found()
  drupal_access_denied()
  drupal_http_request()
  drupal_error_handler()
  _fix_gpc_magic()
  _fix_gpc_magic_files()
  fix_gpc_magic()
  t()
  valid_email_address()
  valid_url()
  flood_register_event()
  flood_is_allowed()
  check_file()
  check_url()
  format_rss_channel()
  format_rss_item()
  format_xml_elements()
  format_plural()
  parse_size()
  format_size()
  format_interval()
  format_date()
  url()
  drupal_attributes()
  l()
  drupal_page_footer()
  drupal_map_assoc()
  drupal_eval()
  drupal_get_path()
  base_path()
  drupal_clone()
  drupal_add_link()
  drupal_add_css()
  drupal_get_css()
  drupal_build_css_cache()
  _drupal_build_css_path()
  drupal_load_stylesheet()
  _process_comment()
  _drupal_load_stylesheet()
  drupal_clear_css_cache()
  drupal_add_js()
  drupal_get_js()
  drupal_add_tabledrag()
  drupal_build_js_cache()
  drupal_clear_js_cache()
  drupal_to_js()
  drupal_json()
  drupal_urlencode()
  drupal_get_private_key()
  drupal_get_token()
  drupal_valid_token()
  xmlrpc()
  _drupal_bootstrap_full()
  page_set_cache()
  drupal_cron_run()
  drupal_cron_cleanup()
  drupal_system_listing()
  drupal_alter()
  drupal_render()
  element_sort()
  element_property()
  element_properties()
  element_child()
  element_children()
  drupal_common_theme()
  drupal_get_schema()
  drupal_install_schema()
  drupal_uninstall_schema()
  drupal_get_schema_unprocessed()
  _drupal_initialize_schema()
  drupal_schema_fields_sql()
  drupal_write_record()
  drupal_parse_info_file()
  watchdog_severity_levels()
  drupal_explode_tags()
  drupal_implode_tags()
  drupal_flush_all_caches()
  _drupal_flush_css_js()

Functions
Functions that are not part of a class:

drupal_set_content($region = NULL, $data = NULL)   X-Ref
Set content for a specified region.

param: $region
param: $data

drupal_get_content($region = NULL, $delimiter = ' ')   X-Ref
Get assigned content.

param: $region
param: $delimiter

drupal_set_breadcrumb($breadcrumb = NULL)   X-Ref
Set the breadcrumb trail for the current page.

param: $breadcrumb

drupal_get_breadcrumb()   X-Ref
Get the breadcrumb trail for the current page.


drupal_set_html_head($data = NULL)   X-Ref
Add output to the head tag of the HTML page.

This function can be called as long the headers aren't sent.

drupal_get_html_head()   X-Ref
Retrieve output to be displayed in the head tag of the HTML page.


drupal_clear_path_cache()   X-Ref
Reset the static variable which holds the aliases mapped for this request.


drupal_set_header($header = NULL)   X-Ref
Set an HTTP response header for the current page.

Note: When sending a Content-Type header, always include a 'charset' type,
too. This is necessary to avoid security bugs (e.g. UTF-7 XSS).

drupal_get_headers()   X-Ref
Get the HTTP response headers for the current page.


drupal_final_markup($content)   X-Ref
Make any final alterations to the rendered xhtml.


drupal_add_feed($url = NULL, $title = '')   X-Ref
Add a feed URL for the current page.

param: $url
param: $title

drupal_get_feeds($delimiter = "\n")   X-Ref
Get the feed URLs for the current page.

param: $delimiter

drupal_query_string_encode($query, $exclude = array()   X-Ref
Parse an array into a valid urlencoded query string.

param: $query
param: $exclude
param: $parent
return:

drupal_get_destination()   X-Ref
Prepare a destination query string for use in combination with drupal_goto().

Used to direct the user back to the referring page after completing a form.
By default the current URL is returned. If a destination exists in the
previous request, that destination is returned. As such, a destination can
persist across multiple pages.


drupal_goto($path = '', $query = NULL, $fragment = NULL, $http_response_code = 302)   X-Ref
Send the user to a different Drupal page.

This issues an on-site HTTP redirect. The function makes sure the redirected
URL is formatted correctly.

Usually the redirected URL is constructed from this function's input
parameters. However you may override that behavior by setting a
destination in either the $_REQUEST-array (i.e. by using
the query string of an URI) or the $_REQUEST['edit']-array (i.e. by
using a hidden form field). This is used to direct the user back to
the proper page after completing a form. For example, after editing
a post on the 'admin/content/node'-page or after having logged on using the
'user login'-block in a sidebar. The function drupal_get_destination()
can be used to help set the destination URL.

Drupal will ensure that messages set by drupal_set_message() and other
session data are written to the database before the user is redirected.

This function ends the request; use it rather than a print theme('page')
statement in your menu callback.

param: $path
param: $query
param: $fragment
param: $http_response_code

drupal_site_offline()   X-Ref
Generates a site off-line message.


drupal_not_found()   X-Ref
Generates a 404 error if the request can not be handled.


drupal_access_denied()   X-Ref
Generates a 403 error if the request is not allowed.


drupal_http_request($url, $headers = array()   X-Ref
Perform an HTTP request.

This is a flexible and powerful HTTP client implementation. Correctly handles
GET, POST, PUT or any other HTTP requests. Handles redirects.

param: $url
param: $headers
param: $method
param: $data
param: $retry
param: $timeout
return:

drupal_error_handler($errno, $message, $filename, $line, $context)   X-Ref
Log errors as defined by administrator.

Error levels:
- 0 = Log errors to database.
- 1 = Log errors to database and to screen.

_fix_gpc_magic(&$item)   X-Ref
No description

_fix_gpc_magic_files(&$item, $key)   X-Ref
Helper function to strip slashes from $_FILES skipping over the tmp_name keys
since PHP generates single backslashes for file paths on Windows systems.

tmp_name does not have backslashes added see
http://php.net/manual/en/features.file-upload.php#42280

fix_gpc_magic()   X-Ref
Fix double-escaping problems caused by "magic quotes" in some PHP installations.


t($string, $args = array()   X-Ref
Translate strings to the page language or a given language.

Human-readable text that will be displayed somewhere within a page should
be run through the t() function.

Examples:
param: $string
param: $args
param: $langcode
return:

valid_email_address($mail)   X-Ref
Verifies the syntax of the given e-mail address.

See RFC 2822 for details.

param: $mail
return:

valid_url($url, $absolute = FALSE)   X-Ref
Verify the syntax of the given URL.

This function should only be used on actual URLs. It should not be used for
Drupal menu paths, which can contain arbitrary characters.
Valid values per RFC 3986.

param: $url
param: $absolute
return:

flood_register_event($name)   X-Ref
Register an event for the current visitor (hostname/IP) to the flood control mechanism.

param: $name

flood_is_allowed($name, $threshold)   X-Ref
Check if the current visitor (hostname/IP) is allowed to proceed with the specified event.

The user is allowed to proceed if he did not trigger the specified event more
than $threshold times per hour.

param: $name
param: $threshold
return:

check_file($filename)   X-Ref
No description

check_url($uri)   X-Ref
Prepare a URL for use in an HTML attribute. Strips harmful protocols.


format_rss_channel($title, $link, $description, $items, $langcode = NULL, $args = array()   X-Ref
Formats an RSS channel.

Arbitrary elements may be added using the $args associative array.

format_rss_item($title, $link, $description, $args = array()   X-Ref
Format a single RSS item.

Arbitrary elements may be added using the $args associative array.

format_xml_elements($array)   X-Ref
Format XML elements.

param: $array

format_plural($count, $singular, $plural, $args = array()   X-Ref
Format a string containing a count of items.

This function ensures that the string is pluralized correctly. Since t() is
called by this function, make sure not to pass already-localized strings to
it.

For example:
param: $count
param: $singular
param: $plural
param: $args
param: $langcode
return:

parse_size($size)   X-Ref
Parse a given byte count.

param: $size
return:

format_size($size, $langcode = NULL)   X-Ref
Generate a string representation for the given byte count.

param: $size
param: $langcode
return:

format_interval($timestamp, $granularity = 2, $langcode = NULL)   X-Ref
Format a time interval with the requested granularity.

param: $timestamp
param: $granularity
param: $langcode
return:

format_date($timestamp, $type = 'medium', $format = '', $timezone = NULL, $langcode = NULL)   X-Ref
Format a date with the given configured format or a custom format string.

Drupal allows administrators to select formatting strings for 'small',
'medium' and 'large' date formats. This function can handle these formats,
as well as any custom format.

param: $timestamp
param: $type
param: $format
param: $timezone
param: $langcode
return:

url($path = NULL, $options = array()   X-Ref
Generates an internal or external URL.

When creating links in modules, consider whether l() could be a better
alternative than url().

param: $path
param: $options
return:

drupal_attributes($attributes = array()   X-Ref
Format an attribute string to insert in a tag.

param: $attributes
return:

l($text, $path, $options = array()   X-Ref
Formats an internal or external URL link as an HTML anchor tag.

This function correctly handles aliased paths, and adds an 'active' class
attribute to links that point to the current page (for theming), so all
internal links output by modules should be generated by this function if
possible.

param: $text
param: $path
param: $options
return:

drupal_page_footer()   X-Ref
Perform end-of-request tasks.

This function sets the page cache if appropriate, and allows modules to
react to the closing of the page by calling hook_exit().

drupal_map_assoc($array, $function = NULL)   X-Ref
Form an associative array from a linear array.

This function walks through the provided array and constructs an associative
array out of it. The keys of the resulting array will be the values of the
input array. The values will be the same as the keys unless a function is
specified, in which case the output of the function is used for the values
instead.

param: $array
param: $function
return:

drupal_eval($code)   X-Ref
Evaluate a string of PHP code.

This is a wrapper around PHP's eval(). It uses output buffering to capture both
returned and printed text. Unlike eval(), we require code to be surrounded by
<?php ?> tags; in other words, we evaluate the code as if it were a stand-alone
PHP file.

Using this wrapper also ensures that the PHP code which is evaluated can not
overwrite any variables in the calling code, unlike a regular eval() call.

param: $code
return:

drupal_get_path($type, $name)   X-Ref
Returns the path to a system item (module, theme, etc.).

param: $type
param: $name
return:

base_path()   X-Ref
Returns the base URL path of the Drupal installation.
At the very least, this will always default to /.


drupal_clone($object)   X-Ref
Provide a substitute clone() function for PHP4.


drupal_add_link($attributes)   X-Ref
Add a <link> tag to the page's HEAD.


drupal_add_css($path = NULL, $type = 'module', $media = 'all', $preprocess = TRUE)   X-Ref
Adds a CSS file to the stylesheet queue.

param: $path
param: $type
param: $media
param: $preprocess
return:

drupal_get_css($css = NULL)   X-Ref
Returns a themed representation of all stylesheets that should be attached to the page.

It loads the CSS in order, with 'module' first, then 'theme' afterwards.
This ensures proper cascading of styles so themes can easily override
module styles through CSS selectors.

Themes may replace module-defined CSS files by adding a stylesheet with the
same filename. For example, themes/garland/system-menus.css would replace
modules/system/system-menus.css. This allows themes to override complete
CSS files, rather than specific selectors, when necessary.

If the original CSS file is being overridden by a theme, the theme is
responsible for supplying an accompanying RTL CSS file to replace the
module's.

param: $css
return:

drupal_build_css_cache($types, $filename)   X-Ref
Aggregate and optimize CSS files, putting them in the files directory.

param: $types
param: $filename
return:

_drupal_build_css_path($matches, $base = NULL)   X-Ref
Helper function for drupal_build_css_cache().

This function will prefix all paths within a CSS file.

drupal_load_stylesheet($file, $optimize = NULL)   X-Ref
Loads the stylesheet and resolves all @import commands.

Loads a stylesheet and replaces @import commands with the contents of the
imported file. Use this instead of file_get_contents when processing
stylesheets.

The returned contents are compressed removing white space and comments only
when CSS aggregation is enabled. This optimization will not apply for
color.module enabled themes with CSS aggregation turned off.

param: $file
param: $optimize
return:

_process_comment($matches)   X-Ref
Process comment blocks.

This is the callback function for the preg_replace_callback()
used in drupal_load_stylesheet_content(). Support for comment
hacks is implemented here.

_drupal_load_stylesheet($matches)   X-Ref
Loads stylesheets recursively and returns contents with corrected paths.

This function is used for recursive loading of stylesheets and
returns the stylesheet content with all url() paths corrected.

drupal_clear_css_cache()   X-Ref
Delete all cached CSS files.


drupal_add_js($data = NULL, $type = 'module', $scope = 'header', $defer = FALSE, $cache = TRUE, $preprocess = TRUE)   X-Ref
Add a JavaScript file, setting or inline code to the page.

The behavior of this function depends on the parameters it is called with.
Generally, it handles the addition of JavaScript to the page, either as
reference to an existing file or as inline code. The following actions can be
performed using this function:

- Add a file ('core', 'module' and 'theme'):
Adds a reference to a JavaScript file to the page. JavaScript files
are placed in a certain order, from 'core' first, to 'module' and finally
'theme' so that files, that are added later, can override previously added
files with ease.

- Add inline JavaScript code ('inline'):
Executes a piece of JavaScript code on the current page by placing the code
directly in the page. This can, for example, be useful to tell the user that
a new message arrived, by opening a pop up, alert box etc.

- Add settings ('setting'):
Adds a setting to Drupal's global storage of JavaScript settings. Per-page
settings are required by some modules to function properly. The settings
will be accessible at Drupal.settings.

param: $data
param: $type
param: $scope
param: $defer
param: $cache
param: $preprocess
return:

drupal_get_js($scope = 'header', $javascript = NULL)   X-Ref
Returns a themed presentation of all JavaScript code for the current page.

References to JavaScript files are placed in a certain order: first, all
'core' files, then all 'module' and finally all 'theme' JavaScript files
are added to the page. Then, all settings are output, followed by 'inline'
JavaScript code. If running update.php, all preprocessing is disabled.

param: $scope
param: $javascript
return:

drupal_add_tabledrag($table_id, $action, $relationship, $group, $subgroup = NULL, $source = NULL, $hidden = TRUE, $limit = 0)   X-Ref
Assist in adding the tableDrag JavaScript behavior to a themed table.

Draggable tables should be used wherever an outline or list of sortable items
needs to be arranged by an end-user. Draggable tables are very flexible and
can manipulate the value of form elements placed within individual columns.

To set up a table to use drag and drop in place of weight select-lists or
in place of a form that contains parent relationships, the form must be
themed into a table. The table must have an id attribute set. If using
theme_table(), the id may be set as such:
param: $table_id
param: $action
param: $relationship
param: $group
param: $subgroup
param: $source
param: $hidden
param: $limit

drupal_build_js_cache($files, $filename)   X-Ref
Aggregate JS files, putting them in the files directory.

param: $files
param: $filename
return:

drupal_clear_js_cache()   X-Ref
Delete all cached JS files.


drupal_to_js($var)   X-Ref
Converts a PHP variable into its Javascript equivalent.

We use HTML-safe strings, i.e. with <, > and & escaped.

drupal_json($var = NULL)   X-Ref
Return data in JSON format.

This function should be used for JavaScript callback functions returning
data in JSON format. It sets the header for JavaScript output.

param: $var

drupal_urlencode($text)   X-Ref
Wrapper around urlencode() which avoids Apache quirks.

Should be used when placing arbitrary data in an URL. Note that Drupal paths
are urlencoded() when passed through url() and do not require urlencoding()
of individual components.

Notes:
- For esthetic reasons, we do not escape slashes. This also avoids a 'feature'
in Apache where it 404s on any path containing '%2F'.
- mod_rewrite unescapes %-encoded ampersands, hashes, and slashes when clean
URLs are used, which are interpreted as delimiters by PHP. These
characters are double escaped so PHP will still see the encoded version.
- With clean URLs, Apache changes '//' to '/', so every second slash is
double escaped.
- This function should only be used on paths, not on query string arguments,
otherwise unwanted double encoding will occur.

param: $text

drupal_get_private_key()   X-Ref
Ensure the private key variable used to generate tokens is set.

return:

drupal_get_token($value = '')   X-Ref
Generate a token based on $value, the current user session and private key.

param: $value

drupal_valid_token($token, $value = '', $skip_anonymous = FALSE)   X-Ref
Validate a token based on $value, the current user session and private key.

param: $token
param: $value
param: $skip_anonymous
return:

xmlrpc($url)   X-Ref
Performs one or more XML-RPC request(s).

param: $url
param: ...
return:

_drupal_bootstrap_full()   X-Ref
No description

page_set_cache()   X-Ref
Store the current page in the cache.

If page_compression is enabled, a gzipped version of the page is stored in
the cache to avoid compressing the output on each request. The cache entry
is unzipped in the relatively rare event that the page is requested by a
client without gzip support.

Page compression requires the PHP zlib extension
(http://php.net/manual/en/ref.zlib.php).


drupal_cron_run()   X-Ref
Executes a cron run when called

return:

drupal_cron_cleanup()   X-Ref
Shutdown function for cron cleanup.


drupal_system_listing($mask, $directory, $key = 'name', $min_depth = 1)   X-Ref
Return an array of system file objects.

Returns an array of file objects of the given type from the site-wide
directory (i.e. modules/), the all-sites directory (i.e.
sites/all/modules/), the profiles directory, and site-specific directory
(i.e. sites/somesite/modules/). The returned array will be keyed using the
key specified (name, basename, filename). Using name or basename will cause
site-specific files to be prioritized over similar files in the default
directories. That is, if a file with the same name appears in both the
site-wide directory and site-specific directory, only the site-specific
version will be included.

param: $mask
param: $directory
param: $key
param: $min_depth
return:

drupal_alter($type, &$data)   X-Ref
Hands off alterable variables to type-specific *_alter implementations.

This dispatch function hands off the passed in variables to type-specific
hook_TYPE_alter() implementations in modules. It ensures a consistent
interface for all altering operations.

param: $type
param: $data
param: ...

drupal_render(&$elements)   X-Ref
Renders HTML given a structured array tree.

Recursively iterates over each of the array elements, generating HTML code.
This function is usually called from within another function, like
drupal_get_form() or node_view().

drupal_render() flags each element with a '#printed' status to indicate that
the element has been rendered, which allows individual elements of a given
array to be rendered independently. This prevents elements from being
rendered more than once on subsequent calls to drupal_render() if, for example,
they are part of a larger array. If the same array or array element is passed
more than once to drupal_render(), it simply returns a NULL value.

param: $elements
return:

element_sort($a, $b)   X-Ref
Function used by uasort to sort structured arrays by weight.


element_property($key)   X-Ref
Check if the key is a property.


element_properties($element)   X-Ref
Get properties of a structured array element. Properties begin with '#'.


element_child($key)   X-Ref
Check if the key is a child.


element_children($element)   X-Ref
Get keys of a structured array tree element that are not properties (i.e., do not begin with '#').


drupal_common_theme()   X-Ref
Provide theme registration for themes across .inc files.


drupal_get_schema($table = NULL, $rebuild = FALSE)   X-Ref
Get the schema definition of a table, or the whole database schema.

The returned schema will include any modifications made by any
module that implements hook_schema_alter().

param: $table
param: $rebuild

drupal_install_schema($module)   X-Ref
Create all tables that a module defines in its hook_schema().

Note: This function does not pass the module's schema through
hook_schema_alter(). The module's tables will be created exactly as the
module defines them.

param: $module
return:

drupal_uninstall_schema($module)   X-Ref
Remove all tables that a module defines in its hook_schema().

Note: This function does not pass the module's schema through
hook_schema_alter(). The module's tables will be created exactly as the
module defines them.

param: $module
return:

drupal_get_schema_unprocessed($module, $table = NULL)   X-Ref
Returns the unprocessed and unaltered version of a module's schema.

Use this function only if you explicitly need the original
specification of a schema, as it was defined in a module's
hook_schema(). No additional default values will be set,
hook_schema_alter() is not invoked and these unprocessed
definitions won't be cached.

This function can be used to retrieve a schema specification in
hook_schema(), so it allows you to derive your tables from existing
specifications.

It is also used by drupal_install_schema() and
drupal_uninstall_schema() to ensure that a module's tables are
created exactly as specified without any changes introduced by a
module that implements hook_schema_alter().

param: $module
param: $table

_drupal_initialize_schema($module, &$schema)   X-Ref
Fill in required default values for table definitions returned by hook_schema().

param: $module
param: $schema

drupal_schema_fields_sql($table, $prefix = NULL)   X-Ref
Retrieve a list of fields from a table schema. The list is suitable for use in a SQL query.

param: $table
param:
return: An array of fields.

drupal_write_record($table, &$object, $update = array()   X-Ref
Save a record to the database based upon the schema.

Default values are filled in for missing items, and 'serial' (auto increment)
types are filled in with IDs.

param: $table
param: $object
param: $update
return:

drupal_parse_info_file($filename)   X-Ref
Parse Drupal info file format.

Files should use an ini-like format to specify values.
White-space generally doesn't matter, except inside values.
e.g.

param: $filename
return:

watchdog_severity_levels()   X-Ref

return:

drupal_explode_tags($tags)   X-Ref
Explode a string of given tags into an array.


drupal_implode_tags($tags)   X-Ref
Implode an array of tags into a string.


drupal_flush_all_caches()   X-Ref
Flush all cached data on the site.

Empties cache tables, rebuilds the menu cache and theme registries, and
invokes a hook so that other modules' cache data can be cleared as well.

_drupal_flush_css_js()   X-Ref
Helper function to change query-strings on css/js files.

Changes the character added to all css/js files as dummy query-string,
so that all browsers are forced to reload fresh files. We keep
20 characters history (FIFO) to avoid repeats, but only the first
(newest) character is actually used on urls, to keep them short.
This is also called from update.php.



Generated: Mon Jul 9 18:01:44 2012 Cross-referenced by PHPXref 0.7